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,184 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
import Rhino # type: ignore
|
|
6
|
+
|
|
7
|
+
from compas.geometry import BrepInvalidError
|
|
8
|
+
from compas_rhino.conversions import point_to_rhino
|
|
9
|
+
|
|
10
|
+
TOLERANCE = 1e-6
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class _RhinoLoopBuilder(object):
|
|
14
|
+
"""Builds a Brep loop.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
loop : :rhino:`Rhino.Geometry.BrepLoop`
|
|
19
|
+
The loop currently being constructed.
|
|
20
|
+
brep : :rhino:`Rhino.Geometry.Brep`
|
|
21
|
+
The parent brep object.
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
result : :rhino: Rhino.Geometry.BrepTrim
|
|
26
|
+
The created loop.
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, loop=None, brep=None):
|
|
31
|
+
self._loop = loop
|
|
32
|
+
self._brep = brep
|
|
33
|
+
|
|
34
|
+
def add_trim(self, curve, edge_index, is_reversed, iso_status, vertex_index):
|
|
35
|
+
"""Add trim to the new Brep.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
curve : :rhino:`Rhino.Geometry.NurbsCurve`
|
|
40
|
+
The curve representing the geometry of this trim.
|
|
41
|
+
edge_index : int
|
|
42
|
+
The index of the already added edge which corresponds with this trim.
|
|
43
|
+
is_reversed : bool
|
|
44
|
+
True if this trim is reversed in direction from its associated edge.
|
|
45
|
+
iso_status : :rhino:`Rhino.Geometry.IsoStatus`
|
|
46
|
+
The iso status of this trim.
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
-------
|
|
50
|
+
:rhino:`Rhino.Geometry.BrepTrim`
|
|
51
|
+
The newly added BrepTrim instance.
|
|
52
|
+
|
|
53
|
+
"""
|
|
54
|
+
c_index = self._brep.AddTrimCurve(curve)
|
|
55
|
+
if edge_index == -1: # singular trim
|
|
56
|
+
vertex = self._brep.Vertices[vertex_index]
|
|
57
|
+
trim = self._brep.Trims.AddSingularTrim(vertex, self._loop, iso_status, c_index)
|
|
58
|
+
else:
|
|
59
|
+
edge = self._brep.Edges[edge_index]
|
|
60
|
+
trim = self._brep.Trims.Add(edge, is_reversed, self._loop, c_index)
|
|
61
|
+
trim.IsoStatus = iso_status
|
|
62
|
+
trim.SetTolerances(TOLERANCE, TOLERANCE)
|
|
63
|
+
return trim
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def result(self):
|
|
67
|
+
return self._loop
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class _RhinoFaceBuilder(object):
|
|
71
|
+
"""Builds a BrepFace.
|
|
72
|
+
|
|
73
|
+
Serves as context for reconstructing the loop elements associated with this face.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
face : :rhino:`Rhino.Geometry.BrepFace`
|
|
78
|
+
The face currently being constructed.
|
|
79
|
+
brep : :rhino:`Rhino.Geometry.Brep`
|
|
80
|
+
The parent brep.
|
|
81
|
+
|
|
82
|
+
Attributes
|
|
83
|
+
----------
|
|
84
|
+
result : :rhino:`Rhino.Geometry.BrepFace`
|
|
85
|
+
The resulting BrepFace.
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def __init__(self, face=None, brep=None):
|
|
90
|
+
self._face = face
|
|
91
|
+
self._brep = brep
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def result(self):
|
|
95
|
+
return self._face
|
|
96
|
+
|
|
97
|
+
def add_loop(self, loop_type):
|
|
98
|
+
"""Add a new loop to this face.
|
|
99
|
+
|
|
100
|
+
Returns a new builder to be used by all the trims of the newly added loop.
|
|
101
|
+
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
loop_type : :rhino:`Rhino.Geometry.BrepLoopType`
|
|
105
|
+
The enumeration value representing the type of this loop.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
:class:`compas_rhino.geometry.RhinoLoopBuilder`
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
loop = self._brep.Loops.Add(loop_type, self._face)
|
|
113
|
+
return _RhinoLoopBuilder(loop, self._brep)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class _RhinoBrepBuilder(object):
|
|
117
|
+
"""Reconstructs a Rhino.Geometry.Brep from COMPAS types
|
|
118
|
+
|
|
119
|
+
Attributes
|
|
120
|
+
----------
|
|
121
|
+
result : :rhino:`Rhino.Geometry.Brep`
|
|
122
|
+
The Brep resulting from the reconstruction, if successful.
|
|
123
|
+
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
def __init__(self):
|
|
127
|
+
self._brep = Rhino.Geometry.Brep()
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def result(self):
|
|
131
|
+
is_valid, log = self._brep.IsValidWithLog()
|
|
132
|
+
if not is_valid:
|
|
133
|
+
raise BrepInvalidError("Brep reconstruction failed!\n{}".format(log))
|
|
134
|
+
return self._brep
|
|
135
|
+
|
|
136
|
+
def add_vertex(self, point):
|
|
137
|
+
"""Add vertext to a new Brep
|
|
138
|
+
|
|
139
|
+
point : :class:`compas.geometry.Point`
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
:rhino:`Rhino.Geometry.BrepVertex`
|
|
144
|
+
|
|
145
|
+
"""
|
|
146
|
+
return self._brep.Vertices.Add(point_to_rhino(point), TOLERANCE)
|
|
147
|
+
|
|
148
|
+
def add_edge(self, edge_curve, start_vertex, end_vertex):
|
|
149
|
+
"""Add edge to the new Brep
|
|
150
|
+
|
|
151
|
+
edge_curve : :class:`compas_rhino.geometry.RhinoNurbsCurve`
|
|
152
|
+
start_vertex: int
|
|
153
|
+
index of the vertex at the start of this edge
|
|
154
|
+
end_vertex: int
|
|
155
|
+
index of the vertex at the end of this edge
|
|
156
|
+
|
|
157
|
+
Returns
|
|
158
|
+
-------
|
|
159
|
+
:rhino:`Rhino.Geometry.BrepEdge`
|
|
160
|
+
|
|
161
|
+
"""
|
|
162
|
+
curve_index = self._brep.AddEdgeCurve(edge_curve)
|
|
163
|
+
s_vertex = self._brep.Vertices[start_vertex]
|
|
164
|
+
e_vertex = self._brep.Vertices[end_vertex]
|
|
165
|
+
return self._brep.Edges.Add(s_vertex, e_vertex, curve_index, TOLERANCE)
|
|
166
|
+
|
|
167
|
+
def add_face(self, surface):
|
|
168
|
+
"""Creates and adds a new face to the brep.
|
|
169
|
+
|
|
170
|
+
Returns a new builder to be used by all the loops related to his new face to add themselves.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
surface : :rhino:`Rhino.Geometry.Surface`
|
|
175
|
+
The surface of this face.
|
|
176
|
+
|
|
177
|
+
Returns
|
|
178
|
+
-------
|
|
179
|
+
:class:`compas_rhino.geometry.RhinoFaceBuilder`
|
|
180
|
+
|
|
181
|
+
"""
|
|
182
|
+
surface_index = self._brep.AddSurface(surface.rhino_surface)
|
|
183
|
+
face = self._brep.Faces.Add(surface_index)
|
|
184
|
+
return _RhinoFaceBuilder(face=face, brep=self._brep)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
import Rhino # type: ignore
|
|
6
|
+
|
|
7
|
+
from compas.geometry import Arc
|
|
8
|
+
from compas.geometry import BrepEdge
|
|
9
|
+
from compas.geometry import Circle
|
|
10
|
+
from compas.geometry import Ellipse
|
|
11
|
+
from compas.geometry import Frame
|
|
12
|
+
from compas.geometry import Line
|
|
13
|
+
from compas_rhino.conversions import arc_to_compas
|
|
14
|
+
from compas_rhino.conversions import arc_to_rhino
|
|
15
|
+
from compas_rhino.conversions import circle_to_compas
|
|
16
|
+
from compas_rhino.conversions import circle_to_rhino
|
|
17
|
+
from compas_rhino.conversions import curve_to_compas_line
|
|
18
|
+
from compas_rhino.conversions import ellipse_to_compas
|
|
19
|
+
from compas_rhino.conversions import ellipse_to_rhino
|
|
20
|
+
from compas_rhino.conversions import frame_to_rhino_plane
|
|
21
|
+
from compas_rhino.conversions import line_to_rhino
|
|
22
|
+
from compas_rhino.conversions import plane_to_compas_frame
|
|
23
|
+
from compas_rhino.conversions import point_to_compas
|
|
24
|
+
from compas_rhino.geometry import RhinoNurbsCurve
|
|
25
|
+
|
|
26
|
+
from .vertex import RhinoBrepVertex
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class RhinoBrepEdge(BrepEdge):
|
|
30
|
+
"""A wrapper for Rhino.Geometry.BrepEdge.
|
|
31
|
+
|
|
32
|
+
The expected native type here is a Rhino.Geometry.BrepTrim.
|
|
33
|
+
a BrepTrim holds a reference to its associated BrepEdge as well as its start a end vertices
|
|
34
|
+
in a correct topological order (!).
|
|
35
|
+
|
|
36
|
+
Attributes
|
|
37
|
+
----------
|
|
38
|
+
curve : :class:`Rhino.Geometry.Curve3D`
|
|
39
|
+
The underlying geometry of this edge.
|
|
40
|
+
start_vertex : :class:`compas_rhino.geometry.RhinoBrepVertex`, read-only
|
|
41
|
+
The start vertex of this edge (taken from BrepTrim).
|
|
42
|
+
end_vertex : :class:`compas_rhino.geometry.RhinoBrepVertex`, read-only
|
|
43
|
+
The end vertex of this edge (taken from BrepTrim).
|
|
44
|
+
vertices : list[:class:`compas_rhino.geometry.RhinoBrepVertex`], read-only
|
|
45
|
+
The list of vertices which comprise this edge (start and end)
|
|
46
|
+
is_circle : bool, read-only
|
|
47
|
+
True if the geometry of this edge is a circle, False otherwise.
|
|
48
|
+
is_line : bool, read-only
|
|
49
|
+
True if the geometry of this edge is a line, False otherwise.
|
|
50
|
+
native_edge : :class:`Rhino.Geometry.BrepEdge`
|
|
51
|
+
The underlying BrepEdge object.
|
|
52
|
+
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __init__(self, rhino_edge=None):
|
|
56
|
+
super(RhinoBrepEdge, self).__init__()
|
|
57
|
+
self._edge = None
|
|
58
|
+
self._curve = None
|
|
59
|
+
self._curve_type = None
|
|
60
|
+
self._start_vertex = None
|
|
61
|
+
self._end_vertex = None
|
|
62
|
+
self._mass_props = None
|
|
63
|
+
if rhino_edge:
|
|
64
|
+
self.native_edge = rhino_edge
|
|
65
|
+
|
|
66
|
+
# ==============================================================================
|
|
67
|
+
# Data
|
|
68
|
+
# ==============================================================================
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def __data__(self):
|
|
72
|
+
curve_type, curve, plane, domain = self._get_curve_geometry()
|
|
73
|
+
return {
|
|
74
|
+
"curve_type": curve_type,
|
|
75
|
+
"curve": curve.__data__,
|
|
76
|
+
"frame": plane_to_compas_frame(plane).__data__,
|
|
77
|
+
"start_vertex": self._edge.StartVertex.VertexIndex,
|
|
78
|
+
"end_vertex": self._edge.EndVertex.VertexIndex,
|
|
79
|
+
"domain": domain,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def __from_data__(cls, data, builder):
|
|
84
|
+
"""Construct an object of this type from the provided data.
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
data : dict
|
|
89
|
+
The data dictionary.
|
|
90
|
+
builder : :class:`compas_rhino.geometry.BrepBuilder`
|
|
91
|
+
The object reconstructing the current Brep.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
:class:`compas.data.Data`
|
|
96
|
+
An instance of this object type if the data contained in the dict has the correct schema.
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
instance = cls()
|
|
100
|
+
edge_curve = cls._create_curve__from_data__(data["curve_type"], data["curve"], data["frame"], data["domain"])
|
|
101
|
+
instance.native_edge = builder.add_edge(edge_curve, data["start_vertex"], data["end_vertex"])
|
|
102
|
+
return instance
|
|
103
|
+
|
|
104
|
+
# ==============================================================================
|
|
105
|
+
# Properties
|
|
106
|
+
# ==============================================================================
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def centroid(self):
|
|
110
|
+
return point_to_compas(self._mass_props.Centroid)
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def curve(self):
|
|
114
|
+
return self._curve
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def native_edge(self):
|
|
118
|
+
return self._native_edge
|
|
119
|
+
|
|
120
|
+
@native_edge.setter
|
|
121
|
+
def native_edge(self, value):
|
|
122
|
+
self._edge = value
|
|
123
|
+
self._mass_props = Rhino.Geometry.LengthMassProperties.Compute(value.EdgeCurve)
|
|
124
|
+
self._curve = RhinoNurbsCurve.from_rhino(value.EdgeCurve.ToNurbsCurve())
|
|
125
|
+
self._start_vertex = RhinoBrepVertex(value.StartVertex)
|
|
126
|
+
self._end_vertex = RhinoBrepVertex(value.EndVertex)
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def start_vertex(self):
|
|
130
|
+
return self._start_vertex
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def end_vertex(self):
|
|
134
|
+
return self._end_vertex
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def vertices(self):
|
|
138
|
+
return [self.start_vertex, self.end_vertex]
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def is_circle(self):
|
|
142
|
+
return self._edge.EdgeCurve.IsCircle()
|
|
143
|
+
|
|
144
|
+
@property
|
|
145
|
+
def is_line(self):
|
|
146
|
+
return self._edge.EdgeCurve.IsLinear()
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def is_ellipse(self):
|
|
150
|
+
return self._edge.EdgeCurve.IsEllipse()
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def length(self):
|
|
154
|
+
return self._mass_props.Length
|
|
155
|
+
|
|
156
|
+
# ==============================================================================
|
|
157
|
+
# Methods
|
|
158
|
+
# ==============================================================================
|
|
159
|
+
|
|
160
|
+
def _get_curve_geometry(self):
|
|
161
|
+
curve = self._edge.EdgeCurve
|
|
162
|
+
domain = [self._edge.Domain[0], self._edge.Domain[1]]
|
|
163
|
+
_, frame = curve.FrameAt(0)
|
|
164
|
+
if isinstance(curve, Rhino.Geometry.LineCurve):
|
|
165
|
+
return "line", curve_to_compas_line(curve), frame, domain
|
|
166
|
+
if isinstance(curve, Rhino.Geometry.NurbsCurve):
|
|
167
|
+
return "nurbs", RhinoNurbsCurve.from_rhino(curve), frame, domain
|
|
168
|
+
if isinstance(curve, Rhino.Geometry.ArcCurve):
|
|
169
|
+
if not curve.IsClosed:
|
|
170
|
+
return "arc", arc_to_compas(curve.Arc), curve.Arc.Plane, domain
|
|
171
|
+
is_circle, circle = curve.TryGetCircle()
|
|
172
|
+
if is_circle:
|
|
173
|
+
return "circle", circle_to_compas(circle), circle.Plane, domain
|
|
174
|
+
is_ellipse, ellipse = curve.TryGetEllipse()
|
|
175
|
+
if is_ellipse:
|
|
176
|
+
return "ellipse", ellipse_to_compas(ellipse), ellipse.Plane, domain
|
|
177
|
+
return "nurbs", curve.ToNurbsCurve(), frame, domain
|
|
178
|
+
raise ValueError("Unknown curve type: {}".format(curve.__class__.__name__))
|
|
179
|
+
|
|
180
|
+
@staticmethod
|
|
181
|
+
def _create_curve__from_data__(curve_type, curve_data, frame_data, domain):
|
|
182
|
+
frame = Frame.__from_data__(frame_data)
|
|
183
|
+
if curve_type == "line":
|
|
184
|
+
line = Line.__from_data__(curve_data)
|
|
185
|
+
curve = Rhino.Geometry.LineCurve(line_to_rhino(line))
|
|
186
|
+
elif curve_type == "circle":
|
|
187
|
+
circle = circle_to_rhino(Circle.__from_data__(curve_data))
|
|
188
|
+
circle.Plane = frame_to_rhino_plane(frame)
|
|
189
|
+
curve = Rhino.Geometry.ArcCurve(circle)
|
|
190
|
+
elif curve_type == "ellipse":
|
|
191
|
+
ellipse = ellipse_to_rhino(Ellipse.__from_data__(curve_data))
|
|
192
|
+
ellipse.Plane = frame_to_rhino_plane(frame)
|
|
193
|
+
curve = Rhino.Geometry.NurbsCurve.CreateFromEllipse(ellipse)
|
|
194
|
+
elif curve_type == "arc":
|
|
195
|
+
arc = arc_to_rhino(Arc.__from_data__(curve_data))
|
|
196
|
+
curve = Rhino.Geometry.ArcCurve(arc)
|
|
197
|
+
elif curve_type == "nurbs":
|
|
198
|
+
curve = RhinoNurbsCurve.__from_data__(curve_data).rhino_curve
|
|
199
|
+
else:
|
|
200
|
+
raise ValueError("Unknown curve type: {}".format(curve_type))
|
|
201
|
+
curve.Domain = Rhino.Geometry.Interval(*domain)
|
|
202
|
+
return curve
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
import Rhino # type: ignore
|
|
6
|
+
|
|
7
|
+
from compas.geometry import Brep
|
|
8
|
+
from compas.geometry import BrepFace
|
|
9
|
+
from compas.geometry import Cylinder
|
|
10
|
+
from compas.geometry import Frame
|
|
11
|
+
from compas.geometry import Sphere
|
|
12
|
+
from compas.geometry import SurfaceType
|
|
13
|
+
from compas_rhino.conversions import cylinder_to_compas
|
|
14
|
+
from compas_rhino.conversions import cylinder_to_rhino
|
|
15
|
+
from compas_rhino.conversions import frame_to_rhino_plane
|
|
16
|
+
from compas_rhino.conversions import plane_to_compas_frame
|
|
17
|
+
from compas_rhino.conversions import sphere_to_compas
|
|
18
|
+
from compas_rhino.conversions import sphere_to_rhino
|
|
19
|
+
from compas_rhino.geometry import RhinoNurbsSurface
|
|
20
|
+
from compas_rhino.geometry.surfaces import RhinoSurface
|
|
21
|
+
|
|
22
|
+
from .edge import RhinoBrepEdge
|
|
23
|
+
from .loop import RhinoBrepLoop
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RhinoBrepFace(BrepFace):
|
|
27
|
+
"""A wrapper for Rhino.Geometry.BrepFace
|
|
28
|
+
|
|
29
|
+
Attributes
|
|
30
|
+
----------
|
|
31
|
+
native_surface : :class:`Rhino.Geometry.Surface`
|
|
32
|
+
The rhino native underlying geometry of this face.
|
|
33
|
+
loops : list[:class:`compas_rhino.geometry.RhinoBrepLoop`], read-only
|
|
34
|
+
The list of loops which comprise this face.
|
|
35
|
+
surface : :class:`compas_rhino.geometry.RhinoNurbsSurface`
|
|
36
|
+
The compas_rhino wrapper of the underlying geometry of this face.
|
|
37
|
+
boundary : :class:`compas_rhino.geometry.RhinoBrepLoop`, read-only
|
|
38
|
+
The loop which defines the outer boundary of this face.
|
|
39
|
+
holes : list[:class:`compas_rhino.geometry.RhinoBrepLoop`], read-only
|
|
40
|
+
The list of loops which comprise the holes of this brep, if any.
|
|
41
|
+
is_plane : float, read-only
|
|
42
|
+
True if the geometry of this face is a plane, False otherwise.
|
|
43
|
+
native_face : :class:`Rhino.Geometry.BrepFace`
|
|
44
|
+
The underlying BrepFace object.
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self, rhino_face=None):
|
|
49
|
+
super(RhinoBrepFace, self).__init__()
|
|
50
|
+
self._loops = None
|
|
51
|
+
self._surface = None
|
|
52
|
+
self._face = None
|
|
53
|
+
if rhino_face:
|
|
54
|
+
self.native_face = rhino_face
|
|
55
|
+
|
|
56
|
+
# ==============================================================================
|
|
57
|
+
# Data
|
|
58
|
+
# ==============================================================================
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def __data__(self):
|
|
62
|
+
surface_type, surface, uv_domain, plane = self._get_surface_geometry(self._face.UnderlyingSurface())
|
|
63
|
+
return {
|
|
64
|
+
"surface_type": surface_type,
|
|
65
|
+
"surface": surface.__data__,
|
|
66
|
+
"uv_domain": uv_domain,
|
|
67
|
+
"frame": plane_to_compas_frame(plane).__data__, # until all shapes have a frame
|
|
68
|
+
"loops": [loop.__data__ for loop in self._loops],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def __from_data__(cls, data, builder):
|
|
73
|
+
"""Construct an object of this type from the provided data.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
data : dict
|
|
78
|
+
The data dictionary.
|
|
79
|
+
builder : :class:`compas_rhino.geometry.BrepBuilder`
|
|
80
|
+
The object reconstructing the current Brep.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
:class:`compas.data.Data`
|
|
85
|
+
An instance of this object type if the data contained in the dict has the correct schema.
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
instance = cls()
|
|
90
|
+
instance._surface = instance._make_surface__from_data__(data["surface_type"], data["surface"], data["uv_domain"], data["frame"])
|
|
91
|
+
face_builder = builder.add_face(instance._surface)
|
|
92
|
+
for loop_data in data["loops"]:
|
|
93
|
+
RhinoBrepLoop.__from_data__(loop_data, face_builder)
|
|
94
|
+
instance.native_face = face_builder.result
|
|
95
|
+
return instance
|
|
96
|
+
|
|
97
|
+
# ==============================================================================
|
|
98
|
+
# Properties
|
|
99
|
+
# ==============================================================================
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def native_surface(self):
|
|
103
|
+
return self._surface
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def area(self):
|
|
107
|
+
return self._mass_props.Area
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def centroid(self):
|
|
111
|
+
return self._mass_props.Centroid
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def edges(self):
|
|
115
|
+
brep = self._face.Brep
|
|
116
|
+
edge_indices = self._face.AdjacentEdges()
|
|
117
|
+
return [RhinoBrepEdge(brep.Edges[index]) for index in edge_indices]
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def loops(self):
|
|
121
|
+
return self._loops
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def surface(self):
|
|
125
|
+
return self._surface
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def boundary(self):
|
|
129
|
+
return self._loops[0]
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def holes(self):
|
|
133
|
+
return self._loops[1:]
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def is_plane(self):
|
|
137
|
+
return self._face.UnderlyingSurface().IsPlanar()
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def is_cone(self):
|
|
141
|
+
return self._face.UnderlyingSurface().IsCone()
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def is_cylinder(self):
|
|
145
|
+
return self._face.UnderlyingSurface().IsCylinder()
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def is_sphere(self):
|
|
149
|
+
return self._face.UnderlyingSurface().IsSphere()
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def is_torus(self):
|
|
153
|
+
return self._face.UnderlyingSurface().IsTorus()
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def native_face(self):
|
|
157
|
+
return self._face
|
|
158
|
+
|
|
159
|
+
@native_face.setter
|
|
160
|
+
def native_face(self, rhino_face):
|
|
161
|
+
self._face = rhino_face
|
|
162
|
+
self._mass_props = Rhino.Geometry.AreaMassProperties.Compute(rhino_face.ToBrep())
|
|
163
|
+
self._loops = [RhinoBrepLoop(loop) for loop in rhino_face.Loops]
|
|
164
|
+
self._surface = RhinoNurbsSurface.from_rhino(self._face.UnderlyingSurface().ToNurbsSurface())
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def nurbssurface(self):
|
|
168
|
+
return self._surface
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def vertices(self):
|
|
172
|
+
vertices = []
|
|
173
|
+
for edge in self.edges:
|
|
174
|
+
vertices.extend(edge.vertices)
|
|
175
|
+
return vertices
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def type(self):
|
|
179
|
+
if self.is_cone:
|
|
180
|
+
return SurfaceType.CONE
|
|
181
|
+
elif self.is_cylinder:
|
|
182
|
+
return SurfaceType.CYLINDER
|
|
183
|
+
elif self.is_sphere:
|
|
184
|
+
return SurfaceType.SPHERE
|
|
185
|
+
elif self.is_torus:
|
|
186
|
+
return SurfaceType.TORUS
|
|
187
|
+
elif self.is_plane:
|
|
188
|
+
return SurfaceType.PLANE
|
|
189
|
+
else:
|
|
190
|
+
return SurfaceType.OTHER_SURFACE
|
|
191
|
+
|
|
192
|
+
# ==============================================================================
|
|
193
|
+
# Methods
|
|
194
|
+
# ==============================================================================
|
|
195
|
+
|
|
196
|
+
@staticmethod
|
|
197
|
+
def _get_surface_geometry(surface):
|
|
198
|
+
uv_domain = [[surface.Domain(0)[0], surface.Domain(0)[1]], [surface.Domain(1)[0], surface.Domain(1)[1]]]
|
|
199
|
+
if isinstance(surface, Rhino.Geometry.PlaneSurface):
|
|
200
|
+
_, plane = surface.FrameAt(0.0, 0.0)
|
|
201
|
+
return "plane", plane_to_compas_frame(plane), uv_domain, plane
|
|
202
|
+
if isinstance(surface, Rhino.Geometry.NurbsSurface):
|
|
203
|
+
_, plane = surface.FrameAt(0.0, 0.0)
|
|
204
|
+
return "nurbs", RhinoNurbsSurface.from_rhino(surface), uv_domain, plane
|
|
205
|
+
if isinstance(surface, Rhino.Geometry.Rhino.Geometry.RevSurface):
|
|
206
|
+
success, cast_surface = surface.TryGetSphere()
|
|
207
|
+
if success:
|
|
208
|
+
return "sphere", sphere_to_compas(cast_surface), uv_domain, cast_surface.EquatorialPlane
|
|
209
|
+
success, cast_surface = surface.TryGetCylinder()
|
|
210
|
+
if success:
|
|
211
|
+
return "cylinder", cylinder_to_compas(cast_surface), uv_domain, cast_surface.BasePlane
|
|
212
|
+
success, cast_surface = surface.TryGetTorus()
|
|
213
|
+
raise NotImplementedError("Support for surface type: {} is not yet implemented.".format(surface.__class__.__name__))
|
|
214
|
+
|
|
215
|
+
def _make_surface__from_data__(self, surface_type, surface_data, uv_domain, frame_data):
|
|
216
|
+
u_domain, v_domain = uv_domain
|
|
217
|
+
frame = Frame.__from_data__(frame_data) # workaround until all shapes have a frame
|
|
218
|
+
if surface_type == "plane":
|
|
219
|
+
frame = Frame.__from_data__(surface_data) # redundancy in shapes which already have a frame
|
|
220
|
+
surface = RhinoSurface.from_frame(frame, u_domain, v_domain)
|
|
221
|
+
elif surface_type == "sphere":
|
|
222
|
+
sphere = self._make_sphere_surface(surface_data, u_domain, v_domain, frame)
|
|
223
|
+
surface = RhinoSurface.from_rhino(sphere)
|
|
224
|
+
elif surface_type == "cylinder":
|
|
225
|
+
cylinder = self._make_cylinder_surface(surface_data, u_domain, v_domain, frame)
|
|
226
|
+
surface = RhinoSurface.from_rhino(cylinder)
|
|
227
|
+
elif surface_type == "nurbs":
|
|
228
|
+
surface = RhinoNurbsSurface.__from_data__(surface_data)
|
|
229
|
+
elif surface_type == "torus":
|
|
230
|
+
raise NotImplementedError("Support for torus surface is not yet implemented!")
|
|
231
|
+
else:
|
|
232
|
+
raise NotImplementedError("Support for surface type: {} is not yet implemented.".format(surface_type))
|
|
233
|
+
surface.rhino_surface.SetDomain(0, Rhino.Geometry.Interval(*u_domain))
|
|
234
|
+
surface.rhino_surface.SetDomain(1, Rhino.Geometry.Interval(*v_domain))
|
|
235
|
+
return surface
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def _make_cylinder_surface(surface_data, u_domain, v_domain, frame):
|
|
239
|
+
cylinder = Cylinder.__from_data__(surface_data)
|
|
240
|
+
cylinder = cylinder_to_rhino(cylinder)
|
|
241
|
+
cylinder.BasePlane = frame_to_rhino_plane(frame)
|
|
242
|
+
surface = Rhino.Geometry.RevSurface.CreateFromCylinder(cylinder)
|
|
243
|
+
surface.SetDomain(0, Rhino.Geometry.Interval(*u_domain))
|
|
244
|
+
surface.SetDomain(1, Rhino.Geometry.Interval(*v_domain))
|
|
245
|
+
return surface
|
|
246
|
+
|
|
247
|
+
@staticmethod
|
|
248
|
+
def _make_sphere_surface(surface_data, u_domain, v_domain, frame):
|
|
249
|
+
sphere = Sphere.__from_data__(surface_data)
|
|
250
|
+
sphere = sphere_to_rhino(sphere)
|
|
251
|
+
# seems Sphere => Rhino.Geometry.RevSurface conversion modifies the orientation of the sphere
|
|
252
|
+
# setting the plane here is overriden by this modification and surface ends up oriented differntly than
|
|
253
|
+
# original.
|
|
254
|
+
# sphere.EquatorialPlane = frame_to_rhino_plane(frame)
|
|
255
|
+
surface = Rhino.Geometry.RevSurface.CreateFromSphere(sphere)
|
|
256
|
+
surface.SetDomain(0, Rhino.Geometry.Interval(*u_domain))
|
|
257
|
+
surface.SetDomain(1, Rhino.Geometry.Interval(*v_domain))
|
|
258
|
+
return surface
|
|
259
|
+
|
|
260
|
+
# ==============================================================================
|
|
261
|
+
# Methods
|
|
262
|
+
# ==============================================================================
|
|
263
|
+
|
|
264
|
+
def adjacent_faces(self):
|
|
265
|
+
"""Returns a list of the faces adjacent to this face.
|
|
266
|
+
|
|
267
|
+
Returns
|
|
268
|
+
-------
|
|
269
|
+
list[:class:`compas_rhino.geometry.RhinoBrepFace`]
|
|
270
|
+
The list of adjacent faces.
|
|
271
|
+
|
|
272
|
+
"""
|
|
273
|
+
face_indices = self._face.AdjacentFaces()
|
|
274
|
+
brep = self._face.Brep
|
|
275
|
+
return [RhinoBrepFace(brep.Faces[index]) for index in face_indices]
|
|
276
|
+
|
|
277
|
+
def as_brep(self):
|
|
278
|
+
"""Returns a Brep representation of this face.
|
|
279
|
+
|
|
280
|
+
Returns
|
|
281
|
+
-------
|
|
282
|
+
:class:`~compas_rhino.geometry.RhinoBrep`
|
|
283
|
+
|
|
284
|
+
"""
|
|
285
|
+
return Brep.from_native(self._face.ToBrep())
|