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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.10", "3.11", "3.12"]
python: ["3.10"]

steps:
- uses: compas-dev/compas-actions.build@v4
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Split binding into separate dynamic libraries.

### Removed


Expand Down
67 changes: 32 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,46 +198,43 @@ find_package(nanobind CONFIG REQUIRED)
#
# Important: If you add a new .cpp file, you must rebuild the project with:
# pip install --no-build-isolation -ve . -Ceditable.rebuild=true
file(GLOB CPP_SOURCES
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
)

# Verify we found all expected source files and remind about type handling
message(STATUS "Found C++ source files (ensure proper type conversion in each):")
# Enhanced PCH configuration
if (ENABLE_PRECOMPILED_HEADERS)
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
set(CMAKE_PCH_WARN_INVALID ON)
endif()

foreach(source ${CPP_SOURCES})
message(STATUS " ${source}")
endforeach()
# Function to add a nanobind module with include directories
function(add_nanobind_module module_name source_file)
nanobind_add_module(${module_name} STABLE_ABI NB_STATIC ${source_file})

nanobind_add_module(
compas_cgal_ext
STABLE_ABI
NB_STATIC
${CPP_SOURCES}
)
target_include_directories(${module_name} PRIVATE
${CGAL_INCLUDE_DIR}
${BOOST_INCLUDE_DIR}
${EIGEN_INCLUDE_DIR}
)

# Set include directories for the extension
target_include_directories(compas_cgal_ext PRIVATE
${CGAL_INCLUDE_DIR}
${BOOST_INCLUDE_DIR}
${EIGEN_INCLUDE_DIR}
)
add_dependencies(${module_name} external_downloads)

# Make sure external dependencies are downloaded before building the extension
add_dependencies(compas_cgal_ext external_downloads)
if (ENABLE_PRECOMPILED_HEADERS)
target_precompile_headers(${module_name} PRIVATE src/compas.h)
endif()

if (ENABLE_PRECOMPILED_HEADERS)
# Enhanced PCH configuration
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
set(CMAKE_PCH_WARN_INVALID ON)
install(TARGETS ${module_name} LIBRARY DESTINATION compas_cgal)
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)

# Configure PCH for the extension
target_precompile_headers(compas_cgal_ext
PRIVATE
src/compas.h
)
endif()

# Install directive for scikit-build-core
install(TARGETS compas_cgal_ext LIBRARY DESTINATION compas_cgal)
10,224 changes: 8,336 additions & 1,888 deletions data/elephant.off

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,5 @@ API Reference
:maxdepth: 1

api/compas_cgal.booleans
api/compas_cgal.intersections
api/compas_cgal.measure
api/compas_cgal.meshing
api/compas_cgal.slicer
api/compas_cgal.skeletonization
api/compas_cgal.subdivision
api/compas_cgal.triangulation
api/compas_cgal.types

11 changes: 0 additions & 11 deletions docs/api/compas_cgal.intersections.rst

This file was deleted.

13 changes: 0 additions & 13 deletions docs/api/compas_cgal.measure.rst

This file was deleted.

11 changes: 0 additions & 11 deletions docs/api/compas_cgal.skeletonization.rst

This file was deleted.

11 changes: 0 additions & 11 deletions docs/api/compas_cgal.slicer.rst

This file was deleted.

14 changes: 0 additions & 14 deletions docs/api/compas_cgal.subdivision.rst

This file was deleted.

15 changes: 0 additions & 15 deletions docs/api/compas_cgal.triangulation.rst

This file was deleted.

18 changes: 0 additions & 18 deletions docs/api/compas_cgal.types.rst

This file was deleted.

3 changes: 1 addition & 2 deletions docs/examples/example_booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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
# from compas_cgal.meshing import mesh_remesh


def input():
Expand All @@ -19,7 +19,6 @@ def input():
A = box.to_vertices_and_faces(triangulated=True)
sphere = Sphere(1, point=[1, 1, 1])
B = sphere.to_vertices_and_faces(u=64, v=64, triangulated=True)
B = mesh_remesh(B, 0.3, 50)
return A, B


Expand Down
14 changes: 0 additions & 14 deletions docs/examples/example_measure.rst

This file was deleted.

40 changes: 0 additions & 40 deletions docs/examples/example_nanobind_types.py

This file was deleted.

23 changes: 0 additions & 23 deletions docs/examples/example_nanobind_types.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/examples/example_reconstruction_pointset_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def reconstruction_pointset_smoothing():
ply_file_path = Path(__file__).parent.parent.parent / "data" / "box.ply"
original_points = Pointcloud.from_ply(ply_file_path)

smoothed_points = pointset_smoothing(original_points, 1000, 3)
smoothed_points = pointset_smoothing(original_points, 100, 3)

return Pointcloud(original_points), Pointcloud(smoothed_points)

Expand Down
7 changes: 3 additions & 4 deletions docs/examples/example_skeletonization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ def main():
translation = Translation.from_vector([0, 0, 2])

mesh = Mesh.from_off(input_file).transformed(translation * rotation * scale)
mesh = mesh.subdivided("loop")
# mesh = mesh.subdivided("loop")
v, f = mesh.to_vertices_and_faces(triangulated=True)

vertices, faces = mesh.to_vertices_and_faces()

skeleton_edges = mesh_skeleton((vertices, faces))
skeleton_edges = mesh_skeleton((v, f))

polylines = []
for start_point, end_point in skeleton_edges:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from compas.geometry import Point
from compas.geometry import Polygon
from compas_viewer import Viewer
from line_profiler import profile
Expand Down
13 changes: 6 additions & 7 deletions src/booleans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ pmp_split(
return result;
};

void init_booleans(nb::module_& m) {
auto submodule = m.def_submodule("booleans");
NB_MODULE(booleans_ext, m) {

submodule.def(
m.def(
"boolean_union",
&pmp_boolean_union,
"Boolean Union from triangular mesh vertices and faces.",
Expand All @@ -78,7 +77,7 @@ void init_booleans(nb::module_& m) {
"VB"_a,
"FB"_a);

submodule.def(
m.def(
"boolean_difference",
&pmp_boolean_difference,
"Boolean Difference from triangular mesh vertices and faces.",
Expand All @@ -87,7 +86,7 @@ void init_booleans(nb::module_& m) {
"VB"_a,
"FB"_a);

submodule.def(
m.def(
"boolean_intersection",
&pmp_boolean_intersection,
"Boolean Intersection from triangular mesh vertices and faces.",
Expand All @@ -96,12 +95,12 @@ void init_booleans(nb::module_& m) {
"VB"_a,
"FB"_a);

submodule.def(
m.def(
"split",
&pmp_split,
"Boolean Split from triangular mesh vertices and faces.",
"VA"_a,
"FA"_a,
"VB"_a,
"FB"_a);
}
}
Loading
Loading