From 6df18b668c4ac990eacc07943954e2970e986ce4 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 6 Feb 2023 12:04:57 +0100 Subject: [PATCH 01/64] CGAL CTest support: rename the test names Now that CTest test names can contain whitespace, we can have better looking names. That is also more practicle because we can now copy-paste the target name in `compilation of `. --- .../test/Circular_kernel_2/CMakeLists.txt | 4 +- .../cmake/modules/CGAL_add_test.cmake | 80 +++++++++---------- ...GAL_enable_end_of_configuration_hook.cmake | 4 +- Installation/test/Installation/CMakeLists.txt | 2 +- Mesh_3/test/Mesh_3/CMakeLists.txt | 28 +++---- Nef_3/test/Nef_3/CMakeLists.txt | 20 ++--- .../Polygon_mesh_processing/CMakeLists.txt | 4 +- .../Plugins/Classification/CMakeLists.txt | 2 +- .../Plugins/Convex_hull/CMakeLists.txt | 2 +- .../Polyhedron/Plugins/PCA/CMakeLists.txt | 2 +- .../Polyhedron/Plugins/PMP/CMakeLists.txt | 22 ++--- .../Plugins/Surface_mesh/CMakeLists.txt | 4 +- .../Surface_mesh_deformation/CMakeLists.txt | 2 +- .../Polyhedron/polyhedron_demo_macros.cmake | 18 ++--- .../test/Triangulation_2/CMakeLists.txt | 22 ++--- .../examples/Triangulation_3/CMakeLists.txt | 6 +- .../test/Triangulation_3/CMakeLists.txt | 16 ++-- 17 files changed, 119 insertions(+), 119 deletions(-) diff --git a/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt b/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt index c271340b266..c59104595f1 100644 --- a/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt +++ b/Circular_kernel_2/test/Circular_kernel_2/CMakeLists.txt @@ -24,7 +24,7 @@ create_single_source_cgal_program("test_Exact_circular_kernel_basic.cpp") if(BUILD_TESTING) set_tests_properties( - execution___of__test_Circular_kernel_basic - execution___of__test_Exact_circular_kernel_basic + "execution of test_Circular_kernel_basic" + "execution of test_Exact_circular_kernel_basic" PROPERTIES RESOURCE_LOCK Circular_kernel_basic) endif() diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index a5c8b2bc83a..984922a772f 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -76,31 +76,31 @@ endfunction() function(cgal_add_compilation_test exe_name) cmake_policy(SET CMP0064 NEW) if(NOT CMAKE_VS_MSBUILD_COMMAND) - if(TEST compilation_of__${exe_name}) + if(TEST "compilation of ${exe_name}") return() endif() - add_test(NAME "compilation_of__${exe_name}" + add_test(NAME "compilation of ${exe_name}" COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${exe_name}" --config "$") - set_property(TEST "compilation_of__${exe_name}" + set_property(TEST "compilation of ${exe_name}" APPEND PROPERTY LABELS "${PROJECT_NAME}") - set_property(TEST "compilation_of__${exe_name}" + set_property(TEST "compilation of ${exe_name}" APPEND PROPERTY FIXTURES_REQUIRED "check_build_system_SetupFixture") - elseif(NOT TARGET compilation_of__${PROJECT_NAME})#CMAKE_VS_MSBUILD_COMMAND + elseif(NOT TARGET "compilation of ${PROJECT_NAME}")#CMAKE_VS_MSBUILD_COMMAND #this target is just a flag, to deal with the scope problem with the tests - add_custom_target(compilation_of__${PROJECT_NAME}) - add_test(NAME "compilation_of__${PROJECT_NAME}" + add_custom_target("compilation of ${PROJECT_NAME}") + add_test(NAME "compilation of ${PROJECT_NAME}" COMMAND ${TIME_COMMAND} "${CMAKE_VS_MSBUILD_COMMAND}" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln" "-m:$ENV{NUMBER_OF_PROCESSORS}" "/t:Build" "/p:Configuration=$") - set_property(TEST "compilation_of__${PROJECT_NAME}" + set_property(TEST "compilation of ${PROJECT_NAME}" APPEND PROPERTY LABELS "${PROJECT_NAME}") - set_property(TEST "compilation_of__${PROJECT_NAME}" + set_property(TEST "compilation of ${PROJECT_NAME}" APPEND PROPERTY FIXTURES_REQUIRED "check_build_system_SetupFixture") - set_tests_properties("compilation_of__${PROJECT_NAME}" + set_tests_properties("compilation of ${PROJECT_NAME}" PROPERTIES RUN_SERIAL TRUE) #because of the scope of the tests, this part cannot go in the relevant CMakeLists if("${PROJECT_NAME}" STREQUAL "Polyhedron_Demo") - set_tests_properties(compilation_of__Polyhedron_Demo PROPERTIES TIMEOUT 2400) + set_tests_properties("compilation of Polyhedron_Demo" PROPERTIES TIMEOUT 2400) elseif("${PROJECT_NAME}" STREQUAL "Mesh_3_Tests" OR "${PROJECT_NAME}" STREQUAL "Mesh_3_Examples") - set_tests_properties(compilation_of__${PROJECT_NAME} PROPERTIES TIMEOUT 1600) + set_tests_properties("compilation of ${PROJECT_NAME}" PROPERTIES TIMEOUT 1600) endif() endif()#CMAKE_VS_MSBUILD_COMMAND @@ -110,11 +110,11 @@ function(cgal_add_compilation_test exe_name) if(NOT TARGET cgal_check_build_system) add_custom_target(cgal_check_build_system) add_dependencies( ALL_CGAL_TARGETS cgal_check_build_system ) - add_test(NAME "check_build_system" + add_test(NAME "check build system" COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "cgal_check_build_system" --config "$") - set_property(TEST "check_build_system" + set_property(TEST "check build system" APPEND PROPERTY LABELS "CGAL_build_system") - set_property(TEST "check_build_system" + set_property(TEST "check build system" PROPERTY FIXTURES_SETUP "check_build_system_SetupFixture") endif() if(TARGET CGAL_Qt5_moc_and_resources) # if CGAL_Qt5 was searched, and is header-only @@ -122,19 +122,19 @@ function(cgal_add_compilation_test exe_name) # message(STATUS "${exe_name} depends on ${linked_libraries}") string(FIND "${linked_libraries}" "CGAL::CGAL_Qt5" link_with_CGAL_Qt5) if(link_with_CGAL_Qt5 STRGREATER "-1" AND - NOT TARGET compilation_of__CGAL_Qt5_moc_and_resources) + NOT TARGET "compilation_of__CGAL_Qt5_moc_and_resources") # This custom target is useless. It is used only as a flag to # detect that the test has already been created. - add_custom_target(compilation_of__CGAL_Qt5_moc_and_resources) - add_dependencies( compilation_of__CGAL_Qt5_moc_and_resources CGAL_Qt5_moc_and_resources ) - add_test(NAME "compilation_of__CGAL_Qt5_moc_and_resources" + add_custom_target("compilation_of__CGAL_Qt5_moc_and_resources") + add_dependencies( "compilation_of__CGAL_Qt5_moc_and_resources" CGAL_Qt5_moc_and_resources ) + add_test(NAME "compilation of CGAL_Qt5_moc_and_resources" COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "CGAL_Qt5_moc_and_resources" --config "$") - set_property(TEST "compilation_of__CGAL_Qt5_moc_and_resources" + set_property(TEST "compilation of CGAL_Qt5_moc_and_resources" APPEND PROPERTY LABELS "CGAL_build_system") - set_property(TEST "compilation_of__CGAL_Qt5_moc_and_resources" + set_property(TEST "compilation of CGAL_Qt5_moc_and_resources" PROPERTY FIXTURES_SETUP "CGAL_Qt5_moc_and_resources_Fixture") - set_property(TEST "compilation_of__CGAL_Qt5_moc_and_resources" - APPEND PROPERTY DEPENDS "check_build_system") + set_property(TEST "compilation of CGAL_Qt5_moc_and_resources" + APPEND PROPERTY DEPENDS "check build system") endif() endif() endfunction(cgal_add_compilation_test) @@ -158,10 +158,10 @@ function(cgal_setup_test_properties test_name) if(exe_name) if(NOT CMAKE_VS_MSBUILD_COMMAND) set_property(TEST "${test_name}" - APPEND PROPERTY DEPENDS "compilation_of__${exe_name}") + APPEND PROPERTY DEPENDS "compilation of ${exe_name}") else()#CMAKE_VS_MSBUILD_COMMAND set_property(TEST "${test_name}" - APPEND PROPERTY DEPENDS "compilation_of__${PROJECT_NAME}") + APPEND PROPERTY DEPENDS "compilation of ${PROJECT_NAME}") endif()#CMAKE_VS_MSBUILD_COMMAND endif() @@ -170,9 +170,9 @@ function(cgal_setup_test_properties test_name) string(FIND "${_binary_dir_abs}" "${_source_dir_abs}" _search_binary_in_source) if(_search_binary_in_source EQUAL "-1") - if(NOT TEST ${PROJECT_NAME}_SetupFixture) + if(NOT TEST "copy source_dir of ${PROJECT_NAME}") if(ANDROID) - add_test(NAME ${PROJECT_NAME}_SetupFixture + add_test(NAME "copy source_dir of ${PROJECT_NAME}" COMMAND ${adb_executable} push ${CMAKE_CURRENT_SOURCE_DIR} @@ -185,51 +185,51 @@ function(cgal_setup_test_properties test_name) ${CGAL_REMOTE_TEST_DIR_PREFIX}${PROJECT_NAME} ) set_property(TEST ${PROJECT_NAME}_copy_GMP_MPFR - APPEND PROPERTY DEPENDS ${PROJECT_NAME}_SetupFixture) + APPEND PROPERTY DEPENDS "copy source_dir of ${PROJECT_NAME}") set_property(TEST ${PROJECT_NAME}_copy_GMP_MPFR PROPERTY FIXTURES_SETUP ${PROJECT_NAME}) elseif(CGAL_RUN_TESTS_THROUGH_SSH) - add_test(NAME ${PROJECT_NAME}_SetupFixture + add_test(NAME "copy source_dir of ${PROJECT_NAME}" COMMAND ${scp_executable} -r ${CMAKE_CURRENT_SOURCE_DIR} ${SSH_HOST}:${CGAL_REMOTE_TEST_DIR_PREFIX}${PROJECT_NAME} ) else() - add_test(NAME ${PROJECT_NAME}_SetupFixture + add_test(NAME "copy source_dir of ${PROJECT_NAME}" COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/__exec_test_dir ) endif() - set_property(TEST ${PROJECT_NAME}_SetupFixture + set_property(TEST "copy source_dir of ${PROJECT_NAME}" PROPERTY FIXTURES_SETUP ${PROJECT_NAME}) if(ANDROID) - add_test(NAME ${PROJECT_NAME}_CleanupFixture + add_test(NAME "cleanup of ${PROJECT_NAME}" COMMAND ${adb_executable} shell rm -rf ${CGAL_REMOTE_TEST_DIR_PREFIX}${PROJECT_NAME} ) elseif(CGAL_RUN_TESTS_THROUGH_SSH) - add_test(NAME ${PROJECT_NAME}_CleanupFixture + add_test(NAME "cleanup of ${PROJECT_NAME}" COMMAND ${ssh_executable} ${SSH_HOST} rm -rf ${CGAL_REMOTE_TEST_DIR_PREFIX}${PROJECT_NAME} ) else() - add_test(NAME ${PROJECT_NAME}_CleanupFixture + add_test(NAME "cleanup of ${PROJECT_NAME}" COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/__exec_test_dir ) endif() - set_property(TEST ${PROJECT_NAME}_CleanupFixture + set_property(TEST "cleanup of ${PROJECT_NAME}" PROPERTY FIXTURES_CLEANUP ${PROJECT_NAME}) set_property(TEST - ${PROJECT_NAME}_CleanupFixture ${PROJECT_NAME}_SetupFixture + "cleanup of ${PROJECT_NAME}" "copy source_dir of ${PROJECT_NAME}" APPEND PROPERTY LABELS "${PROJECT_NAME}") endif() if(NOT ANDROID AND NOT CGAL_RUN_TESTS_THROUGH_SSH) @@ -244,10 +244,10 @@ function(cgal_setup_test_properties test_name) set_property(TEST ${test_name} APPEND PROPERTY FIXTURES_REQUIRED "${exe_name}") if(NOT CMAKE_VS_MSBUILD_COMMAND) - set_property(TEST "compilation_of__${exe_name}" + set_property(TEST "compilation of ${exe_name}" PROPERTY FIXTURES_SETUP "${exe_name}") else()#CMAKE_VS_MSBUILD_COMMAND - set_property(TEST "compilation_of__${PROJECT_NAME}" + set_property(TEST "compilation of ${PROJECT_NAME}" PROPERTY FIXTURES_SETUP "${exe_name}") endif()#CMAKE_VS_MSBUILD_COMMAND if((ANDROID OR CGAL_RUN_TESTS_THROUGH_SSH) AND NOT TEST push_of__${exe_name}) @@ -259,7 +259,7 @@ function(cgal_setup_test_properties test_name) COMMAND ${scp_executable} $ ${SSH_HOST}:${CGAL_REMOTE_TEST_DIR_PREFIX}${PROJECT_NAME}/) endif() set_property(TEST "push_of__${exe_name}" - APPEND PROPERTY DEPENDS "compilation_of__${exe_name}") + APPEND PROPERTY DEPENDS "compilation of ${exe_name}") set_property(TEST "push_of__${exe_name}" APPEND PROPERTY FIXTURES_SETUP "${exe_name}") set_property(TEST "push_of__${exe_name}" @@ -283,7 +283,7 @@ function(cgal_add_test exe_name) set(test_name ${cgal_add_test_TEST_NAME}) # message(" test_name: ${test_name}") if(NOT test_name) - set(test_name "execution___of__${exe_name}") + set(test_name "execution of ${exe_name}") endif() # message(" test_name: ${test_name}") if(cgal_add_test_NO_EXECUTION OR TEST ${test_name}) diff --git a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake index 70716d226c2..81f62d9aab4 100644 --- a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake +++ b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake @@ -106,12 +106,12 @@ endfunction() function(CGAL_hook_fix_ctest_depending_on_Qt5) get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) foreach(_target ${_targets}) - if(NOT TEST compilation_of__${_target}) + if(NOT TEST "compilation of ${_target}") continue() endif() get_property(_target_links TARGET ${_target} PROPERTY LINK_LIBRARIES) if("CGAL_Qt5" IN_LIST _target_links OR "CGAL::CGAL_Qt5" IN_LIST _target_links) - set_property(TEST compilation_of__${_target} APPEND PROPERTY FIXTURES_REQUIRED CGAL_Qt5_moc_and_resources_Fixture) + set_property(TEST "compilation of ${_target}" APPEND PROPERTY FIXTURES_REQUIRED CGAL_Qt5_moc_and_resources_Fixture) endif() endforeach() endfunction() diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 2560f75d5c8..ad6166865a1 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -44,7 +44,7 @@ create_single_source_cgal_program("test_use_h.cpp") create_single_source_cgal_program(will_fail.cpp will_fail_aux.cpp) if(BUILD_TESTING) - set_property(TEST execution___of__will_fail PROPERTY WILL_FAIL TRUE) + set_property(TEST "execution of will_fail" PROPERTY WILL_FAIL TRUE) endif() find_package(TBB QUIET) diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index a776e87da72..e3e04ac9f47 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -112,21 +112,21 @@ if ( CGAL_FOUND ) if(BUILD_TESTING) set_property(TEST - execution___of__test_meshing_verbose - execution___of__test_meshing_polyhedron_with_features - execution___of__test_meshing_implicit_function - execution___of__test_meshing_unit_tetrahedron - execution___of__test_meshing_polyhedron - execution___of__test_meshing_polyhedral_complex - execution___of__test_mesh_capsule_var_distance_bound - execution___of__test_mesh_3_issue_1554 - execution___of__test_mesh_polyhedral_domain_with_features_deprecated - execution___of__test_mesh_cell_base_3 + "execution of test_meshing_verbose" + "execution of test_meshing_polyhedron_with_features" + "execution of test_meshing_implicit_function" + "execution of test_meshing_unit_tetrahedron" + "execution of test_meshing_polyhedron" + "execution of test_meshing_polyhedral_complex" + "execution of test_mesh_capsule_var_distance_bound" + "execution of test_mesh_3_issue_1554" + "execution of test_mesh_polyhedral_domain_with_features_deprecated" + "execution of test_mesh_cell_base_3" PROPERTY RUN_SERIAL 1) if(TARGET test_meshing_3D_image) set_property(TEST - execution___of__test_meshing_3D_image - execution___of__test_meshing_3D_gray_image + "execution of test_meshing_3D_image" + "execution of test_meshing_3D_gray_image" PROPERTY RUN_SERIAL 1) endif() endif() @@ -140,8 +140,8 @@ if ( CGAL_FOUND ) if(BUILD_TESTING) set_tests_properties( - execution___of__test_meshing_polyhedron_with_features - execution___of__test_meshing_verbose + "execution of test_meshing_polyhedron_with_features" + "execution of test_meshing_verbose" PROPERTIES RESOURCE_LOCK Mesh_3_Tests_IO) endif() else() diff --git a/Nef_3/test/Nef_3/CMakeLists.txt b/Nef_3/test/Nef_3/CMakeLists.txt index cb2d078472c..4e41d32b5c2 100644 --- a/Nef_3/test/Nef_3/CMakeLists.txt +++ b/Nef_3/test/Nef_3/CMakeLists.txt @@ -19,15 +19,15 @@ endforeach() if(BUILD_TESTING) set_tests_properties( - execution___of__Nef_3_problematic_construction - execution___of__test_nef_3_io_Cartesian - execution___of__test_nef_3_io_Cartesian_Lazy - execution___of__test_nef_3_io_EPEC - execution___of__test_nef_3_io_EPIC - execution___of__test_nef_3_io_Homogeneous - execution___of__test_nef_3_io_Homogenoeus_Lazy - execution___of__test_with_extended_homogeneous - execution___of__test_with_homogeneous - execution___of__test_with_lazy + "execution of Nef_3_problematic_construction" + "execution of test_nef_3_io_Cartesian" + "execution of test_nef_3_io_Cartesian_Lazy" + "execution of test_nef_3_io_EPEC" + "execution of test_nef_3_io_EPIC" + "execution of test_nef_3_io_Homogeneous" + "execution of test_nef_3_io_Homogenoeus_Lazy" + "execution of test_with_extended_homogeneous" + "execution of test_with_homogeneous" + "execution of test_with_lazy" PROPERTIES RESOURCE_LOCK Nef_3_Tests_IO) endif() diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 909dd292063..ccd0894ac8d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -150,7 +150,7 @@ endif(TARGET CGAL::Ceres_support AND TARGET CGAL::Eigen3_support) if(BUILD_TESTING) set_tests_properties( - execution___of__triangulate_hole_Polyhedron_3_no_delaunay_test - execution___of__triangulate_hole_Polyhedron_3_test + "execution of triangulate_hole_Polyhedron_3_no_delaunay_test" + "execution of triangulate_hole_Polyhedron_3_test" PROPERTIES RESOURCE_LOCK Triangulation_with_hole) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt index a44ae7fd8b4..baac0c98a0a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/CMakeLists.txt @@ -49,7 +49,7 @@ if(TARGET CGAL::Eigen3_support) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__classification_plugin + "compilation of classification_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Convex_hull/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Convex_hull/CMakeLists.txt index 3c923aab368..0bbbd363345 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Convex_hull/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Convex_hull/CMakeLists.txt @@ -12,6 +12,6 @@ target_link_libraries(kernel_plugin PUBLIC scene_surface_mesh_item) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__convex_hull_plugin + "compilation of convex_hull_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PCA/CMakeLists.txt index 4171347a6dc..8ede27ca7ed 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/CMakeLists.txt @@ -40,6 +40,6 @@ target_link_libraries( if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__create_obb_mesh_plugin + "compilation of create_obb_mesh_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 53cfdc9b825..3ff3f653fdf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -55,12 +55,12 @@ if(TARGET CGAL::Eigen3_support) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__extrude_plugin - compilation_of__fairing_plugin + "compilation of extrude_plugin" + "compilation of fairing_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) set_tests_properties( - compilation_of__hole_filling_plugin - compilation_of__smoothing_plugin + "compilation of hole_filling_plugin" + "compilation of smoothing_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() else() @@ -167,12 +167,12 @@ target_link_libraries( if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__join_and_split_plugin - compilation_of__selection_plugin - compilation_of__triangulate_facets_plugin - compilation_of__isotropic_remeshing_plugin - compilation_of__random_perturbation_plugin - compilation_of__engrave_text_plugin - compilation_of__degenerated_faces_plugin + "compilation of join_and_split_plugin" + "compilation of selection_plugin" + "compilation of triangulate_facets_plugin" + "compilation of isotropic_remeshing_plugin" + "compilation of random_perturbation_plugin" + "compilation of engrave_text_plugin" + "compilation of degenerated_faces_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/CMakeLists.txt index 682998322e0..52943788da1 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/CMakeLists.txt @@ -18,7 +18,7 @@ if(NOT CGAL_DISABLE_GMP) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__parameterization_plugin + "compilation of parameterization_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() @@ -36,7 +36,7 @@ if(NOT CGAL_DISABLE_GMP) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__mesh_segmentation_plugin + "compilation of mesh_segmentation_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/CMakeLists.txt index 0954a8c13c3..a9ef41bc0e3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh_deformation/CMakeLists.txt @@ -7,7 +7,7 @@ if(EIGEN3_FOUND AND "${EIGEN3_VERSION}" VERSION_GREATER "3.1.90") if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) set_tests_properties( - compilation_of__edit_plugin + "compilation of edit_plugin" PROPERTIES RESOURCE_LOCK Selection_test_resources) endif() diff --git a/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake b/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake index 0e20273faa7..02cff1948ad 100644 --- a/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake +++ b/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake @@ -36,19 +36,19 @@ include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) target_link_libraries( ${plugin_name} PUBLIC demo_framework) add_dependencies(${plugin_name} demo_framework) if(BUILD_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) - if(NOT TARGET compilation_of__demo_framework) + if(NOT TARGET "compilation_of__demo_framework") # This custom target is useless. It is used only as a flag to # detect that the test has already been created. - add_custom_target(compilation_of__demo_framework) - add_dependencies( compilation_of__demo_framework demo_framework ) - add_test(NAME "compilation_of__demo_framework" + add_custom_target("compilation_of__demo_framework") + add_dependencies( "compilation_of__demo_framework" demo_framework ) + add_test(NAME "compilation of demo_framework" COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "demo_framework" --config "$") - set_property(TEST "compilation_of__demo_framework" + set_property(TEST "compilation of demo_framework" APPEND PROPERTY LABELS "CGAL_build_system") - set_property(TEST "compilation_of__demo_framework" + set_property(TEST "compilation of demo_framework" APPEND PROPERTY FIXTURES_SETUP "demo_framework_SetupFixture") - set_property(TEST "compilation_of__demo_framework" + set_property(TEST "compilation of demo_framework" APPEND PROPERTY DEPENDS "compilation_of__CGAL_Qt5_moc_and_resources") endif() endif() @@ -56,8 +56,8 @@ include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) target_link_libraries( ${plugin_name} PUBLIC Polyhedron_demo_framework) add_dependencies(${plugin_name} Polyhedron_demo_framework) endif() - if(TARGET compilation_of__demo_framework) - set_property(TEST compilation_of__${plugin_name} APPEND PROPERTY FIXTURES_REQUIRED demo_framework_SetupFixture) + if(TARGET "compilation_of__demo_framework") + set_property(TEST "compilation of ${plugin_name}" APPEND PROPERTY FIXTURES_REQUIRED demo_framework_SetupFixture) endif() # Link with CGAL target_link_libraries( ${plugin_name} PUBLIC ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ) diff --git a/Triangulation_2/test/Triangulation_2/CMakeLists.txt b/Triangulation_2/test/Triangulation_2/CMakeLists.txt index bad1f2455bf..4d907809237 100644 --- a/Triangulation_2/test/Triangulation_2/CMakeLists.txt +++ b/Triangulation_2/test/Triangulation_2/CMakeLists.txt @@ -19,16 +19,16 @@ endforeach() if(BUILD_TESTING) set_tests_properties( - execution___of__test_constrained_triangulation_2 - execution___of__test_delaunay_triangulation_2 - execution___of__test_triangulation_geom_traits - execution___of__test_triangulation_2 - execution___of__test_triangulation_2_bis - execution___of__test_delaunay_hierarchy_2 - execution___of__test_const_triang_plus_2 - execution___of__test_regular_triangulation_2 - execution___of__test_const_del_triangulation_2 - execution___of__test_regular_hierarchy_2 - execution___of__test_deprecated_projection_traits + "execution of test_constrained_triangulation_2" + "execution of test_delaunay_triangulation_2" + "execution of test_triangulation_geom_traits" + "execution of test_triangulation_2" + "execution of test_triangulation_2_bis" + "execution of test_delaunay_hierarchy_2" + "execution of test_const_triang_plus_2" + "execution of test_regular_triangulation_2" + "execution of test_const_del_triangulation_2" + "execution of test_regular_hierarchy_2" + "execution of test_deprecated_projection_traits" PROPERTIES RESOURCE_LOCK Triangulation_2_Tests_IO) endif() diff --git a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt index 94b035fc9d0..bb57a112d02 100644 --- a/Triangulation_3/examples/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/examples/Triangulation_3/CMakeLists.txt @@ -43,9 +43,9 @@ if(TARGET CGAL::TBB_support) if(BUILD_TESTING) set_property(TEST - execution___of__parallel_insertion_and_removal_in_regular_3 - execution___of__parallel_insertion_in_delaunay_3 - execution___of__sequential_parallel + "execution of parallel_insertion_and_removal_in_regular_3" + "execution of parallel_insertion_in_delaunay_3" + "execution of sequential_parallel" PROPERTY RUN_SERIAL 1) endif() else() diff --git a/Triangulation_3/test/Triangulation_3/CMakeLists.txt b/Triangulation_3/test/Triangulation_3/CMakeLists.txt index a820549bf20..3d5393a36bf 100644 --- a/Triangulation_3/test/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/test/Triangulation_3/CMakeLists.txt @@ -37,19 +37,19 @@ if(TARGET CGAL::TBB_support) endforeach() if(BUILD_TESTING) set_property(TEST - execution___of__test_delaunay_3 - execution___of__test_regular_3 - execution___of__test_regular_insert_range_with_info + "execution of test_delaunay_3" + "execution of test_regular_3" + "execution of test_regular_insert_range_with_info" PROPERTY RUN_SERIAL 1) endif() endif() if(BUILD_TESTING) set_tests_properties( - execution___of__test_delaunay_hierarchy_3 - execution___of__test_delaunay_hierarchy_3_old - execution___of__test_regular_as_delaunay_3 - execution___of__test_triangulation_3 - execution___of__test_delaunay_3 + "execution of test_delaunay_hierarchy_3" + "execution of test_delaunay_hierarchy_3_old" + "execution of test_regular_as_delaunay_3" + "execution of test_triangulation_3" + "execution of test_delaunay_3" PROPERTIES RESOURCE_LOCK Triangulation_3_Tests_IO) endif() From ef773ab8e4bec653438ff316808a14871efec755 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Sun, 19 Mar 2023 15:37:01 +0200 Subject: [PATCH 02/64] Fixed hole filtering. The code use to erroneously remove holes from an std::deque of holes that do not affect the mink. sum. Now it simply adds those that do affect it. --- .../CGAL/Minkowski_sum_2/Hole_filter_2.h | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h index cfb2cedde6f..8248045f598 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h @@ -26,16 +26,12 @@ namespace CGAL { * to the Minkowski sum boundary. */ template -class Hole_filter_2 -{ +class Hole_filter_2 { private: - typedef Kernel_ Kernel; - typedef Container_ Container; - - typedef CGAL::Polygon_2 Polygon_2; - typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; - typedef typename Polygon_with_holes_2::Hole_iterator Hole_iterator; - typedef std::vector Hole_iterator_vector; + using Kernel = Kernel_; + using Container = Container_; + using Polygon_2 = CGAL::Polygon_2; + using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2; public: /*! Filter out holes of a polygon with holes. @@ -45,29 +41,17 @@ public: */ void operator()(const Polygon_with_holes_2& pgn1, const Polygon_2& pgn2, - Polygon_with_holes_2& filtered_pgn1) const - { - filtered_pgn1 = pgn1; - - Hole_iterator_vector to_erase; + Polygon_with_holes_2& filtered_pgn1) const { Bbox_2 boundary_bbox = pgn2.bbox(); - - Hole_iterator it = filtered_pgn1.holes_begin(); - while (it != filtered_pgn1.holes_end()) { - Bbox_2 hole_bbox = (*it).bbox(); - - if ((hole_bbox.ymax()-hole_bbox.ymin() < - boundary_bbox.ymax()-boundary_bbox.ymin()) || - (hole_bbox.xmax()-hole_bbox.xmin() < + filtered_pgn1 = Polygon_with_holes_2(pgn1.outer_boundary()); + for (const auto& h : pgn1.holes()) { + Bbox_2 hole_bbox = h.bbox(); + if ((hole_bbox.ymax()-hole_bbox.ymin() >= + boundary_bbox.ymax()-boundary_bbox.ymin()) && + (hole_bbox.xmax()-hole_bbox.xmin() >= boundary_bbox.xmax()-boundary_bbox.xmin())) - { - to_erase.push_back(it); - } - ++it; + filtered_pgn1.add_hole(h); } - - typename Hole_iterator_vector::iterator it2 = to_erase.begin(); - while (it2 != to_erase.end()) filtered_pgn1.erase_hole(*it2++); } /*! Filter out holes of a polygon with holes. From c32272876b6ab3aff44a1bd69f462a021d0ab36a Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Sun, 19 Mar 2023 15:41:26 +0200 Subject: [PATCH 03/64] Added a description of a yet another bug fir in the Minkowski_sum_2 package --- Installation/CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 6baa48451f2..25e9701c791 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -106,6 +106,7 @@ extracted from labeled images. ### [2D Minkowski Sums](https://doc.cgal.org/5.6/Manual/packages.html#PkgMinkowskiSum2) - Fixed a bug that made holes in the Minkowski sum disappear +- Fixed hole filtering. The code use to erroneously remove holes from the container of holes of polygons with holes that did not affect the mink. sum. Now it simply adds those that do affect it. [Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5) ----------- From 20c2df0692e1542c6febf8f1925dbd3becf764b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 09:59:21 +0200 Subject: [PATCH 04/64] Add triangulate_PS prototype --- .../triangulate_faces.h | 332 +++++++++++++++++- 1 file changed, 319 insertions(+), 13 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index d479b6d7d1b..9364e899231 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -15,8 +15,6 @@ #include -#include - #include #include @@ -24,6 +22,7 @@ #include #include #include +#include #include #else #include @@ -54,7 +53,8 @@ namespace Triangulate_faces * overridden. */ template -struct Default_visitor { +struct Default_visitor +{ typedef boost::graph_traits GT; typedef typename GT::face_descriptor face_descriptor; @@ -71,7 +71,7 @@ template -class Triangulate_modifier +class Triangulate_polygon_mesh_modifier { typedef Kernel Traits; @@ -91,7 +91,7 @@ class Triangulate_modifier Traits _traits; public: - Triangulate_modifier(VertexPointMap vpmap, const Traits& traits = Traits()) + Triangulate_polygon_mesh_modifier(VertexPointMap vpmap, const Traits& traits = Traits()) : _vpmap(vpmap), _traits(traits) { } @@ -420,9 +420,9 @@ public: } -}; // end class Triangulate_modifier +}; // class Triangulate_polygon_mesh_modifier -}//end namespace internal +} // namespace internal /** * \ingroup PMP_meshing_grp @@ -479,7 +479,7 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor //VertexPointMap typedef typename GetVertexPointMap::type VPMap; VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_property_map(vertex_point, pmesh)); + get_property_map(vertex_point, pmesh)); //Kernel typedef typename GetGeomTraits::type Kernel; @@ -497,7 +497,7 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor get_parameter(np, internal_np::visitor), Triangulate_faces::Default_visitor()); - internal::Triangulate_modifier modifier(vpmap, traits); + internal::Triangulate_polygon_mesh_modifier modifier(vpmap, traits); return modifier.triangulate_face(f, pmesh, use_cdt, visitor); } @@ -574,7 +574,7 @@ bool triangulate_faces(FaceRange face_range, get_parameter(np, internal_np::visitor), Triangulate_faces::Default_visitor()); - internal::Triangulate_modifier modifier(vpmap, traits); + internal::Triangulate_polygon_mesh_modifier modifier(vpmap, traits); return modifier(face_range, pmesh, use_cdt, visitor); } @@ -626,10 +626,316 @@ bool triangulate_faces(PolygonMesh& pmesh, return triangulate_faces(faces(pmesh), pmesh, np); } -} // end namespace Polygon_mesh_processing +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Polygon Soup -} // end namespace CGAL +namespace internal { -#include +template +class Triangulate_polygon_soup_modifier +{ + using Traits = Kernel; + using Point = typename Traits::Point_3; + using Vector = typename Traits::Vector_3; + +private: + Traits _traits; + +public: + Triangulate_polygon_soup_modifier(const Traits& traits = Traits()) + : _traits(traits) + { } + +private: + template + bool triangulate_face_with_CDT(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + Visitor visitor) + { + using Point_ref = typename boost::property_traits::reference; + + using PK = CGAL::Projection_traits_3; + using Vbb = CGAL::Triangulation_vertex_base_with_info_2; + using Vb = CGAL::Triangulation_vertex_base_2; + using Fb = CGAL::Constrained_triangulation_face_base_2; + using TDS = CGAL::Triangulation_data_structure_2; + using Itag = CGAL::No_constraint_intersection_requiring_constructions_tag; + using CDT = CGAL::Constrained_Delaunay_triangulation_2; + using CDT_Vertex_handle = typename CDT::Vertex_handle; + using CDT_Face_handle = typename CDT::Face_handle; + + const std::size_t original_size = polygon.size(); + + Vector n = CGAL::NULL_VECTOR; + for(std::size_t i=0; iinfo() = i; + if(previous != CDT_Vertex_handle() && previous != vh) + cdt.insert_constraint(previous, vh); + + previous = vh; + } + cdt.insert_constraint(previous, first); + + if(cdt.dimension() != 2 || cdt.number_of_vertices() != polygon.size()) + return false; + + std::unordered_map in_domain_map; + boost::associative_property_map< std::unordered_map > in_domain(in_domain_map); + + CGAL::mark_domain_in_triangulation(cdt, in_domain); + + // visitor.before_subface_creations(f); + + for(CDT_Face_handle f : cdt.finite_face_handles()) + { + if(!get(in_domain, f)) + continue; + + triangulated_polygons.push_back({f->vertex(0)->info(), f->vertex(1)->info(), f->vertex(2)->info()}); + // visitor.after_subface_created(face(h0, pmesh)); + } + + // visitor.after_subface_creations(); + return true; + } + + template + bool triangulate_face_with_hole_filling(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + Visitor visitor) + { + namespace PMP = CGAL::Polygon_mesh_processing; + + // gather halfedges around the face + std::vector hole_points; + std::vector hole_points_indices; + + for(std::size_t i : polygon) + { + hole_points.push_back(get(pmap, points[i])); + hole_points_indices.push_back(i); + } + + // use hole filling + typedef CGAL::Triple Face_indices; + std::vector patch; + PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), + parameters::geom_traits(_traits)); + + if(patch.empty()) + return false; + + // visitor.before_subface_creations(f); + + for(const Face_indices& triangle : patch) + { + triangulated_polygons.push_back({hole_points_indices[triangle.first], + hole_points_indices[triangle.second], + hole_points_indices[triangle.third]}); + // visitor.after_subface_created(face(h0, pmesh)); + } + + // visitor.after_subface_creations(); + return true; + } + + template + bool triangulate_face(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + const bool use_cdt, + Visitor visitor) + { + using FT = typename Traits::FT; + using Point_ref = typename boost::property_traits::reference; + + const std::size_t original_size = polygon.size(); + if(original_size == 4) + { + Point_ref p0 = get(pmap, points[polygon[0]]); + Point_ref p1 = get(pmap, points[polygon[1]]); + Point_ref p2 = get(pmap, points[polygon[2]]); + Point_ref p3 = get(pmap, points[polygon[3]]); + + /* Chooses the diagonal that will split the quad in two triangles that maximize + * the scalar product of of the un-normalized normals of the two triangles. + * The lengths of the un-normalized normals (computed using cross-products of two vectors) + * are proportional to the area of the triangles. + * Maximize the scalar product of the two normals will avoid skinny triangles, + * and will also taken into account the cosine of the angle between the two normals. + * In particular, if the two triangles are oriented in different directions, + * the scalar product will be negative. + */ + FT p1p3 = CGAL::cross_product(p2-p1, p3-p2) * CGAL::cross_product(p0-p3, p1-p0); + FT p0p2 = CGAL::cross_product(p1-p0, p1-p2) * CGAL::cross_product(p3-p2, p3-p0); + + // visitor.before_subface_creations(f); + if(p0p2 > p1p3) + { + triangulated_polygons.push_back({polygon[0], polygon[1], polygon[2]}); + triangulated_polygons.push_back({polygon[0], polygon[2], polygon[3]}); + } + else + { + triangulated_polygons.push_back({polygon[0], polygon[1], polygon[3]}); + triangulated_polygons.push_back({polygon[1], polygon[2], polygon[3]}); + } + + // visitor.after_subface_created(face(res,pmesh)); + // visitor.after_subface_created(face(opposite(res,pmesh),pmesh)); + + // visitor.after_subface_creations(); + } + else + { +#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 + if(use_cdt) + return triangulate_face_with_CDT(polygon, points, triangulated_polygons, pmap, visitor); + +#else + CGAL_USE(use_cdt); +#endif + return triangulate_face_with_hole_filling(polygon, points, triangulated_polygons, pmap, visitor); + } + + return true; + } + +public: + template + bool operator()(const PolygonRange& polygons, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + const bool use_cdt, + Visitor visitor) + { + using Polygon = typename boost::range_value::type; + + bool result = true; + triangulated_polygons.reserve(polygons.size()); + + for(const Polygon& polygon : polygons) + { + if(polygon.size() <= 3) + { + triangulated_polygons.push_back(polygon); + continue; + } + + if(!triangulate_face(polygon, points, triangulated_polygons, pmap, use_cdt, visitor)) + result = false; + } + + return result; + } + +}; // class Triangulate_polygon_soup_modifier + +} // namespace internal + +namespace Triangulate_faces { +namespace internal { + +struct Default_visitor_tmp // @tmp +{ + +}; + +} // namespace internal +} // namespace Triangulate_faces + +template +bool triangulate_faces_tmp(const PointRange& points, // @tmp + PolygonRange& polygons, + const NamedParameters& np = parameters::default_values()) +{ + using Polygon = typename boost::range_value::type; + + using parameters::choose_parameter; + using parameters::get_parameter; + + //VertexPointMap + using PMap = typename GetPointMap::const_type; + PMap pmap = choose_parameter(get_parameter(np, internal_np::point_map)); + + //Kernel + using Point = typename boost::property_traits::value_type; + using Def_Kernel = typename CGAL::Kernel_traits::Kernel; + using Kernel = typename internal_np::Lookup_named_param_def< + internal_np::geom_traits_t, + NamedParameters, + Def_Kernel>::type; + Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + + //Option + bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); + + typedef typename internal_np::Lookup_named_param_def< + internal_np::visitor_t, + NamedParameters, + Triangulate_faces::internal::Default_visitor_tmp // default + >::type Visitor; + Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), + Triangulate_faces::internal::Default_visitor_tmp()); + + PolygonRange triangulated_polygons; + internal::Triangulate_polygon_soup_modifier modifier(traits); + const bool success = modifier(polygons, points, triangulated_polygons, pmap, use_cdt, visitor); + + std::swap(polygons, triangulated_polygons); + + return success; +} + +} // namespace Polygon_mesh_processing + +} // namespace CGAL #endif // CGAL_POLYGON_MESH_PROCESSING_TRIANGULATE_FACES_H From 83e89d85a69e32342f1f3ca364da1f38436c83a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 14:58:22 +0200 Subject: [PATCH 05/64] Fix typo --- .../include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index cb24ce8ae7c..bca94855450 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -1125,7 +1125,7 @@ struct Polygon_soup_fixer > /// /// \tparam PointRange a model of the concepts `SequenceContainer` and `Swappable` /// and whose value type is the point type. -/// \tparam PolygonRange a model of the concept `SequenceContainer`. +/// \tparam PolygonRange a model of the concept `SequenceContainer` /// whose `value_type` is itself a model of the concepts `SequenceContainer`, /// `Swappable`, and `ReversibleContainer` whose `value_type` is `std::size_t`. /// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" From 51c1e21847de090f395c64f01a9f096ffcf175ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 14:58:39 +0200 Subject: [PATCH 06/64] Change ITag to No intersections, and try{}catch() the CDT2 code --- .../triangulate_faces.h | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 9364e899231..41d89728e80 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -159,7 +159,7 @@ public: P_traits> Fb1; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::Exact_intersections_tag Itag; + typedef CGAL::No_constraint_intersection_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; @@ -178,28 +178,35 @@ public: template bool triangulate_face_with_CDT(face_descriptor f, PM& pmesh, CDT& cdt, Visitor visitor) { + typedef typename CDT::Vertex_handle Tr_Vertex_handle; + std::size_t original_size = CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size(); - // Halfedge_around_facet_circulator - typedef typename CDT::Vertex_handle Tr_Vertex_handle; - halfedge_descriptor start = halfedge(f, pmesh); - halfedge_descriptor h = start; - Tr_Vertex_handle previous, first; - do + try { - Tr_Vertex_handle vh = cdt.insert(get(_vpmap, target(h, pmesh))); - if (first == Tr_Vertex_handle()) { - first = vh; - } - vh->info() = h; - if(previous != Tr_Vertex_handle() && previous != vh) { - cdt.insert_constraint(previous, vh); - } - previous = vh; - h = next(h, pmesh); + halfedge_descriptor start = halfedge(f, pmesh); + halfedge_descriptor h = start; + Tr_Vertex_handle previous, first; + do + { + Tr_Vertex_handle vh = cdt.insert(get(_vpmap, target(h, pmesh))); + if (first == Tr_Vertex_handle()) { + first = vh; + } + vh->info() = h; + if(previous != Tr_Vertex_handle() && previous != vh) { + cdt.insert_constraint(previous, vh); + } + previous = vh; + h = next(h, pmesh); - } while( h != start ); - cdt.insert_constraint(previous, first); + } while( h != start ); + cdt.insert_constraint(previous, first); + } + catch(const typename CDT::Intersection_of_constraints_exception&) + { + return false; + } // sets mark is_external for(typename CDT::All_faces_iterator fit = cdt.all_faces_begin(), @@ -667,7 +674,7 @@ private: using Vb = CGAL::Triangulation_vertex_base_2; using Fb = CGAL::Constrained_triangulation_face_base_2; using TDS = CGAL::Triangulation_data_structure_2; - using Itag = CGAL::No_constraint_intersection_requiring_constructions_tag; + using Itag = CGAL::No_constraint_intersection_tag; using CDT = CGAL::Constrained_Delaunay_triangulation_2; using CDT_Vertex_handle = typename CDT::Vertex_handle; using CDT_Face_handle = typename CDT::Face_handle; @@ -691,20 +698,27 @@ private: PK cdt_traits(n); CDT cdt(cdt_traits); - CDT_Vertex_handle previous, first; - for(std::size_t i : polygon) + try { - CDT_Vertex_handle vh = cdt.insert(get(pmap, points[i])); - if(first == CDT_Vertex_handle()) - first = vh; + CDT_Vertex_handle previous, first; + for(std::size_t i : polygon) + { + CDT_Vertex_handle vh = cdt.insert(get(pmap, points[i])); + if(first == CDT_Vertex_handle()) + first = vh; - vh->info() = i; - if(previous != CDT_Vertex_handle() && previous != vh) - cdt.insert_constraint(previous, vh); + vh->info() = i; + if(previous != CDT_Vertex_handle() && previous != vh) + cdt.insert_constraint(previous, vh); - previous = vh; + previous = vh; + } + cdt.insert_constraint(previous, first); + } + catch(const typename CDT::Intersection_of_constraints_exception&) + { + return false; } - cdt.insert_constraint(previous, first); if(cdt.dimension() != 2 || cdt.number_of_vertices() != polygon.size()) return false; From 4b2b996e088b6d05e916cd4d10c3e3e2f8051343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 14:59:17 +0200 Subject: [PATCH 07/64] Add visitor for triangulate_polygons() --- .../triangulate_faces.h | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 41d89728e80..77d6f1d36c0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -728,7 +728,7 @@ private: CGAL::mark_domain_in_triangulation(cdt, in_domain); - // visitor.before_subface_creations(f); + visitor.before_subface_creations(polygon); for(CDT_Face_handle f : cdt.finite_face_handles()) { @@ -736,10 +736,10 @@ private: continue; triangulated_polygons.push_back({f->vertex(0)->info(), f->vertex(1)->info(), f->vertex(2)->info()}); - // visitor.after_subface_created(face(h0, pmesh)); + visitor.after_subface_created(triangulated_polygons.back()); } - // visitor.after_subface_creations(); + visitor.after_subface_creations(); return true; } @@ -775,17 +775,17 @@ private: if(patch.empty()) return false; - // visitor.before_subface_creations(f); + visitor.before_subface_creations(polygon); for(const Face_indices& triangle : patch) { triangulated_polygons.push_back({hole_points_indices[triangle.first], hole_points_indices[triangle.second], hole_points_indices[triangle.third]}); - // visitor.after_subface_created(face(h0, pmesh)); + visitor.after_subface_created(triangulated_polygons.back()); } - // visitor.after_subface_creations(); + visitor.after_subface_creations(); return true; } @@ -824,7 +824,7 @@ private: FT p1p3 = CGAL::cross_product(p2-p1, p3-p2) * CGAL::cross_product(p0-p3, p1-p0); FT p0p2 = CGAL::cross_product(p1-p0, p1-p2) * CGAL::cross_product(p3-p2, p3-p0); - // visitor.before_subface_creations(f); + visitor.before_subface_creations(polygon); if(p0p2 > p1p3) { triangulated_polygons.push_back({polygon[0], polygon[1], polygon[2]}); @@ -836,10 +836,10 @@ private: triangulated_polygons.push_back({polygon[1], polygon[2], polygon[3]}); } - // visitor.after_subface_created(face(res,pmesh)); - // visitor.after_subface_created(face(opposite(res,pmesh),pmesh)); + visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-2]); + visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-1]); - // visitor.after_subface_creations(); + visitor.after_subface_creations(); } else { @@ -892,16 +892,22 @@ public: } // namespace internal -namespace Triangulate_faces { +namespace Triangulate_polygons { namespace internal { -struct Default_visitor_tmp // @tmp +struct Default_visitor { + template + void before_subface_creations(const Polygon& /*f_old*/) {} + template + void after_subface_created(const Polygon& /*f_new*/) {} + + void after_subface_creations() {} }; } // namespace internal -} // namespace Triangulate_faces +} // namespace Triangulate_polygons template ::type Visitor; Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), - Triangulate_faces::internal::Default_visitor_tmp()); + Triangulate_polygons::internal::Default_visitor()); PolygonRange triangulated_polygons; internal::Triangulate_polygon_soup_modifier modifier(traits); @@ -949,7 +955,6 @@ bool triangulate_faces_tmp(const PointRange& points, // @tmp } } // namespace Polygon_mesh_processing - } // namespace CGAL #endif // CGAL_POLYGON_MESH_PROCESSING_TRIANGULATE_FACES_H From 7b375129fb6d766924fe94b9135f8f887ad67a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 15:16:37 +0200 Subject: [PATCH 08/64] Document triangulate_polygons() --- .../PackageDescription.txt | 1 + .../triangulate_faces.h | 59 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 8141fbd16f2..2fdc2471124 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -117,6 +117,7 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - `CGAL::Polygon_mesh_processing::fair()` - `CGAL::Polygon_mesh_processing::triangulate_face()` - `CGAL::Polygon_mesh_processing::triangulate_faces()` +- `CGAL::Polygon_mesh_processing::triangulate_polygons()` - \link PMP_meshing_grp `CGAL::Polygon_mesh_processing::isotropic_remeshing()` \endlink - \link PMP_meshing_grp `CGAL::Polygon_mesh_processing::surface_Delaunay_remeshing()` \endlink - \link PMP_meshing_grp `CGAL::Polygon_mesh_processing::split_long_edges()` \endlink diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 77d6f1d36c0..a4594228b20 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -41,11 +41,9 @@ #include namespace CGAL { - namespace Polygon_mesh_processing { +namespace Triangulate_faces { -namespace Triangulate_faces -{ /** \ingroup PMP_meshing_grp * %Default new face visitor model of `PMPTriangulateFaceVisitor`. * All its functions have an empty body. This class can be used as a @@ -895,6 +893,12 @@ public: namespace Triangulate_polygons { namespace internal { +/** \ingroup PMP_meshing_grp +* %Default new polygon visitor model of `PMPTriangulateFaceVisitor`. +* All its functions have an empty body. This class can be used as a +* base class if only some of the functions of the concept require to be +* overridden. +*/ struct Default_visitor { template @@ -909,12 +913,55 @@ struct Default_visitor } // namespace internal } // namespace Triangulate_polygons +/** +* \ingroup PMP_meshing_grp +* +* triangulates all polygons of a polygon soup. This function depends on the package \ref PkgTriangulation2. +* +* @tparam PointRange a model of `ConstRange`. The value type of its iterator is the point type. +* @tparam PolygonRange a model of the concept `SequenceContainer` and `Swappable`, +* whose `value_type` is itself a model of the concepts `SequenceContainer` +* whose `value_type` is `std::size_t`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param points the point geometry of the soup to be triangulated +* @param polygons the polygons to be triangulated +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{point_map} +* \cgalParamDescription{a property map associating points to the elements of the point set `points`} +* \cgalParamType{a model of `ReadablePropertyMap` whose key type is the value type +* of the iterator of `PointRange` and whose value type is `geom_traits::Point_3`} +* \cgalParamDefault{`CGAL::Identity_property_map`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} +* \cgalParamNEnd +* +* \cgalParamNBegin{visitor} +* \cgalParamDescription{a visitor that enables to track how polygons are triangulated into triangles} +* \cgalParamType{a class model of `PMPTriangulateFaceVisitor`} +* \cgalParamDefault{`Triangulate_polygons::Default_visitor`} +* \cgalParamExtra{Note that the visitor will be copied, so +* it must not have any data member that does not have a reference-like type.} +* \cgalParamNEnd +* \cgalNamedParamsEnd +* +* @return `true` if all the polygons have been triangulated. +* +* @see `triangulate_face()` +*/ template -bool triangulate_faces_tmp(const PointRange& points, // @tmp - PolygonRange& polygons, - const NamedParameters& np = parameters::default_values()) +bool triangulate_polygons(const PointRange& points, + PolygonRange& polygons, + const NamedParameters& np = parameters::default_values()) { using Polygon = typename boost::range_value::type; From 6a0a0267bf2fa7a4b15eacd0d6d714e5d8580820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 15:16:52 +0200 Subject: [PATCH 09/64] Test triangulate_polygons() --- .../triangulate_faces_test.cpp | 68 ++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp index 5f239c7dfaa..61546684005 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -1,13 +1,14 @@ #include #include - #include +#include + #include #include #include #include -#include +#include #include @@ -117,21 +118,17 @@ test_triangulate_face() return false; } - unsigned int nb = 0; for(typename boost::graph_traits::face_descriptor fit : faces(mesh)) { - if (nb > 4) - break; - else if (next(next(halfedge(fit, mesh), mesh), mesh) - != prev(halfedge(fit, mesh), mesh)) + if (next(next(halfedge(fit, mesh), mesh), mesh) != prev(halfedge(fit, mesh), mesh)) { - if(CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh)) - ++nb; - else + if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh)) assert(false); } } + assert(CGAL::is_triangle_mesh(mesh)); + return true; } @@ -156,6 +153,9 @@ test_triangulate_triangle_face() if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, mesh, CGAL::parameters::geom_traits(K()))) assert(false); } + + assert(CGAL::is_triangle_mesh(mesh)); + return true; } @@ -238,9 +238,54 @@ test_dual_with_various_faces() if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, sm_dual)) assert(false); } + + assert(CGAL::is_triangle_mesh(sm_dual)); + return true; } +template +bool +test_triangulate_soup() +{ + typedef typename K::Point_3 Point; + typedef CGAL::Surface_mesh Surface_mesh; + + Surface_mesh mesh; + std::ifstream input(CGAL::data_file_path("meshes/elephant.off")); + + if (!input || !(input >> mesh) || mesh.is_empty()) + { + std::cerr << "Not a valid off file." << std::endl; + return false; + } + + typedef typename boost::property_map::type Pmap; + Pmap vpmap = get_property_map(boost::vertex_point, mesh); + + CGAL::Dual dual(mesh); + // copy dual to a sm + Surface_mesh sm_dual; + CGAL::copy_face_graph(dual, sm_dual, + CGAL::parameters::vertex_point_map( + Dual_vpm(mesh, vpmap))); + + std::vector points; + std::vector > polygons; + CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(sm_dual, points, polygons); + + bool success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons); + for(std::size_t i = 0; i < polygons.size(); ++i) + { + assert(polygons[i].size() == 3); + } + + // For compilation + success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons, CGAL::parameters::geom_traits(K())); + + return success; +} + int main() { assert(test_triangulate_faces()); @@ -249,6 +294,7 @@ int main() assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); + assert(test_triangulate_soup()); assert(test_triangulate_faces()); assert(test_triangulate_faces_with_named_parameters()); @@ -256,6 +302,8 @@ int main() assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); + assert(test_triangulate_soup()); + std::cout << "Done" << std::endl; return EXIT_SUCCESS; } From 123c2513fc855feba0a65acaa8878f274b4dca55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 16:48:41 +0200 Subject: [PATCH 10/64] Delegate construction of a 2D CDT to hole filling --- .../triangulate_faces.h | 299 ++---------------- 1 file changed, 28 insertions(+), 271 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index a4594228b20..ff03d1f83f5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -18,16 +18,6 @@ #include #include -#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 -#include -#include -#include -#include -#include -#else -#include -#endif - #include #include #include @@ -40,6 +30,12 @@ #include #include +#ifdef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 +# ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 +# define CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 +# endif +#endif + namespace CGAL { namespace Polygon_mesh_processing { namespace Triangulate_faces { @@ -144,166 +140,17 @@ public: visitor.after_subface_created(face(opposite(res,pmesh),pmesh)); visitor.after_subface_creations(); + + return true; } - else - { -#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 - if (use_cdt) - { - typedef CGAL::Projection_traits_3 P_traits; - typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; - typedef CGAL::Triangulation_face_base_with_info_2 Fb1; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::No_constraint_intersection_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; - P_traits cdt_traits(normal); - CDT cdt(cdt_traits); - return triangulate_face_with_CDT(f, pmesh, cdt, visitor); - } -#else - CGAL_USE(use_cdt); -#endif - return triangulate_face_with_hole_filling(f, pmesh, visitor); - } - return true; + + return triangulate_face_with_hole_filling(f, pmesh, use_cdt, visitor); } - template - bool triangulate_face_with_CDT(face_descriptor f, PM& pmesh, CDT& cdt, Visitor visitor) - { - typedef typename CDT::Vertex_handle Tr_Vertex_handle; - - std::size_t original_size = CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size(); - - try - { - halfedge_descriptor start = halfedge(f, pmesh); - halfedge_descriptor h = start; - Tr_Vertex_handle previous, first; - do - { - Tr_Vertex_handle vh = cdt.insert(get(_vpmap, target(h, pmesh))); - if (first == Tr_Vertex_handle()) { - first = vh; - } - vh->info() = h; - if(previous != Tr_Vertex_handle() && previous != vh) { - cdt.insert_constraint(previous, vh); - } - previous = vh; - h = next(h, pmesh); - - } while( h != start ); - cdt.insert_constraint(previous, first); - } - catch(const typename CDT::Intersection_of_constraints_exception&) - { - return false; - } - - // sets mark is_external - for(typename CDT::All_faces_iterator fit = cdt.all_faces_begin(), - end = cdt.all_faces_end(); - fit != end; ++fit) - { - fit->info().is_external = false; - } - std::queue face_queue; - face_queue.push(cdt.infinite_vertex()->face()); - while(! face_queue.empty() ) - { - typename CDT::Face_handle fh = face_queue.front(); - face_queue.pop(); - - if(fh->info().is_external) - continue; - - fh->info().is_external = true; - for(int i = 0; i <3; ++i) - { - if(!cdt.is_constrained(typename CDT::Edge(fh, i))) - { - face_queue.push(fh->neighbor(i)); - } - } - } - - if(cdt.dimension() != 2 || - cdt.number_of_vertices() != original_size) - return false; - - - // then modify the polyhedron - visitor.before_subface_creations(f); - // make_hole. (see comment in function body) - this->make_hole(halfedge(f, pmesh), pmesh); - - for(typename CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(), - end = cdt.finite_edges_end(); - eit != end; ++eit) - { - typename CDT::Face_handle fh = eit->first; - const int index = eit->second; - typename CDT::Face_handle opposite_fh = fh->neighbor(eit->second); - const int opposite_index = opposite_fh->index(fh); - - const Tr_Vertex_handle va = fh->vertex(cdt. cw(index)); - const Tr_Vertex_handle vb = fh->vertex(cdt.ccw(index)); - - if( ! (is_external(fh) && is_external(opposite_fh))//not both fh are external - && ! cdt.is_constrained(*eit) ) //and edge is not constrained - { - // strictly internal edge - halfedge_descriptor hnew = halfedge(add_edge(pmesh), pmesh), - hnewopp = opposite(hnew, pmesh); - - fh->info().e[index] = hnew; - opposite_fh->info().e[opposite_index] = hnewopp; - - set_target(hnew, target(va->info(), pmesh), pmesh); - set_target(hnewopp, target(vb->info(), pmesh), pmesh); - } - if( cdt.is_constrained(*eit) ) //edge is constrained - { - if(!is_external(fh)) { - fh->info().e[index] = va->info(); - } - if(!is_external(opposite_fh)) { - opposite_fh->info().e[opposite_index] = vb->info(); - } - } - } - for(typename CDT::Finite_faces_iterator fit = cdt.finite_faces_begin(), - end = cdt.finite_faces_end(); - fit != end; ++fit) - { - if(!is_external(fit)) - { - halfedge_descriptor h0 = fit->info().e[0]; - halfedge_descriptor h1 = fit->info().e[1]; - halfedge_descriptor h2 = fit->info().e[2]; - CGAL_assertion(h0 != halfedge_descriptor()); - CGAL_assertion(h1 != halfedge_descriptor()); - CGAL_assertion(h2 != halfedge_descriptor()); - - set_next(h0, h1, pmesh); - set_next(h1, h2, pmesh); - set_next(h2, h0, pmesh); - - Euler::fill_hole(h0, pmesh); - visitor.after_subface_created(face(h0, pmesh)); - } - } - visitor.after_subface_creations(); - return true; - } - - bool triangulate_face_with_hole_filling(face_descriptor f, PM& pmesh, Visitor visitor) + bool triangulate_face_with_hole_filling(face_descriptor f, + PM& pmesh, + const bool use_cdt, + Visitor visitor) { namespace PMP = CGAL::Polygon_mesh_processing; @@ -322,7 +169,8 @@ public: typedef CGAL::Triple Face_indices; std::vector patch; PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), - parameters::geom_traits(_traits)); + parameters::geom_traits(_traits) + .use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch.empty()) return false; @@ -491,7 +339,7 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); //Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); + bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); typedef typename internal_np::Lookup_named_param_def< internal_np::visitor_t, @@ -568,7 +416,7 @@ bool triangulate_faces(FaceRange face_range, Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); //Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); + bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); typedef typename internal_np::Lookup_named_param_def< internal_np::visitor_t, @@ -654,93 +502,6 @@ public: { } private: - template - bool triangulate_face_with_CDT(const Polygon& polygon, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - Visitor visitor) - { - using Point_ref = typename boost::property_traits::reference; - - using PK = CGAL::Projection_traits_3; - using Vbb = CGAL::Triangulation_vertex_base_with_info_2; - using Vb = CGAL::Triangulation_vertex_base_2; - using Fb = CGAL::Constrained_triangulation_face_base_2; - using TDS = CGAL::Triangulation_data_structure_2; - using Itag = CGAL::No_constraint_intersection_tag; - using CDT = CGAL::Constrained_Delaunay_triangulation_2; - using CDT_Vertex_handle = typename CDT::Vertex_handle; - using CDT_Face_handle = typename CDT::Face_handle; - - const std::size_t original_size = polygon.size(); - - Vector n = CGAL::NULL_VECTOR; - for(std::size_t i=0; iinfo() = i; - if(previous != CDT_Vertex_handle() && previous != vh) - cdt.insert_constraint(previous, vh); - - previous = vh; - } - cdt.insert_constraint(previous, first); - } - catch(const typename CDT::Intersection_of_constraints_exception&) - { - return false; - } - - if(cdt.dimension() != 2 || cdt.number_of_vertices() != polygon.size()) - return false; - - std::unordered_map in_domain_map; - boost::associative_property_map< std::unordered_map > in_domain(in_domain_map); - - CGAL::mark_domain_in_triangulation(cdt, in_domain); - - visitor.before_subface_creations(polygon); - - for(CDT_Face_handle f : cdt.finite_face_handles()) - { - if(!get(in_domain, f)) - continue; - - triangulated_polygons.push_back({f->vertex(0)->info(), f->vertex(1)->info(), f->vertex(2)->info()}); - visitor.after_subface_created(triangulated_polygons.back()); - } - - visitor.after_subface_creations(); - return true; - } - template Face_indices; std::vector patch; PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), - parameters::geom_traits(_traits)); + parameters::geom_traits(_traits) + .use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch.empty()) + { + std::cout << "failed hole filling" << std::endl; return false; + } visitor.before_subface_creations(polygon); @@ -838,20 +604,11 @@ private: visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-1]); visitor.after_subface_creations(); - } - else - { -#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 - if(use_cdt) - return triangulate_face_with_CDT(polygon, points, triangulated_polygons, pmap, visitor); -#else - CGAL_USE(use_cdt); -#endif - return triangulate_face_with_hole_filling(polygon, points, triangulated_polygons, pmap, visitor); + return true; } - return true; + return triangulate_face_with_hole_filling(polygon, points, triangulated_polygons, pmap, use_cdt, visitor); } public: @@ -981,8 +738,8 @@ bool triangulate_polygons(const PointRange& points, Def_Kernel>::type; Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - //Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); + // Option + bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); typedef typename internal_np::Lookup_named_param_def< internal_np::visitor_t, From c451b921ef2cd6e774044a06266a8d00613c8e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 16:52:48 +0200 Subject: [PATCH 11/64] Rename internal functions for consistency --- .../triangulate_faces.h | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index ff03d1f83f5..e0a7911c332 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -507,12 +507,12 @@ private: typename PolygonRange, typename PMap, typename Visitor> - bool triangulate_face_with_hole_filling(const Polygon& polygon, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - const bool use_cdt, - Visitor visitor) + bool triangulate_polygon_with_hole_filling(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + const bool use_cdt, + Visitor visitor) { namespace PMP = CGAL::Polygon_mesh_processing; @@ -558,12 +558,12 @@ private: typename PolygonRange, typename PMap, typename Visitor> - bool triangulate_face(const Polygon& polygon, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - const bool use_cdt, - Visitor visitor) + bool triangulate_polygon(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + PMap pmap, + const bool use_cdt, + Visitor visitor) { using FT = typename Traits::FT; using Point_ref = typename boost::property_traits::reference; @@ -608,7 +608,7 @@ private: return true; } - return triangulate_face_with_hole_filling(polygon, points, triangulated_polygons, pmap, use_cdt, visitor); + return triangulate_polygon_with_hole_filling(polygon, points, triangulated_polygons, pmap, use_cdt, visitor); } public: @@ -636,7 +636,7 @@ public: continue; } - if(!triangulate_face(polygon, points, triangulated_polygons, pmap, use_cdt, visitor)) + if(!triangulate_polygon(polygon, points, triangulated_polygons, pmap, use_cdt, visitor)) result = false; } From f570e0ec2ea36e529b5e0dc95cb88e982a34602c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 16:53:08 +0200 Subject: [PATCH 12/64] Enhance tests --- .../triangulate_faces_test.cpp | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp index 61546684005..66085b83c74 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -21,6 +21,8 @@ template bool test_triangulate_faces() { + std::cout << "\n--- test_triangulate_faces(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -43,6 +45,8 @@ template bool test_triangulate_faces_with_named_parameters() { + std::cout << "\n--- test_triangulate_faces_with_named_parameters(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -78,13 +82,15 @@ test_triangulate_faces_with_named_parameters() template bool -test_triangulate_face_range() +test_triangulate_face_range(const std::string& filename) { + std::cout << "\n--- test_triangulate_face_range(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; Surface_mesh mesh; - std::ifstream input(CGAL::data_file_path("meshes/cube_quad.off")); + std::ifstream input(filename); if (!input || !(input >> mesh) || mesh.is_empty()) { @@ -93,6 +99,18 @@ test_triangulate_face_range() } bool success = CGAL::Polygon_mesh_processing::triangulate_faces(faces(mesh), mesh); + + for(auto f : faces(mesh)) + { + if(!is_triangle(halfedge(f, mesh), mesh)) + { + std::cout << "non triangular face:" << std::endl; + for(auto h : halfedges_around_face(halfedge(f, mesh), mesh)) + std::cout << " " << mesh.point(target(h, mesh)) << std::endl; + assert(false); + } + } + assert(CGAL::is_triangle_mesh(mesh)); // For compilation @@ -106,6 +124,8 @@ template bool test_triangulate_face() { + std::cout << "\n--- test_triangulate_face(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -136,6 +156,8 @@ template bool test_triangulate_triangle_face() { + std::cout << "\n--- test_triangulate_triangle_face(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -211,6 +233,8 @@ template bool test_dual_with_various_faces() { + std::cout << "\n--- test_dual_with_various_faces(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -235,7 +259,8 @@ test_dual_with_various_faces() for(typename boost::graph_traits::face_descriptor fit : faces(sm_dual)) { - if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, sm_dual)) + if(!CGAL::Polygon_mesh_processing::triangulate_face(fit, sm_dual, + CGAL::parameters::use_2d_constrained_delaunay_triangulation(true))) assert(false); } @@ -248,6 +273,8 @@ template bool test_triangulate_soup() { + std::cout << "\n--- test_triangulate_soup(" << typeid(K).name() << ") ---" << std::endl; + typedef typename K::Point_3 Point; typedef CGAL::Surface_mesh Surface_mesh; @@ -274,23 +301,30 @@ test_triangulate_soup() std::vector > polygons; CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(sm_dual, points, polygons); - bool success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons); + bool success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons, + CGAL::parameters::geom_traits(K()) + .use_2d_constrained_delaunay_triangulation(false)); for(std::size_t i = 0; i < polygons.size(); ++i) { assert(polygons[i].size() == 3); } // For compilation - success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons, CGAL::parameters::geom_traits(K())); + success = CGAL::Polygon_mesh_processing::triangulate_polygons(points, polygons); return success; } -int main() +int main(int argc, char** argv) { + if(argc > 1) + { + assert(test_triangulate_face_range(argv[1])); + } + assert(test_triangulate_faces()); assert(test_triangulate_faces_with_named_parameters()); - assert(test_triangulate_face_range()); + assert(test_triangulate_face_range(CGAL::data_file_path("meshes/cube_quad.off"))); assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); @@ -298,7 +332,7 @@ int main() assert(test_triangulate_faces()); assert(test_triangulate_faces_with_named_parameters()); - assert(test_triangulate_face_range()); + assert(test_triangulate_face_range(CGAL::data_file_path("meshes/cube_quad.off"))); assert(test_triangulate_face()); assert(test_triangulate_triangle_face()); assert(test_dual_with_various_faces()); From 4d03dbe076e0d849e163d7ff37f2d1d0d9f13c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 Mar 2023 22:42:40 +0200 Subject: [PATCH 13/64] Try-Catch the CDT constraint insertions --- .../Hole_filling/Triangulate_hole_polyline.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 797a6912f26..0bb232eb66b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1442,12 +1442,20 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, vertices[v->info()] = v; } - for (std::size_t i = 0; i < size; ++i) { - const std::size_t ip = (i + 1) % size; - if (vertices[i] != vertices[ip]) { - cdt.insert_constraint(vertices[i], vertices[ip]); + try + { + for (std::size_t i = 0; i < size; ++i) { + const std::size_t ip = (i + 1) % size; + if (vertices[i] != vertices[ip]) { + cdt.insert_constraint(vertices[i], vertices[ip]); + } } } + catch(const typename CDT::Intersection_of_constraints_exception&) + { + visitor.end_planar_phase(false); + return false; + } // Mark external faces. for (typename CDT::All_faces_iterator fit = cdt.all_faces_begin(), From 1365fac894be7f5ea9118ce14e481e4e7178b84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 10:08:10 +0200 Subject: [PATCH 14/64] Move macro --- .../internal/Hole_filling/Triangulate_hole_polyline.h | 5 +++++ .../CGAL/Polygon_mesh_processing/triangulate_faces.h | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 0bb232eb66b..5e84ba9e694 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -15,6 +15,11 @@ #include +#ifdef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 +# ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 +# define CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 +# endif +#endif #include #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index e0a7911c332..cb1d874f855 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -30,12 +30,6 @@ #include #include -#ifdef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 -# ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 -# define CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 -# endif -#endif - namespace CGAL { namespace Polygon_mesh_processing { namespace Triangulate_faces { From 4a2d91e03bd94b15695017acb51a8a27eb3a0789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 10:11:04 +0200 Subject: [PATCH 15/64] Document requirements on faces of triangulate_faces/triangulate_polygons --- .../CGAL/Polygon_mesh_processing/triangulate_faces.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index cb1d874f855..4679e536e51 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -309,6 +309,8 @@ public: * \cgalParamNEnd * \cgalNamedParamsEnd * +* @pre The face `f` is not degenerate. +* * @return `true` if the face has been triangulated. * * @see `triangulate_faces()` @@ -388,6 +390,8 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor * `\cgalParamNEnd * \cgalNamedParamsEnd * +* @pre No face within `face_range` is degenerate. +* * @return `true` if all the faces have been triangulated. * * @see `triangulate_face()` @@ -462,6 +466,8 @@ bool triangulate_faces(FaceRange face_range, * \cgalParamNEnd * \cgalNamedParamsEnd * +* @pre No face of `pmesh` is degenerate. +* * @return `true` if all the faces have been triangulated. * * @see `triangulate_face()` @@ -703,6 +709,8 @@ struct Default_visitor * \cgalParamNEnd * \cgalNamedParamsEnd * +* @pre No polygon within `polygons` is degenerate. +* * @return `true` if all the polygons have been triangulated. * * @see `triangulate_face()` From 9387f087e02077c8f99580f4ff7569fddb85728b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 11:53:27 +0200 Subject: [PATCH 16/64] Refactor to properly forward NPs to triangulate_hole_polyline + other imprvmts --- .../triangulate_faces.h | 766 ++++++++---------- 1 file changed, 338 insertions(+), 428 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 4679e536e51..3cfba555a20 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -15,20 +15,22 @@ #include +#include + +#include #include #include - -#include -#include -#include #include +#include -#include +#include +#include +#include +#include #include -#include #include -#include +#include namespace CGAL { namespace Polygon_mesh_processing { @@ -51,68 +53,157 @@ struct Default_visitor void after_subface_created(face_descriptor /*f_new*/) {} }; -} //end namespace Triangulate_faces +} // namespace Triangulate_faces namespace internal { -template +template class Triangulate_polygon_mesh_modifier { - typedef Kernel Traits; + using vertex_descriptor = typename boost::graph_traits::vertex_descriptor; + using halfedge_descriptor = typename boost::graph_traits::halfedge_descriptor; + using face_descriptor = typename boost::graph_traits::face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef typename Kernel::Point_3 Point; - - struct Face_info { - typename boost::graph_traits::halfedge_descriptor e[3]; - bool is_external; - }; - - typedef typename boost::property_traits::reference Point_ref; - VertexPointMap _vpmap; - Traits _traits; - -public: - Triangulate_polygon_mesh_modifier(VertexPointMap vpmap, const Traits& traits = Traits()) - : _vpmap(vpmap), _traits(traits) +private: + template + bool triangulate_face_with_hole_filling(face_descriptor f, + PolygonMesh& pmesh, + const VPM vpm, + Visitor visitor, + const NamedParameters& np) { - } + namespace PMP = CGAL::Polygon_mesh_processing; - template - bool is_external(Face_handle fh) const { - return fh->info().is_external; - } + using Point = typename boost::property_traits::value_type; - bool triangulate_face(face_descriptor f, PM& pmesh, bool use_cdt, Visitor visitor) - { - typedef typename Traits::FT FT; + // gather halfedges around the face + std::vector hole_points; + std::vector border_vertices; + CGAL_assertion(CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size() > 0); + for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh)) + { + vertex_descriptor v = source(h, pmesh); + hole_points.push_back(get(vpm, v)); + border_vertices.push_back(v); + } - typename Traits::Vector_3 normal = - Polygon_mesh_processing::compute_face_normal( - f, pmesh, CGAL::parameters::geom_traits(_traits) - .vertex_point_map(_vpmap)); + // use hole filling + typedef CGAL::Triple Face_indices; + std::vector patch; + PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), np); - if(normal == typename Traits::Vector_3(0,0,0)) + if(patch.empty()) return false; - std::size_t original_size = CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size(); + // triangulate the hole + std::map, halfedge_descriptor > halfedge_map; + int i = 0; + for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh)) + { + int j = std::size_t(i+1) == hole_points.size() ? 0 : i+1; + halfedge_map[std::make_pair(i, j)] = h; + ++i; + } + + visitor.before_subface_creations(f); + + bool first = true; + std::vector hedges; + hedges.reserve(4); + for(const Face_indices& triangle : patch) + { + if(first) + first = false; + else + f = add_face(pmesh); + + visitor.after_subface_created(f); + + std::array indices = make_array(triangle.first, + triangle.second, + triangle.third, + triangle.first); + for (int i=0; i<3; ++i) + { + typename std::map< std::pair , halfedge_descriptor >::iterator insert_res = + halfedge_map.emplace(std::make_pair(indices[i], indices[i+1]), + boost::graph_traits::null_halfedge()).first; + if(insert_res->second == boost::graph_traits::null_halfedge()) + { + halfedge_descriptor nh = halfedge(add_edge(pmesh), pmesh); + insert_res->second = nh; + halfedge_map[std::make_pair(indices[i+1], indices[i])] = opposite(nh, pmesh); + } + hedges.push_back(insert_res->second); + } + + hedges.push_back(hedges.front()); + for(int i=0; i<3;++i) + { + set_next(hedges[i], hedges[i+1], pmesh); + set_face(hedges[i], f, pmesh); + set_target(hedges[i], border_vertices[indices[i+1]], pmesh); + } + + set_halfedge(f, hedges[0], pmesh); + hedges.clear(); + } + + visitor.after_subface_creations(); + + return true; + } + +public: + template + bool operator()(face_descriptor f, + PolygonMesh& pmesh, + const NamedParameters& np) + { + using Traits = typename GetGeomTraits::type; + using VPM = typename GetVertexPointMap::type; + + using FT = typename Traits::FT; + using Point_ref = typename boost::property_traits::reference; + using Vector = typename Traits::Vector_3; + + using Visitor = typename internal_np::Lookup_named_param_def< + internal_np::visitor_t, + NamedParameters, + Triangulate_faces::Default_visitor // default + >::type; + + using parameters::choose_parameter; + using parameters::get_parameter; + + CGAL_precondition(is_valid_face_descriptor(f, pmesh)); + + Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_property_map(vertex_point, pmesh)); + Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), + Triangulate_faces::Default_visitor()); + + typename Traits::Construct_cross_product_vector_3 cross_product = + traits.construct_cross_product_vector_3_object(); + + typename boost::graph_traits::degree_size_type original_size = degree(f, pmesh); + if(original_size <= 3) + return true; + if(original_size == 4) { halfedge_descriptor v0, v1, v2, v3; v0 = halfedge(f, pmesh); - Point_ref p0 = get(_vpmap, target(v0, pmesh)); + Point_ref p0 = get(vpm, target(v0, pmesh)); v1 = next(v0, pmesh); - Point_ref p1 = get(_vpmap, target(v1, pmesh)); + Point_ref p1 = get(vpm, target(v1, pmesh)); v2 = next(v1, pmesh); - Point_ref p2 = get(_vpmap, target(v2, pmesh)); + Point_ref p2 = get(vpm, target(v2, pmesh)); v3 = next(v2, pmesh); - Point_ref p3 = get(_vpmap, target(v3, pmesh)); + Point_ref p3 = get(vpm, target(v3, pmesh)); /* Chooses the diagonal that will split the quad in two triangles that maximize * the scalar product of of the un-normalized normals of the two triangles. @@ -123,150 +214,23 @@ public: * In particular, if the two triangles are oriented in different directions, * the scalar product will be negative. */ - FT p1p3 = CGAL::cross_product(p2-p1,p3-p2) * CGAL::cross_product(p0-p3,p1-p0); - FT p0p2 = CGAL::cross_product(p1-p0,p1-p2) * CGAL::cross_product(p3-p2,p3-p0); visitor.before_subface_creations(f); - halfedge_descriptor res = (p0p2>p1p3) - ? CGAL::Euler::split_face(v0, v2, pmesh) - : CGAL::Euler::split_face(v1, v3, pmesh); - visitor.after_subface_created(face(res,pmesh)); - visitor.after_subface_created(face(opposite(res,pmesh),pmesh)); + const FT p1p3 = cross_product(p2-p1, p3-p2) * cross_product(p0-p3, p1-p0); + const FT p0p2 = cross_product(p1-p0, p1-p2) * cross_product(p3-p2, p3-p0); + halfedge_descriptor res = (p0p2>p1p3) ? CGAL::Euler::split_face(v0, v2, pmesh) + : CGAL::Euler::split_face(v1, v3, pmesh); + + visitor.after_subface_created(face(res, pmesh)); + visitor.after_subface_created(face(opposite(res, pmesh), pmesh)); visitor.after_subface_creations(); return true; } - return triangulate_face_with_hole_filling(f, pmesh, use_cdt, visitor); + return triangulate_face_with_hole_filling(f, pmesh, vpm, visitor, np); } - - bool triangulate_face_with_hole_filling(face_descriptor f, - PM& pmesh, - const bool use_cdt, - Visitor visitor) - { - namespace PMP = CGAL::Polygon_mesh_processing; - - // gather halfedges around the face - std::vector hole_points; - std::vector border_vertices; - CGAL_assertion(CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size() > 0); - for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh)) - { - vertex_descriptor v = source(h, pmesh); - hole_points.push_back( get(_vpmap, v) ); - border_vertices.push_back(v); - } - - // use hole filling - typedef CGAL::Triple Face_indices; - std::vector patch; - PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), - parameters::geom_traits(_traits) - .use_2d_constrained_delaunay_triangulation(use_cdt)); - - if(patch.empty()) - return false; - - // triangulate the hole - std::map< std::pair , halfedge_descriptor > halfedge_map; - int i=0; - for(halfedge_descriptor h : CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh)) - { - int j = std::size_t(i+1) == hole_points.size() ? 0 : i+1; - halfedge_map[ std::make_pair(i, j) ] = h; - ++i; - } - - visitor.before_subface_creations(f); - bool first = true; - std::vector hedges; - hedges.reserve(4); - for(const Face_indices& triangle : patch) - { - if (first) - first=false; - else - f=add_face(pmesh); - visitor.after_subface_created(f); - - std::array indices = - make_array( triangle.first, - triangle.second, - triangle.third, - triangle.first ); - for (int i=0; i<3; ++i) - { - typename std::map< std::pair , halfedge_descriptor >::iterator insert_res = - halfedge_map.insert( - std::make_pair( std::make_pair(indices[i], indices[i+1]), - boost::graph_traits::null_halfedge() ) ).first; - if (insert_res->second == boost::graph_traits::null_halfedge()) - { - halfedge_descriptor nh = halfedge(add_edge(pmesh), pmesh); - insert_res->second=nh; - halfedge_map[std::make_pair(indices[i+1], indices[i])]=opposite(nh, pmesh); - } - hedges.push_back(insert_res->second); - } - hedges.push_back(hedges.front()); - for(int i=0; i<3;++i) - { - set_next(hedges[i], hedges[i+1], pmesh); - set_face(hedges[i], f, pmesh); - set_target(hedges[i], border_vertices[indices[i+1]], pmesh); - } - set_halfedge(f, hedges[0], pmesh); - hedges.clear(); - } - visitor.after_subface_creations(); - return true; - } - - template - bool operator()(FaceRange face_range, PM& pmesh, bool use_cdt, Visitor visitor) - { - bool result = true; - // One need to store facet handles into a vector, because the list of - // facets of the polyhedron will be modified during the loop, and - // that invalidates the range [facets_begin(), facets_end()[. - std::vector facets; - facets.reserve(std::distance(boost::begin(face_range), boost::end(face_range))); - - //only consider non-triangular faces - for(face_descriptor fit : face_range) - if ( next( next( halfedge(fit, pmesh), pmesh), pmesh) - != prev( halfedge(fit, pmesh), pmesh) ) - facets.push_back(fit); - - // Iterates on the vector of face descriptors - for(face_descriptor f : facets) - { - if(!this->triangulate_face(f, pmesh, use_cdt, visitor)) - result = false; - } - return result; - } - - void make_hole(halfedge_descriptor h, PM& pmesh) - { - //we are not using Euler::make_hole because it has a precondition - //that the hole is not made on the boundary of the mesh - //here we allow making a hole on the boundary, and the pair(s) of - //halfedges that become border-border are fixed by the connectivity - //setting made in operator() - CGAL_assertion(!is_border(h, pmesh)); - face_descriptor fd = face(h, pmesh); - - for(halfedge_descriptor hd : halfedges_around_face(h, pmesh)) - { - CGAL::internal::set_border(hd, pmesh); - } - remove_face(fd, pmesh); - } - - }; // class Triangulate_polygon_mesh_modifier } // namespace internal @@ -309,45 +273,23 @@ public: * \cgalParamNEnd * \cgalNamedParamsEnd * +* This function calls `CGAL::Polygon_mesh_processing::triangulate_hole_polyline()`. +* Refer to its documentation for its named parameters. +* * @pre The face `f` is not degenerate. * * @return `true` if the face has been triangulated. * * @see `triangulate_faces()` */ -template +template bool triangulate_face(typename boost::graph_traits::face_descriptor f, PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { - using parameters::choose_parameter; - using parameters::get_parameter; - - CGAL_precondition(is_valid_face_descriptor(f, pmesh)); - - //VertexPointMap - typedef typename GetVertexPointMap::type VPMap; - VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_property_map(vertex_point, pmesh)); - - //Kernel - typedef typename GetGeomTraits::type Kernel; - Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - - //Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); - - typedef typename internal_np::Lookup_named_param_def< - internal_np::visitor_t, - NamedParameters, - Triangulate_faces::Default_visitor//default - >::type Visitor; - Visitor visitor = choose_parameter( - get_parameter(np, internal_np::visitor), - Triangulate_faces::Default_visitor()); - - internal::Triangulate_polygon_mesh_modifier modifier(vpmap, traits); - return modifier.triangulate_face(f, pmesh, use_cdt, visitor); + internal::Triangulate_polygon_mesh_modifier modifier; + return modifier(f, pmesh, np); } /** @@ -390,43 +332,39 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor * `\cgalParamNEnd * \cgalNamedParamsEnd * +* This function calls `CGAL::Polygon_mesh_processing::triangulate_hole_polyline()` for each face. +* Refer to its documentation for its named parameters. +* * @pre No face within `face_range` is degenerate. * * @return `true` if all the faces have been triangulated. * * @see `triangulate_face()` */ -template +template bool triangulate_faces(FaceRange face_range, PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { - using parameters::choose_parameter; - using parameters::get_parameter; + using face_descriptor = typename boost::graph_traits::face_descriptor; - //VertexPointMap - typedef typename GetVertexPointMap::type VPMap; - VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_property_map(vertex_point, pmesh)); + bool result = true; - //Kernel - typedef typename GetGeomTraits::type Kernel; - Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + // One need to store facet handles into a vector, because the list of + // facets of the polyhedron will be modified during the loop, and + // that invalidates the range [facets_begin(), facets_end()[. + std::vector facets(std::begin(face_range), std::end(face_range)); - //Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); + internal::Triangulate_polygon_mesh_modifier modifier; + for(face_descriptor f : facets) + { + if(!modifier(f, pmesh, np)) + result = false; + } - typedef typename internal_np::Lookup_named_param_def< - internal_np::visitor_t, - NamedParameters, - Triangulate_faces::Default_visitor//default - >::type Visitor; - Visitor visitor = choose_parameter( - get_parameter(np, internal_np::visitor), - Triangulate_faces::Default_visitor()); - - internal::Triangulate_polygon_mesh_modifier modifier(vpmap, traits); - return modifier(face_range, pmesh, use_cdt, visitor); + return result; } /** @@ -466,6 +404,9 @@ bool triangulate_faces(FaceRange face_range, * \cgalParamNEnd * \cgalNamedParamsEnd * +* This function calls `CGAL::Polygon_mesh_processing::triangulate_hole_polyline()` on all the faces of the polygon mesh. +* Refer to its documentation for its named parameters. +* * @pre No face of `pmesh` is degenerate. * * @return `true` if all the faces have been triangulated. @@ -484,169 +425,6 @@ bool triangulate_faces(PolygonMesh& pmesh, //////////////////////////////////////////////////////////////////////////////////////////////////// // Polygon Soup -namespace internal { - -template -class Triangulate_polygon_soup_modifier -{ - using Traits = Kernel; - using Point = typename Traits::Point_3; - using Vector = typename Traits::Vector_3; - -private: - Traits _traits; - -public: - Triangulate_polygon_soup_modifier(const Traits& traits = Traits()) - : _traits(traits) - { } - -private: - template - bool triangulate_polygon_with_hole_filling(const Polygon& polygon, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - const bool use_cdt, - Visitor visitor) - { - namespace PMP = CGAL::Polygon_mesh_processing; - - // gather halfedges around the face - std::vector hole_points; - std::vector hole_points_indices; - - for(std::size_t i : polygon) - { - hole_points.push_back(get(pmap, points[i])); - hole_points_indices.push_back(i); - } - - // use hole filling - typedef CGAL::Triple Face_indices; - std::vector patch; - PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), - parameters::geom_traits(_traits) - .use_2d_constrained_delaunay_triangulation(use_cdt)); - - if(patch.empty()) - { - std::cout << "failed hole filling" << std::endl; - return false; - } - - visitor.before_subface_creations(polygon); - - for(const Face_indices& triangle : patch) - { - triangulated_polygons.push_back({hole_points_indices[triangle.first], - hole_points_indices[triangle.second], - hole_points_indices[triangle.third]}); - visitor.after_subface_created(triangulated_polygons.back()); - } - - visitor.after_subface_creations(); - return true; - } - - template - bool triangulate_polygon(const Polygon& polygon, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - const bool use_cdt, - Visitor visitor) - { - using FT = typename Traits::FT; - using Point_ref = typename boost::property_traits::reference; - - const std::size_t original_size = polygon.size(); - if(original_size == 4) - { - Point_ref p0 = get(pmap, points[polygon[0]]); - Point_ref p1 = get(pmap, points[polygon[1]]); - Point_ref p2 = get(pmap, points[polygon[2]]); - Point_ref p3 = get(pmap, points[polygon[3]]); - - /* Chooses the diagonal that will split the quad in two triangles that maximize - * the scalar product of of the un-normalized normals of the two triangles. - * The lengths of the un-normalized normals (computed using cross-products of two vectors) - * are proportional to the area of the triangles. - * Maximize the scalar product of the two normals will avoid skinny triangles, - * and will also taken into account the cosine of the angle between the two normals. - * In particular, if the two triangles are oriented in different directions, - * the scalar product will be negative. - */ - FT p1p3 = CGAL::cross_product(p2-p1, p3-p2) * CGAL::cross_product(p0-p3, p1-p0); - FT p0p2 = CGAL::cross_product(p1-p0, p1-p2) * CGAL::cross_product(p3-p2, p3-p0); - - visitor.before_subface_creations(polygon); - if(p0p2 > p1p3) - { - triangulated_polygons.push_back({polygon[0], polygon[1], polygon[2]}); - triangulated_polygons.push_back({polygon[0], polygon[2], polygon[3]}); - } - else - { - triangulated_polygons.push_back({polygon[0], polygon[1], polygon[3]}); - triangulated_polygons.push_back({polygon[1], polygon[2], polygon[3]}); - } - - visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-2]); - visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-1]); - - visitor.after_subface_creations(); - - return true; - } - - return triangulate_polygon_with_hole_filling(polygon, points, triangulated_polygons, pmap, use_cdt, visitor); - } - -public: - template - bool operator()(const PolygonRange& polygons, - const PointRange& points, - PolygonRange& triangulated_polygons, - PMap pmap, - const bool use_cdt, - Visitor visitor) - { - using Polygon = typename boost::range_value::type; - - bool result = true; - triangulated_polygons.reserve(polygons.size()); - - for(const Polygon& polygon : polygons) - { - if(polygon.size() <= 3) - { - triangulated_polygons.push_back(polygon); - continue; - } - - if(!triangulate_polygon(polygon, points, triangulated_polygons, pmap, use_cdt, visitor)) - result = false; - } - - return result; - } - -}; // class Triangulate_polygon_soup_modifier - -} // namespace internal - namespace Triangulate_polygons { namespace internal { @@ -670,6 +448,148 @@ struct Default_visitor } // namespace internal } // namespace Triangulate_polygons +namespace internal { + +class Triangulate_polygon_soup_modifier +{ +private: + template + bool triangulate_polygon_with_hole_filling(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, // output + PMap pm, + Visitor visitor, + const NamedParameters& np) + { + namespace PMP = CGAL::Polygon_mesh_processing; + + using Point = typename boost::property_traits::value_type; + using Kernel = typename CGAL::Kernel_traits::type; + + // gather halfedges around the face + std::vector hole_points; + std::vector hole_points_indices; + + for(std::size_t i : polygon) + { + hole_points.push_back(get(pm, points[i])); + hole_points_indices.push_back(i); + } + + // use hole filling + typedef CGAL::Triple Face_indices; + std::vector patch; + PMP::triangulate_hole_polyline(hole_points, std::back_inserter(patch), np); + + if(patch.empty()) + return false; + + visitor.before_subface_creations(polygon); + + for(const Face_indices& triangle : patch) + { + triangulated_polygons.push_back({hole_points_indices[triangle.first], + hole_points_indices[triangle.second], + hole_points_indices[triangle.third]}); + visitor.after_subface_created(triangulated_polygons.back()); + } + + visitor.after_subface_creations(); + return true; + } + +public: + template + bool operator()(const Polygon& polygon, + const PointRange& points, + PolygonRange& triangulated_polygons, + const NamedParameters& np) + { + // PointMap + using PMap = typename GetPointMap::const_type; + using Point_ref = typename boost::property_traits::reference; + + // Kernel + using Point = typename boost::property_traits::value_type; + using Def_Kernel = typename CGAL::Kernel_traits::Kernel; + using Traits = typename internal_np::Lookup_named_param_def< + internal_np::geom_traits_t, + NamedParameters, + Def_Kernel>::type; + using FT = typename Traits::FT; + + // Visitor + using Visitor = typename internal_np::Lookup_named_param_def< + internal_np::visitor_t, + NamedParameters, + Triangulate_polygons::internal::Default_visitor // default + >::type; + + using parameters::choose_parameter; + using parameters::get_parameter; + + PMap pm = choose_parameter(get_parameter(np, internal_np::point_map)); + Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), + Triangulate_polygons::internal::Default_visitor()); + + typename Traits::Construct_cross_product_vector_3 cross_product = + traits.construct_cross_product_vector_3_object(); + + const std::size_t original_size = polygon.size(); + if(original_size == 4) + { + Point_ref p0 = get(pm, points[polygon[0]]); + Point_ref p1 = get(pm, points[polygon[1]]); + Point_ref p2 = get(pm, points[polygon[2]]); + Point_ref p3 = get(pm, points[polygon[3]]); + + /* Chooses the diagonal that will split the quad in two triangles that maximize + * the scalar product of of the un-normalized normals of the two triangles. + * The lengths of the un-normalized normals (computed using cross-products of two vectors) + * are proportional to the area of the triangles. + * Maximize the scalar product of the two normals will avoid skinny triangles, + * and will also taken into account the cosine of the angle between the two normals. + * In particular, if the two triangles are oriented in different directions, + * the scalar product will be negative. + */ + visitor.before_subface_creations(polygon); + + const FT p1p3 = cross_product(p2-p1, p3-p2) * cross_product(p0-p3, p1-p0); + const FT p0p2 = cross_product(p1-p0, p1-p2) * cross_product(p3-p2, p3-p0); + if(p0p2 > p1p3) + { + triangulated_polygons.push_back({polygon[0], polygon[1], polygon[2]}); + triangulated_polygons.push_back({polygon[0], polygon[2], polygon[3]}); + } + else + { + triangulated_polygons.push_back({polygon[0], polygon[1], polygon[3]}); + triangulated_polygons.push_back({polygon[1], polygon[2], polygon[3]}); + } + + visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-2]); + visitor.after_subface_created(triangulated_polygons[triangulated_polygons.size()-1]); + + visitor.after_subface_creations(); + + return true; + } + + return triangulate_polygon_with_hole_filling(polygon, points, triangulated_polygons, pm, visitor, np); + } +}; // class Triangulate_polygon_soup_modifier + +} // namespace internal + /** * \ingroup PMP_meshing_grp * @@ -709,6 +629,9 @@ struct Default_visitor * \cgalParamNEnd * \cgalNamedParamsEnd * +* This function calls `CGAL::Polygon_mesh_processing::triangulate_hole_polyline()` for each polygon. +* Refer to its documentation for its named parameters. +* * @pre No polygon within `polygons` is degenerate. * * @return `true` if all the polygons have been triangulated. @@ -724,36 +647,23 @@ bool triangulate_polygons(const PointRange& points, { using Polygon = typename boost::range_value::type; - using parameters::choose_parameter; - using parameters::get_parameter; - - //VertexPointMap - using PMap = typename GetPointMap::const_type; - PMap pmap = choose_parameter(get_parameter(np, internal_np::point_map)); - - //Kernel - using Point = typename boost::property_traits::value_type; - using Def_Kernel = typename CGAL::Kernel_traits::Kernel; - using Kernel = typename internal_np::Lookup_named_param_def< - internal_np::geom_traits_t, - NamedParameters, - Def_Kernel>::type; - Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - - // Option - bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), true); - - typedef typename internal_np::Lookup_named_param_def< - internal_np::visitor_t, - NamedParameters, - Triangulate_polygons::internal::Default_visitor // default - >::type Visitor; - Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), - Triangulate_polygons::internal::Default_visitor()); - PolygonRange triangulated_polygons; - internal::Triangulate_polygon_soup_modifier modifier(traits); - const bool success = modifier(polygons, points, triangulated_polygons, pmap, use_cdt, visitor); + triangulated_polygons.reserve(polygons.size()); + + bool success = true; + + internal::Triangulate_polygon_soup_modifier modifier; + for(const Polygon& polygon : polygons) + { + if(polygon.size() <= 3) + { + triangulated_polygons.push_back(polygon); + continue; + } + + if(!modifier(polygon, points, triangulated_polygons, np)) + success = false; + } std::swap(polygons, triangulated_polygons); From 962269c03dc495ba700d80f6af094c996e06781c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 12:07:47 +0200 Subject: [PATCH 17/64] Add see also's --- .../include/CGAL/Polygon_mesh_processing/triangulate_faces.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 3cfba555a20..79fe0f624f3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -340,6 +340,7 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor * @return `true` if all the faces have been triangulated. * * @see `triangulate_face()` +* @see `triangulate_polygons()` */ template bool triangulate_faces(PolygonMesh& pmesh, @@ -636,7 +638,7 @@ public: * * @return `true` if all the polygons have been triangulated. * -* @see `triangulate_face()` +* @see `triangulate_faces()` */ template Date: Wed, 29 Mar 2023 12:07:57 +0200 Subject: [PATCH 18/64] Move triangulate_polygons()'s default visitor out of internal namespace so that it is documented --- .../CGAL/Polygon_mesh_processing/triangulate_faces.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 79fe0f624f3..b33f3265cca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -428,7 +428,6 @@ bool triangulate_faces(PolygonMesh& pmesh, // Polygon Soup namespace Triangulate_polygons { -namespace internal { /** \ingroup PMP_meshing_grp * %Default new polygon visitor model of `PMPTriangulateFaceVisitor`. @@ -447,7 +446,6 @@ struct Default_visitor void after_subface_creations() {} }; -} // namespace internal } // namespace Triangulate_polygons namespace internal { @@ -532,7 +530,7 @@ public: using Visitor = typename internal_np::Lookup_named_param_def< internal_np::visitor_t, NamedParameters, - Triangulate_polygons::internal::Default_visitor // default + Triangulate_polygons::Default_visitor // default >::type; using parameters::choose_parameter; @@ -541,7 +539,7 @@ public: PMap pm = choose_parameter(get_parameter(np, internal_np::point_map)); Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); Visitor visitor = choose_parameter(get_parameter(np, internal_np::visitor), - Triangulate_polygons::internal::Default_visitor()); + Triangulate_polygons::Default_visitor()); typename Traits::Construct_cross_product_vector_3 cross_product = traits.construct_cross_product_vector_3_object(); From 5a47df6682a80c2de0f3784141379d63175b173a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 15:29:10 +0200 Subject: [PATCH 19/64] Doc fixes, thanks @albert-github --- .../CGAL/Polygon_mesh_processing/triangulate_faces.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index b33f3265cca..d112e6c8dd6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -206,7 +206,7 @@ public: Point_ref p3 = get(vpm, target(v3, pmesh)); /* Chooses the diagonal that will split the quad in two triangles that maximize - * the scalar product of of the un-normalized normals of the two triangles. + * the scalar product of the un-normalized normals of the two triangles. * The lengths of the un-normalized normals (computed using cross-products of two vectors) * are proportional to the area of the triangles. * Maximize the scalar product of the two normals will avoid skinny triangles, @@ -353,7 +353,7 @@ bool triangulate_faces(FaceRange face_range, bool result = true; - // One need to store facet handles into a vector, because the list of + // One needs to store the facets into a vector, because the list of // facets of the polyhedron will be modified during the loop, and // that invalidates the range [facets_begin(), facets_end()[. std::vector facets(std::begin(face_range), std::end(face_range)); @@ -553,7 +553,7 @@ public: Point_ref p3 = get(pm, points[polygon[3]]); /* Chooses the diagonal that will split the quad in two triangles that maximize - * the scalar product of of the un-normalized normals of the two triangles. + * the scalar product of the un-normalized normals of the two triangles. * The lengths of the un-normalized normals (computed using cross-products of two vectors) * are proportional to the area of the triangles. * Maximize the scalar product of the two normals will avoid skinny triangles, @@ -596,8 +596,8 @@ public: * triangulates all polygons of a polygon soup. This function depends on the package \ref PkgTriangulation2. * * @tparam PointRange a model of `ConstRange`. The value type of its iterator is the point type. -* @tparam PolygonRange a model of the concept `SequenceContainer` and `Swappable`, -* whose `value_type` is itself a model of the concepts `SequenceContainer` +* @tparam PolygonRange a model of the concepts `SequenceContainer` and `Swappable`, +* whose `value_type` is itself a model of the concept `SequenceContainer` * whose `value_type` is `std::size_t`. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * From 70363a3b9c563ee2f82b2e1420bde3bb8c78549e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 15:29:29 +0200 Subject: [PATCH 20/64] Update CHANGES.md --- Installation/CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 6baa48451f2..062ad6eabe2 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -34,6 +34,8 @@ CGAL tetrahedral Delaunay refinement algorithm. - Added the function `CGAL::Polygon_mesh_processing::remove_almost_degenerate_faces()` to remove badly shaped triangles faces in a mesh. +- Added the function `CGAL::Polygon_mesh_processing::triangulate_polygons()`, which allows users to triangulate polygon soups. + ### [3D Simplicial Mesh Data Structure](https://doc.cgal.org/5.6/Manual/packages.html#PkgSMDS3) (new package) - This new package wraps all the existing code that deals with a `MeshComplex_3InTriangulation_3` to describe 3D simplicial meshes, and makes the data structure independent from the tetrahedral mesh generation package. From 8a39016780a06d9d600934ca8f9f6cff86f2fe02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 15:30:25 +0200 Subject: [PATCH 21/64] Visitor of triangulate_faces must be a visitor of HoleFilling too --- .../CGAL/Polygon_mesh_processing/triangulate_faces.h | 10 ++++++---- .../Plugins/PMP/Triangulate_facets_plugin.cpp | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index d112e6c8dd6..35fc824e4ad 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -44,6 +44,7 @@ namespace Triangulate_faces { */ template struct Default_visitor + : public Hole_filling::Default_visitor { typedef boost::graph_traits GT; typedef typename GT::face_descriptor face_descriptor; @@ -266,7 +267,7 @@ public: * * \cgalParamNBegin{visitor} * \cgalParamDescription{a visitor that enables to track how faces are triangulated into subfaces} -* \cgalParamType{a class model of `PMPTriangulateFaceVisitor`} +* \cgalParamType{a class model of `PMPTriangulateFaceVisitor` and `PMPHolefillingVisitor`} * \cgalParamDefault{`Triangulate_faces::Default_visitor`} * \cgalParamExtra{Note that the visitor will be copied, so * it must not have any data member that does not have a reference-like type.} @@ -325,7 +326,7 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor * * \cgalParamNBegin{visitor} * \cgalParamDescription{a visitor that enables to track how faces are triangulated into subfaces} -* \cgalParamType{a class model of `PMPTriangulateFaceVisitor`} +* \cgalParamType{a class model of `PMPTriangulateFaceVisitor` and `PMPHolefillingVisitor`} * \cgalParamDefault{`Triangulate_faces::Default_visitor`} * \cgalParamExtra{Note that the visitor will be copied, so * it must not have any data member that does not have a reference-like type.} @@ -398,7 +399,7 @@ bool triangulate_faces(FaceRange face_range, * * \cgalParamNBegin{visitor} * \cgalParamDescription{a visitor that enables to track how faces are triangulated into subfaces} -* \cgalParamType{a class model of `PMPTriangulateFaceVisitor`} +* \cgalParamType{a class model of `PMPTriangulateFaceVisitor` and `PMPHolefillingVisitor`} * \cgalParamDefault{`Triangulate_faces::Default_visitor`} * \cgalParamExtra{Note that the visitor will be copied, so * it must not have any data member that does not have a reference-like type.} @@ -436,6 +437,7 @@ namespace Triangulate_polygons { * overridden. */ struct Default_visitor + : public Hole_filling::Default_visitor { template void before_subface_creations(const Polygon& /*f_old*/) {} @@ -622,7 +624,7 @@ public: * * \cgalParamNBegin{visitor} * \cgalParamDescription{a visitor that enables to track how polygons are triangulated into triangles} -* \cgalParamType{a class model of `PMPTriangulateFaceVisitor`} +* \cgalParamType{a class model of `PMPTriangulateFaceVisitor` and `PMPHolefillingVisitor`} * \cgalParamDefault{`Triangulate_polygons::Default_visitor`} * \cgalParamExtra{Note that the visitor will be copied, so * it must not have any data member that does not have a reference-like type.} diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp index 3f86836f4bf..c342e536ff2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp @@ -21,6 +21,7 @@ class Polyhedron_demo_triangulate_facets_plugin : typedef boost::graph_traits::face_descriptor face_descriptor; struct Visitor + : public CGAL::Polygon_mesh_processing::Hole_filling::Default_visitor { typedef typename Scene_polyhedron_selection_item::Selection_set_facet Container; Container& faces; From e5c83238259ff1435c45612c192f3e4dfa9fc922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 15:30:56 +0200 Subject: [PATCH 22/64] Add triangulate_polygons() to the demo --- .../Polyhedron/Plugins/PMP/CMakeLists.txt | 2 +- .../Plugins/PMP/Triangulate_facets_plugin.cpp | 74 ++++++++++++------- .../Polyhedron/Scene_polygon_soup_item.cpp | 41 ++++++---- .../demo/Polyhedron/Scene_polygon_soup_item.h | 1 + 4 files changed, 76 insertions(+), 42 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index adcd4f7f02b..9503348b9b7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -100,7 +100,7 @@ add_custom_target(self_intersection_plugin) add_dependencies(self_intersection_plugin selection_plugin) polyhedron_demo_plugin(triangulate_facets_plugin Triangulate_facets_plugin KEYWORDS PMP) -target_link_libraries(triangulate_facets_plugin PUBLIC scene_surface_mesh_item scene_selection_item) +target_link_libraries(triangulate_facets_plugin PUBLIC scene_surface_mesh_item scene_selection_item scene_polygon_soup_item) polyhedron_demo_plugin(corefinement_plugin Corefinement_plugin KEYWORDS PMP) target_link_libraries(corefinement_plugin PUBLIC scene_surface_mesh_item) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp index c342e536ff2..6b85c6fb45b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Triangulate_facets_plugin.cpp @@ -4,10 +4,13 @@ #include "Messages_interface.h" #include #include + #include "Scene_surface_mesh_item.h" #include "Scene_polyhedron_selection_item.h" +#include "Scene_polygon_soup_item.h" #include + using namespace CGAL::Three; class Polyhedron_demo_triangulate_facets_plugin : public QObject, @@ -20,13 +23,13 @@ class Polyhedron_demo_triangulate_facets_plugin : typedef Scene_surface_mesh_item::Face_graph FaceGraph; typedef boost::graph_traits::face_descriptor face_descriptor; - struct Visitor + struct Selection_updater_visitor : public CGAL::Polygon_mesh_processing::Hole_filling::Default_visitor { typedef typename Scene_polyhedron_selection_item::Selection_set_facet Container; Container& faces; - Visitor(Container& container) + Selection_updater_visitor(Container& container) : faces(container) {} void before_subface_creations(face_descriptor fd) @@ -67,6 +70,8 @@ public: return true; if ( qobject_cast(scene->item(index))) return true; + if(qobject_cast(scene->item(index))) + return true; } return false; } @@ -83,39 +88,54 @@ public Q_SLOTS: Scene_polyhedron_selection_item* selection_item = qobject_cast(scene->item(index)); - SMesh* pMesh = (sm_item != nullptr) - ? sm_item->polyhedron() - : selection_item->polyhedron(); + Scene_polygon_soup_item* soup_item = + qobject_cast(scene->item(index)); - if(!pMesh) continue; - if(is_triangle_mesh(*pMesh)) { - CGAL::Three::Three::warning(tr("The polyhedron \"%1\" is already triangulated.") - .arg(sm_item->name()) ); - continue; - } - if (sm_item) + if (soup_item) { - if (!CGAL::Polygon_mesh_processing::triangulate_faces(*pMesh)) - CGAL::Three::Three::warning(tr("Some facets could not be triangulated.")); + soup_item->triangulate(); } - else if (selection_item) + else { - Visitor visitor(selection_item->selected_facets); - if (!CGAL::Polygon_mesh_processing::triangulate_faces( - selection_item->selected_facets, - *pMesh, - CGAL::parameters::visitor(visitor))) - CGAL::Three::Three::warning(tr("Some facets could not be triangulated.")); + SMesh* pMesh = (sm_item != nullptr) ? sm_item->polyhedron() + : selection_item->polyhedron(); - sm_item = selection_item->polyhedron_item(); - selection_item->set_num_faces(num_faces(*sm_item->face_graph())); + if(!pMesh) + continue; - selection_item->invalidateOpenGLBuffers(); - selection_item->itemChanged(); + if(is_triangle_mesh(*pMesh)) + { + CGAL::Three::Three::warning(tr("The polyhedron \"%1\" is already triangulated.") + .arg(sm_item->name()) ); + continue; + } + + if (sm_item) + { + if (!CGAL::Polygon_mesh_processing::triangulate_faces(*pMesh)) + CGAL::Three::Three::warning(tr("Some facets could not be triangulated.")); + + sm_item->invalidateOpenGLBuffers(); + } + else if (selection_item) + { + Selection_updater_visitor visitor(selection_item->selected_facets); + if (!CGAL::Polygon_mesh_processing::triangulate_faces( + selection_item->selected_facets, + *pMesh, + CGAL::parameters::visitor(visitor))) + CGAL::Three::Three::warning(tr("Some facets could not be triangulated.")); + + sm_item = selection_item->polyhedron_item(); + selection_item->set_num_faces(num_faces(*sm_item->face_graph())); + + selection_item->invalidateOpenGLBuffers(); + selection_item->itemChanged(); + } + + sm_item->resetColors(); // @todo should have a visitor to give the color of the parent face } - sm_item->resetColors(); - sm_item->invalidateOpenGLBuffers(); scene->itemChanged(sm_item); } // end of the loop on the selected items diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp index b258e0c5714..8ba8813f349 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -419,6 +420,32 @@ void Scene_polygon_soup_item::inside_out() invalidateOpenGLBuffers(); } +void Scene_polygon_soup_item::repair(bool erase_dup, bool req_same_orientation) +{ + QApplication::setOverrideCursor(Qt::BusyCursor); + CGAL::Polygon_mesh_processing::repair_polygon_soup( + d->soup->points, + d->soup->polygons, + CGAL::parameters::erase_all_duplicates(erase_dup) + .require_same_orientation(req_same_orientation)); + QApplication::restoreOverrideCursor(); + invalidateOpenGLBuffers(); +} + +bool Scene_polygon_soup_item::triangulate() +{ + QApplication::setOverrideCursor(Qt::BusyCursor); + + bool success = true; + + CGAL::Polygon_mesh_processing::triangulate_polygons(d->soup->points, d->soup->polygons); + + QApplication::restoreOverrideCursor(); + invalidateOpenGLBuffers(); + + return success; +} + bool Scene_polygon_soup_item::orient(std::vector& non_manifold_vertices) { @@ -894,20 +921,6 @@ void Scene_polygon_soup_item::computeElements() const QApplication::restoreOverrideCursor(); } -void Scene_polygon_soup_item::repair(bool erase_dup, bool req_same_orientation) -{ - QApplication::setOverrideCursor(Qt::BusyCursor); - CGAL::Polygon_mesh_processing::repair_polygon_soup( - d->soup->points, - d->soup->polygons, - CGAL::parameters:: - erase_all_duplicates(erase_dup) - .require_same_orientation(req_same_orientation)); - QApplication::restoreOverrideCursor(); - - // CGAL::Three::Three::information( -} - CGAL::Three::Scene_item::Header_data Scene_polygon_soup_item::header() const { CGAL::Three::Scene_item::Header_data data; diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h index 5dea8c11f02..9fd1aed124f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h @@ -187,6 +187,7 @@ public Q_SLOTS: bool exportAsSurfaceMesh(SMesh*); void inside_out(); void repair(bool erase_dup, bool req_same_orientation); + bool triangulate(); void setDisplayNonManifoldEdges(const bool); bool displayNonManifoldEdges() const; From c346b4a8365208ea6334515771792d1a2d83b0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 15:46:42 +0200 Subject: [PATCH 23/64] Avoid repetition --- .../include/CGAL/Polygon_mesh_processing/triangulate_faces.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 35fc824e4ad..991113b438b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -623,7 +623,7 @@ public: * \cgalParamNEnd * * \cgalParamNBegin{visitor} -* \cgalParamDescription{a visitor that enables to track how polygons are triangulated into triangles} +* \cgalParamDescription{a visitor that enables to track how polygons are divided into triangles} * \cgalParamType{a class model of `PMPTriangulateFaceVisitor` and `PMPHolefillingVisitor`} * \cgalParamDefault{`Triangulate_polygons::Default_visitor`} * \cgalParamExtra{Note that the visitor will be copied, so From 8f3968000e8cbc222b9ee83396d726e864e696a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 21:09:44 +0200 Subject: [PATCH 24/64] Fix visitor --- .../Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index a15e1f14dfd..37dcedc8adb 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -178,12 +178,13 @@ class Polyhedron_demo_isotropic_remeshing_plugin : typedef std::unordered_set Edge_set; typedef Scene_polyhedron_selection_item::Is_constrained_map Edge_constrained_pmap; - struct Visitor + struct Selection_updater_visitor + : public CGAL::Polygon_mesh_processing::Hole_filling::Default_visitor { typedef typename Scene_polyhedron_selection_item::Selection_set_facet Container; Container& faces; - Visitor(Container& container) + Selection_updater_visitor(Container& container) : faces(container) {} @@ -493,7 +494,7 @@ public Q_SLOTS: (QMessageBox::Ok | QMessageBox::Cancel), QMessageBox::Ok)) { - Visitor visitor(selection_item->selected_facets); + Selection_updater_visitor visitor(selection_item->selected_facets); CGAL::Polygon_mesh_processing::triangulate_faces(selection_item->selected_facets, pmesh, CGAL::parameters::visitor(visitor)); From 23f3813458dcd4219c5a6d4abf53fd123cd18dce Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Sat, 1 Apr 2023 11:48:51 +0300 Subject: [PATCH 25/64] Fixed typos in Minkowski sum bug fix description --- Installation/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 25e9701c791..ead4fb05d23 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -106,7 +106,7 @@ extracted from labeled images. ### [2D Minkowski Sums](https://doc.cgal.org/5.6/Manual/packages.html#PkgMinkowskiSum2) - Fixed a bug that made holes in the Minkowski sum disappear -- Fixed hole filtering. The code use to erroneously remove holes from the container of holes of polygons with holes that did not affect the mink. sum. Now it simply adds those that do affect it. +- Fixed hole filtering. The code used to erroneously remove holes from the container of holes of polygons with holes that did not affect the minkowsi sum. Now it simply adds those that do affect it. [Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5) ----------- From 8ee3eecc85655a680c41c8d5ac27e9c805c9a68e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 08:33:51 +0100 Subject: [PATCH 26/64] Remove unused typedefs --- .../include/CGAL/Polygon_mesh_processing/triangulate_faces.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 991113b438b..1db068ef470 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -168,7 +168,6 @@ public: using FT = typename Traits::FT; using Point_ref = typename boost::property_traits::reference; - using Vector = typename Traits::Vector_3; using Visitor = typename internal_np::Lookup_named_param_def< internal_np::visitor_t, @@ -471,7 +470,6 @@ private: namespace PMP = CGAL::Polygon_mesh_processing; using Point = typename boost::property_traits::value_type; - using Kernel = typename CGAL::Kernel_traits::type; // gather halfedges around the face std::vector hole_points; From e816f17ef496dffc7fa44ac805a75350206bc90f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 08:47:07 +0100 Subject: [PATCH 27/64] Derive Visitor in example to have default implementations of some callbacks --- .../triangulate_faces_split_visitor_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp index f46d09e0f2b..9b246f7678d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_split_visitor_example.cpp @@ -41,7 +41,7 @@ public: }; -struct Visitor +struct Visitor : public CGAL::Polygon_mesh_processing::Triangulate_faces::Default_visitor { typedef std::unordered_map Container; From 49b8f1f7fbe73d32ae2da5bd381a77fa38edfd91 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 23 Mar 2023 14:41:46 +0100 Subject: [PATCH 28/64] Add partial specializations of boost::multiprecision::is_byte_container --- Installation/include/CGAL/config.h | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 22fe30a1823..2149ea244cd 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -597,4 +597,40 @@ inline std::string data_file_path(const std::string& filename) } // end namespace CGAL + +// Workaround for an accidental enable if of Eigen::Matrix in the +// boost::multiprecision::cpp_int constructor for some versions of +// boost + +namespace Eigen{ + template + class Matrix; + template + class Ref; + +} + +namespace boost { + namespace multiprecision { + namespace detail { + template + struct is_byte_container; + + + template + struct is_byte_container< Eigen::Matrix> + { + static const bool value = false; + }; + + template + struct is_byte_container< Eigen::Ref> + { + static const bool value = false; + }; + + } + } +} + #endif // CGAL_CONFIG_H From a9cf79e512c65664663080892ae65be33e4c105d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:21:00 +0100 Subject: [PATCH 29/64] Add more partial specializations --- Installation/include/CGAL/config.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 2149ea244cd..2396191a639 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -608,6 +608,11 @@ namespace Eigen{ template class Ref; + template + class Product; + + template class CwiseBinaryOp; + } namespace boost { @@ -629,6 +634,18 @@ namespace boost { static const bool value = false; }; + template + struct is_byte_container< Eigen::Product> + { + static const bool value = false; + }; + + template + struct is_byte_container< Eigen::CwiseBinaryOp> + { + static const bool value = false; + }; + } } } From 3d9e5898538d4b3fc27b42858271716405c54bb8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:42:17 +0100 Subject: [PATCH 30/64] Remove default value --- Installation/include/CGAL/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 2396191a639..422c4600825 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -608,7 +608,7 @@ namespace Eigen{ template class Ref; - template + template class Product; template class CwiseBinaryOp; From be85b37b374aa67394c6f5f3e9654dc9514d4ec5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:42:43 +0100 Subject: [PATCH 31/64] Simplify expressions --- .../include/CGAL/PCA_util_Eigen.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h index e7fd18b8842..f4a8fc09f80 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h +++ b/Principal_component_analysis/include/CGAL/PCA_util_Eigen.h @@ -368,7 +368,7 @@ assemble_covariance_matrix_3(InputIterator first, transformation << radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius; - FT volume = (FT)(4.0/3.0) * radius * t.squared_radius(); + FT volume = radius * t.squared_radius(); // skip zero measure primitives if(volume == (FT)0.0) @@ -377,8 +377,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (3.0/4.0) * volume * transformation * moment * transformation.transpose(); + transformation = volume * transformation * moment * transformation.transpose(); + volume *= FT(4.0 / 3.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); @@ -453,7 +454,7 @@ assemble_covariance_matrix_3(InputIterator first, transformation << radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius; - FT area = (FT)4.0 * t.squared_radius(); + FT area = t.squared_radius(); // skip zero measure primitives if(area == (FT)0.0) @@ -462,8 +463,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (1.0/4.0) * area * transformation * moment * transformation.transpose(); + transformation = area * transformation * moment * transformation.transpose(); + area *= FT(4.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); From b5f44bdac113c22a9c7b363b53bac25b2276f3c2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 10:55:31 +0100 Subject: [PATCH 32/64] Activate workaround only for boost < 1.79 --- Installation/include/CGAL/config.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 422c4600825..38e6788a438 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -598,6 +598,8 @@ inline std::string data_file_path(const std::string& filename) } // end namespace CGAL +#if BOOST_VERSION < 107900 + // Workaround for an accidental enable if of Eigen::Matrix in the // boost::multiprecision::cpp_int constructor for some versions of // boost @@ -650,4 +652,6 @@ namespace boost { } } +#endif + #endif // CGAL_CONFIG_H From 246cc9ba0b90797bd16d42e059a042ec284df9d1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 4 Apr 2023 11:16:52 +0100 Subject: [PATCH 33/64] Simplify expressions --- Principal_component_analysis/include/CGAL/PCA_util.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/PCA_util.h b/Principal_component_analysis/include/CGAL/PCA_util.h index 9e3508a68a6..d3f7215d801 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util.h +++ b/Principal_component_analysis/include/CGAL/PCA_util.h @@ -391,7 +391,7 @@ assemble_covariance_matrix_3(InputIterator first, 0.0, radius, 0.0, 0.0, 0.0, radius}; Matrix transformation = init_matrix(3,delta); - FT volume = (FT)(4.0/3.0) * radius * t.squared_radius(); + FT volume = radius * t.squared_radius(); // skip zero measure primitives if(volume == (FT)0.0) @@ -400,8 +400,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (3.0/4.0) * volume * transformation * moment * LA::transpose(transformation); + transformation = volume * transformation * moment * LA::transpose(transformation); + volume *= FT(4.0/3.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); @@ -476,7 +477,7 @@ assemble_covariance_matrix_3(InputIterator first, 0.0, radius, 0.0, 0.0, 0.0, radius}; Matrix transformation = init_matrix(3,delta); - FT area = (FT)4.0 * t.squared_radius(); + FT area = t.squared_radius(); // skip zero measure primitives if(area == (FT)0.0) @@ -485,8 +486,9 @@ assemble_covariance_matrix_3(InputIterator first, // Find the 2nd order moment for the sphere wrt to the origin by an affine transformation. // Transform the standard 2nd order moment using the transformation matrix - transformation = (1.0/4.0) * area * transformation * moment * LA::transpose(transformation); + transformation = area * transformation * moment * LA::transpose(transformation); + area *= FT(4.0); // Translate the 2nd order moment to the center of the sphere. FT x0 = t.center().x(); FT y0 = t.center().y(); From 5828644133924676f63f8cfd7e947c64e43a563b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 5 Apr 2023 17:24:04 +0200 Subject: [PATCH 34/64] fix warnings --- .../internal/Hole_filling/Triangulate_hole_polygon_mesh.h | 6 ++++++ .../CGAL/Polygon_mesh_processing/triangulate_hole.h | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h index ab837b05c88..7b36d3295ec 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h @@ -22,6 +22,7 @@ #endif #include #include +#include #include namespace CGAL { @@ -107,6 +108,11 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, Visitor& visitor, const typename Kernel::FT max_squared_distance) { +#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 + CGAL_USE(use_cdt); + CGAL_USE(max_squared_distance); +#endif + typedef Halfedge_around_face_circulator Hedge_around_face_circulator; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h index 46c3a6904be..ba55ceca89e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_hole.h @@ -729,11 +729,8 @@ namespace Polygon_mesh_processing { using parameters::get_parameter; using parameters::get_parameter_reference; - bool use_cdt = -#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 - false; -#else - choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 + bool use_cdt = choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); #endif bool use_dt3 = #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 From df17ad5e245c2189dbb5d29d21da49342a4479f9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 6 Apr 2023 12:47:07 +0200 Subject: [PATCH 35/64] Add a comment to the closing #endif --- Installation/include/CGAL/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 38e6788a438..d492dafc046 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -652,6 +652,6 @@ namespace boost { } } -#endif +#endif // BOOST_VERSION < 107900 #endif // CGAL_CONFIG_H From 3262b21ed76213a8bd14b0511ddd2104ed76c60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 10 Jan 2023 19:09:58 +0100 Subject: [PATCH 36/64] do not evaluate other options if the parameter is provided --- .../CGAL/boost/graph/named_params_helper.h | 100 +++++++++++++++--- 1 file changed, 83 insertions(+), 17 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 1d68f2a6f87..6c438270980 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -110,22 +110,75 @@ public: typedef typename boost::property_traits::value_type type; }; + +template +struct GetVertexPointMap_impl +{ + typedef VPM_from_NP type; + typedef VPM_from_NP const_type; + + template + static const_type + get_const_map(const NamedParameters& np, const PolygonMesh&) + { + return parameters::get_parameter(np, internal_np::vertex_point); + } + + template + static type + get_map(const NamedParameters& np, PolygonMesh&) + { + return parameters::get_parameter(np, internal_np::vertex_point); + } +}; + +template +struct GetVertexPointMap_impl +{ + typedef typename property_map_selector::const_type const_type; + typedef typename property_map_selector::type type; + + template + static const_type + get_const_map(const NamedParameters& np, const PolygonMesh& pm) + { + return get_const_property_map(boost::vertex_point, pm); + } + + template + static type + get_map(const NamedParameters& np, PolygonMesh& pm) + { + return get_property_map(boost::vertex_point, pm); + } +}; + template class GetVertexPointMap { - typedef typename property_map_selector::const_type - DefaultVPMap_const; - typedef typename property_map_selector::type - DefaultVPMap; + typedef typename internal_np::Lookup_named_param_def::type VPM_from_NP; + + typedef GetVertexPointMap_impl Impl; public: - typedef typename internal_np::Lookup_named_param_def::type type; - typedef typename internal_np::Lookup_named_param_def::type const_type; + typedef typename Impl::type type; + typedef typename Impl::const_type const_type; + + static const_type + get_const_map(const NamedParameters& np, const PolygonMesh& pm) + { + return Impl::get_const_map(np, pm); + } + + static type + get_map(const NamedParameters& np, PolygonMesh& pm) + { + return Impl::get_map(np, pm); + } }; template @@ -138,10 +191,15 @@ public: typedef typename CGAL::Kernel_traits::Kernel Kernel; }; -template -class GetGeomTraits + +template +struct GetGeomTraits_impl +{ + typedef GT type; +}; + +template +struct GetGeomTraits_impl { typedef typename CGAL::graph_has_property::type Has_internal_pmap; @@ -154,12 +212,20 @@ class GetGeomTraits typedef typename boost::mpl::if_c::value, typename GetK::Kernel, - Fake_GT>::type DefaultKernel; + Fake_GT>::type type; +}; -public: +template +struct GetGeomTraits +{ typedef typename internal_np::Lookup_named_param_def::type type; + internal_np::Param_not_found>::type GT_from_NP; + typedef typename GetGeomTraits_impl::type type; }; // Define the following structs: From fb7d892e36e54e45e51f3b05609f6763d571feea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Apr 2023 19:12:39 +0200 Subject: [PATCH 37/64] add help for geom traits for function dealing with polygon soups --- .../CGAL/boost/graph/named_params_helper.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 6c438270980..f5b8c44df82 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -344,6 +344,21 @@ public: typedef typename CGAL::Identity_property_map const_type; }; +template +struct GetPolygonSoupGeomTraits +{ + typedef typename internal_np::Lookup_named_param_def < + internal_np::geom_traits_t, + NamedParameters, + typename CGAL::Kernel_traits< + typename boost::property_traits< + typename GetPointMap::type + >::value_type + >::type + > ::type type; +}; + + template struct Point_set_processing_3_np_helper { From dd4a4420f0823984449023166169ccdc70709789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 5 Jan 2023 08:45:09 +0100 Subject: [PATCH 38/64] soup/mesh abstraction --- .../self_intersections.h | 203 +++++++++++++----- 1 file changed, 150 insertions(+), 53 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index cc07ed99f65..f89e5fddef3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -54,6 +54,115 @@ namespace CGAL { namespace Polygon_mesh_processing { namespace internal { +template +struct Triangle_mesh_and_triangle_soup_wrapper +{ + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; // private + + static void get_face_vertices(face_descriptor fd, std::array& vh, const TM& tm) + { + CGAL_assertion(boost::graph_traits::null_face() != fd); + halfedge_descriptor h = halfedge(fd, tm); + vh[0]=source(h, tm); + vh[1]=target(h, tm); + vh[2]=target(next(h, tm), tm); + } + + static bool faces_have_a_shared_edge(face_descriptor f, face_descriptor g, std::array& vh, const TM& tm) + { + CGAL_assertion(boost::graph_traits::null_face() != f); + CGAL_assertion(boost::graph_traits::null_face() != g); + halfedge_descriptor h=halfedge(f, tm); + for(unsigned int i=0; i<3; ++i) + { + halfedge_descriptor opp_h = opposite(h, tm); + if(face(opp_h, tm) == g) + { + vh[0]=source(h, tm); + vh[1]=target(h, tm); + vh[2]=target(next(h, tm), tm); + vh[3]=target(next(opp_h, tm), tm); + return true; + } + h = next(h, tm); + } + return false; + } +}; + +template +struct Triangle_mesh_and_triangle_soup_wrapper< + std::pair, + std::reference_wrapper>> +{ + typedef std::size_t face_descriptor; + typedef std::size_t vertex_descriptor; + + typedef std::pair, + std::reference_wrapper > Soup; + + static void get_face_vertices(face_descriptor fd, std::array& vh, const Soup& soup) + { + const auto& face = soup.second.get()[fd]; + vh[0]=face[0]; + vh[1]=face[1]; + vh[2]=face[2]; + } + + static bool faces_have_a_shared_edge(face_descriptor fd, face_descriptor gd, std::array& vh, const Soup& soup) + { + const auto& f = soup.second.get()[fd]; + const auto& g = soup.second.get()[gd]; + + for(unsigned int i=0; i<3; ++i) + { + for(unsigned int j=0; j<3; ++j) + { + if (f[i]==g[j]) + { + vh[0]=f[i]; + vh[1]=f[(i+1)%3]; + vh[2]=f[(i+2)%3]; + + if (vh[1]==g[(j+1)%3]) + { + vh[3]=g[(j+2)%3]; + return true; + } + if (vh[1]==g[(j+2)%3]) + { + vh[3]=g[(j+1)%3]; + return true; + } + + if (i==0) + { + vh[1]=f[i]; + vh[2]=f[(i+1)%3]; + vh[0]=f[(i+2)%3]; + if (vh[0]==g[(j+1)%3]) + { + vh[3]=g[(j+2)%3]; + return true; + } + if (vh[0]==g[(j+2)%3]) + { + vh[3]=g[(j+1)%3]; + return true; + } + } + + return false; + } + } + } + + return false; + } +}; + template struct Throw_at_count_reached_functor { @@ -82,59 +191,49 @@ struct Throw_at_count_reached_functor { // Checks for 'real' intersections, i.e. not simply a shared vertex or edge template -bool do_faces_intersect(typename boost::graph_traits::halfedge_descriptor h, - typename boost::graph_traits::halfedge_descriptor g, +bool do_faces_intersect(typename Triangle_mesh_and_triangle_soup_wrapper::face_descriptor fh, + typename Triangle_mesh_and_triangle_soup_wrapper::face_descriptor fg, const TM& tmesh, const VPM vpmap, const typename GT::Construct_segment_3& construct_segment, const typename GT::Construct_triangle_3& construct_triangle, const typename GT::Do_intersect_3& do_intersect) { - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef Triangle_mesh_and_triangle_soup_wrapper Wrapper; + typedef typename Wrapper::vertex_descriptor vertex_descriptor; - typedef typename GT::Segment_3 Segment; - typedef typename GT::Triangle_3 Triangle; + typedef typename GT::Segment_3 Segment; + typedef typename GT::Triangle_3 Triangle; - CGAL_assertion(!is_border(h, tmesh)); - CGAL_assertion(!is_border(g, tmesh)); - vertex_descriptor hv[3], gv[3]; - hv[0] = target(h, tmesh); - hv[1] = target(next(h, tmesh), tmesh); - hv[2] = source(h, tmesh); - - gv[0] = target(g, tmesh); - gv[1] = target(next(g, tmesh), tmesh); - gv[2] = source(g, tmesh); + std::array hv, gv; + Wrapper::get_face_vertices(fh, hv, tmesh); + Wrapper::get_face_vertices(fg, gv, tmesh); // check for shared edge - for(unsigned int i=0; i<3; ++i) + std::array verts; + if (Wrapper::faces_have_a_shared_edge(fh, fg, verts, tmesh)) { - halfedge_descriptor opp_h = opposite(h, tmesh); - if(face(opp_h, tmesh) == face(g, tmesh)) - { - // there is an intersection if the four points are coplanar and the triangles overlap - if(CGAL::coplanar(get(vpmap, hv[i]), - get(vpmap, hv[(i+1)%3]), - get(vpmap, hv[(i+2)%3]), - get(vpmap, target(next(opp_h, tmesh), tmesh))) && - CGAL::coplanar_orientation(get(vpmap, hv[(i+2)%3]), - get(vpmap, hv[i]), - get(vpmap, hv[(i+1)%3]), - get(vpmap, target(next(opp_h, tmesh), tmesh))) - == CGAL::POSITIVE) - { - return true; - } - else - { - // there is a shared edge but no intersection - return false; - } - } + if (verts[2]==verts[3]) return false; // only for a soup of triangles - h = next(h, tmesh); + // there is an intersection if the four points are coplanar and the triangles overlap + if(CGAL::coplanar(get(vpmap, verts[0]), + get(vpmap, verts[1]), + get(vpmap, verts[2]), + get(vpmap, verts[3])) && + CGAL::coplanar_orientation(get(vpmap, verts[0]), + get(vpmap, verts[1]), + get(vpmap, verts[2]), + get(vpmap, verts[3])) + == CGAL::POSITIVE) + { + return true; + } + else + { + // there is a shared edge but no intersection + return false; + } } // check for shared vertex --> maybe intersection, maybe not @@ -188,8 +287,6 @@ template struct Strict_intersect_faces // "strict" as in "not sharing a subface" { - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - mutable OutputIterator m_iterator; const TM& m_tmesh; const VPM m_vpmap; @@ -209,10 +306,7 @@ struct Strict_intersect_faces // "strict" as in "not sharing a subface" void operator()(const Box* b, const Box* c) const { - const halfedge_descriptor h = halfedge(b->info(), m_tmesh); - const halfedge_descriptor g = halfedge(c->info(), m_tmesh); - - if(do_faces_intersect(h, g, m_tmesh, m_vpmap, m_construct_segment, m_construct_triangle, m_do_intersect)) + if(do_faces_intersect(b->info(), c->info(), m_tmesh, m_vpmap, m_construct_segment, m_construct_triangle, m_do_intersect)) *m_iterator++ = std::make_pair(b->info(), c->info()); } }; @@ -236,8 +330,9 @@ self_intersections_impl(const FaceRange& face_range, using CGAL::parameters::is_default_parameter; typedef TriangleMesh TM; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef Triangle_mesh_and_triangle_soup_wrapper Wrapper; + typedef typename Wrapper::face_descriptor face_descriptor; + typedef typename Wrapper::vertex_descriptor vertex_descriptor; typedef CGAL::Box_intersection_d::ID_FROM_BOX_ADDRESS Box_policy; typedef CGAL::Box_intersection_d::Box_with_info_d Box; @@ -268,11 +363,13 @@ self_intersections_impl(const FaceRange& face_range, // This loop is very cheap, so there is hardly anything to gain from parallelizing it for(face_descriptor f : face_range) { - halfedge_descriptor h = halfedge(f, tmesh); + std::array vh; + Wrapper::get_face_vertices(f, vh, tmesh); + typename boost::property_traits::reference - p = get(vpmap, target(h,tmesh)), - q = get(vpmap, target(next(h, tmesh), tmesh)), - r = get(vpmap, target(prev(h, tmesh), tmesh)); + p = get(vpmap, vh[0]), + q = get(vpmap, vh[1]), + r = get(vpmap, vh[2]); // tiny fixme: if f is degenerate, we might still have a real intersection between f // and another face f', but right now we are not creating a box for f and thus not returning those @@ -342,7 +439,7 @@ self_intersections_impl(const FaceRange& face_range, std::atomic atomic_counter(counter); Throw_functor throwing_count_functor(atomic_counter, maximum_number, std::back_inserter(face_pairs)); Throwing_after_count_output_iterator count_filter(throwing_count_functor); - Filtered_intersecting_faces_filter limited_callback(tmesh, vpmap, gt, count_filter); + Filtered_intersecting_faces_filter limited_callback(tmesh, vpmap, gt, count_filter); CGAL::box_self_intersection_d(box_ptr.begin(), box_ptr.end(), limited_callback, cutoff); } catch(const CGAL::internal::Throw_at_output_exception&) From f8ab63088a8c482095af34624380d9b46eea4a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 10 Jan 2023 19:19:32 +0100 Subject: [PATCH 39/64] add self-intersection functions for soup no doc for now --- .../self_intersections.h | 112 ++++++++++++++++-- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index f89e5fddef3..a00ea645f7e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -43,6 +43,7 @@ #endif #include +#include #include #include @@ -94,8 +95,8 @@ struct Triangle_mesh_and_triangle_soup_wrapper template struct Triangle_mesh_and_triangle_soup_wrapper< - std::pair, - std::reference_wrapper>> + std::pair> { typedef std::size_t face_descriptor; typedef std::size_t vertex_descriptor; @@ -116,14 +117,14 @@ struct Triangle_mesh_and_triangle_soup_wrapper< const auto& f = soup.second.get()[fd]; const auto& g = soup.second.get()[gd]; - for(unsigned int i=0; i<3; ++i) + for(unsigned int i=0; i<2; ++i) // no need to check f[2] if neither f[0] nor f[1] are shared { for(unsigned int j=0; j<3; ++j) { if (f[i]==g[j]) { vh[0]=f[i]; - vh[1]=f[(i+1)%3]; + vh[1]=f[i+1]; vh[2]=f[(i+2)%3]; if (vh[1]==g[(j+1)%3]) @@ -340,9 +341,9 @@ self_intersections_impl(const FaceRange& face_range, typedef typename GetGeomTraits::type GT; GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); - typedef typename GetVertexPointMap::const_type VPM; - VPM vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_const_property_map(boost::vertex_point, tmesh)); + typedef GetVertexPointMap VPM_helper; + typedef typename VPM_helper::const_type VPM; + VPM vpmap = VPM_helper::get_const_map(np, tmesh); const bool do_limit = !(is_default_parameter::value); const unsigned int maximum_number = choose_parameter(get_parameter(np, internal_np::maximum_number), 0); @@ -753,6 +754,103 @@ bool does_self_intersect(const TriangleMesh& tmesh, return does_self_intersect(faces(tmesh), tmesh, np); } + +#ifndef DOXYGEN_RUNNING + +template +struct Property_map_for_soup +{ + typedef std::size_t key_type; + typedef typename boost::property_traits::value_type value_type; + //typedef typename boost::property_traits::category category; + typedef boost::readable_property_map_tag category; + typedef typename boost::property_traits::reference reference; + + const PointRange& points; + VPM vpm; + + Property_map_for_soup(const PointRange& points, VPM vpm) + : points(points) + , vpm(vpm) + {} + + inline friend + reference get(const Property_map_for_soup& map, key_type k) + { + return get(map.vpm, map.points[k]); + } +}; + +template +FacePairOutputIterator +triangle_soup_self_intersections(const PointRange& points, + const TriangleRange& triangles, + FacePairOutputIterator out, + const CGAL_NP_CLASS& np = parameters::default_values()) +{ + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef typename CGAL::GetPointMap::const_type Point_map_base; + Point_map_base pm_base = choose_parameter(get_parameter(np, internal_np::point_map)); + typedef Property_map_for_soup Point_map; + + return self_intersections(boost::irange(0, triangles.size()), + std::make_pair(std::cref(points), std::cref(triangles)), + out, + parameters::vertex_point_map(Point_map(points,pm_base))); +} + +template +bool does_triangle_soup_self_intersect(const PointRange& points, + const TriangleRange& triangles, + const CGAL_NP_CLASS& np = parameters::default_values()) +{ + try + { + using parameters::choose_parameter; + using parameters::get_parameter; + + CGAL::Emptyset_iterator unused_out; + typedef typename CGAL::GetPointMap::const_type Point_map_base; + Point_map_base pm_base = choose_parameter(get_parameter(np, internal_np::point_map)); + typedef Property_map_for_soup Point_map; + + typename Kernel_traits::value_type>::Kernel k; + + internal::self_intersections_impl(boost::irange(0, triangles.size()), + std::make_pair(std::cref(points), std::cref(triangles)), + unused_out, true /*throw*/, + parameters::vertex_point_map(Point_map(points,pm_base)) + .geom_traits(k)); + } + catch (const CGAL::internal::Throw_at_output_exception&) + { + return true; + } + #if defined(CGAL_LINKED_WITH_TBB) && TBB_USE_CAPTURED_EXCEPTION + catch (const tbb::captured_exception& e) + { + const char* ti1 = e.name(); + const char* ti2 = typeid(const CGAL::internal::Throw_at_output_exception&).name(); + const std::string tn1(ti1); + const std::string tn2(ti2); + if (tn1 == tn2) return true; + else throw; + } + #endif + return false; +} + +#endif + }// namespace Polygon_mesh_processing }// namespace CGAL From 96868b9fc4086d3ac790656debbbf0095ebe262d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 12 Jan 2023 13:42:40 +0100 Subject: [PATCH 40/64] fix debug code --- .../self_intersections.h | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index a00ea645f7e..5ea0d530eb3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -91,6 +91,11 @@ struct Triangle_mesh_and_triangle_soup_wrapper } return false; } + + static bool is_pure_triangle(const TM& tm) + { + return is_triangle_mesh(tm); + } }; template @@ -101,12 +106,11 @@ struct Triangle_mesh_and_triangle_soup_wrapper< typedef std::size_t face_descriptor; typedef std::size_t vertex_descriptor; - typedef std::pair, - std::reference_wrapper > Soup; + typedef std::pair Soup; static void get_face_vertices(face_descriptor fd, std::array& vh, const Soup& soup) { - const auto& face = soup.second.get()[fd]; + const auto& face = soup.second[fd]; vh[0]=face[0]; vh[1]=face[1]; vh[2]=face[2]; @@ -114,8 +118,8 @@ struct Triangle_mesh_and_triangle_soup_wrapper< static bool faces_have_a_shared_edge(face_descriptor fd, face_descriptor gd, std::array& vh, const Soup& soup) { - const auto& f = soup.second.get()[fd]; - const auto& g = soup.second.get()[gd]; + const auto& f = soup.second[fd]; + const auto& g = soup.second[gd]; for(unsigned int i=0; i<2; ++i) // no need to check f[2] if neither f[0] nor f[1] are shared { @@ -162,6 +166,14 @@ struct Triangle_mesh_and_triangle_soup_wrapper< return false; } + + static bool is_pure_triangle(const Soup& soup) + { + for (const typename std::iterator_traits::value_type& t : soup.second) + if (t.size()!=3) + return false; + return true; + } }; template @@ -324,14 +336,15 @@ self_intersections_impl(const FaceRange& face_range, const bool throw_on_SI, const NamedParameters& np) { - CGAL_precondition(CGAL::is_triangle_mesh(tmesh)); + typedef TriangleMesh TM; + typedef Triangle_mesh_and_triangle_soup_wrapper Wrapper; + + CGAL_precondition(Wrapper::is_pure_triangle(tmesh)); using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; using CGAL::parameters::is_default_parameter; - typedef TriangleMesh TM; - typedef Triangle_mesh_and_triangle_soup_wrapper Wrapper; typedef typename Wrapper::face_descriptor face_descriptor; typedef typename Wrapper::vertex_descriptor vertex_descriptor; @@ -682,8 +695,6 @@ bool does_self_intersect(const FaceRange& face_range, const TriangleMesh& tmesh, const NamedParameters& np = parameters::default_values()) { - CGAL_precondition(CGAL::is_triangle_mesh(tmesh)); - try { CGAL::Emptyset_iterator unused_out; From 5f3d748e19e2142dd3b42f02b150bf87983723e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 28 Mar 2023 16:41:32 +0200 Subject: [PATCH 41/64] add doc for self-intersection related functions for soups --- .../PackageDescription.txt | 2 + .../self_intersections.h | 125 ++++++++++++++++-- 2 files changed, 114 insertions(+), 13 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 8141fbd16f2..8f85c769189 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -150,6 +150,8 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. \cgalCRPSection{Intersection Functions} - `CGAL::Polygon_mesh_processing::does_self_intersect()` - `CGAL::Polygon_mesh_processing::self_intersections()` +- `CGAL::Polygon_mesh_processing::does_triangle_soup_self_intersect()` +- `CGAL::Polygon_mesh_processing::triangle_soup_self_intersections()` - \link PMP_intersection_grp `CGAL::Polygon_mesh_processing::do_intersect()` \endlink - `CGAL::Polygon_mesh_processing::intersecting_meshes()` diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index 5ea0d530eb3..f331c79ef17 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -601,9 +601,9 @@ self_intersections(const FaceRange& face_range, * * @param tmesh the triangulated surface mesh to be checked * @param out output iterator to be filled with all pairs of non-adjacent faces that intersect. - In case `tmesh` contains some degenerate faces, for each degenerate face `f` a pair `(f,f)` - will be put in `out` before any other self intersection between non-degenerate faces. - These are the only pairs where degenerate faces will be reported. + * In case `tmesh` contains some degenerate faces, for each degenerate face `f` a pair `(f,f)` + * will be put in `out` before any other self intersection between non-degenerate faces. + * These are the only pairs where degenerate faces will be reported. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -767,7 +767,6 @@ bool does_self_intersect(const TriangleMesh& tmesh, #ifndef DOXYGEN_RUNNING - template struct Property_map_for_soup { @@ -791,16 +790,71 @@ struct Property_map_for_soup return get(map.vpm, map.points[k]); } }; +#endif +/** + * \ingroup PMP_intersection_grp + * + * collects intersections between all the triangles in a triangle soup. + * + * Two triangles of the soup are said to intersect if the corresponding geometric triangles intersect + * and the intersection is not an edge nor a vertex of both triangles + * (with the same point ids, ignoring the orientation for an edge). + * + * A triangle soup self-intersects if at least two triangles of the soup intersect. + * Two triangles of the soup are considered to intersect if the geometric triangles are not disjoint + * and the intersection is not a restricted to the same point (i.e. with the same id) or to a triangle edge + * (i.e. with the same ids, the edge orientation being ignored). + * + * This function depends on the package \ref PkgBoxIntersectionD + * + * @tparam ConcurrencyTag enables sequential versus parallel algorithm. + * Possible values are `Sequential_tag`, `Parallel_tag`, and `Parallel_if_available_tag`. + * @tparam PointRange a model of the concept `RandomAccessContainer` + * whose value type is the point type + * @tparam TriangleRange a model of the concept `RandomAccessContainer` whose + * value type is a model of the concept `RandomAccessContainer` whose value type is `std::size_t` + * @tparam TriangleIdPairOutputIterator a model of `OutputIterator` holding objects of type + * `std::pair` + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param points points of the soup of polygons + * @param triangles each element in the range describes a triangle using the indices of the points in `points` + * @param out output iterator to be filled with all pairs of ids of triangles intersecting (the id of a triangle is its position in `triangles`). + * In case the triangle soup contains some degenerate faces, for each degenerate face `t` with id `i` a pair `(i,i)` + * will be put in `out` before any other self intersection between non-degenerate faces. + * These are the only pairs where degenerate faces will be reported. + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{point_map} + * \cgalParamDescription{a property map associating points to the elements of the range `points`} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type convertible to the point type + * of the vertex point map associated to the polygon mesh} + * \cgalParamDefault{`CGAL::Identity_property_map`} + * \cgalParamNEnd + * + * \cgalParamNBegin{geom_traits} + * \cgalParamDescription{an instance of a geometric traits class} + * \cgalParamType{a class model of `PMPSelfIntersectionTraits`} + * \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} + * \cgalParamExtra{The geometric traits class must be compatible with the point type of the point map.} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * @return `true` if the triangle soup self-intersects, and `false` otherwise. + * + * @sa `does_triangle_soup_self_intersect()` + */ template -FacePairOutputIterator +TriangleIdPairOutputIterator triangle_soup_self_intersections(const PointRange& points, const TriangleRange& triangles, - FacePairOutputIterator out, + TriangleIdPairOutputIterator out, const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; @@ -809,13 +863,60 @@ triangle_soup_self_intersections(const PointRange& points, typedef typename CGAL::GetPointMap::const_type Point_map_base; Point_map_base pm_base = choose_parameter(get_parameter(np, internal_np::point_map)); typedef Property_map_for_soup Point_map; + typedef typename GetPolygonSoupGeomTraits::type GT; + GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); return self_intersections(boost::irange(0, triangles.size()), std::make_pair(std::cref(points), std::cref(triangles)), out, - parameters::vertex_point_map(Point_map(points,pm_base))); + parameters::vertex_point_map(Point_map(points,pm_base)). + geom_traits(gt)); } +/** + * \ingroup PMP_intersection_grp + * + * \brief tests if a triangle soup self-intersects. + * + * A triangle soup self-intersects if at least two triangles of the soup intersect. + * Two triangles of the soup are said to intersect if the corresponding geometric triangles intersect + * and the intersection is not an edge nor a vertex of both triangles + * (with the same point ids, ignoring the orientation for an edge). + * + * This function depends on the package \ref PkgBoxIntersectionD + * + * @tparam ConcurrencyTag enables sequential versus parallel algorithm. + * Possible values are `Sequential_tag`, `Parallel_tag`, and `Parallel_if_available_tag`. + * @tparam PointRange a model of the concept `RandomAccessContainer` + * whose value type is the point type + * @tparam TriangleRange a model of the concept `RandomAccessContainer` whose + * value type is a model of the concept `RandomAccessContainer` whose value type is `std::size_t` + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param points points of the soup of polygons + * @param triangles each element in the range describes a triangle using the indices of the points in `points` + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{point_map} + * \cgalParamDescription{a property map associating points to the elements of the range `points`} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type convertible to the point type + * of the vertex point map associated to the polygon mesh} + * \cgalParamDefault{`CGAL::Identity_property_map`} + * \cgalParamNEnd + * + * \cgalParamNBegin{geom_traits} + * \cgalParamDescription{an instance of a geometric traits class} + * \cgalParamType{a class model of `PMPSelfIntersectionTraits`} + * \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} + * \cgalParamExtra{The geometric traits class must be compatible with the point type of the point map.} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * @return `out` + * + * @sa `triangle_soup_self_intersections()` + */ template ::const_type Point_map_base; Point_map_base pm_base = choose_parameter(get_parameter(np, internal_np::point_map)); typedef Property_map_for_soup Point_map; - - typename Kernel_traits::value_type>::Kernel k; + typedef typename GetPolygonSoupGeomTraits::type GT; + GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); internal::self_intersections_impl(boost::irange(0, triangles.size()), std::make_pair(std::cref(points), std::cref(triangles)), unused_out, true /*throw*/, parameters::vertex_point_map(Point_map(points,pm_base)) - .geom_traits(k)); + .geom_traits(gt)); } catch (const CGAL::internal::Throw_at_output_exception&) { @@ -860,8 +961,6 @@ bool does_triangle_soup_self_intersect(const PointRange& points, return false; } -#endif - }// namespace Polygon_mesh_processing }// namespace CGAL From 9cd2e031dbb826141aa60f3972c3bee3d0bcf2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Apr 2023 15:15:09 +0200 Subject: [PATCH 42/64] fix after review from Mael --- .../self_intersections.h | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index f331c79ef17..3a368e73459 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -521,7 +521,7 @@ self_intersections_impl(const FaceRange& face_range, * Two faces are said to intersect if the corresponding triangles intersect * and the intersection is not an edge nor a vertex incident to both faces. * - * This function depends on the package \ref PkgBoxIntersectionD + * This function depends on the package \ref PkgBoxIntersectionD. * * @pre `CGAL::is_triangle_mesh(tmesh)` * @@ -588,7 +588,7 @@ self_intersections(const FaceRange& face_range, * Two faces are said to intersect if the corresponding triangles intersect * and the intersection is not an edge nor a vertex incident to both faces. * - * This function depends on the package \ref PkgBoxIntersectionD + * This function depends on the package \ref PkgBoxIntersectionD. * * @pre `CGAL::is_triangle_mesh(tmesh)` * @@ -652,7 +652,7 @@ self_intersections(const TriangleMesh& tmesh, * * \brief tests if a set of faces of a triangulated surface mesh self-intersects. * - * This function depends on the package \ref PkgBoxIntersectionD + * This function depends on the package \ref PkgBoxIntersectionD. * * @pre `CGAL::is_triangle_mesh(tmesh)` * @@ -723,7 +723,7 @@ bool does_self_intersect(const FaceRange& face_range, * * \brief tests if a triangulated surface mesh self-intersects. * - * This function depends on the package \ref PkgBoxIntersectionD + * This function depends on the package \ref PkgBoxIntersectionD. * * @pre `CGAL::is_triangle_mesh(tmesh)` * @@ -801,12 +801,7 @@ struct Property_map_for_soup * and the intersection is not an edge nor a vertex of both triangles * (with the same point ids, ignoring the orientation for an edge). * - * A triangle soup self-intersects if at least two triangles of the soup intersect. - * Two triangles of the soup are considered to intersect if the geometric triangles are not disjoint - * and the intersection is not a restricted to the same point (i.e. with the same id) or to a triangle edge - * (i.e. with the same ids, the edge orientation being ignored). - * - * This function depends on the package \ref PkgBoxIntersectionD + * This function depends on the package \ref PkgBoxIntersectionD. * * @tparam ConcurrencyTag enables sequential versus parallel algorithm. * Possible values are `Sequential_tag`, `Parallel_tag`, and `Parallel_if_available_tag`. @@ -818,19 +813,18 @@ struct Property_map_for_soup * `std::pair` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * - * @param points points of the soup of polygons + * @param points points of the soup of triangles * @param triangles each element in the range describes a triangle using the indices of the points in `points` * @param out output iterator to be filled with all pairs of ids of triangles intersecting (the id of a triangle is its position in `triangles`). - * In case the triangle soup contains some degenerate faces, for each degenerate face `t` with id `i` a pair `(i,i)` - * will be put in `out` before any other self intersection between non-degenerate faces. - * These are the only pairs where degenerate faces will be reported. + * In case the triangle soup contains some degenerate triangles, for each degenerate triangle `t` with id `i` a pair `(i,i)` + * will be put in `out` before any other self intersection between non-degenerate triangles. + * These are the only pairs where degenerate triangles will be reported. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} * \cgalParamDescription{a property map associating points to the elements of the range `points`} - * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type convertible to the point type - * of the vertex point map associated to the polygon mesh} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal Kernel.} * \cgalParamDefault{`CGAL::Identity_property_map`} * \cgalParamNEnd * @@ -842,9 +836,11 @@ struct Property_map_for_soup * \cgalParamNEnd * \cgalNamedParamsEnd * - * @return `true` if the triangle soup self-intersects, and `false` otherwise. + * @return `out` * * @sa `does_triangle_soup_self_intersect()` + * @sa `self_intersections()` + * @sa `does_self_intersect()` */ template Date: Thu, 6 Apr 2023 15:39:54 +0200 Subject: [PATCH 43/64] fix after Andreas' review --- .../Polygon_mesh_processing/self_intersections.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index 3a368e73459..88fe5369daa 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -519,7 +519,7 @@ self_intersections_impl(const FaceRange& face_range, * * collects intersections between a subset of faces of a triangulated surface mesh. * Two faces are said to intersect if the corresponding triangles intersect - * and the intersection is not an edge nor a vertex incident to both faces. + * and the intersection is neither an edge nor a vertex incident to both faces. * * This function depends on the package \ref PkgBoxIntersectionD. * @@ -586,7 +586,7 @@ self_intersections(const FaceRange& face_range, * * collects intersections between all the faces of a triangulated surface mesh. * Two faces are said to intersect if the corresponding triangles intersect - * and the intersection is not an edge nor a vertex incident to both faces. + * and the intersection is neither an edge nor a vertex incident to both faces. * * This function depends on the package \ref PkgBoxIntersectionD. * @@ -798,7 +798,7 @@ struct Property_map_for_soup * collects intersections between all the triangles in a triangle soup. * * Two triangles of the soup are said to intersect if the corresponding geometric triangles intersect - * and the intersection is not an edge nor a vertex of both triangles + * and the intersection is neither an edge nor a vertex of both triangles * (with the same point ids, ignoring the orientation for an edge). * * This function depends on the package \ref PkgBoxIntersectionD. @@ -824,7 +824,7 @@ struct Property_map_for_soup * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} * \cgalParamDescription{a property map associating points to the elements of the range `points`} - * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal Kernel.} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal `Kernel`.} * \cgalParamDefault{`CGAL::Identity_property_map`} * \cgalParamNEnd * @@ -876,7 +876,7 @@ triangle_soup_self_intersections(const PointRange& points, * * A triangle soup self-intersects if at least two triangles of the soup intersect. * Two triangles of the soup are said to intersect if the corresponding geometric triangles intersect - * and the intersection is not an edge nor a vertex of both triangles + * and the intersection is neither an edge nor a vertex of both triangles * (with the same point ids, ignoring the orientation for an edge). * * This function depends on the package \ref PkgBoxIntersectionD. @@ -896,7 +896,7 @@ triangle_soup_self_intersections(const PointRange& points, * \cgalNamedParamsBegin * \cgalParamNBegin{point_map} * \cgalParamDescription{a property map associating points to the elements of the range `points`} - * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal Kernel.} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal `Kernel`.} * \cgalParamDefault{`CGAL::Identity_property_map`} * \cgalParamNEnd * From 89859163826505fff38e225be36912004cf0e07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Apr 2023 17:05:10 +0200 Subject: [PATCH 44/64] add note --- .../CGAL/Polygon_mesh_processing/self_intersections.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index 88fe5369daa..01cf832155b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -602,8 +602,8 @@ self_intersections(const FaceRange& face_range, * @param tmesh the triangulated surface mesh to be checked * @param out output iterator to be filled with all pairs of non-adjacent faces that intersect. * In case `tmesh` contains some degenerate faces, for each degenerate face `f` a pair `(f,f)` - * will be put in `out` before any other self intersection between non-degenerate faces. - * These are the only pairs where degenerate faces will be reported. + * will be put in `out` before any other self intersection between non-degenerate faces.
+ * Note that these are the only pairs where degenerate faces will be reported. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -817,8 +817,8 @@ struct Property_map_for_soup * @param triangles each element in the range describes a triangle using the indices of the points in `points` * @param out output iterator to be filled with all pairs of ids of triangles intersecting (the id of a triangle is its position in `triangles`). * In case the triangle soup contains some degenerate triangles, for each degenerate triangle `t` with id `i` a pair `(i,i)` - * will be put in `out` before any other self intersection between non-degenerate triangles. - * These are the only pairs where degenerate triangles will be reported. + * will be put in `out` before any other self intersection between non-degenerate triangles.
+ * Note that these are the only pairs where degenerate triangles will be reported. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin From 28c97d293fe7a855aad5441bbeef490b7abc71c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 11 Apr 2023 09:25:29 +0200 Subject: [PATCH 45/64] fix warnings --- BGL/include/CGAL/boost/graph/named_params_helper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index f5b8c44df82..1e0efd6faa6 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -141,14 +141,14 @@ struct GetVertexPointMap_impl template static const_type - get_const_map(const NamedParameters& np, const PolygonMesh& pm) + get_const_map(const NamedParameters& /* np */, const PolygonMesh& pm) { return get_const_property_map(boost::vertex_point, pm); } template static type - get_map(const NamedParameters& np, PolygonMesh& pm) + get_map(const NamedParameters& /* np */, PolygonMesh& pm) { return get_property_map(boost::vertex_point, pm); } From a361f79e1f29a24b5f905c9b6e2e95af33d598e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 12 Apr 2023 16:21:26 +0200 Subject: [PATCH 46/64] add missing parameter --- .../self_intersections.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index 01cf832155b..3524b46c775 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -822,6 +822,14 @@ struct Property_map_for_soup * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin + * \cgalParamNBegin{maximum_number} + * \cgalParamDescription{the maximum number of self intersections that will be detected and returned by the function.} + * \cgalParamType{unsigned int} + * \cgalParamDefault{No limit.} + * \cgalParamExtra{In parallel mode, the number of returned self-intersections is at least `maximum_number` + * (and not exactly that number) as no strong synchronization is put on threads for performance reasons.} + * \cgalParamNEnd + * * \cgalParamNBegin{point_map} * \cgalParamDescription{a property map associating points to the elements of the range `points`} * \cgalParamType{a model of `ReadablePropertyMap` whose value type is a point type from a \cgal `Kernel`.} @@ -855,6 +863,7 @@ triangle_soup_self_intersections(const PointRange& points, { using parameters::choose_parameter; using parameters::get_parameter; + using parameters::is_default_parameter; typedef typename CGAL::GetPointMap::const_type Point_map_base; Point_map_base pm_base = choose_parameter(get_parameter(np, internal_np::point_map)); @@ -862,6 +871,17 @@ triangle_soup_self_intersections(const PointRange& points, typedef typename GetPolygonSoupGeomTraits::type GT; GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); + const bool do_limit = !(is_default_parameter::value); + if (do_limit) + { + return self_intersections(boost::irange(0, triangles.size()), + std::make_pair(std::cref(points), std::cref(triangles)), + out, + parameters::vertex_point_map(Point_map(points,pm_base)). + geom_traits(gt). + maximum_number(choose_parameter(get_parameter(np, internal_np::maximum_number), 0))); + } + return self_intersections(boost::irange(0, triangles.size()), std::make_pair(std::cref(points), std::cref(triangles)), out, From b123ccf125367c34150f2a84a0d990be469c29aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 12 Apr 2023 16:21:42 +0200 Subject: [PATCH 47/64] copy mesh test for soup --- .../Polygon_mesh_processing/CMakeLists.txt | 1 + .../self_intersection_triangle_soup_test.cpp | 190 ++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index d3fc45f270e..3752a6cacd1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -21,6 +21,7 @@ create_single_source_cgal_program("point_inside_surface_mesh_test.cpp") create_single_source_cgal_program("polygon_mesh_slicer_test.cpp") create_single_source_cgal_program("self_intersection_polyhedron_test.cpp") create_single_source_cgal_program("self_intersection_surface_mesh_test.cpp") +create_single_source_cgal_program("self_intersection_triangle_soup_test.cpp") create_single_source_cgal_program("pmp_do_intersect_test.cpp") create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp") create_single_source_cgal_program("test_stitching.cpp") diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp new file mode 100644 index 00000000000..a6c88d934cc --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp @@ -0,0 +1,190 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; +typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; + +namespace PMP = ::CGAL::Polygon_mesh_processing; +namespace CP = ::CGAL::parameters; + +template +int test_self_intersections(const std::string filename, + const bool expected) +{ + std::vector points; + std::vector< std::array > triangles; + + bool read_ok = CGAL::IO::read_polygon_soup(filename, points, triangles); + + if ( !read_ok ) { + std::cerr << "Error: cannot read file: " << filename << std::endl; + return 1; + } + + std::cout << "Reading file: " << filename << std::endl; + + CGAL::Timer timer; + timer.start(); + + std::vector > intersected_tris; + + PMP::triangle_soup_self_intersections(points, triangles, std::back_inserter(intersected_tris)); + bool intersecting_1 = !intersected_tris.empty(); + + std::cout << "self_intersections test took " << timer.time() << " sec." << std::endl; + std::cout << intersected_tris.size() << " pairs of triangles are intersecting." << std::endl; + + timer.reset(); + + bool intersecting_2 = + PMP::does_triangle_soup_self_intersect(points, triangles); + + std::cout << "does_self_intersect test took " << timer.time() << " sec." << std::endl; + std::cout << (intersecting_2 ? "There is a self-intersection." : + "There are no self-intersections.") << std::endl; + + assert(intersecting_1 == intersecting_2); + assert(intersecting_1 == expected); + + std::cout << filename << " passed the tests." << std::endl << std::endl; + + return 0; +} + +template +int test_limited_self_intersections(const std::string& filename) +{ + std::vector points; + std::vector< std::array > triangles; + + bool read_ok = CGAL::IO::read_polygon_soup(filename, points, triangles); + + if ( !read_ok ) { + std::cerr << "Error: cannot read file: " << filename << std::endl; + return 1; + } + + CGAL::Timer timer; + timer.start(); + + std::vector > intersected_tris; + +#ifdef CGAL_LINKED_WITH_TBB + PMP::triangle_soup_self_intersections()( + points, triangles, + std::back_inserter(intersected_tris), CGAL::parameters::maximum_number(40)); + std::cout << "self_intersections test for 40 SI took " << timer.time() << " sec." << std::endl; + std::cout << "Found " << intersected_tris.size() << " SIs." << std::endl; + if(intersected_tris.size() < 40) + { + std::cerr<<"Not enough intersections found in parallel."<( + points, triangles, + std::back_inserter(intersected_tris), CGAL::parameters::maximum_number(40)); + std::cout << "self_intersections test for 40 SI took " << timer.time() << " sec." << std::endl; + timer.reset(); + if(intersected_tris.size() != 40) + { + std::cerr<<"Too many intersections found in sequential"< self_intersection_surface_mesh_test data/U.off false + + // First test ---------------------------------------------------------------- + bool expected = false; + std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/elephant.off"); + if(argc > 1) { + assert(argc > 2); + std::stringstream ss(argv[2]); + ss >> std::boolalpha >> expected; + assert(!ss.fail()); // make sure that argv[2] is either 'true' or 'false' + } + + std::cout << "First test (EPICK):" << std::endl; + int r = test_self_intersections(filename, expected); + + std::cout << "First test (EPECK):" << std::endl; + r += test_self_intersections(filename, expected); + + // Second test --------------------------------------------------------------- + expected = true; + filename = (argc > 3) ? argv[3] : CGAL::data_file_path("meshes/mannequin-devil.off"); + if(argc > 3) { + assert(argc > 4); + std::stringstream ss(argv[4]); + ss >> std::boolalpha >> expected; + assert(!ss.fail()); + } + + std::cout << "Second test (EPICK):" << std::endl; + r += test_self_intersections(filename, expected); + + std::cout << "Second test (EPECK):" << std::endl; + r += test_self_intersections(filename, expected); + + // Third test ---------------------------------------------------------------- + expected = true; + filename = (argc > 5) ? argv[5] : "data/overlapping_triangles.off"; + if(argc > 5) { + assert(argc > 6); + std::stringstream ss(argv[6]); + ss >> std::boolalpha >> expected; + assert(!ss.fail()); + } + + std::cout << "Third test (EPICK):" << std::endl; + r += test_self_intersections(filename, expected); + + std::cout << "Third test (EPECK):" << std::endl; + r += test_self_intersections(filename, expected); + + // Fourth test ---------------------------------------------------------------- + expected = true; + filename = (argc > 7) ? argv[7] : "data_degeneracies/degtri_single.off"; + if(argc > 7) { + assert(argc > 8); + std::stringstream ss(argv[8]); + ss >> std::boolalpha >> expected; + assert(!ss.fail()); + } + + std::cout << "Fourth test (EPICK):" << std::endl; + r += test_self_intersections(filename, expected); + + std::cout << "Fourth test (EPECK):" << std::endl; + r += test_self_intersections(filename, expected); + + filename = (argc > 9) ? argv[9] : CGAL::data_file_path("meshes/mannequin-devil.off"); + + std::cout << "Test with maximum_number (EPICK):" << std::endl; + r += test_limited_self_intersections(filename); + + std::cout << "Test with maximum_number (EPECK):" << std::endl; + r += test_limited_self_intersections(filename); + + return r; +} From 23932583700deab21752ce8aec9cbc1cebe38290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 12 Apr 2023 16:59:05 +0200 Subject: [PATCH 48/64] add triangle soup specific tests --- .../self_intersection_triangle_soup_test.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp index a6c88d934cc..e067e13c129 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp @@ -186,5 +186,49 @@ int main(int argc, char** argv) std::cout << "Test with maximum_number (EPECK):" << std::endl; r += test_limited_self_intersections(filename); + // extra hand written tests + { + // shared edge with same point: no self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0), Point_3(0,-1,0)}; + std::vector< std::array > triangles={{0,1,2}, {0,1,3}}; + assert(!PMP::does_triangle_soup_self_intersect(points, triangles)); + } + { + // shared edge with duplicated points: self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0),Point_3(0,0,0), Point_3(1,0,0), Point_3(0,-1,0)}; + std::vector< std::array > triangles={{0,1,2}, {3,4,5}}; + assert(PMP::does_triangle_soup_self_intersect(points, triangles)); + } + { + // shared vertex with same point: no self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0), Point_3(0,2,0), Point_3(1,2,0)}; + std::vector< std::array > triangles={{0,1,2}, {3,4,2}}; + assert(!PMP::does_triangle_soup_self_intersect(points, triangles)); + } + { + // shared vertex with duplicated points: self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0), Point_3(0,2,0), Point_3(1,2,0), Point_3(0,1,0)}; + std::vector< std::array > triangles={{0,1,2}, {3,4,5}}; + assert(PMP::does_triangle_soup_self_intersect(points, triangles)); + } + { + // 4 triangles around a shared edge: no self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0), Point_3(0,-1,0), Point_3(0,0,1), Point_3(0,0,-1)}; + std::vector< std::array > triangles={{0,1,2},{0,1,3},{0,1,4},{0,1,5}}; + assert(!PMP::does_triangle_soup_self_intersect(points, triangles)); + } + { + // 4 triangles around a shared edge but two triangles intersecting: self-intersection + typedef EPICK::Point_3 Point_3; + std::vector points = {Point_3(0,0,0), Point_3(1,0,0), Point_3(0,1,0), Point_3(0,0.5,0), Point_3(0,0,1), Point_3(0,0,-1)}; + std::vector< std::array > triangles={{0,1,2},{0,1,3},{0,1,4},{0,1,5}}; + assert(PMP::does_triangle_soup_self_intersect(points, triangles)); + } + return r; } From 8fe0633fb5895d1fdc1fdd7bc99f3b7ed8439d2c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 15:44:21 +0200 Subject: [PATCH 49/64] add new possible gmp name for MSVC gmp-10 was compiled with vcpkg and installed on Christo --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index 3f407098996..fbc511c3889 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -8,6 +8,7 @@ int main() { #define GMP_SONAME "libgmp-10" #define MPFR_SONAME "libmpfr-4" #define GMP_SONAME_BACKUP "gmp" +#define GMP_SONAME_BACKUP_2 "gmp-10" #define MPFR_SONAME_BACKUP "mpfr-6" #define GMP_MAJOR 5 #define MPFR_MAJOR 3 @@ -66,7 +67,9 @@ int main() { int major, minor, patch, build; if(!get_version_info(GMP_SONAME, major, minor, patch, build)) { if(!get_version_info(GMP_SONAME_BACKUP, major, minor, patch, build)) { - return 1; + if (!get_version_info(GMP_SONAME_BACKUP_2, major, minor, patch, build)) { + return 1; + } } } From 3c6a4c16c4b4e92e77884485ffb6e8986e1e5d6a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 15:58:49 +0200 Subject: [PATCH 50/64] add debug info for the testsuite --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index fbc511c3889..67ed1e76ee4 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -42,6 +42,12 @@ bool get_version_info(const LPCTSTR name, std::cerr << "Query FileVersion of \"" << fileName << "\"\n"; DWORD handle = 0; size = GetFileVersionInfoSize(fileName, &handle); + + DWORD err = GetLastError(); + if (size == 0) { + std::cerr << "GetFileVersionInfoSize failed with error " << err << std::endl; + } + BYTE* versionInfo = new BYTE[size]; if (!GetFileVersionInfo(fileName, handle, size, versionInfo)) { From 37c0b5eaa60558e5b4516608851ef0970fa4e176 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:14:19 +0200 Subject: [PATCH 51/64] add gmp-10 as a hint for findGMP and add GMP_DIR and MPFR_DIR as hints to find all includes and libs --- Installation/cmake/modules/FindGMP.cmake | 7 +++++-- Installation/cmake/modules/FindMPFR.cmake | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Installation/cmake/modules/FindGMP.cmake b/Installation/cmake/modules/FindGMP.cmake index 3a1d355d41f..f452c0287f7 100644 --- a/Installation/cmake/modules/FindGMP.cmake +++ b/Installation/cmake/modules/FindGMP.cmake @@ -26,22 +26,25 @@ if( NOT GMP_in_cache ) NAMES gmp.h HINTS ENV GMP_INC_DIR ENV GMP_DIR + $ENV{GMP_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include PATH_SUFFIXES include DOC "The directory containing the GMP header files" ) - find_library(GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 mpir + find_library(GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 gmp-10 mpir HINTS ENV GMP_LIB_DIR ENV GMP_DIR + $ENV{GMP_DIR}/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the Release GMP library" ) - find_library(GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 mpir + find_library(GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 gmp-10 mpir HINTS ENV GMP_LIB_DIR ENV GMP_DIR + $ENV{GMP_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the Debug GMP library" diff --git a/Installation/cmake/modules/FindMPFR.cmake b/Installation/cmake/modules/FindMPFR.cmake index b21fb1f678e..4d1bc43553d 100644 --- a/Installation/cmake/modules/FindMPFR.cmake +++ b/Installation/cmake/modules/FindMPFR.cmake @@ -25,6 +25,7 @@ if (NOT MPFR_in_cache) NAMES mpfr.h HINTS ENV MPFR_INC_DIR ENV MPFR_DIR + $ENV{MPFR_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include PATH_SUFFIXES include DOC "The directory containing the MPFR header files" @@ -33,6 +34,7 @@ if (NOT MPFR_in_cache) find_library(MPFR_LIBRARIES NAMES mpfr libmpfr-4 libmpfr-1 HINTS ENV MPFR_LIB_DIR ENV MPFR_DIR + $ENV{MPFR_DIR}/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the MPFR library" From 3077d8b6572bd1d540b9519aae3842c450f16127 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:33:20 +0200 Subject: [PATCH 52/64] remove useless definitions --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index 67ed1e76ee4..e7ccd4307d2 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -10,9 +10,6 @@ int main() { #define GMP_SONAME_BACKUP "gmp" #define GMP_SONAME_BACKUP_2 "gmp-10" #define MPFR_SONAME_BACKUP "mpfr-6" -#define GMP_MAJOR 5 -#define MPFR_MAJOR 3 - #include #include From d4b5fec0a673a6c717a7d1d428f9beadc9539bfe Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:40:15 +0200 Subject: [PATCH 53/64] be verbose when loading succeeded --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index e7ccd4307d2..17ec0939d6a 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -33,6 +33,9 @@ bool get_version_info(const LPCTSTR name, std::cerr << name << " is not loaded!\n"; return false; } + else + std::cerr << name << " is loaded.\n"; + char fileName[_MAX_PATH]; DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH); fileName[size] = NULL; From afb4ac68b3e00013abdbc8010b31e407bee18210 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Fri, 14 Apr 2023 09:52:28 +0200 Subject: [PATCH 54/64] Do not draw shalfloop to avoid segfault(TODO draw something?) --- Nef_3/include/CGAL/draw_nef_3.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Nef_3/include/CGAL/draw_nef_3.h b/Nef_3/include/CGAL/draw_nef_3.h index e654ea9aae7..e561b3fef70 100644 --- a/Nef_3/include/CGAL/draw_nef_3.h +++ b/Nef_3/include/CGAL/draw_nef_3.h @@ -131,21 +131,23 @@ protected: ++fc; while(fc!=f->facet_cycles_end()) { - se = SHalfedge_const_handle(fc); - hc_start=se; - hc_end=hc_start; - CGAL_For_all(hc_start, hc_end) { - Vertex_const_handle vh=hc_start->source()->center_vertex(); - viewer.add_point_in_face(vh->point(), - viewer.get_vertex_normal(vh)); + if(fc.is_shalfedge()) + { + se = SHalfedge_const_handle(fc); + hc_start=se; + hc_end=hc_start; + CGAL_For_all(hc_start, hc_end) { + Vertex_const_handle vh=hc_start->source()->center_vertex(); + viewer.add_point_in_face(vh->point(), + viewer.get_vertex_normal(vh)); + } + viewer.add_point_in_face(hc_start->source()->center_vertex()->point(), + viewer.get_vertex_normal(hc_start->source()->center_vertex())); + viewer.add_point_in_face(lastvh->point(), + viewer.get_vertex_normal(lastvh)); } - viewer.add_point_in_face(hc_start->source()->center_vertex()->point(), - viewer.get_vertex_normal(hc_start->source()->center_vertex())); - viewer.add_point_in_face(lastvh->point(), - viewer.get_vertex_normal(lastvh)); ++fc; } - viewer.face_end(); facets_done[f]=true; n_faces++; From 12c8e60e6eef2c3ced0145aac6bb1c18df0021ac Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 17 Apr 2023 10:07:35 +0200 Subject: [PATCH 55/64] fix name of a custom target on Windows --- Installation/cmake/modules/CGAL_add_test.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index 984922a772f..0591b7266d6 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -85,9 +85,9 @@ function(cgal_add_compilation_test exe_name) APPEND PROPERTY LABELS "${PROJECT_NAME}") set_property(TEST "compilation of ${exe_name}" APPEND PROPERTY FIXTURES_REQUIRED "check_build_system_SetupFixture") - elseif(NOT TARGET "compilation of ${PROJECT_NAME}")#CMAKE_VS_MSBUILD_COMMAND + elseif(NOT TARGET "compilation_of__${PROJECT_NAME}")#CMAKE_VS_MSBUILD_COMMAND #this target is just a flag, to deal with the scope problem with the tests - add_custom_target("compilation of ${PROJECT_NAME}") + add_custom_target("compilation_of__${PROJECT_NAME}") add_test(NAME "compilation of ${PROJECT_NAME}" COMMAND ${TIME_COMMAND} "${CMAKE_VS_MSBUILD_COMMAND}" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln" "-m:$ENV{NUMBER_OF_PROCESSORS}" "/t:Build" "/p:Configuration=$") set_property(TEST "compilation of ${PROJECT_NAME}" From 6d279d976d97dff745ffe465453edd1085148127 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 18 Apr 2023 10:45:39 +0200 Subject: [PATCH 56/64] Incorrect usage of `xmlns` in HTML headers In #7075 the usage of `xmlns` was changed from: ``` ``` into ``` ``` this is not correct, the usage has to be `http` as in the definition https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd we see: ``` ``` --- Documentation/doc/resources/1.8.13/header.html | 2 +- Documentation/doc/resources/1.8.13/header_package.html | 2 +- Documentation/doc/resources/1.8.14/header.html | 2 +- Documentation/doc/resources/1.8.14/header_package.html | 2 +- Documentation/doc/resources/1.8.20/header.html | 2 +- Documentation/doc/resources/1.8.20/header_package.html | 2 +- Documentation/doc/resources/1.8.4/header.html | 2 +- Documentation/doc/resources/1.8.4/header_package.html | 2 +- Documentation/doc/resources/1.9.3/header.html | 2 +- Documentation/doc/resources/1.9.3/header_package.html | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/doc/resources/1.8.13/header.html b/Documentation/doc/resources/1.8.13/header.html index aaa5e95ea30..8c8b86f5b9d 100644 --- a/Documentation/doc/resources/1.8.13/header.html +++ b/Documentation/doc/resources/1.8.13/header.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.13/header_package.html b/Documentation/doc/resources/1.8.13/header_package.html index 9e6fe125d50..544fd3ced7f 100644 --- a/Documentation/doc/resources/1.8.13/header_package.html +++ b/Documentation/doc/resources/1.8.13/header_package.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.14/header.html b/Documentation/doc/resources/1.8.14/header.html index aaa5e95ea30..8c8b86f5b9d 100644 --- a/Documentation/doc/resources/1.8.14/header.html +++ b/Documentation/doc/resources/1.8.14/header.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.14/header_package.html b/Documentation/doc/resources/1.8.14/header_package.html index f429c63135d..89f76a8a441 100644 --- a/Documentation/doc/resources/1.8.14/header_package.html +++ b/Documentation/doc/resources/1.8.14/header_package.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.20/header.html b/Documentation/doc/resources/1.8.20/header.html index c0530eec8bf..50e4e4dcb49 100644 --- a/Documentation/doc/resources/1.8.20/header.html +++ b/Documentation/doc/resources/1.8.20/header.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.20/header_package.html b/Documentation/doc/resources/1.8.20/header_package.html index d2a1ed6051b..007d84e7b10 100644 --- a/Documentation/doc/resources/1.8.20/header_package.html +++ b/Documentation/doc/resources/1.8.20/header_package.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.8.4/header.html b/Documentation/doc/resources/1.8.4/header.html index 8ffa7e46ea8..5cb6f690aea 100644 --- a/Documentation/doc/resources/1.8.4/header.html +++ b/Documentation/doc/resources/1.8.4/header.html @@ -1,5 +1,5 @@ - + diff --git a/Documentation/doc/resources/1.8.4/header_package.html b/Documentation/doc/resources/1.8.4/header_package.html index e47f3e9a158..3905338b162 100644 --- a/Documentation/doc/resources/1.8.4/header_package.html +++ b/Documentation/doc/resources/1.8.4/header_package.html @@ -1,5 +1,5 @@ - + diff --git a/Documentation/doc/resources/1.9.3/header.html b/Documentation/doc/resources/1.9.3/header.html index c0530eec8bf..50e4e4dcb49 100644 --- a/Documentation/doc/resources/1.9.3/header.html +++ b/Documentation/doc/resources/1.9.3/header.html @@ -1,6 +1,6 @@ - + diff --git a/Documentation/doc/resources/1.9.3/header_package.html b/Documentation/doc/resources/1.9.3/header_package.html index d2a1ed6051b..007d84e7b10 100644 --- a/Documentation/doc/resources/1.9.3/header_package.html +++ b/Documentation/doc/resources/1.9.3/header_package.html @@ -1,6 +1,6 @@ - + From 451223a2e8611ff40dff8de074de3ad4690bd262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:20:04 +0200 Subject: [PATCH 57/64] Fix not forwarding verbose NP to inner functions --- .../include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h index 4fe8a9deaf0..fe136bd4545 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h @@ -101,7 +101,7 @@ bool read_polygon_mesh(const std::string& fname, std::vector points; std::vector > faces; - if(!CGAL::IO::read_polygon_soup(fname, points, faces)) + if(!CGAL::IO::read_polygon_soup(fname, points, faces, CGAL::parameters::verbose(verbose))) { if(verbose) std::cerr << "Warning: cannot read polygon soup" << std::endl; From b7ca320000b92d378e9e97f28d0e41e064eee09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:20:49 +0200 Subject: [PATCH 58/64] Fix null char reading and backslash separated multi lines --- Stream_support/include/CGAL/IO/OBJ.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 9cdc507e3cc..da8b51f9af6 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -72,12 +73,30 @@ bool read_OBJ(std::istream& is, bool tex_found(false), norm_found(false); while(getline(is, line)) { - if(line.empty()) - continue; + // get last non-whitespace, non-null character + auto last = std::find_if(line.rbegin(), line.rend(), [](char c) { return c != '\0' && !std::isspace(c); }); + if(last == line.rend()) + continue; // line is empty or only whitespace + + // keep reading lines as long as the last non-whitespace, non-null character is a backslash + while(last != line.rend() && *last == '\\') + { + // remove everything from the backslash (included) + line = line.substr(0, line.size() - (last - line.rbegin()) - 1); + + std::string next_line; + if(!getline(is, next_line)) + break; + + line += next_line; + last = std::find_if(line.rbegin(), line.rend(), [](char c) { return c != '\0' && !std::isspace(c); }); + } + + CGAL_assertion(!line.empty()); std::istringstream iss(line); if(!(iss >> s)) - continue; // can't read anything on the line, whitespace only? + continue; if(s == "v") { From d33fc1ad075c123adaa68d583c1a79b70e147f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:21:54 +0200 Subject: [PATCH 59/64] Add missing error message --- Stream_support/include/CGAL/IO/OBJ.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index da8b51f9af6..5d9a14e94b0 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -146,7 +146,11 @@ bool read_OBJ(std::istream& is, } if(iss.bad()) + { + if(verbose) + std::cerr << "error while reading OBJ face." << std::endl; return false; + } } else if(s.front() == '#') { @@ -172,15 +176,15 @@ bool read_OBJ(std::istream& is, else { if(verbose) - std::cerr << "error: unrecognized line: " << s << std::endl; + std::cerr << "Error: unrecognized line: " << s << std::endl; return false; } } if(norm_found && verbose) - std::cout<<"NOTE: normals were found in this file, but were discarded."< Date: Tue, 18 Apr 2023 12:08:39 +0200 Subject: [PATCH 60/64] Minor example improvements --- .../triangulate_faces_example.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp index ce098ae6d4b..52982dbb923 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp @@ -23,18 +23,32 @@ int main(int argc, char* argv[]) Surface_mesh mesh; if(!PMP::IO::read_polygon_mesh(filename, mesh)) { - std::cerr << "Invalid input." << std::endl; - return 1; + std::cerr << "Error: Invalid input." << std::endl; + return EXIT_FAILURE; } + if(is_empty(mesh)) + { + std::cerr << "Warning: empty file?" << std::endl; + return EXIT_SUCCESS; + } + + if(!CGAL::is_triangle_mesh(mesh)) + std::cout << "Input mesh is not triangulated." << std::endl; + else + std::cout << "Input mesh is triangulated." << std::endl; + PMP::triangulate_faces(mesh); // Confirm that all faces are triangles. for(boost::graph_traits::face_descriptor f : faces(mesh)) + { if(!CGAL::is_triangle(halfedge(f, mesh), mesh)) std::cerr << "Error: non-triangular face left in mesh." << std::endl; + } + CGAL::IO::write_polygon_mesh(outfilename, mesh, CGAL::parameters::stream_precision(17)); - return 0; + return EXIT_SUCCESS; } From 254251d3f6e707201bcb401d3b617ebff1a3b606 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 18 Apr 2023 13:14:03 +0200 Subject: [PATCH 61/64] Incorrect usage of `xmlns` in HTML headers A bit hidden usage corrected as well. --- Documentation/doc/scripts/generate_how_to_cite.py | 2 +- Documentation/doc/scripts/html_output_post_processing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/doc/scripts/generate_how_to_cite.py b/Documentation/doc/scripts/generate_how_to_cite.py index 470c71d4e45..71e1c6258c9 100644 --- a/Documentation/doc/scripts/generate_how_to_cite.py +++ b/Documentation/doc/scripts/generate_how_to_cite.py @@ -80,7 +80,7 @@ result_txt_footer=r""" """ pre_html=r""" - + diff --git a/Documentation/doc/scripts/html_output_post_processing.py b/Documentation/doc/scripts/html_output_post_processing.py index 11b49c0378a..2250aa92887 100755 --- a/Documentation/doc/scripts/html_output_post_processing.py +++ b/Documentation/doc/scripts/html_output_post_processing.py @@ -55,7 +55,7 @@ def write_out_html(d, fn): f = codecs.open(fn, 'w', encoding='utf-8') # this is the normal doxygen doctype, which is thrown away by pyquery f.write('\n') - f.write('') + f.write('') if d.html() is not None: f.write(d.html(method='html')) f.write('\n') From ebe6c3f25652e01f82712f4d4e9b8fae1b3f3bc5 Mon Sep 17 00:00:00 2001 From: albert-github Date: Thu, 20 Apr 2023 12:18:44 +0200 Subject: [PATCH 62/64] Correcting usage of `iframe` tag Correcting usage usage of `iframe` tag: - add value to `allowfullscreen` - prevent warnings on dtd validation about usage of `center` tag inside a `p` tag --- .../Surface_mesh_deformation.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Surface_mesh_deformation/doc/Surface_mesh_deformation/Surface_mesh_deformation.txt b/Surface_mesh_deformation/doc/Surface_mesh_deformation/Surface_mesh_deformation.txt index dcd7977c310..d26b649300b 100644 --- a/Surface_mesh_deformation/doc/Surface_mesh_deformation/Surface_mesh_deformation.txt +++ b/Surface_mesh_deformation/doc/Surface_mesh_deformation/Surface_mesh_deformation.txt @@ -218,29 +218,29 @@ and clicking with the left button of the mouse. The displacement of the vertices is triggered when the Ctrl button is pressed. \anchor SModelingVideo_1 -\htmlonly +\htmlonly[block]
- -
+
Video 1 Grouping of control vertices.
+ \endhtmlonly \anchor SModelingVideo_2 -\htmlonly +\htmlonly[block]
- -
+
Video 2 Convergence: this video shows that upon fast changes of the positions of the control vertices, more iteration steps are needed to reach the convergence.
+ \endhtmlonly \anchor SModelingVideo_3 -\htmlonly +\htmlonly[block]
- -
+
Video 3 A complete example: changing the pose of a dinausor.
+ \endhtmlonly From 1a6ece1cea72720b3e841a9afa07879f32924d1b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Apr 2023 17:27:23 +0200 Subject: [PATCH 63/64] Qt5::Svg is now only optional for CGAL_Qt5 --- GraphicsView/include/CGAL/Qt/DemosMainWindow.h | 3 ++- .../include/CGAL/Qt/DemosMainWindow_impl.h | 6 +++++- .../modules/CGAL_SetupCGAL_Qt5Dependencies.cmake | 16 +++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/DemosMainWindow.h b/GraphicsView/include/CGAL/Qt/DemosMainWindow.h index 8ea7d1e3f70..d28d98b3718 100644 --- a/GraphicsView/include/CGAL/Qt/DemosMainWindow.h +++ b/GraphicsView/include/CGAL/Qt/DemosMainWindow.h @@ -93,8 +93,9 @@ protected Q_SLOTS: void popupAboutCGAL(); void popupAboutDemo(); +#if QT_SVG_LIB void exportSVG(); - +#endif void openRecentFile_aux(); void addToRecentFiles(QString fileName); void updateRecentFileActions(); diff --git a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h index 009b142b963..80b4a7c9620 100644 --- a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h +++ b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h @@ -38,7 +38,9 @@ #include #include #include -#include +#if QT_SVG_LIB +# include +#endif #include #include @@ -159,6 +161,7 @@ DemosMainWindow::setupOptionsMenu(QMenu* menuOptions) actionUse_Antialiasing->setChecked(true); } +#if QT_SVG_LIB CGAL_INLINE_FUNCTION void DemosMainWindow::setupExportSVG(QAction* action, QGraphicsView* view) @@ -189,6 +192,7 @@ void DemosMainWindow::exportSVG() this->view->render(&painter); painter.end(); } +#endif // QT_SVG_LIB CGAL_INLINE_FUNCTION void diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake index 0c11f8b5ffd..c6701aeb1a1 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_Qt5Dependencies.cmake @@ -9,7 +9,7 @@ # # .. code-block:: cmake # -# find_package(Qt5 QUIET COMPONENTS OpenGL Svg) +# find_package(Qt5 QUIET COMPONENTS OpenGL Widgets) # # and defines the variable :variable:`CGAL_Qt5_FOUND` and the function # :command:`CGAL_setup_CGAL_Qt5_dependencies`. @@ -24,14 +24,14 @@ set(CGAL_SetupCGAL_Qt5Dependencies_included TRUE) # Used Modules # ^^^^^^^^^^^^ # - :module:`Qt5Config` -find_package(Qt5 QUIET COMPONENTS OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS OpenGL Widgets OPTIONAL_COMPONENTS Svg) set(CGAL_Qt5_MISSING_DEPS "") if(NOT Qt5OpenGL_FOUND) set(CGAL_Qt5_MISSING_DEPS "Qt5OpenGL") endif() -if(NOT Qt5Svg_FOUND) - set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5Svg") +if(NOT Qt5Widgets_FOUND) + set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5Widgets") endif() if(NOT Qt5_FOUND) set(CGAL_Qt5_MISSING_DEPS "${CGAL_Qt5_MISSING_DEPS} Qt5") @@ -75,8 +75,10 @@ if(NOT CGAL_Qt5_MISSING_DEPS) POSITION_INDEPENDENT_CODE TRUE EXCLUDE_FROM_ALL TRUE AUTOMOC TRUE) - target_link_libraries(CGAL_Qt5_moc_and_resources CGAL::CGAL Qt5::Widgets Qt5::OpenGL Qt5::Svg ) - + target_link_libraries(CGAL_Qt5_moc_and_resources PUBLIC CGAL::CGAL Qt5::Widgets Qt5::OpenGL ) + if(Qt5Svg_FOUND) + target_link_libraries(CGAL_Qt5_moc_and_resources PUBLIC Qt5::Svg) + endif() add_library(CGAL::CGAL_Qt5_moc_and_resources ALIAS CGAL_Qt5_moc_and_resources) add_library(CGAL::Qt5_moc_and_resources ALIAS CGAL_Qt5_moc_and_resources) endif() @@ -112,7 +114,7 @@ function(CGAL_setup_CGAL_Qt5_dependencies target) endif() target_link_libraries( ${target} INTERFACE CGAL::CGAL) target_link_libraries( ${target} INTERFACE CGAL::Qt5_moc_and_resources) - target_link_libraries( ${target} INTERFACE Qt5::OpenGL Qt5::Svg ) + target_link_libraries( ${target} INTERFACE Qt5::OpenGL Qt5::Widgets ) # Remove -Wdeprecated-copy, for g++ >= 9.0, because Qt5, as of # version 5.12, has a lot of [-Wdeprecated-copy] warnings. From fe5a36c08eea26f3b749f40241ada7be7401f162 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Apr 2023 17:27:37 +0200 Subject: [PATCH 64/64] fix all the CMakeLists.txt for Qt5 --- AABB_tree/demo/AABB_tree/CMakeLists.txt | 4 ++-- Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt | 4 ++-- .../demo/Arrangement_on_surface_2/CMakeLists.txt | 4 ++-- CGAL_ipelets/demo/CGAL_ipelets/mesh_2.cpp | 4 ++-- Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt | 4 ++-- GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Bounding_volumes/CMakeLists.txt | 4 ++-- GraphicsView/demo/Circular_kernel_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Generator/CMakeLists.txt | 4 ++-- GraphicsView/demo/GraphicsView/CMakeLists.txt | 4 ++-- GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt | 4 ++-- .../demo/Periodic_2_triangulation_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Polygon/CMakeLists.txt | 4 ++-- GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt | 4 ++-- .../demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Snap_rounding_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Spatial_searching_2/CMakeLists.txt | 4 ++-- GraphicsView/demo/Stream_lines_2/CMakeLists.txt | 4 ++-- .../demo/Hyperbolic_triangulation_2/CMakeLists.txt | 2 +- .../demo/Linear_cell_complex/CMakeLists.txt | 8 +++----- .../CMakeLists.txt | 5 ++--- .../demo/Periodic_3_triangulation_3/CMakeLists.txt | 4 ++-- .../demo/Periodic_Lloyd_3/CMakeLists.txt | 4 ++-- .../demo/Polyline_simplification_2/CMakeLists.txt | 4 ++-- .../demo/Principal_component_analysis/CMakeLists.txt | 4 ++-- Triangulation_3/demo/Triangulation_3/CMakeLists.txt | 4 ++-- .../demo/Triangulation_on_sphere_2/CMakeLists.txt | 4 ++-- 29 files changed, 58 insertions(+), 61 deletions(-) diff --git a/AABB_tree/demo/AABB_tree/CMakeLists.txt b/AABB_tree/demo/AABB_tree/CMakeLists.txt index c777eba1798..d0fcdd47ade 100644 --- a/AABB_tree/demo/AABB_tree/CMakeLists.txt +++ b/AABB_tree/demo/AABB_tree/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories(BEFORE ./ ./include) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS Script OpenGL Gui Svg) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -53,7 +53,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) #${CGAL_Qt5_MOC_FILES} ) # Link with Qt libraries - target_link_libraries(AABB_demo PRIVATE Qt5::OpenGL Qt5::Gui + target_link_libraries(AABB_demo PRIVATE Qt5::Widgets Qt5::OpenGL CGAL::CGAL CGAL::CGAL_Qt5) add_to_cached_list(CGAL_EXECUTABLE_TARGETS AABB_demo) diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt index ec2a2a8dbb4..7498df1b70a 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/CMakeLists.txt @@ -19,7 +19,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -40,7 +40,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Alpha_shape_3) target_link_libraries(Alpha_shape_3 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::OpenGL Qt5::Gui) + Qt5::Widgets Qt5::OpenGL) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Alpha_shape_3) diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt index 82e33197dae..7992c9b19fa 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/CMakeLists.txt @@ -13,7 +13,7 @@ if(POLICY CMP0071) endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core Qt5) -find_package(Qt5 QUIET COMPONENTS Gui Widgets) +find_package(Qt5 QUIET COMPONENTS Widgets) if (CGAL_Qt5_FOUND AND Qt5_FOUND) include(${CGAL_USE_FILE}) @@ -110,7 +110,7 @@ if (CGAL_Qt5_FOUND AND Qt5_FOUND) ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES}) - target_link_libraries(arrangement_2 PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets) + target_link_libraries(arrangement_2 PRIVATE Qt5::Widgets) target_link_libraries(arrangement_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5) if(CGAL_Core_FOUND) target_link_libraries(arrangement_2 PRIVATE CGAL::CGAL_Core) diff --git a/CGAL_ipelets/demo/CGAL_ipelets/mesh_2.cpp b/CGAL_ipelets/demo/CGAL_ipelets/mesh_2.cpp index a450cac2c7e..8b4a70e49fe 100644 --- a/CGAL_ipelets/demo/CGAL_ipelets/mesh_2.cpp +++ b/CGAL_ipelets/demo/CGAL_ipelets/mesh_2.cpp @@ -108,8 +108,8 @@ void IpeletMesh2::protected_run(int fn) mesher.refine_mesh(); } else - CGAL::refine_Delaunay_mesh_2(cdt,list_of_seeds.begin(), list_of_seeds.end(), - Criteria(0.125, alpha)); + CGAL::refine_Delaunay_mesh_2(cdt, + CGAL::parameters::criteria(Criteria(0.125, alpha)).seeds(list_of_seeds)); for (CDT::Finite_edges_iterator it=cdt.finite_edges_begin(); it!=cdt.finite_edges_end();++it) diff --git a/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt b/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt index 54c3be3aba4..de903d372ba 100644 --- a/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt +++ b/Circular_kernel_3/demo/Circular_kernel_3/CMakeLists.txt @@ -12,7 +12,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -23,7 +23,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Circular_kernel_3) target_link_libraries(Circular_kernel_3 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::OpenGL Qt5::Gui) + Qt5::Widgets Qt5::OpenGL) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Circular_kernel_3) diff --git a/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt b/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt index ca4a58c5958..eb84c251f4c 100644 --- a/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt +++ b/GraphicsView/demo/Alpha_shapes_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -37,7 +37,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Alpha_shapes_2) target_link_libraries(Alpha_shapes_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Alpha_shapes_2) diff --git a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt index ab0f43011f9..d104dcbb6a8 100644 --- a/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt +++ b/GraphicsView/demo/Apollonius_graph_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) @@ -38,7 +38,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Apollonius_graph_2) target_link_libraries(Apollonius_graph_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Apollonius_graph_2) diff --git a/GraphicsView/demo/Bounding_volumes/CMakeLists.txt b/GraphicsView/demo/Bounding_volumes/CMakeLists.txt index 69a30838cea..78f97078c03 100644 --- a/GraphicsView/demo/Bounding_volumes/CMakeLists.txt +++ b/GraphicsView/demo/Bounding_volumes/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -40,7 +40,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Bounding_volumes) target_link_libraries(Bounding_volumes PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Bounding_volumes) diff --git a/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt b/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt index eb2e2b79011..35165d8a056 100644 --- a/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt +++ b/GraphicsView/demo/Circular_kernel_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) @@ -38,7 +38,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Circular_kernel_2) target_link_libraries(Circular_kernel_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Circular_kernel_2) diff --git a/GraphicsView/demo/Generator/CMakeLists.txt b/GraphicsView/demo/Generator/CMakeLists.txt index 3be28ec735d..efd77cce428 100644 --- a/GraphicsView/demo/Generator/CMakeLists.txt +++ b/GraphicsView/demo/Generator/CMakeLists.txt @@ -14,7 +14,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -36,7 +36,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Generator_2) - target_link_libraries(Generator_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui) + target_link_libraries(Generator_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Generator_2) diff --git a/GraphicsView/demo/GraphicsView/CMakeLists.txt b/GraphicsView/demo/GraphicsView/CMakeLists.txt index 51617b00b87..6fddf7a0485 100644 --- a/GraphicsView/demo/GraphicsView/CMakeLists.txt +++ b/GraphicsView/demo/GraphicsView/CMakeLists.txt @@ -14,7 +14,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -25,7 +25,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS min) - target_link_libraries(min PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui) + target_link_libraries(min PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(min) diff --git a/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt b/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt index 432cb655369..7cf32558839 100644 --- a/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt +++ b/GraphicsView/demo/L1_Voronoi_diagram_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -38,7 +38,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS L1_voronoi_diagram_2) target_link_libraries(L1_voronoi_diagram_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(L1_voronoi_diagram_2) diff --git a/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt b/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt index a6de2468c40..45327610ba1 100644 --- a/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt +++ b/GraphicsView/demo/Largest_empty_rect_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -37,7 +37,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Largest_empty_rectangle_2) target_link_libraries(Largest_empty_rectangle_2 - PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui) + PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Largest_empty_rectangle_2) diff --git a/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt b/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt index 2f964941bb0..20aea1ba614 100644 --- a/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt +++ b/GraphicsView/demo/Periodic_2_triangulation_2/CMakeLists.txt @@ -12,7 +12,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -49,7 +49,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) Periodic_2_Delaunay_triangulation_2) target_link_libraries(Periodic_2_Delaunay_triangulation_2 - PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui) + PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Periodic_2_Delaunay_triangulation_2) diff --git a/GraphicsView/demo/Polygon/CMakeLists.txt b/GraphicsView/demo/Polygon/CMakeLists.txt index 8314d618d2f..86776216da9 100644 --- a/GraphicsView/demo/Polygon/CMakeLists.txt +++ b/GraphicsView/demo/Polygon/CMakeLists.txt @@ -22,7 +22,7 @@ if(NOT TARGET CGAL::Eigen3_support) return() endif() -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) include(${CGAL_USE_FILE}) @@ -49,7 +49,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Polygon_2) target_link_libraries(Polygon_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - CGAL::Eigen3_support Qt5::Gui) + CGAL::Eigen3_support Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Polygon_2) diff --git a/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt b/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt index 745fbb09ed0..bd04cffba0d 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt +++ b/GraphicsView/demo/Segment_Delaunay_graph_2/CMakeLists.txt @@ -20,7 +20,7 @@ set(QT_USE_QTMAIN TRUE) set(QT_USE_QTSCRIPT TRUE) set(QT_USE_QTOPENGL TRUE) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -43,7 +43,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Segment_voronoi_2) target_link_libraries(Segment_voronoi_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Segment_voronoi_2) diff --git a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt index f1d5e4fbbd4..5985a26066c 100644 --- a/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt +++ b/GraphicsView/demo/Segment_Delaunay_graph_Linf_2/CMakeLists.txt @@ -20,7 +20,7 @@ set(QT_USE_QTMAIN TRUE) set(QT_USE_QTSCRIPT TRUE) set(QT_USE_QTOPENGL TRUE) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ./include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -42,7 +42,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Segment_voronoi_linf_2) target_link_libraries(Segment_voronoi_linf_2 PRIVATE CGAL::CGAL - CGAL::CGAL_Qt5 Qt5::Gui) + CGAL::CGAL_Qt5 Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Segment_voronoi_linf_2) diff --git a/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt b/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt index 0b7ebdeb6d8..7b5135384fe 100644 --- a/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt +++ b/GraphicsView/demo/Snap_rounding_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) set(CMAKE_AUTOMOC ON) @@ -36,7 +36,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Snap_rounding_2) target_link_libraries(Snap_rounding_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Snap_rounding_2) diff --git a/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt b/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt index f5d5aad6d14..799a2f3641a 100644 --- a/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt +++ b/GraphicsView/demo/Spatial_searching_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -37,7 +37,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Spatial_searching_2) target_link_libraries(Spatial_searching_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Spatial_searching_2) diff --git a/GraphicsView/demo/Stream_lines_2/CMakeLists.txt b/GraphicsView/demo/Stream_lines_2/CMakeLists.txt index 0067351b4e1..1331495dda2 100644 --- a/GraphicsView/demo/Stream_lines_2/CMakeLists.txt +++ b/GraphicsView/demo/Stream_lines_2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -37,7 +37,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Stream_lines_2) target_link_libraries(Stream_lines_2 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::Gui) + Qt5::Widgets) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Stream_lines_2) diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt index fbdf3791ccb..74c8c4af6b8 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt @@ -15,7 +15,7 @@ find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core Qt5) find_package(LEDA QUIET) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS OpenGL Gui) +find_package(Qt5 QUIET COMPONENTS Widgets) if(CGAL_Qt5_FOUND AND Qt5_FOUND diff --git a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt index 66c6e7088aa..3a5c447f893 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt @@ -42,11 +42,9 @@ add_definitions(-DCMAP_WITH_INDEX) # to use cc with index (handle otherwise) ################## find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg) +find_package(Qt5 COMPONENTS Widgets OpenGL) -if(NOT - (CGAL_Qt5_FOUND - AND Qt5_FOUND)) +if(NOT CGAL_Qt5_FOUND OR NOT Qt5_FOUND) message("NOTICE: This demo requires CGAL and Qt5, and will not be compiled.") @@ -79,7 +77,7 @@ else() add_to_cached_list(CGAL_EXECUTABLE_TARGETS Linear_cell_complex_3_demo) target_link_libraries(Linear_cell_complex_3_demo - PUBLIC CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui Qt5::OpenGL) + PUBLIC CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets Qt5::OpenGL) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Linear_cell_complex_3_demo) diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt index 96eb570c9c9..5a0db034bac 100644 --- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt +++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/CMakeLists.txt @@ -19,7 +19,7 @@ include_directories(BEFORE ./ ./include) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Find Qt5 itself -find_package(Qt5 5.4 QUIET COMPONENTS OpenGL) +find_package(Qt5 5.4 QUIET COMPONENTS Widgets) if(Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -68,8 +68,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_executable(Otr2_demo ${SRCS} ${CGAL_Qt5_MOC_FILES} ${UI_FILES} ${CGAL_Qt5_RESOURCE_FILES}) - target_link_libraries(Otr2_demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui - Qt5::OpenGL) + target_link_libraries(Otr2_demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) # Link with pthread if necessary if(CIMG_INCLUDE_DIR) diff --git a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt index 3692008579e..02063139e95 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_3_triangulation_3/CMakeLists.txt @@ -17,7 +17,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS OpenGL Help Core) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL Help) if(Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) @@ -73,7 +73,7 @@ if(CGAL_Qt5_FOUND add_to_cached_list(CGAL_EXECUTABLE_TARGETS periodic_3_triangulation_3_demo) target_link_libraries(periodic_3_triangulation_3_demo - PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::OpenGL) + PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets Qt5::OpenGL) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(periodic_3_triangulation_3_demo) diff --git a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt index 63284a9ba62..19f73e78462 100644 --- a/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt +++ b/Periodic_3_triangulation_3/demo/Periodic_Lloyd_3/CMakeLists.txt @@ -19,7 +19,7 @@ set(CMAKE_AUTOMOC ON) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS Script Help OpenGL Svg) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL Help) if(Qt5Help_VERSION VERSION_LESS 5.12) set(CGAL_QCOLLECTIONGENERATOR_TARGET Qt5::qcollectiongenerator) @@ -68,7 +68,7 @@ if(CGAL_Qt5_FOUND add_to_cached_list(CGAL_EXECUTABLE_TARGETS Periodic_Lloyd_3) target_link_libraries(Periodic_Lloyd_3 PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - Qt5::OpenGL) + Qt5::Widgets Qt5::OpenGL) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(Periodic_Lloyd_3) diff --git a/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt b/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt index 002fd913902..0eeb0f70465 100644 --- a/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt +++ b/Polyline_simplification_2/demo/Polyline_simplification_2/CMakeLists.txt @@ -17,7 +17,7 @@ find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) set(CMAKE_INCLUDE_CURRENT_DIR ON) -find_package(Qt5 QUIET COMPONENTS Script OpenGL Widgets Svg) +find_package(Qt5 QUIET COMPONENTS Widgets) include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -39,7 +39,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES}) target_link_libraries(Polyline_simplification_2 - PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui) + PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Widgets) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Polyline_simplification_2) diff --git a/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt index 6ec0024f3a5..65ca38e4a6f 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt +++ b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT TARGET CGAL::Eigen3_support) endif() # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS Script OpenGL) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) if(CGAL_Qt5_FOUND AND Qt5_FOUND) @@ -51,7 +51,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) ${CGAL_Qt5_MOC_FILES}) target_link_libraries(PCA_demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 - CGAL::Eigen3_support Qt5::Gui) + CGAL::Eigen3_support Qt5::Widgets Qt5::OpenGL) add_to_cached_list(CGAL_EXECUTABLE_TARGETS PCA_demo) diff --git a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt index d142ca17989..9069f7c5b6c 100644 --- a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt @@ -20,7 +20,7 @@ set(CMAKE_AUTOMOC ON) find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) -find_package(Qt5 QUIET COMPONENTS OpenGL) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) if(Qt5_FOUND) add_definitions(-DQT_NO_KEYWORDS) @@ -70,7 +70,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND) add_to_cached_list(CGAL_EXECUTABLE_TARGETS T3_demo) target_link_libraries(T3_demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5) - target_link_libraries(T3_demo PRIVATE Qt5::OpenGL) + target_link_libraries(T3_demo PRIVATE Qt5::Widgets Qt5::OpenGL) if(TARGET CGAL::TBB_support) target_link_libraries(T3_demo PUBLIC CGAL::TBB_support) endif() diff --git a/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/CMakeLists.txt b/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/CMakeLists.txt index c9b21f4d7ee..1e0f6497bce 100644 --- a/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/CMakeLists.txt +++ b/Triangulation_on_sphere_2/demo/Triangulation_on_sphere_2/CMakeLists.txt @@ -24,7 +24,7 @@ endif() find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Find Qt5 itself -find_package(Qt5 QUIET COMPONENTS Script OpenGL Gui Svg) +find_package(Qt5 QUIET COMPONENTS Widgets OpenGL) find_package(Eigen3 3.1.0 QUIET) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) @@ -42,7 +42,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND TARGET CGAL::Eigen3_support) add_to_cached_list( CGAL_EXECUTABLE_TARGETS Triangulation_on_sphere_2_Demo ) - target_link_libraries( Triangulation_on_sphere_2_Demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 CGAL::Eigen3_support) + target_link_libraries( Triangulation_on_sphere_2_Demo PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 Qt5::OpenGL Qt5::Widgets CGAL::Eigen3_support) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test( Triangulation_on_sphere_2_Demo )