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,102 @@
|
|
|
1
|
+
from compas.plugins import pluggable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@pluggable(category="triangulation")
|
|
5
|
+
def delaunay_triangulation(points):
|
|
6
|
+
"""Construct a Delaunay triangulation of set of vertices.
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
----------
|
|
10
|
+
points : list
|
|
11
|
+
XY(Z) coordinates of the points to triangulate.
|
|
12
|
+
|
|
13
|
+
Returns
|
|
14
|
+
-------
|
|
15
|
+
(list, list)
|
|
16
|
+
The vertices of the triangulation, and the faces of the triangulation.
|
|
17
|
+
|
|
18
|
+
Examples
|
|
19
|
+
--------
|
|
20
|
+
>>>
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
from numpy import asarray
|
|
24
|
+
from scipy.spatial import Delaunay
|
|
25
|
+
|
|
26
|
+
xyz = asarray(points)
|
|
27
|
+
d = Delaunay(xyz[:, 0:2])
|
|
28
|
+
return xyz, d.simplices
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
delaunay_triangulation.__pluggable__ = True
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@pluggable(category="triangulation")
|
|
35
|
+
def constrained_delaunay_triangulation(boundary, polylines=None, polygons=None):
|
|
36
|
+
"""Construct a Delaunay triangulation of set of vertices, constrained to the specified segments.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
boundary : list
|
|
41
|
+
Ordered points on the boundary.
|
|
42
|
+
polylines : list, optional
|
|
43
|
+
Lists of ordered points defining internal guide curves.
|
|
44
|
+
polygons : list, optional
|
|
45
|
+
Lists of ordered points defining holes in the triangulation.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
(list, list)
|
|
50
|
+
The vertices of the triangulation, and the faces of the triangulation.
|
|
51
|
+
|
|
52
|
+
Notes
|
|
53
|
+
-----
|
|
54
|
+
No additional points will be inserted in the triangulation.
|
|
55
|
+
|
|
56
|
+
Examples
|
|
57
|
+
--------
|
|
58
|
+
>>>
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
constrained_delaunay_triangulation.__pluggable__ = True
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pluggable(category="triangulation")
|
|
68
|
+
def conforming_delaunay_triangulation(boundary, polylines=None, polygons=None, angle=None, area=None):
|
|
69
|
+
"""Construct a Conforming Delaunay triangulation of set of vertices, constrained to the specified segments.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
boundary : list
|
|
74
|
+
Ordered points on the boundary.
|
|
75
|
+
polylines : list, optional
|
|
76
|
+
Lists of ordered points defining internal guide curves.
|
|
77
|
+
polygons : list, optional
|
|
78
|
+
Lists of ordered points defining holes in the triangulation.
|
|
79
|
+
angle : float, optional
|
|
80
|
+
Minimum angle constraint for the triangles of the triangulation.
|
|
81
|
+
If an angle constraint is given, "Steiner points" may be inserted internally
|
|
82
|
+
and along the constraint segments to satisfy the constraint.
|
|
83
|
+
The angle constraint should be specified in degrees.
|
|
84
|
+
area : float, optional
|
|
85
|
+
Maximum area constraint for the triangles of the triangulation.
|
|
86
|
+
If an area constraint is given, "Steiner points" may be inserted internally
|
|
87
|
+
and along the constraint segments to satisfy the constraint.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
(list, list)
|
|
92
|
+
The vertices of the triangulation, and the faces of the triangulation.
|
|
93
|
+
|
|
94
|
+
Examples
|
|
95
|
+
--------
|
|
96
|
+
>>>
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
raise NotImplementedError
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
conforming_delaunay_triangulation.__pluggable__ = True
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
class Ear(object):
|
|
2
|
+
"""Represents an Ear of a polygon. An Ear is a triangle formed by three consecutive vertices of the polygon.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
points : list
|
|
7
|
+
List of points representing the polygon.
|
|
8
|
+
indexes : list
|
|
9
|
+
List of indices of the points representing the polygon.
|
|
10
|
+
ind : int
|
|
11
|
+
Index of the vertex of the Ear triangle.
|
|
12
|
+
|
|
13
|
+
Attributes
|
|
14
|
+
----------
|
|
15
|
+
index : int
|
|
16
|
+
Index of the vertex of the Ear triangle.
|
|
17
|
+
coords : list
|
|
18
|
+
Coordinates of the vertex of the Ear triangle.
|
|
19
|
+
next : int
|
|
20
|
+
Index of the next vertex of the Ear triangle.
|
|
21
|
+
prew : int
|
|
22
|
+
Index of the previous vertex of the Ear triangle.
|
|
23
|
+
neighbour_coords : list
|
|
24
|
+
Coordinates of the next and previous vertices of the Ear triangle.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, points, indexes, ind):
|
|
29
|
+
self.index = ind
|
|
30
|
+
self.coords = points[ind]
|
|
31
|
+
length = len(indexes)
|
|
32
|
+
index_in_indexes_arr = indexes.index(ind)
|
|
33
|
+
self.next = indexes[(index_in_indexes_arr + 1) % length]
|
|
34
|
+
if index_in_indexes_arr == 0:
|
|
35
|
+
self.prew = indexes[length - 1]
|
|
36
|
+
else:
|
|
37
|
+
self.prew = indexes[index_in_indexes_arr - 1]
|
|
38
|
+
self.neighbour_coords = [points[self.prew], points[self.next]]
|
|
39
|
+
|
|
40
|
+
def is_inside(self, point):
|
|
41
|
+
"""Check if a given point is inside the triangle formed by the Ear.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
bool
|
|
46
|
+
True, if the point is inside the triangle, False otherwise.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
p1 = self.coords
|
|
50
|
+
p2 = self.neighbour_coords[0]
|
|
51
|
+
p3 = self.neighbour_coords[1]
|
|
52
|
+
p0 = point
|
|
53
|
+
|
|
54
|
+
d = [
|
|
55
|
+
(p1[0] - p0[0]) * (p2[1] - p1[1]) - (p2[0] - p1[0]) * (p1[1] - p0[1]),
|
|
56
|
+
(p2[0] - p0[0]) * (p3[1] - p2[1]) - (p3[0] - p2[0]) * (p2[1] - p0[1]),
|
|
57
|
+
(p3[0] - p0[0]) * (p1[1] - p3[1]) - (p1[0] - p3[0]) * (p3[1] - p0[1]),
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
if d[0] * d[1] >= 0 and d[2] * d[1] >= 0 and d[0] * d[2] >= 0:
|
|
61
|
+
return True
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
def is_ear_point(self, p):
|
|
65
|
+
"""Check if a given point is one of the vertices of the Ear triangle.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
bool
|
|
70
|
+
True, if the point is a vertex of the Ear triangle, False otherwise.
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
if p == self.coords or p in self.neighbour_coords:
|
|
74
|
+
return True
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
def validate(self, points, indexes, ears):
|
|
78
|
+
"""Validate if the Ear triangle is a valid Ear by checking its convexity and that no points lie inside.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
bool
|
|
83
|
+
True if the Ear triangle is valid, False otherwise.
|
|
84
|
+
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
not_ear_points = [points[i] for i in indexes if points[i] != self.coords and points[i] not in self.neighbour_coords]
|
|
88
|
+
insides = [self.is_inside(p) for p in not_ear_points]
|
|
89
|
+
if self.is_convex() and True not in insides:
|
|
90
|
+
for e in ears:
|
|
91
|
+
if e.is_ear_point(self.coords):
|
|
92
|
+
return False
|
|
93
|
+
return True
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def is_convex(self):
|
|
97
|
+
"""Check if the Ear triangle is convex.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
bool
|
|
102
|
+
True if the Ear triangle is convex, False otherwise.
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
a = self.neighbour_coords[0]
|
|
106
|
+
b = self.coords
|
|
107
|
+
c = self.neighbour_coords[1]
|
|
108
|
+
ab = [b[0] - a[0], b[1] - a[1]]
|
|
109
|
+
bc = [c[0] - b[0], c[1] - b[1]]
|
|
110
|
+
if ab[0] * bc[1] - ab[1] * bc[0] <= 0:
|
|
111
|
+
return False
|
|
112
|
+
return True
|
|
113
|
+
|
|
114
|
+
def get_triangle(self):
|
|
115
|
+
"""Get the indices of the vertices forming the Ear triangle.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
list
|
|
120
|
+
List of vertex indices forming the Ear triangle.
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
return [self.prew, self.index, self.next]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class Earcut(object):
|
|
127
|
+
"""A class for triangulating points forming a polygon using the Ear-cutting algorithm.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
points : list
|
|
132
|
+
List of points representing the polygon.
|
|
133
|
+
|
|
134
|
+
Attributes
|
|
135
|
+
----------
|
|
136
|
+
vertices : list
|
|
137
|
+
List of points representing the polygon.
|
|
138
|
+
ears : list
|
|
139
|
+
List of Ear objects representing the Ears of the polygon.
|
|
140
|
+
neighbours : list
|
|
141
|
+
List of indices of the neighbouring vertices.
|
|
142
|
+
triangles : list
|
|
143
|
+
List of triangles forming the triangulation of the polygon.
|
|
144
|
+
length : int
|
|
145
|
+
Number of vertices of the polygon.
|
|
146
|
+
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
def __init__(self, points):
|
|
150
|
+
self.vertices = points
|
|
151
|
+
self.ears = []
|
|
152
|
+
self.neighbours = []
|
|
153
|
+
self.triangles = []
|
|
154
|
+
self.length = len(points)
|
|
155
|
+
|
|
156
|
+
def update_neighbours(self):
|
|
157
|
+
"""Update the list of neighboring vertices."""
|
|
158
|
+
neighbours = []
|
|
159
|
+
self.neighbours = neighbours
|
|
160
|
+
|
|
161
|
+
def add_ear(self, new_ear):
|
|
162
|
+
"""Add a new Ear to the list of Ears and update neighboring vertices.
|
|
163
|
+
|
|
164
|
+
Parameters
|
|
165
|
+
----------
|
|
166
|
+
new_ear : Ear
|
|
167
|
+
Ear object to be added to the list of Ears.
|
|
168
|
+
|
|
169
|
+
"""
|
|
170
|
+
self.ears.append(new_ear)
|
|
171
|
+
self.neighbours.append(new_ear.prew)
|
|
172
|
+
self.neighbours.append(new_ear.next)
|
|
173
|
+
|
|
174
|
+
def find_ears(self):
|
|
175
|
+
"""Find valid Ear triangles among the vertices and add them to the Ears list."""
|
|
176
|
+
i = 0
|
|
177
|
+
indexes = list(range(self.length))
|
|
178
|
+
while True:
|
|
179
|
+
if i >= self.length:
|
|
180
|
+
break
|
|
181
|
+
new_ear = Ear(self.vertices, indexes, i)
|
|
182
|
+
if new_ear.validate(self.vertices, indexes, self.ears):
|
|
183
|
+
self.add_ear(new_ear)
|
|
184
|
+
indexes.remove(new_ear.index)
|
|
185
|
+
i += 1
|
|
186
|
+
|
|
187
|
+
def triangulate(self):
|
|
188
|
+
"""Triangulate the polygon using the Ear-cutting algorithm.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
list[list[int]]
|
|
193
|
+
List of triangles forming the triangulation of the polygon.
|
|
194
|
+
|
|
195
|
+
Raises
|
|
196
|
+
------
|
|
197
|
+
ValueError
|
|
198
|
+
If no Ears were found for triangulation.
|
|
199
|
+
IndexError
|
|
200
|
+
If no more Ears were found for triangulation.
|
|
201
|
+
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
if self.length < 3:
|
|
205
|
+
raise ValueError("Polygon must have at least 3 vertices.")
|
|
206
|
+
elif self.length == 3:
|
|
207
|
+
self.triangles.append([0, 1, 2])
|
|
208
|
+
return self.triangles
|
|
209
|
+
|
|
210
|
+
indexes = list(range(self.length))
|
|
211
|
+
self.find_ears()
|
|
212
|
+
|
|
213
|
+
num_of_ears = len(self.ears)
|
|
214
|
+
|
|
215
|
+
if num_of_ears == 0:
|
|
216
|
+
raise ValueError("No ears found for triangulation.")
|
|
217
|
+
if num_of_ears == 1:
|
|
218
|
+
self.triangles.append(self.ears[0].get_triangle())
|
|
219
|
+
return
|
|
220
|
+
|
|
221
|
+
while True:
|
|
222
|
+
if len(self.ears) == 2 and len(indexes) == 4:
|
|
223
|
+
self.triangles.append(self.ears[0].get_triangle())
|
|
224
|
+
self.triangles.append(self.ears[1].get_triangle())
|
|
225
|
+
break
|
|
226
|
+
|
|
227
|
+
if len(self.ears) == 0:
|
|
228
|
+
raise IndexError("Unable to find more Ears for triangulation.")
|
|
229
|
+
current = self.ears.pop(0)
|
|
230
|
+
|
|
231
|
+
indexes.remove(current.index)
|
|
232
|
+
self.neighbours.remove(current.prew)
|
|
233
|
+
self.neighbours.remove(current.next)
|
|
234
|
+
|
|
235
|
+
self.triangles.append(current.get_triangle())
|
|
236
|
+
|
|
237
|
+
# Check if prew and next vertices form new ears
|
|
238
|
+
prew_ear_new = Ear(self.vertices, indexes, current.prew)
|
|
239
|
+
next_ear_new = Ear(self.vertices, indexes, current.next)
|
|
240
|
+
if prew_ear_new.validate(self.vertices, indexes, self.ears) and prew_ear_new.index not in self.neighbours:
|
|
241
|
+
self.add_ear(prew_ear_new)
|
|
242
|
+
continue
|
|
243
|
+
if next_ear_new.validate(self.vertices, indexes, self.ears) and next_ear_new.index not in self.neighbours:
|
|
244
|
+
self.add_ear(next_ear_new)
|
|
245
|
+
continue
|
|
246
|
+
|
|
247
|
+
return self.triangles
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def earclip_polygon(polygon):
|
|
251
|
+
"""Triangulate a polygon using the ear clipping method.
|
|
252
|
+
The polygon is assumed to be planar and non-self-intersecting and position on XY plane.
|
|
253
|
+
The winding direction is checked. If the polygon is not oriented counter-clockwise, it is reversed.
|
|
254
|
+
|
|
255
|
+
Parameters
|
|
256
|
+
----------
|
|
257
|
+
polygon : :class:`compas.geometry.Polygon`
|
|
258
|
+
A polygon defined by a sequence of points.
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
list[[int, int, int]]
|
|
263
|
+
A list of triangles referencing the points of the original polygon.
|
|
264
|
+
|
|
265
|
+
Raises
|
|
266
|
+
------
|
|
267
|
+
ValueError
|
|
268
|
+
If no ears were found for triangulation.
|
|
269
|
+
IndexError
|
|
270
|
+
If no more ears were found for triangulation.
|
|
271
|
+
|
|
272
|
+
"""
|
|
273
|
+
|
|
274
|
+
# Orient the copy of polygon points to XY plane.
|
|
275
|
+
from compas.geometry import Frame # Avoid circular import.
|
|
276
|
+
from compas.geometry import Plane # Avoid circular import.
|
|
277
|
+
from compas.geometry import Transformation # Avoid circular import.
|
|
278
|
+
|
|
279
|
+
frame = Frame.from_plane(Plane(polygon.points[0], polygon.normal))
|
|
280
|
+
xform = Transformation.from_frame_to_frame(frame, Frame.worldXY())
|
|
281
|
+
points = [point.transformed(xform) for point in polygon.points]
|
|
282
|
+
|
|
283
|
+
# Check polygon winding by signed area of all current and next points pairs.
|
|
284
|
+
sum_val = 0.0
|
|
285
|
+
for p0, p1 in zip(points, points[1:] + [points[0]]):
|
|
286
|
+
sum_val += (p1[0] - p0[0]) * (p1[1] + p0[1])
|
|
287
|
+
|
|
288
|
+
if sum_val > 0.0:
|
|
289
|
+
points.reverse()
|
|
290
|
+
|
|
291
|
+
# Run the Earcut algorithm.
|
|
292
|
+
ear_cut = Earcut(points)
|
|
293
|
+
triangles = ear_cut.triangulate()
|
|
294
|
+
|
|
295
|
+
# Reverse the triangles to match the original polygon winding.
|
|
296
|
+
if sum_val > 0.0:
|
|
297
|
+
n = len(points) - 1
|
|
298
|
+
for i in range(len(triangles)):
|
|
299
|
+
triangles[i] = [abs(triangles[i][j % 3] - n) for j in range(3)]
|
|
300
|
+
return triangles
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
from math import pi
|
|
6
|
+
|
|
7
|
+
from compas.geometry import angle_points
|
|
8
|
+
from compas.itertools import window
|
|
9
|
+
from compas.plugins import pluggable
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pluggable(category="trimesh")
|
|
13
|
+
def trimesh_gaussian_curvature(M):
|
|
14
|
+
r"""Compute the discrete gaussian curvature of a triangle mesh.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
M : tuple[sequence[[float, float, float] | :class:`compas.geometry.Point`], sequence[[int, int, int]]]
|
|
19
|
+
A mesh represented by a list of vertices and a list of faces.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
list[float]
|
|
24
|
+
The discrete gaussian curvature per vertex.
|
|
25
|
+
|
|
26
|
+
Warnings
|
|
27
|
+
--------
|
|
28
|
+
The default implementation willnot check if the mesh is a triangle mesh.
|
|
29
|
+
It will simpliy compute the curvature at every vertex as if it were surrounded by triangles.
|
|
30
|
+
This requires the faces of the mesh to be at least convex polygons.
|
|
31
|
+
|
|
32
|
+
Notes
|
|
33
|
+
-----
|
|
34
|
+
The angular deficit at a vertex is defined as the difference between a full
|
|
35
|
+
circle angle (:math:`2\pi`) and the sum of the angles in the adjacent trianlges.
|
|
36
|
+
|
|
37
|
+
.. math::
|
|
38
|
+
|
|
39
|
+
k_{G}(v_{i}) = 2\pi - \sum_{j \in N(i)} \theta_{ij}
|
|
40
|
+
|
|
41
|
+
where :math:`N(i)` are the triangles incident on vertex :math:`i` and :math:`\theta_{ij}`
|
|
42
|
+
is the angle at vertex :math:`i` in triangle :math:`j`.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
>>>
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
vertices, faces = M
|
|
50
|
+
pi2 = 2 * pi
|
|
51
|
+
curvature = [0] * len(vertices)
|
|
52
|
+
for face in faces:
|
|
53
|
+
for u, v, w in window(face + face[0:2], 3):
|
|
54
|
+
a = vertices[u]
|
|
55
|
+
b = vertices[v]
|
|
56
|
+
c = vertices[w]
|
|
57
|
+
curvature[u] += angle_points(a, b, c)
|
|
58
|
+
curvature[v] += angle_points(b, a, c)
|
|
59
|
+
curvature[w] += angle_points(c, a, b)
|
|
60
|
+
return [pi2 - c for c in curvature]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
trimesh_gaussian_curvature.__pluggable__ = True
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pluggable(category="trimesh")
|
|
67
|
+
def trimesh_principal_curvature(M):
|
|
68
|
+
"""Compute the principal curvature directions of a triangle mesh.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
M : tuple[sequence[[float, float, float] | :class:`compas.geometry.Point`], sequence[[int, int, int]]]
|
|
73
|
+
A mesh represented by a list of vertices and a list of faces.
|
|
74
|
+
|
|
75
|
+
Returns
|
|
76
|
+
-------
|
|
77
|
+
list[tuple[[float, float, float], [float, float]]]
|
|
78
|
+
The curvature directions per vertex.
|
|
79
|
+
|
|
80
|
+
Examples
|
|
81
|
+
--------
|
|
82
|
+
>>>
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
raise NotImplementedError
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
trimesh_principal_curvature.__pluggable__ = True
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@pluggable(category="trimesh")
|
|
92
|
+
def trimesh_mean_curvature(M):
|
|
93
|
+
"""Compute the discrete mean curvature of a triangle mesh.
|
|
94
|
+
|
|
95
|
+
Parameters
|
|
96
|
+
----------
|
|
97
|
+
M : tuple[sequence[[float, float, float] | :class:`compas.geometry.Point`], sequence[[int, int, int]]]
|
|
98
|
+
A mesh represented by a list of vertices and a list of faces.
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
list[float]
|
|
103
|
+
The discrete mean curvature per vertex.
|
|
104
|
+
|
|
105
|
+
Examples
|
|
106
|
+
--------
|
|
107
|
+
>>>
|
|
108
|
+
|
|
109
|
+
"""
|
|
110
|
+
raise NotImplementedError
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
trimesh_mean_curvature.__pluggable__ = True
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from numpy import asarray
|
|
2
|
+
|
|
3
|
+
from .trimesh_gradient_numpy import trimesh_gradient_numpy
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def trimesh_descent_numpy(M):
|
|
7
|
+
"""Compute the descent directions of a triangular mesh as the gradient of the vertex heights.
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
M : tuple[vertices, faces]
|
|
12
|
+
The vertices and faces of the mesh.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
list[list[float]]]
|
|
17
|
+
The descent directions.
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
vertices, faces = M
|
|
21
|
+
V = asarray(vertices)
|
|
22
|
+
F = asarray(faces)
|
|
23
|
+
G = trimesh_gradient_numpy((V, F))
|
|
24
|
+
sfield = V[:, 2].reshape((-1, 1))
|
|
25
|
+
vfield = -G.dot(sfield)
|
|
26
|
+
return vfield.reshape((-1, 3), order="F")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from compas.plugins import pluggable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@pluggable(category="trimesh")
|
|
5
|
+
def trimesh_geodistance(M, source, method="exact"):
|
|
6
|
+
"""Compute the geodesic distance from every vertex of the mesh to a source vertex.
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
----------
|
|
10
|
+
M : tuple[sequence[[float, float, float] | :class:`compas.geometry.Point`], sequence[[int, int, int]]]
|
|
11
|
+
A mesh represented by a list of vertices and a list of faces.
|
|
12
|
+
source : int
|
|
13
|
+
The index of the vertex from where the geodesic distances should be calculated.
|
|
14
|
+
method : Literal['exact', 'heat'], optional
|
|
15
|
+
The method for calculating the distances.
|
|
16
|
+
|
|
17
|
+
Returns
|
|
18
|
+
-------
|
|
19
|
+
list[float]
|
|
20
|
+
A list of geodesic distances from the source vertex.
|
|
21
|
+
|
|
22
|
+
Raises
|
|
23
|
+
------
|
|
24
|
+
NotImplementedError
|
|
25
|
+
If `method` is not one of ``{'exact', 'heat'}``.
|
|
26
|
+
|
|
27
|
+
Examples
|
|
28
|
+
--------
|
|
29
|
+
>>>
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
raise NotImplementedError
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
trimesh_geodistance.__pluggable__ = True
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.sparse import coo_matrix # type: ignore
|
|
3
|
+
|
|
4
|
+
from compas.linalg import normalizerow
|
|
5
|
+
from compas.linalg import normrow
|
|
6
|
+
from compas.linalg import rot90
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def trimesh_gradient_numpy(M, rtype="array"):
|
|
10
|
+
"""Construct the gradient operator of a trianglular mesh.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
V : array
|
|
15
|
+
Vertex coordinates of the mesh.
|
|
16
|
+
F : array
|
|
17
|
+
Face vertex indices of the mesh.
|
|
18
|
+
rtype : {'array', 'csc', 'csr', 'coo', 'list'}
|
|
19
|
+
Format of the result.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
array-like
|
|
24
|
+
Depending on rtype return type.
|
|
25
|
+
|
|
26
|
+
Notes
|
|
27
|
+
-----
|
|
28
|
+
The gradient operator is fully determined by the connectivity of the mesh
|
|
29
|
+
and the coordinate difference vectors associated with the edges
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
V, F = M
|
|
33
|
+
v = V.shape[0]
|
|
34
|
+
f = F.shape[0]
|
|
35
|
+
f0 = F[:, 0] # Index of first vertex of each face
|
|
36
|
+
f1 = F[:, 1] # Index of second vertex of each face
|
|
37
|
+
f2 = F[:, 2] # Index of last vertex of each face
|
|
38
|
+
v01 = V[f1, :] - V[f0, :] # Vector from vertex 0 to 1 for each face
|
|
39
|
+
v12 = V[f2, :] - V[f1, :] # Vector from vertex 1 to 2 for each face
|
|
40
|
+
v20 = V[f0, :] - V[f2, :] # Vector from vertex 2 to 0 for each face
|
|
41
|
+
n = np.cross(v12, v20) # Normal vector to each face
|
|
42
|
+
A2 = normrow(n) # Length of normal vector is twice the area of the face
|
|
43
|
+
A2 = np.tile(A2, (1, 3))
|
|
44
|
+
u = normalizerow(n) # Unit normals for each face
|
|
45
|
+
v01_ = np.divide(rot90(v01, u), A2) # Vector perpendicular to v01, normalized by A2
|
|
46
|
+
v20_ = np.divide(rot90(v20, u), A2) # Vector perpendicular to v20, normalized by A2
|
|
47
|
+
i = np.hstack(
|
|
48
|
+
( # Nonzero rows
|
|
49
|
+
0 * f + np.tile(np.arange(f), (1, 4)),
|
|
50
|
+
1 * f + np.tile(np.arange(f), (1, 4)),
|
|
51
|
+
2 * f + np.tile(np.arange(f), (1, 4)),
|
|
52
|
+
)
|
|
53
|
+
).flatten()
|
|
54
|
+
j = np.tile(np.hstack((f1, f0, f2, f0)), (1, 3)).flatten() # Nonzero columns
|
|
55
|
+
data = np.hstack(
|
|
56
|
+
(
|
|
57
|
+
np.hstack((v20_[:, 0], -v20_[:, 0], v01_[:, 0], -v01_[:, 0])),
|
|
58
|
+
np.hstack((v20_[:, 1], -v20_[:, 1], v01_[:, 1], -v01_[:, 1])),
|
|
59
|
+
np.hstack((v20_[:, 2], -v20_[:, 2], v01_[:, 2], -v01_[:, 2])),
|
|
60
|
+
)
|
|
61
|
+
).flatten()
|
|
62
|
+
|
|
63
|
+
G = coo_matrix((data, (i, j)), shape=(3 * f, v))
|
|
64
|
+
|
|
65
|
+
if rtype == "array":
|
|
66
|
+
return G.toarray()
|
|
67
|
+
elif rtype == "csr":
|
|
68
|
+
return G.tocsr()
|
|
69
|
+
elif rtype == "csc":
|
|
70
|
+
return G.tocsc()
|
|
71
|
+
elif rtype == "coo":
|
|
72
|
+
return G
|
|
73
|
+
else:
|
|
74
|
+
return G
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
from __future__ import division
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
from compas.plugins import pluggable
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pluggable(category="trimesh")
|
|
9
|
+
def trimesh_isolines(M, S, N=50):
|
|
10
|
+
"""Compute isolines on a triangle mesh using a scalarfield of data points
|
|
11
|
+
assigned to its vertices.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
M : tuple[sequence[[float, float, float] | :class:`compas.geometry.Point`], sequence[[int, int, int]]]
|
|
16
|
+
A mesh represented by a list of vertices and a list of faces.
|
|
17
|
+
S : list[float]
|
|
18
|
+
A list of scalars.
|
|
19
|
+
N : int, optional
|
|
20
|
+
The number of isolines.
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
list[[float, float, float]]
|
|
25
|
+
The coordinates of the polyline points.
|
|
26
|
+
list[[int, int]]
|
|
27
|
+
The segments of the polylines defined as pairs of points.
|
|
28
|
+
|
|
29
|
+
Notes
|
|
30
|
+
-----
|
|
31
|
+
To convert the vertices and edges to sets of isolines, use :func:`groupsort_isolines`
|
|
32
|
+
|
|
33
|
+
Examples
|
|
34
|
+
--------
|
|
35
|
+
>>>
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
trimesh_isolines.__pluggable__ = True
|