diff --git a/CHANGELOG.md b/CHANGELOG.md index 10ac70d3..fd0a37cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Split binding into separate dynamic libraries. +* The documentation contribution guide has been updated based on the single-file and single dynamic library build process. +* Example images in the documentation have been updated. +* The Python/C++ module name has been changed from `name_ext` to `_name`. ### Removed diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dd9181e..c1aa73b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,16 +225,16 @@ function(add_nanobind_module module_name source_file) endfunction() # Add new modules here -add_nanobind_module(types_std src/types_std.cpp) -add_nanobind_module(booleans_ext src/booleans.cpp) -add_nanobind_module(meshing_ext src/meshing.cpp) -add_nanobind_module(intersections_ext src/intersections.cpp) -add_nanobind_module(measure_ext src/measure.cpp) -add_nanobind_module(reconstruction_ext src/reconstruction.cpp) -add_nanobind_module(skeletonization_ext src/skeletonization.cpp) -add_nanobind_module(slicer_ext src/slicer.cpp) -add_nanobind_module(straight_skeleton_2_ext src/straight_skeleton_2.cpp) -add_nanobind_module(triangulation_ext src/triangulation.cpp) -add_nanobind_module(subdivision_ext src/subdivision.cpp) +add_nanobind_module(_types_std src/types_std.cpp) +add_nanobind_module(_booleans src/booleans.cpp) +add_nanobind_module(_meshing src/meshing.cpp) +add_nanobind_module(_intersections src/intersections.cpp) +add_nanobind_module(_measure src/measure.cpp) +add_nanobind_module(_reconstruction src/reconstruction.cpp) +add_nanobind_module(_skeletonization src/skeletonization.cpp) +add_nanobind_module(_slicer src/slicer.cpp) +add_nanobind_module(_straight_skeleton_2 src/straight_skeleton_2.cpp) +add_nanobind_module(_triangulation src/triangulation.cpp) +add_nanobind_module(_subdivision src/subdivision.cpp) diff --git a/docs/_images/example_booleans.png b/docs/_images/example_booleans.png index 7ae165a6..2e81f4fd 100644 Binary files a/docs/_images/example_booleans.png and b/docs/_images/example_booleans.png differ diff --git a/docs/_images/example_intersections.png b/docs/_images/example_intersections.png index 95290820..bbb569c5 100644 Binary files a/docs/_images/example_intersections.png and b/docs/_images/example_intersections.png differ diff --git a/docs/_images/example_meshing.png b/docs/_images/example_meshing.png index 6a71534a..3914b9ab 100644 Binary files a/docs/_images/example_meshing.png and b/docs/_images/example_meshing.png differ diff --git a/docs/_images/example_reconstruction_pointset_normal_estimation.png b/docs/_images/example_reconstruction_pointset_normal_estimation.png index 3f287602..94100b5e 100644 Binary files a/docs/_images/example_reconstruction_pointset_normal_estimation.png and b/docs/_images/example_reconstruction_pointset_normal_estimation.png differ diff --git a/docs/_images/example_reconstruction_pointset_outlier_removal.png b/docs/_images/example_reconstruction_pointset_outlier_removal.png index 75db19b4..0250aeac 100644 Binary files a/docs/_images/example_reconstruction_pointset_outlier_removal.png and b/docs/_images/example_reconstruction_pointset_outlier_removal.png differ diff --git a/docs/_images/example_reconstruction_pointset_reduction.png b/docs/_images/example_reconstruction_pointset_reduction.png index 9ff1c47e..428a8458 100644 Binary files a/docs/_images/example_reconstruction_pointset_reduction.png and b/docs/_images/example_reconstruction_pointset_reduction.png differ diff --git a/docs/_images/example_reconstruction_pointset_smoothing.png b/docs/_images/example_reconstruction_pointset_smoothing.png index d002be1d..421fc4f3 100644 Binary files a/docs/_images/example_reconstruction_pointset_smoothing.png and b/docs/_images/example_reconstruction_pointset_smoothing.png differ diff --git a/docs/_images/example_reconstruction_poisson_surface_reconstruction.png b/docs/_images/example_reconstruction_poisson_surface_reconstruction.png index 4372fb3b..d1738313 100644 Binary files a/docs/_images/example_reconstruction_poisson_surface_reconstruction.png and b/docs/_images/example_reconstruction_poisson_surface_reconstruction.png differ diff --git a/docs/_images/example_skeletonization.png b/docs/_images/example_skeletonization.png index 4174f51e..7faa327a 100644 Binary files a/docs/_images/example_skeletonization.png and b/docs/_images/example_skeletonization.png differ diff --git a/docs/_images/example_slicer.png b/docs/_images/example_slicer.png index f60d4343..cf049a46 100644 Binary files a/docs/_images/example_slicer.png and b/docs/_images/example_slicer.png differ diff --git a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton.png b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton.png index 1c6b3935..d4d7b5e5 100644 Binary files a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton.png and b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton.png differ diff --git a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_offset_polygon.png b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_offset_polygon.png index 8d76f032..ad945b0f 100644 Binary files a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_offset_polygon.png and b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_offset_polygon.png differ diff --git a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_weighted_offset_polygon.png b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_weighted_offset_polygon.png index c2007c2b..c6e37dc0 100644 Binary files a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_weighted_offset_polygon.png and b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_weighted_offset_polygon.png differ diff --git a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_with_holes.png b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_with_holes.png index fac4b2dd..f7e26951 100644 Binary files a/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_with_holes.png and b/docs/_images/example_straight_skeleton_2_interior_straight_skeleton_with_holes.png differ diff --git a/docs/_images/example_subdivision.png b/docs/_images/example_subdivision.png index 50a89207..3bec3a1e 100644 Binary files a/docs/_images/example_subdivision.png and b/docs/_images/example_subdivision.png differ diff --git a/docs/_images/example_triangulation.png b/docs/_images/example_triangulation.png index a86b1423..35937ee9 100644 Binary files a/docs/_images/example_triangulation.png and b/docs/_images/example_triangulation.png differ diff --git a/docs/api.rst b/docs/api.rst index 64036238..8c795e7e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -6,5 +6,13 @@ API Reference :maxdepth: 1 api/compas_cgal.booleans + api/compas_cgal.intersections + api/compas_cgal.measure api/compas_cgal.meshing - + api/compas_cgal.skeletonization + api/compas_cgal.slicer + api/compas_cgal.subdivision + api/compas_cgal.triangulation + api/compas_cgal.reconstruction + api/compas_cgal.straight_skeleton_2 + api/compas_cgal.types \ No newline at end of file diff --git a/docs/api/compas_cgal.intersections.rst b/docs/api/compas_cgal.intersections.rst new file mode 100644 index 00000000..05d81a05 --- /dev/null +++ b/docs/api/compas_cgal.intersections.rst @@ -0,0 +1,11 @@ +******************************************************************************** +compas_cgal.intersections +******************************************************************************** + +.. currentmodule:: compas_cgal.intersections + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + intersection_mesh_mesh diff --git a/docs/api/compas_cgal.measure.rst b/docs/api/compas_cgal.measure.rst new file mode 100644 index 00000000..fbee84b8 --- /dev/null +++ b/docs/api/compas_cgal.measure.rst @@ -0,0 +1,13 @@ +******************************************************************************** +compas_cgal.measure +******************************************************************************** + +.. currentmodule:: compas_cgal.measure + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + mesh_area + mesh_volume + mesh_centroid diff --git a/docs/api/compas_cgal.reconstruction.rst b/docs/api/compas_cgal.reconstruction.rst new file mode 100644 index 00000000..3c58615d --- /dev/null +++ b/docs/api/compas_cgal.reconstruction.rst @@ -0,0 +1,16 @@ +******************************************************************************** +compas_cgal.reconstruction +******************************************************************************** + +.. currentmodule:: compas_cgal.reconstruction + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + poisson_surface_reconstruction + pointset_outlier_removal + pointset_reduction + pointset_smoothing + pointset_normal_estimation + diff --git a/docs/api/compas_cgal.skeletonization.rst b/docs/api/compas_cgal.skeletonization.rst new file mode 100644 index 00000000..dec7b372 --- /dev/null +++ b/docs/api/compas_cgal.skeletonization.rst @@ -0,0 +1,11 @@ +******************************************************************************** +compas_cgal.skeletonization +******************************************************************************** + +.. currentmodule:: compas_cgal.skeletonization + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + mesh_skeleton diff --git a/docs/api/compas_cgal.slicer.rst b/docs/api/compas_cgal.slicer.rst new file mode 100644 index 00000000..dc992448 --- /dev/null +++ b/docs/api/compas_cgal.slicer.rst @@ -0,0 +1,11 @@ +******************************************************************************** +compas_cgal.slicer +******************************************************************************** + +.. currentmodule:: compas_cgal.slicer + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + slice_mesh_planes diff --git a/docs/api/compas_cgal.straight_skeleton_2.rst b/docs/api/compas_cgal.straight_skeleton_2.rst new file mode 100644 index 00000000..b53d61fe --- /dev/null +++ b/docs/api/compas_cgal.straight_skeleton_2.rst @@ -0,0 +1,16 @@ +******************************************************************************** +compas_cgal.straight_skeleton_2 +******************************************************************************** + +.. currentmodule:: compas_cgal.straight_skeleton_2 + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + interior_straight_skeleton + interior_straight_skeleton_with_holes + offset_polygon + offset_polygon_with_holes + weighted_offset_polygon + diff --git a/docs/api/compas_cgal.subdivision.rst b/docs/api/compas_cgal.subdivision.rst new file mode 100644 index 00000000..80c141c2 --- /dev/null +++ b/docs/api/compas_cgal.subdivision.rst @@ -0,0 +1,14 @@ +******************************************************************************** +compas_cgal.subdivision +******************************************************************************** + +.. currentmodule:: compas_cgal.subdivision + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + mesh_subdivide_catmull_clark + mesh_subdivide_loop + mesh_subdivide_sqrt3 + diff --git a/docs/api/compas_cgal.triangulation.rst b/docs/api/compas_cgal.triangulation.rst new file mode 100644 index 00000000..50419272 --- /dev/null +++ b/docs/api/compas_cgal.triangulation.rst @@ -0,0 +1,15 @@ +******************************************************************************** +compas_cgal.triangulation +******************************************************************************** + +.. currentmodule:: compas_cgal.triangulation + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + delaunay_triangulation + constrained_delaunay_triangulation + conforming_delaunay_triangulation + refined_delaunay_mesh + diff --git a/docs/api/compas_cgal.types.rst b/docs/api/compas_cgal.types.rst new file mode 100644 index 00000000..ebd65e72 --- /dev/null +++ b/docs/api/compas_cgal.types.rst @@ -0,0 +1,18 @@ +******************************************************************************** +compas_cgal.types +******************************************************************************** + +.. currentmodule:: compas_cgal.types + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + Vertices + Faces + VerticesFaces + Planes + VerticesNumpy + FacesNumpy + VerticesFacesNumpy + PolylinesNumpy diff --git a/docs/devguide/contribute.rst b/docs/devguide/contribute.rst index 89479962..13402693 100644 --- a/docs/devguide/contribute.rst +++ b/docs/devguide/contribute.rst @@ -44,7 +44,7 @@ Define new methods declarations in ``src/new_module.h``: // Your method declarations here -Implement the functions and add the nanobind module registration: ``src/new_module.cpp``: +Implement the functions and add the nanobind module registration: ``src/new_module.cpp``, we name modules started with ``_``: .. code-block:: cpp @@ -52,10 +52,9 @@ Implement the functions and add the nanobind module registration: ``src/new_modu // Your method definitions here - void init_new_module(nb::module_& m) { - auto submodule = m.def_submodule("new_module"); + NB_MODULE(_new_module, m) { - submodule.def( + m.def( "python_function_name", &cpp_function_name, "description", @@ -64,30 +63,27 @@ Implement the functions and add the nanobind module registration: ``src/new_modu ); } -Add the submodule registration to ``src/compas_cgal.cpp``: +Rebuild the project with: -.. code-block:: cpp +.. code-block:: bash - #include "compas.h" + pip install --no-build-isolation -ve . -Ceditable.rebuild=true - ... - init_new_module(m); - ... - NB_MODULE(compas_cgal_ext, m) { - ... - init_new_module(m); - } +CMake +----- -Rebuild the project with: +Add the new module to the CMakeLists.txt file: -.. code-block:: bash +.. code-block:: cmake - pip install --no-build-isolation -ve . -Ceditable.rebuild=true + add_nanobind_module(_new_module src/new_module.cpp) +.. note:: + - We build small dynamic libraries for each module to avoid large monolithic libraries for two reasons: build time and file size. + - If your package requires C++ standard library data types (e.g., vector, array, map, etc.), bind them in the `types_std.cpp` file. + - Do not bind C++ types with the same names, as this will result in errors even if they are in different namespaces and libraries. -.. note:: - It is advisable to include all the headers from 3rd-party libraries to the precompiled header ``src/compas.h`` so that your compilation time decreases. Python Binding -------------- diff --git a/docs/devguide/overview.rst b/docs/devguide/overview.rst index 3835a0e4..b9699b73 100644 --- a/docs/devguide/overview.rst +++ b/docs/devguide/overview.rst @@ -10,7 +10,6 @@ Overview - File and Folder Structure ------------------------- diff --git a/docs/examples/example_booleans.py b/docs/examples/example_booleans.py index 5a8f6f8c..2b17f08d 100644 --- a/docs/examples/example_booleans.py +++ b/docs/examples/example_booleans.py @@ -10,7 +10,6 @@ from compas_cgal.booleans import boolean_intersection_mesh_mesh from compas_cgal.booleans import boolean_union_mesh_mesh from compas_cgal.booleans import split_mesh_mesh -# from compas_cgal.meshing import mesh_remesh def input(): diff --git a/docs/examples/example_reconstruction_pointset_smoothing.py b/docs/examples/example_reconstruction_pointset_smoothing.py index a855a35d..c2ecf752 100644 --- a/docs/examples/example_reconstruction_pointset_smoothing.py +++ b/docs/examples/example_reconstruction_pointset_smoothing.py @@ -35,6 +35,6 @@ def reconstruction_pointset_smoothing(): config.renderer.gridsize = (20000, 20, 20000, 20) viewer = Viewer(config=config) -viewer.scene.add(c_smoothing_0, pointcolor=(0.0, 0.0, 0.0)) -viewer.scene.add(c_smoothing_1, pointcolor=(1.0, 0.0, 0.0)) +viewer.scene.add(c_smoothing_0, pointcolor=(0.0, 0.0, 0.0), pointsize=3) +viewer.scene.add(c_smoothing_1, pointcolor=(1.0, 0.0, 0.0), pointsize=7) viewer.show() diff --git a/src/booleans.cpp b/src/booleans.cpp index a7bfdf49..eb0ea67c 100644 --- a/src/booleans.cpp +++ b/src/booleans.cpp @@ -66,7 +66,7 @@ pmp_split( return result; }; -NB_MODULE(booleans_ext, m) { +NB_MODULE(_booleans, m) { m.def( "boolean_union", diff --git a/src/compas_cgal/booleans.py b/src/compas_cgal/booleans.py index 90034bdb..1cfa707d 100644 --- a/src/compas_cgal/booleans.py +++ b/src/compas_cgal/booleans.py @@ -3,7 +3,7 @@ import numpy as np from compas.plugins import plugin -from compas_cgal import booleans_ext +from compas_cgal import _booleans from .types import VerticesFaces from .types import VerticesFacesNumpy @@ -43,13 +43,13 @@ def _boolean( FB = np.asarray(FB, dtype=np.int32) if operation == "union": - result = booleans_ext.boolean_union(VA, FA, VB, FB) + result = _booleans.boolean_union(VA, FA, VB, FB) elif operation == "difference": - result = booleans_ext.boolean_difference(VA, FA, VB, FB) + result = _booleans.boolean_difference(VA, FA, VB, FB) elif operation == "intersection": - result = booleans_ext.boolean_intersection(VA, FA, VB, FB) + result = _booleans.boolean_intersection(VA, FA, VB, FB) elif operation == "split": - result = booleans_ext.split(VA, FA, VB, FB) + result = _booleans.split(VA, FA, VB, FB) else: raise NotImplementedError diff --git a/src/compas_cgal/intersections.py b/src/compas_cgal/intersections.py index eb340461..4cb286c9 100644 --- a/src/compas_cgal/intersections.py +++ b/src/compas_cgal/intersections.py @@ -1,8 +1,8 @@ import numpy as np from compas.plugins import plugin -from compas_cgal import intersections_ext -from compas_cgal import types_std +from compas_cgal import _intersections +from compas_cgal import _types_std from .types import PolylinesNumpy from .types import VerticesFaces @@ -49,6 +49,6 @@ def intersection_mesh_mesh( VB = np.asarray(VB, dtype=np.float64, order="C") FB = np.asarray(FB, dtype=np.int32, order="C") - pointsets: types_std.VectorRowMatrixXd = intersections_ext.intersection_mesh_mesh(VA, FA, VB, FB) + pointsets: _types_std.VectorRowMatrixXd = _intersections.intersection_mesh_mesh(VA, FA, VB, FB) return pointsets diff --git a/src/compas_cgal/measure.py b/src/compas_cgal/measure.py index 830d4f6e..6b1fd8e1 100644 --- a/src/compas_cgal/measure.py +++ b/src/compas_cgal/measure.py @@ -2,8 +2,8 @@ from compas.geometry import Point from compas.plugins import plugin -from compas_cgal import measure_ext -from compas_cgal import types_std +from compas_cgal import _measure +from compas_cgal import _types_std from .types import VerticesFaces @@ -25,7 +25,7 @@ def mesh_area(mesh: VerticesFaces) -> float: V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return measure_ext.area(V, F) + return _measure.area(V, F) @plugin(category="trimesh", pluggable_name="trimesh_volume") @@ -57,7 +57,7 @@ def mesh_volume(mesh: VerticesFaces) -> float: V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return measure_ext.volume(V, F) + return _measure.volume(V, F) def mesh_centroid(mesh: VerticesFaces) -> list[float]: @@ -77,6 +77,6 @@ def mesh_centroid(mesh: VerticesFaces) -> list[float]: V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - vector_of_double: types_std.VectorDouble = measure_ext.centroid(V, F) + vector_of_double: _types_std.VectorDouble = _measure.centroid(V, F) point = Point(*vector_of_double) return point diff --git a/src/compas_cgal/meshing.py b/src/compas_cgal/meshing.py index e0af555d..6bc82024 100644 --- a/src/compas_cgal/meshing.py +++ b/src/compas_cgal/meshing.py @@ -1,7 +1,7 @@ import numpy as np from compas.plugins import plugin -from compas_cgal import meshing_ext +from compas_cgal import _meshing from .types import VerticesFaces from .types import VerticesFacesNumpy @@ -51,4 +51,4 @@ def mesh_remesh( V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return meshing_ext.remesh(V, F, target_edge_length, number_of_iterations) + return _meshing.remesh(V, F, target_edge_length, number_of_iterations) diff --git a/src/compas_cgal/reconstruction.py b/src/compas_cgal/reconstruction.py index 4ea6636e..f3629836 100644 --- a/src/compas_cgal/reconstruction.py +++ b/src/compas_cgal/reconstruction.py @@ -5,7 +5,7 @@ from compas.geometry import Point from compas.geometry import Vector -from compas_cgal import reconstruction_ext +from compas_cgal import _reconstruction from .types import FloatNx3 from .types import IntNx3 @@ -66,7 +66,7 @@ def poisson_surface_reconstruction( N = N / norms[:, np.newaxis] try: - return reconstruction_ext.poisson_surface_reconstruction(P, N) + return _reconstruction.poisson_surface_reconstruction(P, N) except RuntimeError as e: raise RuntimeError(f"Poisson surface reconstruction failed: {str(e)}") @@ -94,7 +94,7 @@ def pointset_outlier_removal( """ P = np.asarray(points, dtype=np.float64, order="C") - return reconstruction_ext.pointset_outlier_removal(P, nnnbrs, radius) + return _reconstruction.pointset_outlier_removal(P, nnnbrs, radius) def pointset_reduction( @@ -117,7 +117,7 @@ def pointset_reduction( """ P = np.asarray(points, dtype=np.float64, order="C") - return reconstruction_ext.pointset_reduction(P, spacing) + return _reconstruction.pointset_reduction(P, spacing) def pointset_smoothing( @@ -141,7 +141,7 @@ def pointset_smoothing( """ P = np.asarray(points, dtype=np.float64, order="C") - return reconstruction_ext.pointset_smoothing(P, neighbors, iterations) + return _reconstruction.pointset_smoothing(P, neighbors, iterations) def pointset_normal_estimation( @@ -167,4 +167,4 @@ def pointset_normal_estimation( """ P = np.asarray(points, dtype=np.float64, order="C") - return reconstruction_ext.pointset_normal_estimation(P, neighbors, erase) + return _reconstruction.pointset_normal_estimation(P, neighbors, erase) diff --git a/src/compas_cgal/skeletonization.py b/src/compas_cgal/skeletonization.py index b6992a8c..41925a2c 100644 --- a/src/compas_cgal/skeletonization.py +++ b/src/compas_cgal/skeletonization.py @@ -1,8 +1,8 @@ import numpy as np from compas.plugins import plugin -from compas_cgal import skeletonization_ext -from compas_cgal import types_std # noqa: F401 +from compas_cgal import _skeletonization +from compas_cgal import _types_std # noqa: F401 from .types import PolylinesNumpySkeleton from .types import VerticesFaces @@ -47,7 +47,7 @@ def mesh_skeleton(mesh: VerticesFaces) -> PolylinesNumpySkeleton: F_numpy = np.asarray(F, dtype=np.int32, order="C") # Ensure C-contiguous # Get start and end points as flattened vectorS - start_points, end_points = skeletonization_ext.mesh_skeleton(V_numpy, F_numpy) + start_points, end_points = _skeletonization.mesh_skeleton(V_numpy, F_numpy) # Convert flattened vectors to list of point coordinates edges = [] diff --git a/src/compas_cgal/slicer.py b/src/compas_cgal/slicer.py index 1b5eaaba..8a7c7be8 100644 --- a/src/compas_cgal/slicer.py +++ b/src/compas_cgal/slicer.py @@ -2,8 +2,8 @@ from compas.geometry import Plane from compas.plugins import plugin -from compas_cgal import slicer_ext -from compas_cgal import types_std # noqa: F401 +from compas_cgal import _slicer +from compas_cgal import _types_std # noqa: F401 from .types import PolylinesNumpy from .types import VerticesFaces @@ -47,7 +47,7 @@ def slice_mesh_planes(mesh: VerticesFaces, planes: list[Plane]) -> PolylinesNump P = np.array(points, dtype=np.float64, order="C") N = np.array(normals, dtype=np.float64, order="C") - pointsets = slicer_ext.slice_mesh(V, F, P, N) + pointsets = _slicer.slice_mesh(V, F, P, N) return pointsets diff --git a/src/compas_cgal/straight_skeleton_2.py b/src/compas_cgal/straight_skeleton_2.py index 1ae73a5e..9e9c37c2 100644 --- a/src/compas_cgal/straight_skeleton_2.py +++ b/src/compas_cgal/straight_skeleton_2.py @@ -7,8 +7,8 @@ from compas.geometry import normal_polygon from compas.tolerance import TOL -from compas_cgal import straight_skeleton_2_ext -from compas_cgal import types_std # noqa: F401 +from compas_cgal import _straight_skeleton_2 +from compas_cgal import _types_std # noqa: F401 from .types import IntNx1 from .types import IntNx2 @@ -74,7 +74,7 @@ def interior_straight_skeleton(points, as_graph=True) -> Union[Graph, Tuple[Vert if not TOL.is_allclose(normal, [0, 0, 1]): raise ValueError("The normal of the polygon should be [0, 0, 1]. The normal of the provided polygon is {}".format(normal)) V = np.asarray(points, dtype=np.float64, order="C") - points, indices, edges, edge_types = straight_skeleton_2_ext.create_interior_straight_skeleton(V) + points, indices, edges, edge_types = _straight_skeleton_2.create_interior_straight_skeleton(V) if as_graph: return graph_from_skeleton_data(points, indices, edges, edge_types) return points, indices, edges, edge_types @@ -117,7 +117,7 @@ def interior_straight_skeleton_with_holes(points, holes, as_graph=True) -> Union raise ValueError("The normal of the hole should be [0, 0, -1]. The normal of the provided {}-th hole is {}".format(i, normal_hole)) hole = np.asarray(points, dtype=np.float64) H.append(hole) - points, indices, edges, edge_types = straight_skeleton_2_ext.create_interior_straight_skeleton_with_holes(V, H) + points, indices, edges, edge_types = _straight_skeleton_2.create_interior_straight_skeleton_with_holes(V, H) if as_graph: return graph_from_skeleton_data(points, indices, edges, edge_types) return points, indices, edges, edge_types @@ -150,9 +150,9 @@ def offset_polygon(points, offset) -> list[Polygon]: V = np.asarray(points, dtype=np.float64, order="C") offset = float(offset) if offset < 0: # outside - offset_polygons = straight_skeleton_2_ext.create_offset_polygons_2_outer(V, abs(offset))[1:] # first one is box + offset_polygons = _straight_skeleton_2.create_offset_polygons_2_outer(V, abs(offset))[1:] # first one is box else: # inside - offset_polygons = straight_skeleton_2_ext.create_offset_polygons_2_inner(V, offset) + offset_polygons = _straight_skeleton_2.create_offset_polygons_2_inner(V, offset) return [Polygon(points.tolist()) for points in offset_polygons] @@ -195,9 +195,9 @@ def offset_polygon_with_holes(points, holes, offset) -> list[Tuple[Polygon, list H.append(hole) if offset < 0: # outside - offset_polygons = straight_skeleton_2_ext.create_offset_polygons_2_outer_with_holes(V, H, abs(offset)) + offset_polygons = _straight_skeleton_2.create_offset_polygons_2_outer_with_holes(V, H, abs(offset)) else: # inside - offset_polygons = straight_skeleton_2_ext.create_offset_polygons_2_inner_with_holes(V, H, offset) + offset_polygons = _straight_skeleton_2.create_offset_polygons_2_inner_with_holes(V, H, offset) result = [] for points, holes_np in offset_polygons: @@ -245,9 +245,9 @@ def weighted_offset_polygon(points, offset, weights) -> list[Polygon]: if W.shape[0] != V.shape[0]: raise ValueError("The number of weights should be equal to the number of points %d != %d." % (W.shape[0], V.shape[0])) if offset < 0: - offset_polygons = straight_skeleton_2_ext.create_weighted_offset_polygons_2_outer(V, abs(offset), W) + offset_polygons = _straight_skeleton_2.create_weighted_offset_polygons_2_outer(V, abs(offset), W) # Return all except the first polygon which is the bounding box return [Polygon(points.tolist()) for points in offset_polygons[1:]] else: - offset_polygons = straight_skeleton_2_ext.create_weighted_offset_polygons_2_inner(V, offset, W) + offset_polygons = _straight_skeleton_2.create_weighted_offset_polygons_2_inner(V, offset, W) return [Polygon(points.tolist()) for points in offset_polygons] diff --git a/src/compas_cgal/subdivision.py b/src/compas_cgal/subdivision.py index 2e8abc6e..6125da31 100644 --- a/src/compas_cgal/subdivision.py +++ b/src/compas_cgal/subdivision.py @@ -1,7 +1,7 @@ import numpy as np -from compas_cgal import subdivision_ext -from compas_cgal import types_std # noqa: F401 +from compas_cgal import _subdivision +from compas_cgal import _types_std # noqa: F401 from .types import VerticesFaces from .types import VerticesFacesNumpy @@ -36,7 +36,7 @@ def mesh_subdivide_catmull_clark(mesh: VerticesFaces, k=1) -> VerticesFacesNumpy V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return subdivision_ext.subd_catmullclark(V, F, k) + return _subdivision.subd_catmullclark(V, F, k) def mesh_subdivide_loop(mesh: VerticesFaces, k=1) -> VerticesFacesNumpy: @@ -57,7 +57,7 @@ def mesh_subdivide_loop(mesh: VerticesFaces, k=1) -> VerticesFacesNumpy: V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return subdivision_ext.subd_loop(V, F, k) + return _subdivision.subd_loop(V, F, k) def mesh_subdivide_sqrt3(mesh: VerticesFaces, k=1) -> VerticesFacesNumpy: @@ -78,4 +78,4 @@ def mesh_subdivide_sqrt3(mesh: VerticesFaces, k=1) -> VerticesFacesNumpy: V, F = mesh V = np.asarray(V, dtype=np.float64, order="C") F = np.asarray(F, dtype=np.int32, order="C") - return subdivision_ext.subd_sqrt3(V, F, k) + return _subdivision.subd_sqrt3(V, F, k) diff --git a/src/compas_cgal/triangulation.py b/src/compas_cgal/triangulation.py index 634731a7..f329380f 100644 --- a/src/compas_cgal/triangulation.py +++ b/src/compas_cgal/triangulation.py @@ -2,8 +2,8 @@ from compas.geometry import Point from compas.plugins import plugin -from compas_cgal import triangulation_ext -from compas_cgal import types_std +from compas_cgal import _triangulation +from compas_cgal import _types_std from compas_cgal.types import FacesNumpy from compas_cgal.types import VerticesFacesNumpy @@ -35,7 +35,7 @@ def delaunay_triangulation(points: list[Point]) -> FacesNumpy: """ vertices = np.asarray(points, dtype=np.float64, order="C") - return triangulation_ext.delaunay_triangulation(vertices) + return _triangulation.delaunay_triangulation(vertices) @plugin(category="triangulation", requires=["compas_cgal"]) @@ -68,19 +68,19 @@ def constrained_delaunay_triangulation( points = points or [] points = np.asarray(points, dtype=np.float64, order="C") - holes_vector = types_std.VectorRowMatrixXd() + holes_vector = _types_std.VectorRowMatrixXd() if holes: for hole in holes: hole_array = np.asarray(hole, dtype=np.float64, order="C") holes_vector.append(hole_array) - curves_vector = types_std.VectorRowMatrixXd() + curves_vector = _types_std.VectorRowMatrixXd() if curves: for curve in curves: curve_array = np.asarray(curve, dtype=np.float64, order="C") curves_vector.append(curve_array) - return triangulation_ext.constrained_delaunay_triangulation( + return _triangulation.constrained_delaunay_triangulation( boundary, # numpy array points, # numpy array holes_vector, # VectorRowMatrixXd @@ -124,7 +124,7 @@ def conforming_delaunay_triangulation( points = np.asarray(points, dtype=np.float64, order="C") # Convert holes to numpy arrays and create vector - holes_vector = types_std.VectorRowMatrixXd() + holes_vector = _types_std.VectorRowMatrixXd() if holes: for hole in holes: if len(hole) < 3: @@ -133,7 +133,7 @@ def conforming_delaunay_triangulation( holes_vector.append(hole_array) # Create empty vector for curves - curves_vector = types_std.VectorRowMatrixXd() + curves_vector = _types_std.VectorRowMatrixXd() if curves: for curve in curves: @@ -141,7 +141,7 @@ def conforming_delaunay_triangulation( curves_vector.append(curve_array) # Call C++ function with all required arguments - result = triangulation_ext.constrained_delaunay_triangulation( + result = _triangulation.constrained_delaunay_triangulation( boundary, # numpy array points, # numpy array holes_vector, # VectorRefRowMatrixXd @@ -195,7 +195,7 @@ def refined_delaunay_mesh( points = np.asarray(points, dtype=np.float64, order="C") # Create vectors for holes and curves with proper type conversion - holes_vector = types_std.VectorRowMatrixXd() + holes_vector = _types_std.VectorRowMatrixXd() if holes: for hole in holes: if len(hole) < 3: @@ -203,7 +203,7 @@ def refined_delaunay_mesh( hole_array = np.asarray(hole, dtype=np.float64, order="C") holes_vector.append(hole_array) - curves_vector = types_std.VectorRowMatrixXd() + curves_vector = _types_std.VectorRowMatrixXd() if curves: for curve in curves: curve_array = np.asarray(curve, dtype=np.float64, order="C") @@ -212,7 +212,7 @@ def refined_delaunay_mesh( maxlength = maxlength or 0.0 # Call C++ function with proper type conversion and parameter order - return triangulation_ext.refined_delaunay_mesh( + return _triangulation.refined_delaunay_mesh( boundary, # B: numpy array (Nx2) points, # P: numpy array (Mx2) holes_vector, # holes: VectorRowMatrixXd diff --git a/src/intersections.cpp b/src/intersections.cpp index e835c3c0..6e2139c8 100644 --- a/src/intersections.cpp +++ b/src/intersections.cpp @@ -17,7 +17,7 @@ pmp_intersection_mesh_mesh( return result; } -NB_MODULE(intersections_ext, m) { +NB_MODULE(_intersections, m) { m.def( diff --git a/src/measure.cpp b/src/measure.cpp index 11c49bed..3f69b7d0 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -32,7 +32,7 @@ pmp_centroid( } -NB_MODULE(measure_ext, m) { +NB_MODULE(_measure, m) { m.def( diff --git a/src/meshing.cpp b/src/meshing.cpp index 97833ff8..e75c05b6 100644 --- a/src/meshing.cpp +++ b/src/meshing.cpp @@ -27,7 +27,7 @@ pmp_remesh( } -NB_MODULE(meshing_ext, m) { +NB_MODULE(_meshing, m) { m.def( "remesh", &pmp_remesh, diff --git a/src/reconstruction.cpp b/src/reconstruction.cpp index 3fd84b46..c38be6c9 100644 --- a/src/reconstruction.cpp +++ b/src/reconstruction.cpp @@ -231,7 +231,7 @@ pointset_normal_estimation( } -NB_MODULE(reconstruction_ext, m) { +NB_MODULE(_reconstruction, m) { m.def( "poisson_surface_reconstruction", diff --git a/src/skeletonization.cpp b/src/skeletonization.cpp index 1d2c382f..5760347b 100644 --- a/src/skeletonization.cpp +++ b/src/skeletonization.cpp @@ -46,7 +46,7 @@ pmp_mesh_skeleton( return std::make_tuple(start_points, end_points); }; -NB_MODULE(skeletonization_ext, m) { +NB_MODULE(_skeletonization, m) { m.def( diff --git a/src/slicer.cpp b/src/slicer.cpp index 758932f3..fd1a7579 100644 --- a/src/slicer.cpp +++ b/src/slicer.cpp @@ -28,7 +28,7 @@ pmp_slice_mesh( return result; }; -NB_MODULE(slicer_ext, m) { +NB_MODULE(_slicer, m) { m.def( diff --git a/src/straight_skeleton_2.cpp b/src/straight_skeleton_2.cpp index f8a6556f..b8f8a799 100644 --- a/src/straight_skeleton_2.cpp +++ b/src/straight_skeleton_2.cpp @@ -284,7 +284,7 @@ pmp_create_weighted_offset_polygons_2_outer( throw std::runtime_error("CGAL precondition failed: Invalid input for weighted offset"); } } -NB_MODULE(straight_skeleton_2_ext, m) { +NB_MODULE(_straight_skeleton_2, m) { m.def( "create_interior_straight_skeleton", diff --git a/src/subdivision.cpp b/src/subdivision.cpp index 6377d07f..b7122064 100644 --- a/src/subdivision.cpp +++ b/src/subdivision.cpp @@ -36,7 +36,7 @@ subd_sqrt3( return compas::mesh_to_vertices_and_faces(mesh); } -NB_MODULE(subdivision_ext, m) { +NB_MODULE(_subdivision, m) { m.def( "subd_catmullclark", diff --git a/src/triangulation.cpp b/src/triangulation.cpp index 2e49c888..b4b5f55d 100644 --- a/src/triangulation.cpp +++ b/src/triangulation.cpp @@ -394,7 +394,7 @@ pmp_refined_delaunay_mesh( return std::make_tuple(vertices_out, faces_out); } -NB_MODULE(triangulation_ext, m) { +NB_MODULE(_triangulation, m) { m.def( diff --git a/src/types_std.cpp b/src/types_std.cpp index 9fb9885e..739582f4 100644 --- a/src/types_std.cpp +++ b/src/types_std.cpp @@ -1,6 +1,6 @@ #include "types_std.h" -NB_MODULE(types_std, m) { +NB_MODULE(_types_std, m) { nb::bind_vector>(m, "VectorDouble"); nb::bind_vector>(m, "VectorInt");