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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added build flags for file size reduction in `CMakeLists.txt`.

### Changed

* Precompiled header is optional and set to OFF to reduce deployment built size.
* Moved `compas.h` module specific headers to the individual source files.

### Removed

* Remove unnecessary headers from `compas_cgal.h`.


## [0.7.3] 2025-03-18

Expand Down
39 changes: 31 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ project(cgal_wrapper LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_DEBUG "")

# =====================================================================
# Set this flag to ON for developing to reduce build time.
# Set this flag to OFF for publishing for file size reduction.
# =====================================================================
option(ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers for the build" OFF)

# =====================================================================
# Build size reduction.
# =====================================================================

if (NOT ENABLE_PRECOMPILED_HEADERS)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O1") # Optimize for size on MSVC
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os") # Optimize for size on GCC/Clang
endif()
endif()

# =====================================================================
# Dependencies
Expand Down Expand Up @@ -196,15 +217,17 @@ target_include_directories(compas_cgal_ext PRIVATE
# Make sure external dependencies are downloaded before building the extension
add_dependencies(compas_cgal_ext external_downloads)

# Enhanced PCH configuration
set(CMAKE_PCH_INSTANTIATE_TEMPLATES OFF)
set(CMAKE_PCH_WARN_INVALID OFF)
if (ENABLE_PRECOMPILED_HEADERS)
# Enhanced PCH configuration
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
set(CMAKE_PCH_WARN_INVALID ON)

# Configure PCH for the extension
target_precompile_headers(compas_cgal_ext
PRIVATE
src/compas.h
)
# 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)
4 changes: 4 additions & 0 deletions src/booleans.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include "compas.h"

// CGAL boolean
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/clip.h>

/**
* Compute the boolean union of two triangle meshes.
*
Expand Down
88 changes: 0 additions & 88 deletions src/compas.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,12 @@
// This file is referenced in CMakeLists PCH section.

// STD
#include <stdlib.h>
#include <vector>
#include <array>
#include <map>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <limits>
#include <chrono>
#include <float.h>
#include <inttypes.h>
#include <cstring>
#include <set>
#include <unordered_set>
#include <list>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <filesystem>
#include <utility>


// Nanobind
#include <nanobind/nanobind.h>
#include <nanobind/eigen/dense.h>
#include <nanobind/eigen/sparse.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/bind_vector.h>
#include <nanobind/stl/shared_ptr.h>
Expand All @@ -49,7 +23,6 @@ using namespace nb::literals; // enables syntax for annotating function and argu
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>


// Eigen
#include <Eigen/Core>
#include <Eigen/Dense>
Expand All @@ -62,67 +35,6 @@ using namespace nb::literals; // enables syntax for annotating function and argu
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>

// CGAL remesh
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>

// CGAL measure
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Point_3.h>

// CGAL boolean
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/clip.h>

// CGAL intersection
#include <CGAL/Polygon_mesh_processing/intersection.h>

// CGAL reconstruction
#include <CGAL/poisson_surface_reconstruction.h>
#include <CGAL/property_map.h>
#include <CGAL/remove_outliers.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/jet_smooth_point_set.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/grid_simplify_point_set.h>

// CGAL skeletonization
#include <CGAL/Mean_curvature_flow_skeletonization.h>
#include <CGAL/boost/graph/split_graph_into_polylines.h>

// CGAL slicer
#include <CGAL/Polygon_mesh_slicer.h>

// CGAL subdivision
#include <CGAL/subdivision_method_3.h>

// CGAL triangulation
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_2.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Delaunay_mesher_2.h>
#include <CGAL/Delaunay_mesh_vertex_base_2.h>
#include <CGAL/Delaunay_mesh_face_base_2.h>
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
#include <CGAL/Triangulation_conformer_2.h>
#include <CGAL/lloyd_optimize_mesh_2.h>

// CGAL straight skeleton 2
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h>
#include <CGAL/create_offset_polygons_2.h>
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
#include <CGAL/create_weighted_straight_skeleton_2.h>
#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h>


namespace compas
{
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
Expand Down
3 changes: 3 additions & 0 deletions src/intersections.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "compas.h"

// CGAL intersection
#include <CGAL/Polygon_mesh_processing/intersection.h>

/**
* Compute intersection between two triangle meshes.
*
Expand Down
1 change: 1 addition & 0 deletions src/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pmp_volume(
{
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);
double volume = CGAL::Polygon_mesh_processing::volume(mesh);
int a = 0;
return volume;
}

Expand Down
4 changes: 4 additions & 0 deletions src/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include "compas.h"

// CGAL measure
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Point_3.h>

/**
* @brief Computes the surface area of a triangle mesh.
*
Expand Down
9 changes: 4 additions & 5 deletions src/meshing.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* @file meshing.h
* @brief Header file for mesh processing operations using CGAL
*/

#pragma once

#include "compas.h"

// CGAL remesh
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>

namespace compas {

/**
Expand Down
12 changes: 12 additions & 0 deletions src/reconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

#include "compas.h"

// CGAL reconstruction
#include <CGAL/poisson_surface_reconstruction.h>
#include <CGAL/property_map.h>
#include <CGAL/remove_outliers.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/jet_smooth_point_set.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/grid_simplify_point_set.h>

/**
* @brief Perform Poisson surface reconstruction on an oriented pointcloud with normals.
*
Expand Down
4 changes: 4 additions & 0 deletions src/skeletonization.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include "compas.h"

// CGAL skeletonization
#include <CGAL/Mean_curvature_flow_skeletonization.h>
#include <CGAL/boost/graph/split_graph_into_polylines.h>

/**
* @brief Compute the geometric skeleton of a triangle mesh using mean curvature flow.
*
Expand Down
3 changes: 3 additions & 0 deletions src/slicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "compas.h"

// CGAL slicer
#include <CGAL/Polygon_mesh_slicer.h>

/**
* @brief Slice a mesh with a set of planes defined by points and normals.
*
Expand Down
10 changes: 10 additions & 0 deletions src/straight_skeleton_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

#include "compas.h"

// CGAL straight skeleton 2
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h>
#include <CGAL/create_offset_polygons_2.h>
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
#include <CGAL/create_weighted_straight_skeleton_2.h>
#include <CGAL/create_offset_polygons_from_polygon_with_holes_2.h>


/**
* @brief Creates a straight skeleton from a simple polygon without holes.
*
Expand Down
3 changes: 3 additions & 0 deletions src/subdivision.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "compas.h"

// CGAL subdivision
#include <CGAL/subdivision_method_3.h>

/**
* @brief Subdivide a mesh with the Catmull-Clark scheme.
*
Expand Down
14 changes: 14 additions & 0 deletions src/triangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

#include "compas.h"

// CGAL triangulation
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_2.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Delaunay_mesher_2.h>
#include <CGAL/Delaunay_mesh_vertex_base_2.h>
#include <CGAL/Delaunay_mesh_face_base_2.h>
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
#include <CGAL/Triangulation_conformer_2.h>
#include <CGAL/lloyd_optimize_mesh_2.h>

/**
* @brief Delaunay Triangulation of a given set of points.
*
Expand Down
Loading