Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c766340
add a way to check that only named parameters used by a function are …
sloriot Jan 8, 2024
5485062
add a way to disable the check
sloriot Jan 8, 2024
adff72c
fix ambiguity
sloriot Mar 14, 2024
c4b113a
use enable_if_t
sloriot Mar 14, 2024
c0ef2b1
add a macro to ease the check
sloriot Mar 25, 2024
29679af
add constexpr for NP and a flag for to disable allowed nps
sloriot Apr 18, 2024
57116c8
start adding checks
sloriot Oct 23, 2024
3dc32c5
fix version of the script to add the np macro checking
sloriot Apr 18, 2025
d8be4cb
improvements + inplace writing
sloriot Apr 18, 2025
28d11fc
handle some particular cases
sloriot Apr 18, 2025
e53eb25
always replace the macro to handle the update
sloriot Oct 25, 2025
ea3f73d
emit an error if no parameter was found
sloriot Oct 25, 2025
7475b9e
handle several nps
sloriot Oct 25, 2025
8e0edd5
handle np only
sloriot Oct 26, 2025
eba48ec
fix macro name
sloriot Oct 26, 2025
ea8d366
use struct as np variable is not a constexpr
sloriot Jan 26, 2026
3733f17
improve the CGAL named parameters API and implementation
lrineau Oct 8, 2026
7a02159
Merge remote-tracking branch 'lrineau/STL_Extension-improve_np-lrinea…
lrineau Oct 8, 2026
e221fa6
fix CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS
lrineau Oct 8, 2026
73bb4de
NP: fix Boost_parameter_compatibility_wrapper
lrineau Oct 8, 2026
98a1fe9
NP: fix Boost_parameter_compatibility_wrapper, again
lrineau Oct 8, 2026
a9f990b
NP: fix Boost_parameter_compatibility_wrapper
lrineau Oct 8, 2026
41557b3
check_headers now checks also check_headers_linked_twice
lrineau Oct 9, 2026
ae3e09d
test and fix ref_only and cref_only with more cases
lrineau Oct 9, 2026
5c0c0d4
KSP: fix checks with CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS
lrineau Oct 8, 2026
1e19449
fix -fsyntax-only
lrineau Oct 9, 2026
903be6c
Merge remote-tracking branch 'lrineau/STL_Extension-improve_np-lrinea…
lrineau Oct 9, 2026
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: 2 additions & 0 deletions Convex_hull_3/include/CGAL/convex_hull_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ void convex_hull_3(const VertexListGraph& g,
PolygonMesh& pm,
const NamedParameters& np = parameters::default_values())
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, vertex_point_t);

using CGAL::parameters::choose_parameter;
using CGAL::parameters::get_parameter;

Expand Down
62 changes: 30 additions & 32 deletions Installation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ if(CGAL_BRANCH_BUILD)
find_package(GMP REQUIRED)
find_package(Doxygen REQUIRED)
find_package(Eigen3 REQUIRED)
include(CGAL_Eigen3_support)
get_target_property(CGAL_EIGEN_3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
find_package(Qt6 COMPONENTS Core Widgets OpenGL Gui REQUIRED)
set(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
Expand All @@ -843,23 +844,18 @@ if(CGAL_BRANCH_BUILD)
find_package(OpenMesh)
find_package(OpenCV QUIET)

set(compile_options
"\
${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE \
${Qt6Widgets_DEFINITIONS} ${Qt6OpenGL_DEFINITIONS} ${Qt6Gui_DEFINITIONS} \
${Qt6OpenGL_EXECUTABLE_COMPILE_FLAGS} -fPIC \
${Qt6Gui_EXECUTABLE_COMPILE_FLAGS} \
${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_Qt6_3RD_PARTY_DEFINITIONS} \
${CGAL_DEFINITIONS}" -std=c++17)
message("COMPILATION OPTIONS ARE : ${compile_options}")
set(compile_options ${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE ${Qt6Widgets_DEFINITIONS}
${Qt6OpenGL_DEFINITIONS} ${Qt6Gui_DEFINITIONS} ${Qt6OpenGL_EXECUTABLE_COMPILE_FLAGS} -fPIC
${Qt6Gui_EXECUTABLE_COMPILE_FLAGS} ${CGAL_3RD_PARTY_DEFINITIONS} ${CGAL_Qt6_3RD_PARTY_DEFINITIONS}
${CGAL_DEFINITIONS} -std=c++17)
message("COMPILATION OPTIONS ARE: ${compile_options}")

if(NOT OpenMesh_FOUND)
set(compile_options
"${compile_options} \
-DCGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYMESH_ARRAYKERNELT_H \
-DCGAL_BOOST_GRAPH_GRAPH_TRAITS_TRIMESH_ARRAYKERNELT_H \
-DCGAL_PROPERTIES_POLYMESH_ARRAYKERNELT_H \
-DCGAL_PROPERTIES_TRIMESH_ARRAYKERNELT_H")
list(APPEND compile_options
-DCGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYMESH_ARRAYKERNELT_H
-DCGAL_BOOST_GRAPH_GRAPH_TRAITS_TRIMESH_ARRAYKERNELT_H
-DCGAL_PROPERTIES_POLYMESH_ARRAYKERNELT_H
-DCGAL_PROPERTIES_TRIMESH_ARRAYKERNELT_H)
message(
STATUS
"Skip headers \
Expand All @@ -870,17 +866,17 @@ ${CGAL_DEFINITIONS}" -std=c++17)
because OpenMesh_FOUND is false.")
endif()
if(NOT OpenCV_FOUND)
set(compile_options "${compile_options} \
-DCGAL_CLASSIFICATION_OPENCV_RANDOM_FOREST_CLASSIFIER_H")
list(APPEND compile_options
-DCGAL_CLASSIFICATION_OPENCV_RANDOM_FOREST_CLASSIFIER_H)
message(STATUS "Skip header \
\"CGAL/Classification/OpenCV_random_forest_classifier.h\" \
because OpenCV_FOUND is false")
endif()
if(LEDA_FOUND)
set(compile_options "${compile_options} -DCGAL_USE_LEDA")
list(APPEND compile_options -DCGAL_USE_LEDA)
endif()
if(NOT IPE_FOUND)
set(compile_options "${compile_options} -DCGAL_IPELET_BASE_H=1")
list(APPEND compile_options -DCGAL_IPELET_BASE_H=1)
message(STATUS "Skip header \"CGAL/CGAL_ipelet_base.h\" \
because IPE_FOUND is false.")
endif()
Expand Down Expand Up @@ -929,7 +925,6 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.")
${GMP_INCLUDE_DIR}
${Qt6OpenGL_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Gui_DEFINITIONS}
${CGAL_3RD_PARTY_INCLUDE_DIRS}
${CGAL_Qt6_3RD_PARTY_INCLUDE_DIRS})
list(APPEND include_options "-I${incdir}")
Expand Down Expand Up @@ -1062,6 +1057,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
endif() # end the if on list_of_documented_headers
endforeach() # look on headers
add_custom_target(check_pkg_${package}_headers
COMMENT "Check headers for package ${package}"
DEPENDS ${check_pkg_headers_depends})
add_custom_command(
OUTPUT ${CGAL_BINARY_DIR}/package_info/${package}/included_headers
Expand All @@ -1078,6 +1074,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
${check_pkg_headers_depends})
add_custom_target(
pkg_${package}_deps
COMMENT "Compute dependencies for package ${package}"
DEPENDS ${CGAL_BINARY_DIR}/package_info/${package}/dependencies)
list(APPEND check_pkg_target_list check_pkg_${package}_headers)
list(APPEND packages_deps
Expand All @@ -1095,26 +1092,27 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
file(COPY_FILE ${CGAL_BINARY_DIR}/test_headers.cpp ${CGAL_BINARY_DIR}/test_headers2.cpp)
file(APPEND ${CGAL_BINARY_DIR}/test_headers.cpp "int main(){}\n")

add_custom_target(check_headers DEPENDS ${check_pkg_target_list})

string(REPLACE " " ";" compile_options ${compile_options})
string(REPLACE " " ";" include_options ${include_options_str})
add_custom_command(
TARGET check_headers
POST_BUILD
COMMAND ${CMAKE_CXX_COMPILER} ${compile_options} ${include_options} -x
c++ -fsyntax-only ${CGAL_BINARY_DIR}/test_headers.cpp)

# New check that headers can be included in different compilation units, that can be linked
# together. That checks for missing `inline` keywords.
add_executable(check_headers_linked_twice
${CGAL_BINARY_DIR}/test_headers.cpp
${CGAL_BINARY_DIR}/test_headers2.cpp)
target_link_libraries(check_headers_linked_twice PRIVATE CGAL::CGAL CGAL::CGAL_Qt6 Qt6::Widgets)
target_link_libraries(check_headers_linked_twice PRIVATE CGAL::CGAL CGAL::CGAL_Qt6 Qt6::Widgets CGAL::Eigen3_support)
target_compile_options(check_headers_linked_twice PRIVATE ${compile_options} ${include_options})
if(VTK_FOUND)
target_link_libraries(check_headers_linked_twice PRIVATE VTK::IOImage)
endif()
target_compile_options(check_headers_linked_twice PRIVATE ${compile_options} ${include_options})

add_custom_target(check_headers DEPENDS ${check_pkg_target_list} check_headers_linked_twice)

string(REPLACE " " ";" include_options ${include_options_str})
add_custom_command(
TARGET check_headers
COMMENT "Check that all headers can be included in the same translation unit"
POST_BUILD
COMMAND ${CMAKE_CXX_COMPILER} ${compile_options} ${include_options} -x
c++ -fsyntax-only "${CGAL_BINARY_DIR}/test_headers.cpp")


add_custom_target(packages_dependencies DEPENDS ${packages_deps})
message(
Expand Down
21 changes: 17 additions & 4 deletions Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ class Kinetic_space_partition_3 {
: m_parameters(
parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false),
parameters::choose_parameter(parameters::get_parameter(np, internal_np::debug), false)), // use true here to export all steps
m_input2regularized() {}
m_input2regularized()
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, verbose_t, debug_t);
}

/*!
\brief constructs a kinetic space partition object.
Expand Down Expand Up @@ -357,7 +360,11 @@ class Kinetic_space_partition_3 {
: m_parameters(
parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false),
parameters::choose_parameter(parameters::get_parameter(np, internal_np::debug), false)), // use true here to export all steps
m_input2regularized() {
m_input2regularized()
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, point_t, debug_t, verbose_t, reorient_bbox_t,
bbox_dilation_ratio_t, max_octree_depth_t, max_octree_node_size_t);

insert(points, polygons, np);
}

Expand Down Expand Up @@ -394,7 +401,10 @@ class Kinetic_space_partition_3 {
void insert(
const PointRange& points,
const PolygonRange& polygons,
const NamedParameters& np = CGAL::parameters::default_values()) {
const NamedParameters& np = CGAL::parameters::default_values())
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, point_t, debug_t, verbose_t, reorient_bbox_t,
bbox_dilation_ratio_t, max_octree_depth_t, max_octree_node_size_t);

using NP_helper = Point_set_processing_3_np_helper<PointRange, NamedParameters>;
using PointMap = typename NP_helper::Point_map;
Expand Down Expand Up @@ -486,7 +496,10 @@ class Kinetic_space_partition_3 {
template<
typename NamedParameters = parameters::Default_named_parameters>
void initialize(
const NamedParameters& np = CGAL::parameters::default_values()) {
const NamedParameters& np = CGAL::parameters::default_values())
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, reorient_bbox_t, bbox_dilation_ratio_t, max_octree_depth_t, max_octree_node_size_t);

Timer timer;
m_parameters.bbox_dilation_ratio = parameters::choose_parameter(
parameters::get_parameter(np, internal_np::bbox_dilation_ratio), FT(11) / FT(10));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ class Kinetic_surface_reconstruction_3 {
Kinetic_surface_reconstruction_3(Point_range& points,
const NamedParameters& np = CGAL::parameters::default_values()) : m_max_distance_to_plane(-1), m_points(points), m_ground_polygon_index(-1),
m_kinetic_partition(np), m_bbox_diagonal(-1), m_lcc(m_lcc_from_kinetic_partition) {
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, point_t, normal_t, verbose_t, debug_t);

m_verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false);
m_debug = parameters::choose_parameter(parameters::get_parameter(np, internal_np::debug), false);

Expand Down Expand Up @@ -284,6 +286,10 @@ class Kinetic_surface_reconstruction_3 {
*/
template<typename CGAL_NP_TEMPLATE_PARAMETERS>
std::size_t regularize_planar_shapes(const CGAL_NP_CLASS& np = parameters::default_values()) {
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, point_t, normal_t, k_neighbors_t, maximum_distance_t, maximum_angle_t,
minimum_region_size_t, angle_tolerance_t, maximum_offset_t,
regularize_parallelism_t, regularize_orthogonality_t, regularize_coplanarity_t,
regularize_axis_symmetry_t, symmetry_direction_t);
if (m_regions.empty())
return 0;

Expand Down Expand Up @@ -467,7 +473,13 @@ class Kinetic_surface_reconstruction_3 {
\cgalNamedParamsEnd
*/
template<typename CGAL_NP_TEMPLATE_PARAMETERS>
void detection_and_partition(std::size_t k, const CGAL_NP_CLASS& np = parameters::default_values()) {
void detection_and_partition(std::size_t k, const CGAL_NP_CLASS& np = parameters::default_values())
{
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, point_t, normal_t, k_neighbors_t, maximum_distance_t, maximum_angle_t,
minimum_region_size_t, angle_tolerance_t, maximum_offset_t, regularize_parallelism_t,
regularize_orthogonality_t, regularize_coplanarity_t, regularize_axis_symmetry_t,
symmetry_direction_t, reorient_bbox_t, bbox_dilation_ratio_t);

detect_planar_shapes(np);
regularize_planar_shapes(np);
partition(k);
Expand Down Expand Up @@ -545,6 +557,9 @@ class Kinetic_surface_reconstruction_3 {
*/
template<typename CGAL_NP_TEMPLATE_PARAMETERS>
void partition(std::size_t k, const CGAL_NP_CLASS& np = parameters::default_values()) {
CGAL_CHECK_AUTHORIZED_NAMED_PARAMETERS(np, reorient_bbox_t, bbox_dilation_ratio_t, point_t, normal_t, verbose_t,
debug_t, max_octree_depth_t, max_octree_node_size_t);

if (m_regions.empty())
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,24 +1187,24 @@ std::size_t snap_non_conformal_one_way(const HalfedgeRange& halfedge_range_S,
// \param np_A an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
//
// \cgalNamedParamsBegin
// \cgalParamBegin{vertex_point_map}
// \cgalParamNBegin{vertex_point_map}
// the property map with the points associated to the vertices of the source mesh.
// The type of this map is model of `ReadWritePropertyMap`. If this parameter is omitted,
// an internal property map for `CGAL::vertex_point_t` must be available in `TriangleMesh`.
// \cgalParamEnd
// \cgalParamBegin{geom_traits}
// \cgalParamNEnd
// \cgalParamNBegin{geom_traits}
// a geometric traits class instance, must be a model of `Kernel`
// \cgalParamEnd
// \cgalParamNEnd
// \cgalNamedParamsEnd
//
// \param np_B an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
//
// \cgalNamedParamsBegin
// \cgalParamBegin{vertex_point_map}
// \cgalParamNBegin{vertex_point_map}
// the property map with the points associated to the vertices of the target mesh.
// The type of this map is model of `ReadablePropertyMap`. If this parameter is omitted,
// an internal property map for `CGAL::vertex_point_t` must be available in `TriangleMesh`.
// \cgalParamEnd
// \cgalParamNEnd
// \cgalNamedParamsEnd
//
// \return the number of snapped vertex pairs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1227,24 +1227,24 @@ namespace experimental {
// \param np_A an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
//
// \cgalNamedParamsBegin
// \cgalParamBegin{vertex_point_map}
// \cgalParamNBegin{vertex_point_map}
// the property map with the points associated to the vertices of the source mesh.
// The type of this map is model of `ReadWritePropertyMap`. If this parameter is omitted,
// an internal property map for `CGAL::vertex_point_t` must be available in `PolygonMesh`.
// \cgalParamEnd
// \cgalParamBegin{geom_traits}
// \cgalParamNEnd
// \cgalParamNBegin{geom_traits}
// a geometric traits class instance, must be a model of `Kernel`
// \cgalParamEnd
// \cgalParamNEnd
// \cgalNamedParamsEnd
//
// \param np_B an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
//
// \cgalNamedParamsBegin
// \cgalParamBegin{vertex_point_map}
// \cgalParamNBegin{vertex_point_map}
// the property map with the points associated to the vertices of the target mesh.
// The type of this map is model of `ReadablePropertyMap`. If this parameter is omitted,
// an internal property map for `CGAL::vertex_point_t` must be available in `PolygonMesh`.
// \cgalParamEnd
// \cgalParamNEnd
// \cgalNamedParamsEnd
//
// \return the number of snapped vertex pairs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#include <CGAL/Dynamic_property_map.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>

#include <CGAL/Surface_mesh.h>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/boost/graph/properties.h>
#include <CGAL/property_map.h>
#include <CGAL/use.h>

#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <boost/property_map/property_map.hpp>

#include <cassert>
#include <map>
#include <sstream>
#include <iostream>
#include <unordered_map>


namespace CGAL {
Expand Down Expand Up @@ -65,11 +77,15 @@ void my_function_with_named_parameters(PolygonMesh& mesh, const NamedParameters&

VCM vcm_np = choose_parameter<Default_VCM>(get_parameter(np, internal_np::vertex_is_constrained));

auto vcmap = choose_parameter(get_parameter(np, internal_np::vertex_color_map),
CGAL::dynamic_vertex_property_t<bool>{}, mesh, false);

//demonstrates usage for those values.
for(auto v : vertices(mesh))
{
std::cout<<"vertex #"<<get(vim, v)<<" : "<<get(vpm, v)<<" : "<<get(vcm_np, v)<<std::endl;
put(vcmap, v, true);
assert(get(vcmap, v));
}

if (!do_project_is_default)
Expand Down Expand Up @@ -114,7 +130,17 @@ int main()
typedef boost::associative_property_map<VCmap> Vertex_constrained_pmap;
Vertex_constrained_pmap vcm_pmap(vcm);
CGAL::my_function_with_named_parameters(sm);

VCmap colors;
for(auto v : vertices(sm))
colors[v] = false;
Vertex_constrained_pmap color_pmap(colors);

CGAL::my_function_with_named_parameters(sm, CGAL::parameters::vertex_is_constrained_map(vcm_pmap)
.vertex_color_map(color_pmap)
.do_project(true));
for(auto v : vertices(sm))
assert(colors[v]);

return 0;
}
Loading
Loading