From 7d6b31e6700d352393554fa006d018794c5d1abe Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Sun, 24 Nov 2019 20:49:15 +0100 Subject: [PATCH] Add test for surface mesh topology --- .../include/CGAL/Combinatorial_map.h | 24 ++++++++ .../include/CGAL/Curves_on_surface_topology.h | 7 ++- .../test/Surface_mesh_topology/CMakeLists.txt | 59 ++++++++++++------- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 090468b0047..85e6e0bad5a 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -2469,6 +2469,30 @@ namespace CGAL { run(*this, adart, amark); } + /// Keep the biggest connected component. + /// @return the size (in number of darts) of the biggest cc. + std::size_t keep_biggest_connected_component() + { + std::map ccs; + + size_type treated=get_new_mark(); + for (auto it=darts().begin(), itend=darts().end(); it!=itend; ++it) + { + if (!is_marked(it, treated)) + { ccs[mark_cell(it, treated)]=it; } + } + + if (ccs.size()>1) + { // Here all darts are marked + this->template unmark_cell(ccs.rbegin()->second, treated); // Unmark the biggest cc + erase_marked_darts(treated); + } + + free_mark(treated); + + return ccs.rbegin()->first; + } + /** Count the marked cells (at least one marked dart). * @param amark the mark to consider. * @param avector containing the dimensions of the cells to count. diff --git a/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h b/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h index c55df06ab5c..2e3539168d6 100644 --- a/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h +++ b/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h @@ -35,8 +35,9 @@ class Curves_on_surface_topology { public: typedef internal::Minimal_quadrangulation Minimal_quadrangulation; + typedef typename Minimal_quadrangulation::Original_map Original_map; typedef typename Minimal_quadrangulation::Reduced_map Reduced_map; - + Curves_on_surface_topology(const Mesh& amesh, bool /* display_time */=false) : m_original_mesh(amesh), m_minimal_quadrangulation(nullptr) @@ -56,6 +57,10 @@ public: } } + /// Return the original map. + const Original_map& get_original_map() const + { return m_minimal_quadrangulation->get_original_map(); } + /// Return the reduced map computed in the minimal quadrangulation. /// @pre is_minimal_quadrangulation_computed() const Reduced_map& get_minimal_quadrangulation() const diff --git a/Surface_mesh_topology/test/Surface_mesh_topology/CMakeLists.txt b/Surface_mesh_topology/test/Surface_mesh_topology/CMakeLists.txt index 7e76a3bcb93..20c2af2ec11 100644 --- a/Surface_mesh_topology/test/Surface_mesh_topology/CMakeLists.txt +++ b/Surface_mesh_topology/test/Surface_mesh_topology/CMakeLists.txt @@ -7,27 +7,44 @@ if(CGAL_Qt5_FOUND) add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS) endif() -if ( CGAL_FOUND ) - create_single_source_cgal_program("fundamental_group_of_the_circle.cpp") - create_single_source_cgal_program("fundamental_group_of_the_torus.cpp") - create_single_source_cgal_program("homotopy_big_cylinder.cpp") - create_single_source_cgal_program("homotopy_double_torus_with_holes.cpp") - create_single_source_cgal_program("homotopy_rond_point_saucisse.cpp") - create_single_source_cgal_program("homotopy_small_cylinder.cpp") - create_single_source_cgal_program("path_tests.cpp") - create_single_source_cgal_program("path_with_rle_deformation_tests.cpp") - create_single_source_cgal_program("test_homotopy.cpp") - create_single_source_cgal_program("tests_path_on_surface.cpp") +if ( NOT CGAL_FOUND ) - if(CGAL_Qt5_FOUND) - target_link_libraries(fundamental_group_of_the_circle PUBLIC CGAL::CGAL_Qt5) - target_link_libraries(fundamental_group_of_the_torus PUBLIC CGAL::CGAL_Qt5) - target_link_libraries(path_with_rle_deformation_tests PUBLIC CGAL::CGAL_Qt5) - target_link_libraries(test_homotopy PUBLIC CGAL::CGAL_Qt5) - endif() + message(FATAL_ERROR "This program requires the CGAL library, and will not be compiled.") -else() - - message(STATUS "This program requires the CGAL library, and will not be compiled.") - +endif() + +set(HEADER_FILES + ../../include/CGAL/Curves_on_surface_topology.h + ../../include/CGAL/draw_face_graph_with_paths.h + ../../include/CGAL/Path_on_surface.h + ../../include/CGAL/Polygonal_schema.h + ../../include/CGAL/Polygonal_schema_min_items.h + ../../include/CGAL/Surface_mesh_topology/internal/Minimal_quadrangulation.h + ../../include/CGAL/Surface_mesh_topology/internal/Path_generators.h + ../../include/CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h + ) + +set(SOURCE_FILES + fundamental_group_of_the_circle.cpp + fundamental_group_of_the_torus.cpp + homotopy_big_cylinder.cpp + homotopy_double_torus_with_holes.cpp + homotopy_rond_point_saucisse.cpp + homotopy_small_cylinder.cpp + path_tests.cpp + path_with_rle_deformation_tests.cpp + test_homotopy.cpp + test_homotopy_with_polygonal_schema.cpp + tests_path_on_surface.cpp + ) + +foreach(cppfile ${SOURCE_FILES}) + create_single_source_cgal_program("${cppfile}" ${HEADER_FILES}) +endforeach() + +if(CGAL_Qt5_FOUND) + target_link_libraries(fundamental_group_of_the_circle PUBLIC CGAL::CGAL_Qt5) + target_link_libraries(fundamental_group_of_the_torus PUBLIC CGAL::CGAL_Qt5) + target_link_libraries(path_with_rle_deformation_tests PUBLIC CGAL::CGAL_Qt5) + target_link_libraries(test_homotopy PUBLIC CGAL::CGAL_Qt5) endif()