diff --git a/CHANGELOG.md b/CHANGELOG.md index 133bef32..37b6917d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed `Element.graph_node` to `Element.graphnode`. * Changed `Element.tree_node` to `Element.treenode`. * Changed `blockmodel_interfaces` to use the bestfit frame shared by two aligned interfaces instead of the frame of first face of the pair. +* Changed notebook.scene `__all__` is moved to notebook folder for building documentation. ### Removed diff --git a/docs/api.rst b/docs/api.rst index 6d119177..e9f2bd2d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2,14 +2,14 @@ API Reference ******************************************************************************** + .. toctree:: :maxdepth: 1 :titlesonly: - api/compas_model.algorithms api/compas_model.elements api/compas_model.interactions api/compas_model.materials api/compas_model.models api/compas_model.notebook - api/compas_model.scene + api/compas_model.scene \ No newline at end of file diff --git a/docs/api/compas_model.algorithms.rst b/docs/api/compas_model.algorithms.rst deleted file mode 100644 index b518d2af..00000000 --- a/docs/api/compas_model.algorithms.rst +++ /dev/null @@ -1,14 +0,0 @@ -******************************************************************************** -compas_model.algorithms -******************************************************************************** - -.. currentmodule:: compas_model.algorithms - -Functions -========= - -.. autosummary:: - :toctree: generated/ - :nosignatures: - - blockmodel_interfaces \ No newline at end of file diff --git a/docs/api/compas_model.models.rst b/docs/api/compas_model.models.rst index cd9ec05a..23fb894f 100644 --- a/docs/api/compas_model.models.rst +++ b/docs/api/compas_model.models.rst @@ -13,6 +13,6 @@ Classes ElementNode ElementTree - GroupNode InteractionGraph Model + BlockModel \ No newline at end of file diff --git a/docs/api/compas_model.notebook.rst b/docs/api/compas_model.notebook.rst index 551c46de..f1ab209c 100644 --- a/docs/api/compas_model.notebook.rst +++ b/docs/api/compas_model.notebook.rst @@ -4,7 +4,6 @@ compas_model.notebook .. currentmodule:: compas_model.notebook - Classes ======= @@ -12,12 +11,5 @@ Classes :toctree: generated/ :nosignatures: - scene.ThreeBlockObject - - -Functions -========= - -.. autosummary:: - :toctree: generated/ - :nosignatures: + ThreeBlockObject + ThreeModelObject \ No newline at end of file diff --git a/docs/api/compas_model.scene.rst b/docs/api/compas_model.scene.rst index 9178f00e..32b9c15a 100644 --- a/docs/api/compas_model.scene.rst +++ b/docs/api/compas_model.scene.rst @@ -4,7 +4,6 @@ compas_model.scene .. currentmodule:: compas_model.scene - Classes ======= @@ -12,4 +11,6 @@ Classes :toctree: generated/ :nosignatures: - ElementObject \ No newline at end of file + ElementObject + BlockObject + ModelObject \ No newline at end of file diff --git a/docs/examples/dem/000_stack.rst b/docs/examples/dem/000_stack.rst index 819ce9d1..2e6e8a0b 100644 --- a/docs/examples/dem/000_stack.rst +++ b/docs/examples/dem/000_stack.rst @@ -38,5 +38,5 @@ As a result, the stack requires equilibriating "glue" forces (in red) at those i Code ==== -.. literalinclude:: 100_stack.py - :language: python +.. .. literalinclude:: 100_stack.py +.. :language: python diff --git a/src/compas_model/algorithms/interfaces.py b/src/compas_model/algorithms/interfaces.py index 265b6256..48a240fa 100644 --- a/src/compas_model/algorithms/interfaces.py +++ b/src/compas_model/algorithms/interfaces.py @@ -1,11 +1,12 @@ from math import fabs +from shapely.geometry import Polygon as ShapelyPolygon + from compas.datastructures import Mesh from compas.geometry import Frame from compas.geometry import Plane from compas.geometry import Polygon from compas.geometry import Transformation -from compas.geometry import Vector from compas.geometry import bestfit_frame_numpy from compas.geometry import centroid_polygon from compas.geometry import is_colinear @@ -13,8 +14,6 @@ from compas.geometry import is_parallel_vector_vector from compas.geometry import transform_points from compas.itertools import window -from shapely.geometry import Polygon as ShapelyPolygon - from compas_model.elements import BlockGeometry from compas_model.interactions import ContactInterface from compas_model.models import Model diff --git a/src/compas_model/algorithms/overlaps.py b/src/compas_model/algorithms/overlaps.py index 77ef6135..eee50b7f 100644 --- a/src/compas_model/algorithms/overlaps.py +++ b/src/compas_model/algorithms/overlaps.py @@ -1,12 +1,15 @@ from compas.geometry import Brep from compas.tolerance import TOL -from compas_occ.brep import OCCBrepFace as BrepFace - from compas_model.interactions import ContactInterface from compas_model.models import Model from .nnbrs import find_nearest_neighbours +try: + from compas_occ.brep import OCCBrepFace as BrepFace +except ImportError: + print("compas_occ not installed. Using compas.geometry.BrepFace instead.") + def model_overlaps( model: Model, diff --git a/src/compas_model/analysis/cra.py b/src/compas_model/analysis/cra.py index c5bc2b43..9574af27 100644 --- a/src/compas_model/analysis/cra.py +++ b/src/compas_model/analysis/cra.py @@ -1,10 +1,14 @@ -from compas_assembly.datastructures import Assembly -from compas_assembly.datastructures import Block -from compas_cra.equilibrium import cra_penalty_solve as _cra_penalty_solve - from compas_model.interactions import ContactInterface from compas_model.models import Model +try: + from compas_cra.equilibrium import cra_penalty_solve as _cra_penalty_solve + + from compas_assembly.datastructures import Assembly + from compas_assembly.datastructures import Block +except ImportError: + print("compas_cra not installed. Using compas.geometry.BrepFace instead.") + def cra_penalty_solve( model: Model, diff --git a/src/compas_model/elements/block.py b/src/compas_model/elements/block.py index d2e5e1f4..c3e0661c 100644 --- a/src/compas_model/elements/block.py +++ b/src/compas_model/elements/block.py @@ -14,7 +14,6 @@ from compas.geometry import oriented_bounding_box from compas.geometry import volume_polyhedron from compas.geometry.brep.brep import Brep - from compas_model.elements import Element from compas_model.elements import Feature diff --git a/src/compas_model/elements/element.py b/src/compas_model/elements/element.py index 7012d2f7..e217128e 100644 --- a/src/compas_model/elements/element.py +++ b/src/compas_model/elements/element.py @@ -12,7 +12,6 @@ from compas.geometry import Frame from compas.geometry import Shape from compas.geometry import Transformation - from compas_model.materials import Material if TYPE_CHECKING: diff --git a/src/compas_model/elements/plate.py b/src/compas_model/elements/plate.py index 73bc9062..95c10db1 100644 --- a/src/compas_model/elements/plate.py +++ b/src/compas_model/elements/plate.py @@ -4,7 +4,6 @@ from compas.geometry import bounding_box from compas.geometry import oriented_bounding_box from compas.itertools import pairwise - from compas_model.elements import Element from compas_model.elements import Feature diff --git a/src/compas_model/models/blockmodel.py b/src/compas_model/models/blockmodel.py index 039a0569..709699d9 100644 --- a/src/compas_model/models/blockmodel.py +++ b/src/compas_model/models/blockmodel.py @@ -2,14 +2,17 @@ from compas.geometry import Brep from compas.tolerance import Tolerance -from compas_occ.brep import OCCBrepFace as BrepFace - from compas_model.algorithms.nnbrs import find_nearest_neighbours from compas_model.elements import Element from compas_model.interactions import ContactInterface from .model import Model +try: + from compas_occ.brep import OCCBrepFace as BrepFace +except ImportError: + print("compas_occ not installed. Using compas.geometry.BrepFace instead.") + class BlockModel(Model): def __init__(self, name: Optional[str] = None) -> None: diff --git a/src/compas_model/models/elementnode.py b/src/compas_model/models/elementnode.py index f3b82cc5..8f45a15d 100644 --- a/src/compas_model/models/elementnode.py +++ b/src/compas_model/models/elementnode.py @@ -2,7 +2,6 @@ from typing import Optional from compas.datastructures import TreeNode - from compas_model.elements import Element if TYPE_CHECKING: diff --git a/src/compas_model/models/elementtree.py b/src/compas_model/models/elementtree.py index b5e71391..f66e6771 100644 --- a/src/compas_model/models/elementtree.py +++ b/src/compas_model/models/elementtree.py @@ -1,7 +1,6 @@ from typing import Optional from compas.datastructures import Tree - from compas_model.elements import Element from .elementnode import ElementNode diff --git a/src/compas_model/models/interactiongraph.py b/src/compas_model/models/interactiongraph.py index 07059a83..44036a12 100644 --- a/src/compas_model/models/interactiongraph.py +++ b/src/compas_model/models/interactiongraph.py @@ -2,7 +2,6 @@ from typing import Optional from compas.datastructures import Graph - from compas_model.elements import Element # noqa: F401 from compas_model.interactions import Interaction # noqa: F401 diff --git a/src/compas_model/models/model.py b/src/compas_model/models/model.py index 73c1e834..831d6d55 100644 --- a/src/compas_model/models/model.py +++ b/src/compas_model/models/model.py @@ -7,7 +7,6 @@ from compas.datastructures import Datastructure from compas.geometry import Frame from compas.geometry import Transformation - from compas_model.elements import Element from compas_model.interactions import Interaction from compas_model.materials import Material diff --git a/src/compas_model/notebook/__init__.py b/src/compas_model/notebook/__init__.py index e69de29b..ad8b196b 100644 --- a/src/compas_model/notebook/__init__.py +++ b/src/compas_model/notebook/__init__.py @@ -0,0 +1,6 @@ +from .scene import ThreeBlockObject, ThreeModelObject + +__all__ = [ + "ThreeBlockObject", + "ThreeModelObject", +] diff --git a/src/compas_model/notebook/scene/__init__.py b/src/compas_model/notebook/scene/__init__.py index e219c18d..72e6d19e 100644 --- a/src/compas_model/notebook/scene/__init__.py +++ b/src/compas_model/notebook/scene/__init__.py @@ -18,11 +18,3 @@ def register_scene_objects(): register(BlockElement, ThreeBlockObject, context="Notebook") register(Model, ThreeModelObject, context="Notebook") - - # print("PyThreeJS Model elements registered.") - - -__all__ = [ - "ThreeBlockObject", - "ThreeModelObjec", -] diff --git a/src/compas_model/notebook/scene/blockobject.py b/src/compas_model/notebook/scene/blockobject.py index d40dbfa2..1360ed45 100644 --- a/src/compas_model/notebook/scene/blockobject.py +++ b/src/compas_model/notebook/scene/blockobject.py @@ -1,11 +1,11 @@ -import compas.datastructures # noqa: F401 -import compas.geometry # noqa: F401 import numpy import pythreejs as three -from compas.geometry import Polygon -from compas.geometry import earclip_polygon from compas_notebook.scene import ThreeSceneObject +import compas.datastructures # noqa: F401 +import compas.geometry # noqa: F401 +from compas.geometry import Polygon +from compas.geometry import earclip_polygon from compas_model.scene import BlockObject diff --git a/src/compas_model/notebook/scene/modelobject.py b/src/compas_model/notebook/scene/modelobject.py index 0bf80aca..fb157bd6 100644 --- a/src/compas_model/notebook/scene/modelobject.py +++ b/src/compas_model/notebook/scene/modelobject.py @@ -1,7 +1,7 @@ -import compas.datastructures # noqa: F401 -import compas.geometry # noqa: F401 from compas_notebook.scene import ThreeSceneObject +import compas.datastructures # noqa: F401 +import compas.geometry # noqa: F401 from compas_model.scene import ElementObject from compas_model.scene import ModelObject diff --git a/src/compas_model/scene/elementobject.py b/src/compas_model/scene/elementobject.py index a59fea20..8f3c5a6f 100644 --- a/src/compas_model/scene/elementobject.py +++ b/src/compas_model/scene/elementobject.py @@ -3,12 +3,11 @@ from __future__ import print_function import compas.geometry # noqa: F401 +import compas_model.elements # noqa: F401 from compas.colors import Color from compas.scene import SceneObject from compas.scene.descriptors.colordict import ColorDictAttribute -import compas_model.elements # noqa: F401 - class ElementObject(SceneObject): """Base class for all element scene objects. diff --git a/src/compas_model/scene/modelobject.py b/src/compas_model/scene/modelobject.py index fafb2355..7b72c1f6 100644 --- a/src/compas_model/scene/modelobject.py +++ b/src/compas_model/scene/modelobject.py @@ -3,9 +3,8 @@ from __future__ import print_function import compas.geometry # noqa: F401 -from compas.scene import SceneObject - import compas_model.models # noqa: F401 +from compas.scene import SceneObject class ModelObject(SceneObject): diff --git a/src/compas_model/viewers/blockmodelviewer.py b/src/compas_model/viewers/blockmodelviewer.py index ab7e1056..a94e9426 100644 --- a/src/compas_model/viewers/blockmodelviewer.py +++ b/src/compas_model/viewers/blockmodelviewer.py @@ -2,16 +2,19 @@ from compas.datastructures import Mesh from compas.geometry import Line from compas.itertools import remap_values -from compas_viewer import Viewer -from compas_viewer.components import Button -from compas_viewer.components.slider import Slider -from compas_viewer.scene import GroupObject - from compas_model.elements import BlockElement from compas_model.elements import BlockGeometry from compas_model.interactions import ContactInterface from compas_model.models import Model +try: + from compas_viewer import Viewer + from compas_viewer.components import Button + from compas_viewer.components.slider import Slider + from compas_viewer.scene import GroupObject +except ImportError: + print("compas_viewer not installed. Using compas.geometry.BrepFace instead.") + def toggle_supports(): viewer = BlockModelViewer()