diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt index 95d98601c9b..bb69a046df3 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/CMakeLists.txt @@ -65,6 +65,7 @@ create_single_source_cgal_program( "segmentation_via_sdf_values_example.cpp" ) create_single_source_cgal_program( "segmentation_with_facet_ids_example.cpp" ) create_single_source_cgal_program( "segmentation_from_sdf_values_SM_example.cpp") +create_single_source_cgal_program( "segmentation_from_sdf_values_LCC_example.cpp") if(OpenMesh_FOUND) create_single_source_cgal_program( "segmentation_from_sdf_values_OpenMesh_example.cpp" ) diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp index 52a4a6518b0..dc74b39d2d3 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp @@ -1,15 +1,16 @@ #include #include +#include #include #include #include +#include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; struct Myitem @@ -25,15 +26,16 @@ struct Myitem }; typedef CGAL::Linear_cell_complex_for_combinatorial_map<2, 3, MyTraits, Myitem> LCC; +typedef typename LCC::Attribute_const_handle<2>::type Facet_const_handle; int main() { - // create and read Polyhedron + // create and read LCC LCC mesh; - CGAL::load_off_v2("data/cactus.off"); + CGAL::load_off_v2(mesh, "data/cactus.off"); // create a property-map for SDF values - typedef std::map Facet_double_map; + typedef CGAL::Unique_hash_map Facet_double_map; Facet_double_map internal_sdf_map; boost::associative_property_map sdf_property_map(internal_sdf_map); @@ -41,20 +43,23 @@ int main() CGAL::sdf_values(mesh, sdf_property_map); // create a property-map for segment-ids - typedef std::map Facet_int_map; + typedef CGAL::Unique_hash_map Facet_int_map; Facet_int_map internal_segment_map; boost::associative_property_map segment_property_map(internal_segment_map); // segment the mesh using default parameters for number of levels, and smoothing lambda // Any other scalar values can be used instead of using SDF values computed using the CGAL function - std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map); + std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, + segment_property_map); std::cout << "Number of segments: " << number_of_segments << std::endl; // print segment-ids - for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin(); - facet_it != mesh.facets_end(); ++facet_it) { - // ids are between [0, number_of_segments -1] - std::cout << segment_property_map[facet_it] << " "; + for(typename LCC::Attribute_range<2>::type::const_iterator + facet_it=mesh.template attributes<2>().begin(); + facet_it!=mesh.template attributes<2>().end(); ++facet_it) + { + // ids are between [0, number_of_segments -1] + std::cout << segment_property_map[facet_it] << " "; } std::cout << std::endl; diff --git a/TODO-some-files-cgal-bgl.txt b/TODO-some-files-cgal-bgl.txt index fc171c78ced..fd085e6fe5d 100644 --- a/TODO-some-files-cgal-bgl.txt +++ b/TODO-some-files-cgal-bgl.txt @@ -17,6 +17,8 @@ Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_l ./Ridges_3/examples/Ridges_3/Ridges_Umbilics_SM.cpp +./Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp + ============================================= ./Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_LCC.cpp @@ -31,6 +33,5 @@ Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_l TODO -./Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp ./Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/MCF_Skeleton_sm_example.cpp ./Surface_mesh_skeletonization/examples/Surface_mesh_skeletonization/simple_mcfskel_sm_example.cpp