COMPAS 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compas/__init__.py +274 -0
- compas/__main__.py +31 -0
- compas/_iotools.py +80 -0
- compas/_os.py +746 -0
- compas/colors/__init__.py +14 -0
- compas/colors/cmcrameri/acton.txt +256 -0
- compas/colors/cmcrameri/actonS.txt +100 -0
- compas/colors/cmcrameri/bam.txt +256 -0
- compas/colors/cmcrameri/bamO.txt +256 -0
- compas/colors/cmcrameri/bamako.txt +256 -0
- compas/colors/cmcrameri/bamakoS.txt +100 -0
- compas/colors/cmcrameri/batlow.txt +256 -0
- compas/colors/cmcrameri/batlowK.txt +256 -0
- compas/colors/cmcrameri/batlowS.txt +100 -0
- compas/colors/cmcrameri/batlowW.txt +256 -0
- compas/colors/cmcrameri/berlin.txt +256 -0
- compas/colors/cmcrameri/bilbao.txt +256 -0
- compas/colors/cmcrameri/bilbaoS.txt +100 -0
- compas/colors/cmcrameri/broc.txt +256 -0
- compas/colors/cmcrameri/brocO.txt +256 -0
- compas/colors/cmcrameri/buda.txt +256 -0
- compas/colors/cmcrameri/budaS.txt +100 -0
- compas/colors/cmcrameri/bukavu.txt +256 -0
- compas/colors/cmcrameri/cork.txt +256 -0
- compas/colors/cmcrameri/corkO.txt +256 -0
- compas/colors/cmcrameri/davos.txt +256 -0
- compas/colors/cmcrameri/davosS.txt +100 -0
- compas/colors/cmcrameri/devon.txt +256 -0
- compas/colors/cmcrameri/devonS.txt +100 -0
- compas/colors/cmcrameri/fes.txt +256 -0
- compas/colors/cmcrameri/grayC.txt +256 -0
- compas/colors/cmcrameri/grayCS.txt +100 -0
- compas/colors/cmcrameri/hawaii.txt +256 -0
- compas/colors/cmcrameri/hawaiiS.txt +100 -0
- compas/colors/cmcrameri/imola.txt +256 -0
- compas/colors/cmcrameri/imolaS.txt +100 -0
- compas/colors/cmcrameri/lajolla.txt +256 -0
- compas/colors/cmcrameri/lajollaS.txt +100 -0
- compas/colors/cmcrameri/lapaz.txt +256 -0
- compas/colors/cmcrameri/lapazS.txt +100 -0
- compas/colors/cmcrameri/lisbon.txt +256 -0
- compas/colors/cmcrameri/nuuk.txt +256 -0
- compas/colors/cmcrameri/nuukS.txt +100 -0
- compas/colors/cmcrameri/oleron.txt +256 -0
- compas/colors/cmcrameri/oslo.txt +256 -0
- compas/colors/cmcrameri/osloS.txt +100 -0
- compas/colors/cmcrameri/roma.txt +256 -0
- compas/colors/cmcrameri/romaO.txt +256 -0
- compas/colors/cmcrameri/tofino.txt +256 -0
- compas/colors/cmcrameri/tokyo.txt +256 -0
- compas/colors/cmcrameri/tokyoS.txt +100 -0
- compas/colors/cmcrameri/turku.txt +256 -0
- compas/colors/cmcrameri/turkuS.txt +100 -0
- compas/colors/cmcrameri/vanimo.txt +256 -0
- compas/colors/cmcrameri/vik.txt +256 -0
- compas/colors/cmcrameri/vikO.txt +256 -0
- compas/colors/color.py +1118 -0
- compas/colors/colordict.py +103 -0
- compas/colors/colormap.py +306 -0
- compas/colors/html_colors.py +149 -0
- compas/colors/mpl_colormap.py +1064 -0
- compas/data/__init__.py +31 -0
- compas/data/coercion.py +71 -0
- compas/data/conftest.py +10 -0
- compas/data/data.py +342 -0
- compas/data/encoders.py +240 -0
- compas/data/exceptions.py +2 -0
- compas/data/json.py +240 -0
- compas/data/samples/boxes.obj +250 -0
- compas/data/samples/butt_model.obj +2829 -0
- compas/data/samples/cone.stl +0 -0
- compas/data/samples/cube.off +16 -0
- compas/data/samples/cube_ascii.stl +56114 -0
- compas/data/samples/cube_binary.stl +0 -0
- compas/data/samples/cube_binary_2.stl +0 -0
- compas/data/samples/doosabin.json +1 -0
- compas/data/samples/faces.obj +63 -0
- compas/data/samples/faces_big.obj +9663 -0
- compas/data/samples/faces_reversed.obj +63 -0
- compas/data/samples/fink.obj +135 -0
- compas/data/samples/grid_irregular.obj +303 -0
- compas/data/samples/hypar.obj +148 -0
- compas/data/samples/lines.json +1 -0
- compas/data/samples/lines.obj +282 -0
- compas/data/samples/lines_big.obj +40322 -0
- compas/data/samples/lines_bigger.obj +161282 -0
- compas/data/samples/lines_noleaves.obj +422 -0
- compas/data/samples/mesh.obj +874 -0
- compas/data/samples/mesh_100_faces.json +1893 -0
- compas/data/samples/mesh_110_faces.json +2081 -0
- compas/data/samples/open_edges.obj +424 -0
- compas/data/samples/point.json +1 -0
- compas/data/samples/quadmesh.obj +183 -0
- compas/data/samples/quadmesh_planar.obj +181 -0
- compas/data/samples/saddle.obj +314 -0
- compas/data/samples/spline.obj +72 -0
- compas/data/samples/tubemesh.json +1 -0
- compas/data/samples/tubemesh.obj +378 -0
- compas/data/samples/tubemesh.off +374 -0
- compas/data/samples/tubemesh.ply +551 -0
- compas/data/schema.py +137 -0
- compas/data/validators.py +243 -0
- compas/datastructures/__init__.py +75 -0
- compas/datastructures/_mutablemapping.py +148 -0
- compas/datastructures/assembly/__init__.py +0 -0
- compas/datastructures/assembly/assembly.py +234 -0
- compas/datastructures/assembly/exceptions.py +6 -0
- compas/datastructures/assembly/part.py +228 -0
- compas/datastructures/attributes.py +85 -0
- compas/datastructures/cell_network/__init__.py +0 -0
- compas/datastructures/cell_network/cell_network.py +4190 -0
- compas/datastructures/datastructure.py +309 -0
- compas/datastructures/graph/__init__.py +0 -0
- compas/datastructures/graph/duality.py +197 -0
- compas/datastructures/graph/graph.py +2478 -0
- compas/datastructures/graph/operations/__init__.py +0 -0
- compas/datastructures/graph/operations/join.py +124 -0
- compas/datastructures/graph/operations/split.py +63 -0
- compas/datastructures/graph/planarity.py +292 -0
- compas/datastructures/graph/smoothing.py +59 -0
- compas/datastructures/mesh/__init__.py +0 -0
- compas/datastructures/mesh/conway.py +553 -0
- compas/datastructures/mesh/duality.py +104 -0
- compas/datastructures/mesh/mesh.py +5103 -0
- compas/datastructures/mesh/operations/__init__.py +0 -0
- compas/datastructures/mesh/operations/collapse.py +350 -0
- compas/datastructures/mesh/operations/extrude.py +0 -0
- compas/datastructures/mesh/operations/insert.py +120 -0
- compas/datastructures/mesh/operations/merge.py +83 -0
- compas/datastructures/mesh/operations/split.py +263 -0
- compas/datastructures/mesh/operations/substitute.py +37 -0
- compas/datastructures/mesh/operations/swap.py +62 -0
- compas/datastructures/mesh/operations/weld.py +107 -0
- compas/datastructures/mesh/remesh.py +234 -0
- compas/datastructures/mesh/slice.py +170 -0
- compas/datastructures/mesh/smoothing.py +187 -0
- compas/datastructures/mesh/subdivision.py +754 -0
- compas/datastructures/tree/__init__.py +0 -0
- compas/datastructures/tree/tree.py +504 -0
- compas/datastructures/volmesh/__init__.py +0 -0
- compas/datastructures/volmesh/volmesh.py +4203 -0
- compas/files/__init__.py +27 -0
- compas/files/_xml/__init__.py +0 -0
- compas/files/_xml/xml_cli.py +213 -0
- compas/files/_xml/xml_cpython.py +32 -0
- compas/files/_xml/xml_pre_38.py +58 -0
- compas/files/_xml/xml_shared.py +40 -0
- compas/files/gltf/__init__.py +0 -0
- compas/files/gltf/constants.py +59 -0
- compas/files/gltf/data_classes.py +657 -0
- compas/files/gltf/extensions.py +317 -0
- compas/files/gltf/gltf.py +92 -0
- compas/files/gltf/gltf_children.py +64 -0
- compas/files/gltf/gltf_content.py +615 -0
- compas/files/gltf/gltf_exporter.py +465 -0
- compas/files/gltf/gltf_mesh.py +273 -0
- compas/files/gltf/gltf_node.py +348 -0
- compas/files/gltf/gltf_parser.py +115 -0
- compas/files/gltf/gltf_reader.py +310 -0
- compas/files/gltf/gltf_scene.py +125 -0
- compas/files/gltf/helpers.py +59 -0
- compas/files/obj.py +680 -0
- compas/files/off.py +296 -0
- compas/files/ply.py +697 -0
- compas/files/stl.py +436 -0
- compas/files/xml.py +328 -0
- compas/geometry/__init__.py +772 -0
- compas/geometry/_core/__init__.py +0 -0
- compas/geometry/_core/_algebra.py +2826 -0
- compas/geometry/_core/angles.py +408 -0
- compas/geometry/_core/centroids.py +573 -0
- compas/geometry/_core/distance.py +895 -0
- compas/geometry/_core/normals.py +149 -0
- compas/geometry/_core/nurbs.py +367 -0
- compas/geometry/_core/predicates_2.py +582 -0
- compas/geometry/_core/predicates_3.py +1111 -0
- compas/geometry/_core/quaternions.py +196 -0
- compas/geometry/_core/size.py +204 -0
- compas/geometry/_core/tangent.py +56 -0
- compas/geometry/_core/transformations.py +1121 -0
- compas/geometry/_core/transformations_numpy.py +279 -0
- compas/geometry/bbox.py +145 -0
- compas/geometry/bbox_numpy.py +306 -0
- compas/geometry/bestfit.py +77 -0
- compas/geometry/bestfit_numpy.py +259 -0
- compas/geometry/booleans.py +297 -0
- compas/geometry/booleans_shapely.py +147 -0
- compas/geometry/brep/__init__.py +112 -0
- compas/geometry/brep/brep.py +1131 -0
- compas/geometry/brep/edge.py +302 -0
- compas/geometry/brep/errors.py +22 -0
- compas/geometry/brep/face.py +329 -0
- compas/geometry/brep/loop.py +87 -0
- compas/geometry/brep/trim.py +46 -0
- compas/geometry/brep/vertex.py +46 -0
- compas/geometry/contours.py +32 -0
- compas/geometry/curves/__init__.py +0 -0
- compas/geometry/curves/arc.py +429 -0
- compas/geometry/curves/bezier.py +345 -0
- compas/geometry/curves/circle.py +500 -0
- compas/geometry/curves/conic.py +16 -0
- compas/geometry/curves/curve.py +614 -0
- compas/geometry/curves/ellipse.py +408 -0
- compas/geometry/curves/hyperbola.py +336 -0
- compas/geometry/curves/line.py +431 -0
- compas/geometry/curves/nurbs.py +412 -0
- compas/geometry/curves/parabola.py +256 -0
- compas/geometry/curves/polyline.py +724 -0
- compas/geometry/frame.py +769 -0
- compas/geometry/geometry.py +296 -0
- compas/geometry/hull.py +146 -0
- compas/geometry/hull_numpy.py +82 -0
- compas/geometry/icp_numpy.py +104 -0
- compas/geometry/interpolation_barycentric.py +38 -0
- compas/geometry/interpolation_coons.py +102 -0
- compas/geometry/interpolation_tweening.py +87 -0
- compas/geometry/intersection.py +121 -0
- compas/geometry/intersections.py +1105 -0
- compas/geometry/kdtree.py +153 -0
- compas/geometry/offset.py +208 -0
- compas/geometry/pca_numpy.py +87 -0
- compas/geometry/plane.py +657 -0
- compas/geometry/point.py +664 -0
- compas/geometry/pointcloud.py +409 -0
- compas/geometry/polygon.py +473 -0
- compas/geometry/polyhedron.py +650 -0
- compas/geometry/projection.py +155 -0
- compas/geometry/quadmesh_planarize.py +30 -0
- compas/geometry/quadmesh_planarize_none.py +114 -0
- compas/geometry/quaternion.py +544 -0
- compas/geometry/reflection.py +102 -0
- compas/geometry/rotation.py +354 -0
- compas/geometry/scale.py +100 -0
- compas/geometry/shapes/__init__.py +0 -0
- compas/geometry/shapes/box.py +747 -0
- compas/geometry/shapes/capsule.py +472 -0
- compas/geometry/shapes/cone.py +309 -0
- compas/geometry/shapes/cylinder.py +355 -0
- compas/geometry/shapes/shape.py +300 -0
- compas/geometry/shapes/sphere.py +362 -0
- compas/geometry/shapes/torus.py +294 -0
- compas/geometry/shear.py +115 -0
- compas/geometry/surfaces/__init__.py +0 -0
- compas/geometry/surfaces/conical.py +166 -0
- compas/geometry/surfaces/cylindrical.py +251 -0
- compas/geometry/surfaces/extrusion.py +0 -0
- compas/geometry/surfaces/nurbs.py +380 -0
- compas/geometry/surfaces/planar.py +223 -0
- compas/geometry/surfaces/revolution.py +0 -0
- compas/geometry/surfaces/spherical.py +259 -0
- compas/geometry/surfaces/surface.py +689 -0
- compas/geometry/surfaces/toroidal.py +198 -0
- compas/geometry/transformation.py +554 -0
- compas/geometry/translation.py +104 -0
- compas/geometry/triangulation_delaunay.py +102 -0
- compas/geometry/triangulation_earclip.py +300 -0
- compas/geometry/trimesh_curvature.py +113 -0
- compas/geometry/trimesh_descent_numpy.py +26 -0
- compas/geometry/trimesh_geodistance.py +35 -0
- compas/geometry/trimesh_gradient_numpy.py +74 -0
- compas/geometry/trimesh_isolines.py +41 -0
- compas/geometry/trimesh_matrices.py +31 -0
- compas/geometry/trimesh_matrices_numpy.py +191 -0
- compas/geometry/trimesh_parametrisation.py +55 -0
- compas/geometry/trimesh_pull_points_numpy.py +216 -0
- compas/geometry/trimesh_remeshing.py +97 -0
- compas/geometry/trimesh_samplepoints_numpy.py +108 -0
- compas/geometry/trimesh_slicing.py +28 -0
- compas/geometry/trimesh_smoothing_numpy.py +34 -0
- compas/geometry/vector.py +889 -0
- compas/itertools.py +441 -0
- compas/linalg.py +634 -0
- compas/matrices.py +314 -0
- compas/plugins.py +488 -0
- compas/rpc/__init__.py +20 -0
- compas/rpc/__main__.py +77 -0
- compas/rpc/dispatcher.py +181 -0
- compas/rpc/errors.py +11 -0
- compas/rpc/proxy.py +437 -0
- compas/rpc/server.py +79 -0
- compas/rpc/services/__init__.py +0 -0
- compas/rpc/services/default.py +87 -0
- compas/rpc/services/watcher.py +43 -0
- compas/scene/__init__.py +56 -0
- compas/scene/assemblyobject.py +3 -0
- compas/scene/context.py +154 -0
- compas/scene/descriptors/__init__.py +0 -0
- compas/scene/descriptors/attribute.py +30 -0
- compas/scene/descriptors/color.py +91 -0
- compas/scene/descriptors/colordict.py +101 -0
- compas/scene/descriptors/protocol.py +12 -0
- compas/scene/exceptions.py +7 -0
- compas/scene/geometryobject.py +58 -0
- compas/scene/graphobject.py +173 -0
- compas/scene/meshobject.py +238 -0
- compas/scene/scene.py +144 -0
- compas/scene/sceneobject.py +253 -0
- compas/scene/volmeshobject.py +252 -0
- compas/tolerance.py +879 -0
- compas/topology/__init__.py +45 -0
- compas/topology/combinatorics.py +108 -0
- compas/topology/connectivity.py +129 -0
- compas/topology/orientation.py +204 -0
- compas/topology/traversal.py +567 -0
- compas/utilities/__init__.py +25 -0
- compas/utilities/azync.py +155 -0
- compas/utilities/datetime.py +40 -0
- compas/utilities/decorators.py +136 -0
- compas/utilities/remote.py +54 -0
- compas/utilities/ssh.py +169 -0
- compas-2.1.1.dist-info/AUTHORS.md +42 -0
- compas-2.1.1.dist-info/LICENSE +21 -0
- compas-2.1.1.dist-info/METADATA +132 -0
- compas-2.1.1.dist-info/RECORD +468 -0
- compas-2.1.1.dist-info/WHEEL +5 -0
- compas-2.1.1.dist-info/entry_points.txt +2 -0
- compas-2.1.1.dist-info/top_level.txt +4 -0
- compas_blender/__init__.py +250 -0
- compas_blender/collections.py +130 -0
- compas_blender/conversions/__init__.py +48 -0
- compas_blender/conversions/breps.py +0 -0
- compas_blender/conversions/colors.py +23 -0
- compas_blender/conversions/curves.py +125 -0
- compas_blender/conversions/geometry.py +161 -0
- compas_blender/conversions/meshes.py +148 -0
- compas_blender/conversions/surfaces.py +48 -0
- compas_blender/conversions/transformations.py +46 -0
- compas_blender/data.py +30 -0
- compas_blender/geometry/__init__.py +14 -0
- compas_blender/geometry/booleans.py +100 -0
- compas_blender/install.py +338 -0
- compas_blender/objects.py +326 -0
- compas_blender/print_python_path.py +18 -0
- compas_blender/scene/__init__.py +116 -0
- compas_blender/scene/boxobject.py +64 -0
- compas_blender/scene/capsuleobject.py +73 -0
- compas_blender/scene/circleobject.py +53 -0
- compas_blender/scene/coneobject.py +70 -0
- compas_blender/scene/curveobject.py +58 -0
- compas_blender/scene/cylinderobject.py +70 -0
- compas_blender/scene/frameobject.py +105 -0
- compas_blender/scene/graphobject.py +257 -0
- compas_blender/scene/lineobject.py +60 -0
- compas_blender/scene/meshobject.py +508 -0
- compas_blender/scene/planeobject.py +81 -0
- compas_blender/scene/pointcloudobject.py +67 -0
- compas_blender/scene/pointobject.py +71 -0
- compas_blender/scene/polygonobject.py +57 -0
- compas_blender/scene/polyhedronobject.py +57 -0
- compas_blender/scene/polylineobject.py +54 -0
- compas_blender/scene/sceneobject.py +249 -0
- compas_blender/scene/sphereobject.py +72 -0
- compas_blender/scene/surfaceobject.py +54 -0
- compas_blender/scene/torusobject.py +73 -0
- compas_blender/scene/vectorobject.py +69 -0
- compas_blender/scene/volmeshobject.py +475 -0
- compas_blender/utilities/__init__.py +38 -0
- compas_blender/utilities/drawing.py +768 -0
- compas_ghpython/__init__.py +124 -0
- compas_ghpython/components/Compas_FromJson/code.py +18 -0
- compas_ghpython/components/Compas_Info/code.py +15 -0
- compas_ghpython/components/Compas_RpcCall/code.py +31 -0
- compas_ghpython/components/Compas_ToJson/code.py +19 -0
- compas_ghpython/components/Compas_ToRhinoGeometry/code.py +15 -0
- compas_ghpython/components/__init__.py +99 -0
- compas_ghpython/install.py +29 -0
- compas_ghpython/scene/__init__.py +115 -0
- compas_ghpython/scene/boxobject.py +40 -0
- compas_ghpython/scene/brepobject.py +40 -0
- compas_ghpython/scene/capsuleobject.py +41 -0
- compas_ghpython/scene/circleobject.py +40 -0
- compas_ghpython/scene/coneobject.py +40 -0
- compas_ghpython/scene/curveobject.py +42 -0
- compas_ghpython/scene/cylinderobject.py +38 -0
- compas_ghpython/scene/ellipseobject.py +40 -0
- compas_ghpython/scene/frameobject.py +67 -0
- compas_ghpython/scene/graphobject.py +77 -0
- compas_ghpython/scene/lineobject.py +39 -0
- compas_ghpython/scene/meshobject.py +137 -0
- compas_ghpython/scene/planeobject.py +61 -0
- compas_ghpython/scene/pointobject.py +38 -0
- compas_ghpython/scene/polygonobject.py +48 -0
- compas_ghpython/scene/polyhedronobject.py +48 -0
- compas_ghpython/scene/polylineobject.py +39 -0
- compas_ghpython/scene/sceneobject.py +12 -0
- compas_ghpython/scene/sphereobject.py +39 -0
- compas_ghpython/scene/surfaceobject.py +42 -0
- compas_ghpython/scene/torusobject.py +39 -0
- compas_ghpython/scene/vectorobject.py +51 -0
- compas_ghpython/scene/volmeshobject.py +154 -0
- compas_ghpython/sets.py +83 -0
- compas_ghpython/timer.py +36 -0
- compas_ghpython/uninstall.py +31 -0
- compas_ghpython/utilities/__init__.py +33 -0
- compas_ghpython/utilities/drawing.py +457 -0
- compas_rhino/__init__.py +607 -0
- compas_rhino/conduits/__init__.py +16 -0
- compas_rhino/conduits/base.py +121 -0
- compas_rhino/conduits/faces.py +91 -0
- compas_rhino/conduits/labels.py +102 -0
- compas_rhino/conduits/lines.py +109 -0
- compas_rhino/conduits/points.py +111 -0
- compas_rhino/conversions/__init__.py +168 -0
- compas_rhino/conversions/breps.py +122 -0
- compas_rhino/conversions/curves.py +453 -0
- compas_rhino/conversions/docobjects.py +0 -0
- compas_rhino/conversions/exceptions.py +7 -0
- compas_rhino/conversions/extrusions.py +80 -0
- compas_rhino/conversions/geometry.py +187 -0
- compas_rhino/conversions/meshes.py +281 -0
- compas_rhino/conversions/shapes.py +291 -0
- compas_rhino/conversions/surfaces.py +355 -0
- compas_rhino/conversions/transformations.py +45 -0
- compas_rhino/geometry/__init__.py +44 -0
- compas_rhino/geometry/booleans.py +118 -0
- compas_rhino/geometry/brep/__init__.py +40 -0
- compas_rhino/geometry/brep/brep.py +554 -0
- compas_rhino/geometry/brep/builder.py +184 -0
- compas_rhino/geometry/brep/edge.py +202 -0
- compas_rhino/geometry/brep/face.py +285 -0
- compas_rhino/geometry/brep/loop.py +129 -0
- compas_rhino/geometry/brep/trim.py +99 -0
- compas_rhino/geometry/brep/vertex.py +76 -0
- compas_rhino/geometry/curves/__init__.py +43 -0
- compas_rhino/geometry/curves/curve.py +382 -0
- compas_rhino/geometry/curves/nurbs.py +298 -0
- compas_rhino/geometry/surfaces/__init__.py +50 -0
- compas_rhino/geometry/surfaces/nurbs.py +370 -0
- compas_rhino/geometry/surfaces/surface.py +407 -0
- compas_rhino/geometry/trimesh_curvature.py +344 -0
- compas_rhino/geometry/trimesh_slicing.py +65 -0
- compas_rhino/install.py +382 -0
- compas_rhino/install_plugin.py +169 -0
- compas_rhino/install_with_pip.py +20 -0
- compas_rhino/layers.py +347 -0
- compas_rhino/objects.py +1141 -0
- compas_rhino/print_python_path.py +18 -0
- compas_rhino/scene/__init__.py +123 -0
- compas_rhino/scene/boxobject.py +44 -0
- compas_rhino/scene/brepobject.py +41 -0
- compas_rhino/scene/capsuleobject.py +45 -0
- compas_rhino/scene/circleobject.py +43 -0
- compas_rhino/scene/coneobject.py +43 -0
- compas_rhino/scene/curveobject.py +43 -0
- compas_rhino/scene/cylinderobject.py +43 -0
- compas_rhino/scene/ellipseobject.py +44 -0
- compas_rhino/scene/frameobject.py +99 -0
- compas_rhino/scene/graphobject.py +364 -0
- compas_rhino/scene/helpers.py +33 -0
- compas_rhino/scene/lineobject.py +43 -0
- compas_rhino/scene/meshobject.py +673 -0
- compas_rhino/scene/planeobject.py +71 -0
- compas_rhino/scene/pointobject.py +43 -0
- compas_rhino/scene/polygonobject.py +45 -0
- compas_rhino/scene/polyhedronobject.py +45 -0
- compas_rhino/scene/polylineobject.py +43 -0
- compas_rhino/scene/sceneobject.py +123 -0
- compas_rhino/scene/sphereobject.py +43 -0
- compas_rhino/scene/surfaceobject.py +42 -0
- compas_rhino/scene/torusobject.py +43 -0
- compas_rhino/scene/vectorobject.py +49 -0
- compas_rhino/scene/volmeshobject.py +518 -0
- compas_rhino/ui.py +114 -0
- compas_rhino/uninstall.py +243 -0
- compas_rhino/uninstall_plugin.py +91 -0
- compas_rhino/utilities/__init__.py +37 -0
- compas_rhino/utilities/constructors.py +71 -0
- compas_rhino/utilities/drawing.py +1081 -0
|
@@ -0,0 +1,747 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
from compas.geometry import Frame
|
|
6
|
+
from compas.geometry import Line
|
|
7
|
+
from compas.geometry import Transformation
|
|
8
|
+
from compas.geometry import Vector
|
|
9
|
+
from compas.geometry import centroid_points
|
|
10
|
+
from compas.geometry import transform_points
|
|
11
|
+
|
|
12
|
+
from .shape import Shape
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Box(Shape):
|
|
16
|
+
"""A box is defined by a frame and its dimensions along the frame's x-, y- and z-axes.
|
|
17
|
+
|
|
18
|
+
The center of the box is positioned at the origin of the
|
|
19
|
+
coordinate system defined by the frame. The box is axis-aligned to the frame.
|
|
20
|
+
|
|
21
|
+
A box is a three-dimensional geometric shape with 8 vertices, 12 edges and 6
|
|
22
|
+
faces. The edges of a box meet at its vertices at 90 degree angles. The
|
|
23
|
+
faces of a box are planar. Faces which do not share an edge are parallel.
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
xsize : float
|
|
28
|
+
The size of the box in the box frame's x direction.
|
|
29
|
+
ysize : float, optional
|
|
30
|
+
The size of the box in the box frame's y direction.
|
|
31
|
+
Defaults to the value of ``xsize``.
|
|
32
|
+
zsize : float, optional
|
|
33
|
+
The size of the box in the box frame's z direction.
|
|
34
|
+
Defaults to the value of ``xsize``.
|
|
35
|
+
frame : :class:`compas.geometry.Frame`, optional
|
|
36
|
+
The frame of the box.
|
|
37
|
+
Defaults to ``Frame.worldXY()``.
|
|
38
|
+
name : str, optional
|
|
39
|
+
The name of the shape.
|
|
40
|
+
|
|
41
|
+
Attributes
|
|
42
|
+
----------
|
|
43
|
+
area : float, read-only
|
|
44
|
+
The surface area of the box.
|
|
45
|
+
depth : float, read-only
|
|
46
|
+
The depth of the box in Y direction.
|
|
47
|
+
diagonal : :class:`compas.geometry.Line`, read-only
|
|
48
|
+
Diagonal of the box.
|
|
49
|
+
dimensions : list[float], read-only
|
|
50
|
+
The dimensions of the box in the local frame.
|
|
51
|
+
frame : :class:`compas.geometry.Frame`
|
|
52
|
+
The box's frame.
|
|
53
|
+
height : float, read-only
|
|
54
|
+
The height of the box in Z direction.
|
|
55
|
+
volume : float, read-only
|
|
56
|
+
The volume of the box.
|
|
57
|
+
width : float, read-only
|
|
58
|
+
The width of the box in X direction.
|
|
59
|
+
xmin : float, read-only
|
|
60
|
+
Minimum value along local X axis.
|
|
61
|
+
xmax : float, read-only
|
|
62
|
+
Maximum value along local X axis.
|
|
63
|
+
xsize : float
|
|
64
|
+
The size of the box in the box frame's x direction.
|
|
65
|
+
ymin : float, read-only
|
|
66
|
+
Minimum value along local Y axis.
|
|
67
|
+
ymax : float, read-only
|
|
68
|
+
Maximum value along local Y axis.
|
|
69
|
+
ysize : float
|
|
70
|
+
The size of the box in the box frame's y direction.
|
|
71
|
+
zmin : float, read-only
|
|
72
|
+
Minimum value along local Z axis.
|
|
73
|
+
zmax : float, read-only
|
|
74
|
+
Maximum value along local Z axis.
|
|
75
|
+
zsize : float
|
|
76
|
+
The size of the box in the box frame's z direction.
|
|
77
|
+
|
|
78
|
+
Examples
|
|
79
|
+
--------
|
|
80
|
+
>>> box = Box(1)
|
|
81
|
+
>>> box.xsize
|
|
82
|
+
1.0
|
|
83
|
+
>>> box.ysize
|
|
84
|
+
1.0
|
|
85
|
+
>>> box.zsize
|
|
86
|
+
1.0
|
|
87
|
+
>>> box.volume
|
|
88
|
+
1.0
|
|
89
|
+
>>> box.area
|
|
90
|
+
6.0
|
|
91
|
+
|
|
92
|
+
>>> box = Box(1, 2, 3)
|
|
93
|
+
>>> box.xsize
|
|
94
|
+
1.0
|
|
95
|
+
>>> box.ysize
|
|
96
|
+
2.0
|
|
97
|
+
>>> box.zsize
|
|
98
|
+
3.0
|
|
99
|
+
>>> box.volume
|
|
100
|
+
6.0
|
|
101
|
+
>>> box.area
|
|
102
|
+
22.0
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
DATASCHEMA = {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"xsize": {"type": "number", "minimum": 0},
|
|
110
|
+
"ysize": {"type": "number", "minimum": 0},
|
|
111
|
+
"zsize": {"type": "number", "minimum": 0},
|
|
112
|
+
"frame": Frame.DATASCHEMA,
|
|
113
|
+
},
|
|
114
|
+
"additionalProperties": False,
|
|
115
|
+
"minProperties": 4,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def __data__(self):
|
|
120
|
+
return {
|
|
121
|
+
"xsize": self.xsize,
|
|
122
|
+
"ysize": self.ysize,
|
|
123
|
+
"zsize": self.zsize,
|
|
124
|
+
"frame": self.frame.__data__,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@classmethod
|
|
128
|
+
def __from_data__(cls, data):
|
|
129
|
+
return cls(
|
|
130
|
+
xsize=data["xsize"],
|
|
131
|
+
ysize=data["ysize"],
|
|
132
|
+
zsize=data["zsize"],
|
|
133
|
+
frame=Frame.__from_data__(data["frame"]),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
def __init__(self, xsize=1.0, ysize=None, zsize=None, frame=None, name=None):
|
|
137
|
+
super(Box, self).__init__(frame=frame, name=name)
|
|
138
|
+
self._xsize = None
|
|
139
|
+
self._ysize = None
|
|
140
|
+
self._zsize = None
|
|
141
|
+
self.xsize = xsize
|
|
142
|
+
self.ysize = xsize if ysize is None else ysize
|
|
143
|
+
self.zsize = xsize if zsize is None else zsize
|
|
144
|
+
|
|
145
|
+
def __repr__(self):
|
|
146
|
+
return "{0}(xsize={1}, ysize={2}, zsize={3}, frame={4!r})".format(
|
|
147
|
+
type(self).__name__,
|
|
148
|
+
self.xsize,
|
|
149
|
+
self.ysize,
|
|
150
|
+
self.zsize,
|
|
151
|
+
self.frame,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# ==========================================================================
|
|
155
|
+
# Properties
|
|
156
|
+
# ==========================================================================
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def xsize(self):
|
|
160
|
+
if self._xsize is None:
|
|
161
|
+
raise ValueError("The size of the box along the local X axis is not set.")
|
|
162
|
+
return self._xsize
|
|
163
|
+
|
|
164
|
+
@xsize.setter
|
|
165
|
+
def xsize(self, xsize):
|
|
166
|
+
if xsize < 0:
|
|
167
|
+
raise ValueError("The minimum value of the size of the box along the local X axis is zero.")
|
|
168
|
+
self._xsize = float(xsize)
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def ysize(self):
|
|
172
|
+
if self._ysize is None:
|
|
173
|
+
raise ValueError("The size of the box along the local Y axis is not set.")
|
|
174
|
+
return self._ysize
|
|
175
|
+
|
|
176
|
+
@ysize.setter
|
|
177
|
+
def ysize(self, ysize):
|
|
178
|
+
if ysize < 0:
|
|
179
|
+
raise ValueError("The minimum value of the size of the box along the local Y axis is zero.")
|
|
180
|
+
self._ysize = float(ysize)
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def zsize(self):
|
|
184
|
+
if self._zsize is None:
|
|
185
|
+
raise ValueError("The size of the box along the local Z axis is not set.")
|
|
186
|
+
return self._zsize
|
|
187
|
+
|
|
188
|
+
@zsize.setter
|
|
189
|
+
def zsize(self, zsize):
|
|
190
|
+
if zsize < 0:
|
|
191
|
+
raise ValueError("The minimum value of the size of the box along the local Z axis is zero.")
|
|
192
|
+
self._zsize = float(zsize)
|
|
193
|
+
|
|
194
|
+
@property
|
|
195
|
+
def xmin(self):
|
|
196
|
+
return self.frame.point.x - 0.5 * self.xsize
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def xmax(self):
|
|
200
|
+
return self.frame.point.x + 0.5 * self.xsize
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def ymin(self):
|
|
204
|
+
return self.frame.point.y - 0.5 * self.ysize
|
|
205
|
+
|
|
206
|
+
@property
|
|
207
|
+
def ymax(self):
|
|
208
|
+
return self.frame.point.y + 0.5 * self.ysize
|
|
209
|
+
|
|
210
|
+
@property
|
|
211
|
+
def zmin(self):
|
|
212
|
+
return self.frame.point.z - 0.5 * self.zsize
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def zmax(self):
|
|
216
|
+
return self.frame.point.z + 0.5 * self.zsize
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def width(self):
|
|
220
|
+
return self.xsize
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def depth(self):
|
|
224
|
+
return self.ysize
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
def height(self):
|
|
228
|
+
return self.zsize
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def diagonal(self):
|
|
232
|
+
a = self.frame.point + self.frame.xaxis * -0.5 * self.xsize + self.frame.yaxis * -0.5 * self.ysize + self.frame.zaxis * -0.5 * self.zsize
|
|
233
|
+
b = self.frame.point + self.frame.xaxis * 0.5 * self.xsize + self.frame.yaxis * 0.5 * self.ysize + self.frame.zaxis * 0.5 * self.zsize
|
|
234
|
+
return Line(a, b)
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def dimensions(self):
|
|
238
|
+
return [self.xsize, self.ysize, self.zsize]
|
|
239
|
+
|
|
240
|
+
@property
|
|
241
|
+
def area(self):
|
|
242
|
+
return 2 * self.xsize * self.ysize + 2 * self.ysize * self.zsize + 2 * self.zsize * self.xsize
|
|
243
|
+
|
|
244
|
+
@property
|
|
245
|
+
def volume(self):
|
|
246
|
+
return self.xsize * self.ysize * self.zsize
|
|
247
|
+
|
|
248
|
+
@property
|
|
249
|
+
def bottom(self):
|
|
250
|
+
return [0, 1, 2, 3]
|
|
251
|
+
|
|
252
|
+
@property
|
|
253
|
+
def front(self):
|
|
254
|
+
return [0, 3, 5, 4]
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def right(self):
|
|
258
|
+
return [3, 2, 6, 5]
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def back(self):
|
|
262
|
+
return [2, 1, 7, 6]
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def left(self):
|
|
266
|
+
return [1, 0, 4, 7]
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def top(self):
|
|
270
|
+
return [4, 5, 6, 7]
|
|
271
|
+
|
|
272
|
+
@property
|
|
273
|
+
def points(self):
|
|
274
|
+
point = self.frame.point
|
|
275
|
+
xaxis = self.frame.xaxis
|
|
276
|
+
yaxis = self.frame.yaxis
|
|
277
|
+
zaxis = self.frame.zaxis
|
|
278
|
+
|
|
279
|
+
dx = 0.5 * self.xsize
|
|
280
|
+
dy = 0.5 * self.ysize
|
|
281
|
+
dz = 0.5 * self.zsize
|
|
282
|
+
|
|
283
|
+
a = point + xaxis * -dx + yaxis * -dy + zaxis * -dz
|
|
284
|
+
b = point + xaxis * -dx + yaxis * +dy + zaxis * -dz
|
|
285
|
+
c = point + xaxis * +dx + yaxis * +dy + zaxis * -dz
|
|
286
|
+
d = point + xaxis * +dx + yaxis * -dy + zaxis * -dz
|
|
287
|
+
e = a + zaxis * self.zsize
|
|
288
|
+
f = d + zaxis * self.zsize
|
|
289
|
+
g = c + zaxis * self.zsize
|
|
290
|
+
h = b + zaxis * self.zsize
|
|
291
|
+
|
|
292
|
+
return [a, b, c, d, e, f, g, h]
|
|
293
|
+
|
|
294
|
+
# ==========================================================================
|
|
295
|
+
# Constructors
|
|
296
|
+
# ==========================================================================
|
|
297
|
+
|
|
298
|
+
@classmethod
|
|
299
|
+
def from_width_height_depth(cls, width, height, depth): # type: (...) -> Box
|
|
300
|
+
"""Construct a box from its width, height and depth.
|
|
301
|
+
|
|
302
|
+
Note that width is along the X-axis, height along Z-axis, and depth along the Y-axis.
|
|
303
|
+
|
|
304
|
+
Parameters
|
|
305
|
+
----------
|
|
306
|
+
width : float
|
|
307
|
+
Width of the box.
|
|
308
|
+
height : float
|
|
309
|
+
Height of the box.
|
|
310
|
+
depth : float
|
|
311
|
+
Depth of the box.
|
|
312
|
+
|
|
313
|
+
Returns
|
|
314
|
+
-------
|
|
315
|
+
:class:`compas.geometry.Box`
|
|
316
|
+
The resulting box.
|
|
317
|
+
|
|
318
|
+
Notes
|
|
319
|
+
-----
|
|
320
|
+
The box is axis-aligned to the world coordinate system and centered at the origin.
|
|
321
|
+
|
|
322
|
+
Examples
|
|
323
|
+
--------
|
|
324
|
+
>>> box = Box.from_width_height_depth(1.0, 2.0, 3.0)
|
|
325
|
+
|
|
326
|
+
"""
|
|
327
|
+
width = float(width)
|
|
328
|
+
height = float(height)
|
|
329
|
+
depth = float(depth)
|
|
330
|
+
|
|
331
|
+
return cls(width, depth, height)
|
|
332
|
+
|
|
333
|
+
@classmethod
|
|
334
|
+
def from_bounding_box(cls, bbox): # type: (...) -> Box
|
|
335
|
+
"""Construct a box from the result of a bounding box calculation.
|
|
336
|
+
|
|
337
|
+
Parameters
|
|
338
|
+
----------
|
|
339
|
+
bbox : list[[float, float, float] | :class:`compas.geometry.Point`]
|
|
340
|
+
A list of 8 point locations, representing the corners of the bounding box.
|
|
341
|
+
Positions 0, 1, 2, 3 are the bottom corners.
|
|
342
|
+
Positions 4, 5, 6, 7 are the top corners.
|
|
343
|
+
Both the top and bottom face are oriented in CCW direction, starting at the bottom, left-most point.
|
|
344
|
+
|
|
345
|
+
Returns
|
|
346
|
+
-------
|
|
347
|
+
:class:`compas.geometry.Box`
|
|
348
|
+
The box shape.
|
|
349
|
+
|
|
350
|
+
Examples
|
|
351
|
+
--------
|
|
352
|
+
>>> from compas.geometry import bounding_box
|
|
353
|
+
>>> bbox = bounding_box([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]])
|
|
354
|
+
>>> box = Box.from_bounding_box(bbox)
|
|
355
|
+
>>> box.width
|
|
356
|
+
1.0
|
|
357
|
+
>>> box.height
|
|
358
|
+
1.0
|
|
359
|
+
>>> box.depth
|
|
360
|
+
1.0
|
|
361
|
+
|
|
362
|
+
"""
|
|
363
|
+
a = bbox[0]
|
|
364
|
+
b = bbox[1]
|
|
365
|
+
d = bbox[3]
|
|
366
|
+
e = bbox[4]
|
|
367
|
+
xaxis = Vector.from_start_end(a, b)
|
|
368
|
+
yaxis = Vector.from_start_end(a, d)
|
|
369
|
+
zaxis = Vector.from_start_end(a, e)
|
|
370
|
+
xsize = xaxis.length
|
|
371
|
+
ysize = yaxis.length
|
|
372
|
+
zsize = zaxis.length
|
|
373
|
+
frame = Frame(centroid_points(bbox), xaxis, yaxis)
|
|
374
|
+
return cls(xsize=xsize, ysize=ysize, zsize=zsize, frame=frame)
|
|
375
|
+
|
|
376
|
+
@classmethod
|
|
377
|
+
def from_corner_corner_height(cls, corner1, corner2, height): # type: (...) -> Box
|
|
378
|
+
"""Construct a box from the opposite corners of its base and its height.
|
|
379
|
+
|
|
380
|
+
Parameters
|
|
381
|
+
----------
|
|
382
|
+
corner1 : [float, float, float] | :class:`compas.geometry.Point`
|
|
383
|
+
The XYZ coordinates of the bottom left corner of the base of the box.
|
|
384
|
+
corner2 : [float, float, float] | :class:`compas.geometry.Point`
|
|
385
|
+
The XYZ coordinates of the top right corner of the base of the box.
|
|
386
|
+
height : float
|
|
387
|
+
The height of the box.
|
|
388
|
+
|
|
389
|
+
Returns
|
|
390
|
+
-------
|
|
391
|
+
:class:`compas.geometry.Box`
|
|
392
|
+
The resulting box.
|
|
393
|
+
|
|
394
|
+
Examples
|
|
395
|
+
--------
|
|
396
|
+
>>> box = Box.from_corner_corner_height([0.0, 0.0, 0.0], [1.0, 1.0, 0.0], 1.0)
|
|
397
|
+
|
|
398
|
+
"""
|
|
399
|
+
if height == 0:
|
|
400
|
+
raise Exception("The box should have a height.")
|
|
401
|
+
|
|
402
|
+
x1, y1, z1 = corner1
|
|
403
|
+
x2, y2, z2 = corner2
|
|
404
|
+
|
|
405
|
+
if z1 != z2:
|
|
406
|
+
raise Exception("Corners should be in the same horizontal plane.")
|
|
407
|
+
|
|
408
|
+
xaxis = Vector(x2 - x1, 0, 0)
|
|
409
|
+
yaxis = Vector(0, y2 - y1, 0)
|
|
410
|
+
width = xaxis.length
|
|
411
|
+
depth = yaxis.length
|
|
412
|
+
point = [0.5 * (x1 + x2), 0.5 * (y1 + y2), z1 + 0.5 * height]
|
|
413
|
+
frame = Frame(point, xaxis, yaxis)
|
|
414
|
+
|
|
415
|
+
return cls(xsize=width, ysize=depth, zsize=height, frame=frame)
|
|
416
|
+
|
|
417
|
+
@classmethod
|
|
418
|
+
def from_diagonal(cls, diagonal): # type: (...) -> Box
|
|
419
|
+
"""Construct a box from its main diagonal.
|
|
420
|
+
|
|
421
|
+
Parameters
|
|
422
|
+
----------
|
|
423
|
+
diagonal : [point, point] | :class:`compas.geometry.Line`
|
|
424
|
+
The diagonal of the box, represented by a pair of points in space.
|
|
425
|
+
|
|
426
|
+
Returns
|
|
427
|
+
-------
|
|
428
|
+
:class:`compas.geometry.Box`
|
|
429
|
+
The resulting box.
|
|
430
|
+
|
|
431
|
+
Examples
|
|
432
|
+
--------
|
|
433
|
+
>>> diagonal = [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]
|
|
434
|
+
>>> box = Box.from_diagonal(diagonal)
|
|
435
|
+
|
|
436
|
+
"""
|
|
437
|
+
d1, d2 = diagonal
|
|
438
|
+
|
|
439
|
+
x1, y1, z1 = d1
|
|
440
|
+
x2, y2, z2 = d2
|
|
441
|
+
|
|
442
|
+
if z1 == z2:
|
|
443
|
+
raise Exception("The box has no height.")
|
|
444
|
+
|
|
445
|
+
xaxis = Vector(x2 - x1, 0, 0)
|
|
446
|
+
yaxis = Vector(0, y2 - y1, 0)
|
|
447
|
+
zaxis = Vector(0, 0, z2 - z1)
|
|
448
|
+
width = xaxis.length
|
|
449
|
+
depth = yaxis.length
|
|
450
|
+
height = zaxis.length
|
|
451
|
+
point = [0.5 * (x1 + x2), 0.5 * (y1 + y2), 0.5 * (z1 + z2)]
|
|
452
|
+
frame = Frame(point, xaxis, yaxis)
|
|
453
|
+
|
|
454
|
+
return cls(width, depth, height, frame)
|
|
455
|
+
|
|
456
|
+
@classmethod
|
|
457
|
+
def from_points(cls, points): # type: (...) -> Box
|
|
458
|
+
"""Construct a box from a set of points.
|
|
459
|
+
|
|
460
|
+
Parameters
|
|
461
|
+
----------
|
|
462
|
+
points : list[:class:`compas.geometry.Point`]
|
|
463
|
+
A list of points.
|
|
464
|
+
|
|
465
|
+
Returns
|
|
466
|
+
-------
|
|
467
|
+
:class:`compas.geometry.Box`
|
|
468
|
+
The resulting box.
|
|
469
|
+
|
|
470
|
+
"""
|
|
471
|
+
from compas.geometry import bounding_box
|
|
472
|
+
|
|
473
|
+
bbox = bounding_box(points)
|
|
474
|
+
return cls.from_bounding_box(bbox)
|
|
475
|
+
|
|
476
|
+
# ==========================================================================
|
|
477
|
+
# Conversions
|
|
478
|
+
# ==========================================================================
|
|
479
|
+
|
|
480
|
+
def to_vertices_and_faces(self, triangulated=False):
|
|
481
|
+
"""Returns a list of vertices and faces.
|
|
482
|
+
|
|
483
|
+
Parameters
|
|
484
|
+
----------
|
|
485
|
+
triangulated: bool, optional
|
|
486
|
+
If True, triangulate the faces.
|
|
487
|
+
|
|
488
|
+
Returns
|
|
489
|
+
-------
|
|
490
|
+
list[list[float]], list[list[int]]
|
|
491
|
+
A list of vertex locations, and a list of faces,
|
|
492
|
+
with each face defined as a list of indices into the list of vertices.
|
|
493
|
+
|
|
494
|
+
"""
|
|
495
|
+
point = self.frame.point
|
|
496
|
+
xaxis = self.frame.xaxis
|
|
497
|
+
yaxis = self.frame.yaxis
|
|
498
|
+
zaxis = self.frame.zaxis
|
|
499
|
+
|
|
500
|
+
dx = 0.5 * self.xsize
|
|
501
|
+
dy = 0.5 * self.ysize
|
|
502
|
+
dz = 0.5 * self.zsize
|
|
503
|
+
|
|
504
|
+
a = point + xaxis * -dx + yaxis * -dy + zaxis * -dz
|
|
505
|
+
b = point + xaxis * -dx + yaxis * +dy + zaxis * -dz
|
|
506
|
+
c = point + xaxis * +dx + yaxis * +dy + zaxis * -dz
|
|
507
|
+
d = point + xaxis * +dx + yaxis * -dy + zaxis * -dz
|
|
508
|
+
e = a + zaxis * self.zsize
|
|
509
|
+
f = d + zaxis * self.zsize
|
|
510
|
+
g = c + zaxis * self.zsize
|
|
511
|
+
h = b + zaxis * self.zsize
|
|
512
|
+
|
|
513
|
+
vertices = [a, b, c, d, e, f, g, h]
|
|
514
|
+
_faces = [self.bottom, self.front, self.right, self.back, self.left, self.top]
|
|
515
|
+
|
|
516
|
+
if triangulated:
|
|
517
|
+
faces = []
|
|
518
|
+
for a, b, c, d in _faces:
|
|
519
|
+
faces.append([a, b, c])
|
|
520
|
+
faces.append([a, c, d])
|
|
521
|
+
else:
|
|
522
|
+
faces = _faces
|
|
523
|
+
|
|
524
|
+
return vertices, faces
|
|
525
|
+
|
|
526
|
+
def to_mesh(self, triangulated=False):
|
|
527
|
+
"""Returns a mesh representation of the box.
|
|
528
|
+
|
|
529
|
+
Parameters
|
|
530
|
+
----------
|
|
531
|
+
triangulated: bool, optional
|
|
532
|
+
If True, triangulate the faces.
|
|
533
|
+
|
|
534
|
+
Returns
|
|
535
|
+
-------
|
|
536
|
+
:class:`compas.datastructures.Mesh`
|
|
537
|
+
|
|
538
|
+
"""
|
|
539
|
+
from compas.datastructures import Mesh
|
|
540
|
+
|
|
541
|
+
vertices, faces = self.to_vertices_and_faces(triangulated=triangulated)
|
|
542
|
+
|
|
543
|
+
mesh = Mesh.from_vertices_and_faces(vertices, faces)
|
|
544
|
+
|
|
545
|
+
return mesh
|
|
546
|
+
|
|
547
|
+
def to_brep(self):
|
|
548
|
+
"""Returns a BREP representation of the box.
|
|
549
|
+
|
|
550
|
+
Returns
|
|
551
|
+
-------
|
|
552
|
+
:class:`compas.brep.Brep`
|
|
553
|
+
|
|
554
|
+
"""
|
|
555
|
+
from compas.geometry import Brep
|
|
556
|
+
|
|
557
|
+
return Brep.from_box(self)
|
|
558
|
+
|
|
559
|
+
# ==========================================================================
|
|
560
|
+
# Transformations
|
|
561
|
+
# ==========================================================================
|
|
562
|
+
|
|
563
|
+
# def transform(self, transformation):
|
|
564
|
+
# """Transform the box.
|
|
565
|
+
|
|
566
|
+
# Parameters
|
|
567
|
+
# ----------
|
|
568
|
+
# transformation : :class:`Transformation`
|
|
569
|
+
# The transformation used to transform the Box.
|
|
570
|
+
|
|
571
|
+
# Returns
|
|
572
|
+
# -------
|
|
573
|
+
# None
|
|
574
|
+
|
|
575
|
+
# Examples
|
|
576
|
+
# --------
|
|
577
|
+
# >>> box = Box(Frame.worldXY(), 1.0, 2.0, 3.0)
|
|
578
|
+
# >>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
|
|
579
|
+
# >>> T = Transformation.from_frame(frame)
|
|
580
|
+
# >>> box.transform(T)
|
|
581
|
+
|
|
582
|
+
# """
|
|
583
|
+
# self.frame.transform(transformation)
|
|
584
|
+
# # Always local scaling, non-uniform scaling based on frame not yet considered.
|
|
585
|
+
# Sc, _, _, _, _ = transformation.decomposed()
|
|
586
|
+
# scalex = Sc[0, 0]
|
|
587
|
+
# scaley = Sc[1, 1]
|
|
588
|
+
# scalez = Sc[2, 2]
|
|
589
|
+
# self.xsize *= scalex
|
|
590
|
+
# self.ysize *= scaley
|
|
591
|
+
# self.zsize *= scalez
|
|
592
|
+
|
|
593
|
+
def scale(self, factor):
|
|
594
|
+
"""Scale the box.
|
|
595
|
+
|
|
596
|
+
Parameters
|
|
597
|
+
----------
|
|
598
|
+
factor : float
|
|
599
|
+
The scaling factor.
|
|
600
|
+
|
|
601
|
+
Returns
|
|
602
|
+
-------
|
|
603
|
+
None
|
|
604
|
+
|
|
605
|
+
"""
|
|
606
|
+
self.xsize *= factor
|
|
607
|
+
self.ysize *= factor
|
|
608
|
+
self.zsize *= factor
|
|
609
|
+
|
|
610
|
+
# ==========================================================================
|
|
611
|
+
# Methods
|
|
612
|
+
# ==========================================================================
|
|
613
|
+
|
|
614
|
+
def corner(self, index):
|
|
615
|
+
"""Return one of the eight corners of the box.
|
|
616
|
+
|
|
617
|
+
Parameters
|
|
618
|
+
----------
|
|
619
|
+
index : int
|
|
620
|
+
The index of the corner.
|
|
621
|
+
|
|
622
|
+
Returns
|
|
623
|
+
-------
|
|
624
|
+
:class:`compas.geometry.Point`
|
|
625
|
+
The corner point.
|
|
626
|
+
|
|
627
|
+
Raises
|
|
628
|
+
------
|
|
629
|
+
ValueError
|
|
630
|
+
If the index is not between 0 and 7.
|
|
631
|
+
|
|
632
|
+
"""
|
|
633
|
+
if index < 0 or index > 7:
|
|
634
|
+
raise ValueError("Index should be between 0 and 7.")
|
|
635
|
+
|
|
636
|
+
point = self.frame.point
|
|
637
|
+
xaxis = self.frame.xaxis
|
|
638
|
+
yaxis = self.frame.yaxis
|
|
639
|
+
zaxis = self.frame.zaxis
|
|
640
|
+
dx = 0.5 * self.xsize
|
|
641
|
+
dy = 0.5 * self.ysize
|
|
642
|
+
dz = 0.5 * self.zsize
|
|
643
|
+
if index == 0:
|
|
644
|
+
return point + xaxis * -dx + yaxis * -dy + zaxis * -dz
|
|
645
|
+
if index == 1:
|
|
646
|
+
return point + xaxis * -dx + yaxis * +dy + zaxis * -dz
|
|
647
|
+
if index == 2:
|
|
648
|
+
return point + xaxis * +dx + yaxis * +dy + zaxis * -dz
|
|
649
|
+
if index == 3:
|
|
650
|
+
return point + xaxis * +dx + yaxis * -dy + zaxis * -dz
|
|
651
|
+
if index == 4:
|
|
652
|
+
return point + xaxis * -dx + yaxis * -dy + zaxis * +dz
|
|
653
|
+
if index == 5:
|
|
654
|
+
return point + xaxis * -dx + yaxis * +dy + zaxis * +dz
|
|
655
|
+
if index == 6:
|
|
656
|
+
return point + xaxis * +dx + yaxis * +dy + zaxis * +dz
|
|
657
|
+
if index == 7:
|
|
658
|
+
return point + xaxis * +dx + yaxis * -dy + zaxis * +dz
|
|
659
|
+
|
|
660
|
+
def contains_point(self, point, tol=1e-6):
|
|
661
|
+
"""Verify if the box contains a given point.
|
|
662
|
+
|
|
663
|
+
Parameters
|
|
664
|
+
----------
|
|
665
|
+
point : [float, float, float] | :class:`compas.geometry.Point`
|
|
666
|
+
The point to test.
|
|
667
|
+
tol : float, optional
|
|
668
|
+
The tolerance for the point containment check.
|
|
669
|
+
|
|
670
|
+
Returns
|
|
671
|
+
-------
|
|
672
|
+
bool
|
|
673
|
+
|
|
674
|
+
See Also
|
|
675
|
+
--------
|
|
676
|
+
contains_points
|
|
677
|
+
|
|
678
|
+
"""
|
|
679
|
+
T = Transformation.from_change_of_basis(Frame.worldXY(), self.frame)
|
|
680
|
+
x, y, z = transform_points([point], T)[0]
|
|
681
|
+
|
|
682
|
+
dx = 0.5 * self.xsize + tol
|
|
683
|
+
|
|
684
|
+
if x < -dx or x > +dx:
|
|
685
|
+
return False
|
|
686
|
+
|
|
687
|
+
dy = 0.5 * self.ysize + tol
|
|
688
|
+
|
|
689
|
+
if y < -dy or y > +dy:
|
|
690
|
+
return False
|
|
691
|
+
|
|
692
|
+
dz = 0.5 * self.zsize + tol
|
|
693
|
+
|
|
694
|
+
if z < -dz or z > +dz:
|
|
695
|
+
return False
|
|
696
|
+
|
|
697
|
+
return True
|
|
698
|
+
|
|
699
|
+
def contains_points(self, points, tol=1e-6):
|
|
700
|
+
"""Verify if the box contains the given points.
|
|
701
|
+
|
|
702
|
+
Parameters
|
|
703
|
+
----------
|
|
704
|
+
points : list[[float, float, float]] | list[:class:`compas.geometry.Point`]
|
|
705
|
+
A list of points.
|
|
706
|
+
tol : float, optional
|
|
707
|
+
The tolerance for the point containment check.
|
|
708
|
+
|
|
709
|
+
Returns
|
|
710
|
+
-------
|
|
711
|
+
list[bool]
|
|
712
|
+
|
|
713
|
+
See Also
|
|
714
|
+
--------
|
|
715
|
+
contains_point
|
|
716
|
+
|
|
717
|
+
Examples
|
|
718
|
+
--------
|
|
719
|
+
>>> from compas.geometry import Point, Box
|
|
720
|
+
>>> box = Box(Frame.worldXY(), 2.0, 2.0, 2.0)
|
|
721
|
+
>>> points = [Point(0.0, 0.0, 0.0), Point(1.0, 1.0, 1.0)]
|
|
722
|
+
>>> results = box.contains_points(points)
|
|
723
|
+
>>> all(results)
|
|
724
|
+
True
|
|
725
|
+
|
|
726
|
+
"""
|
|
727
|
+
dx = 0.5 * self.xsize + tol
|
|
728
|
+
dy = 0.5 * self.ysize + tol
|
|
729
|
+
dz = 0.5 * self.zsize + tol
|
|
730
|
+
|
|
731
|
+
T = Transformation.from_change_of_basis(Frame.worldXY(), self.frame)
|
|
732
|
+
points = transform_points(points, T)
|
|
733
|
+
results = [False] * len(points)
|
|
734
|
+
|
|
735
|
+
for index, (x, y, z) in enumerate(points):
|
|
736
|
+
if x < -dx or x > +dx:
|
|
737
|
+
continue
|
|
738
|
+
|
|
739
|
+
if y < -dy or y > +dy:
|
|
740
|
+
continue
|
|
741
|
+
|
|
742
|
+
if z < -dz or z > +dz:
|
|
743
|
+
continue
|
|
744
|
+
|
|
745
|
+
results[index] = True
|
|
746
|
+
|
|
747
|
+
return results
|