Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Binary file modified docs/_images/example_booleans.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_intersections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_meshing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_reconstruction_pointset_reduction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_reconstruction_pointset_smoothing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_skeletonization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_slicer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_subdivision.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/example_triangulation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions docs/api/compas_cgal.intersections.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
********************************************************************************
compas_cgal.intersections
********************************************************************************

.. currentmodule:: compas_cgal.intersections

.. autosummary::
:toctree: generated/
:nosignatures:

intersection_mesh_mesh
13 changes: 13 additions & 0 deletions docs/api/compas_cgal.measure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
********************************************************************************
compas_cgal.measure
********************************************************************************

.. currentmodule:: compas_cgal.measure

.. autosummary::
:toctree: generated/
:nosignatures:

mesh_area
mesh_volume
mesh_centroid
16 changes: 16 additions & 0 deletions docs/api/compas_cgal.reconstruction.rst
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions docs/api/compas_cgal.skeletonization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
********************************************************************************
compas_cgal.skeletonization
********************************************************************************

.. currentmodule:: compas_cgal.skeletonization

.. autosummary::
:toctree: generated/
:nosignatures:

mesh_skeleton
11 changes: 11 additions & 0 deletions docs/api/compas_cgal.slicer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
********************************************************************************
compas_cgal.slicer
********************************************************************************

.. currentmodule:: compas_cgal.slicer

.. autosummary::
:toctree: generated/
:nosignatures:

slice_mesh_planes
16 changes: 16 additions & 0 deletions docs/api/compas_cgal.straight_skeleton_2.rst
Original file line number Diff line number Diff line change
@@ -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

14 changes: 14 additions & 0 deletions docs/api/compas_cgal.subdivision.rst
Original file line number Diff line number Diff line change
@@ -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

15 changes: 15 additions & 0 deletions docs/api/compas_cgal.triangulation.rst
Original file line number Diff line number Diff line change
@@ -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

18 changes: 18 additions & 0 deletions docs/api/compas_cgal.types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
********************************************************************************
compas_cgal.types
********************************************************************************

.. currentmodule:: compas_cgal.types

.. autosummary::
:toctree: generated/
:nosignatures:

Vertices
Faces
VerticesFaces
Planes
VerticesNumpy
FacesNumpy
VerticesFacesNumpy
PolylinesNumpy
34 changes: 15 additions & 19 deletions docs/devguide/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@ 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

#include "new_module"

// 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",
Expand All @@ -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
--------------
Expand Down
1 change: 0 additions & 1 deletion docs/devguide/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Overview




File and Folder Structure
-------------------------

Expand Down
1 change: 0 additions & 1 deletion docs/examples/example_booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/example_reconstruction_pointset_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src/booleans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pmp_split(
return result;
};

NB_MODULE(booleans_ext, m) {
NB_MODULE(_booleans, m) {

m.def(
"boolean_union",
Expand Down
10 changes: 5 additions & 5 deletions src/compas_cgal/booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/compas_cgal/intersections.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions src/compas_cgal/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down Expand Up @@ -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]:
Expand All @@ -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
4 changes: 2 additions & 2 deletions src/compas_cgal/meshing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Loading
Loading