From 0212343669ab36311adf39ab4649a06c6210f26b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 1 Jul 2019 14:15:55 +0200 Subject: [PATCH] add doc for split_ccs --- .../PackageDescription.txt | 1 + .../Polygon_mesh_processing.txt | 3 + .../connected_components.h | 64 ++++++++++++++----- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 8adfb2ddbda..72595546a7b 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -156,6 +156,7 @@ and provides a list of the parameters that are used in this package. - `CGAL::Polygon_mesh_processing::connected_components()` - `CGAL::Polygon_mesh_processing::keep_large_connected_components()` - `CGAL::Polygon_mesh_processing::keep_largest_connected_components()` +- `CGAL::Polygon_mesh_processing::split_connected_components()` - \link keep_connected_components_grp `CGAL::Polygon_mesh_processing::keep_connected_components()` \endlink - \link keep_connected_components_grp `CGAL::Polygon_mesh_processing::remove_connected_components()` \endlink diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 26ea1b7df8e..5eae3e6d9de 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -715,6 +715,9 @@ enables the user to keep only the largest connected components. This feature can for example be useful for noisy data were small connected components should be discarded in favour of major connected components. +Also, the function `CGAL::Polygon_mesh_processing::split_connected_components()` +enables the user to split the connected components of a polygon mesh in as many +polygon meshes. \subsection CCExample Connected Components Example diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 4886e4e4493..ba8b718021b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -804,6 +804,7 @@ void keep_connected_components(PolygonMesh& pmesh namespace internal{ + template std::pair get_map(MapFromNP m, Default_tag, Dynamic_tag, Mesh&) @@ -833,7 +834,7 @@ struct No_mark }; -template < class TriangleMesh, class OutputIterator, +template < class PolygonMesh, class OutputIterator, class FIMap, class VIMap, class HIMap, class Ecm > OutputIterator split_connected_components_impl( @@ -842,7 +843,7 @@ OutputIterator split_connected_components_impl( std::pair vim,//pair(map, need_init) Ecm ecm, OutputIterator out, - const TriangleMesh& tm + const PolygonMesh& tm ) { if(fim.second) @@ -871,7 +872,7 @@ OutputIterator split_connected_components_impl( } typename boost::template property_map< - TriangleMesh, CGAL::dynamic_face_property_t >::const_type + PolygonMesh, CGAL::dynamic_face_property_t >::const_type pidmap = get(CGAL::dynamic_face_property_t(), tm); int nb_patches = @@ -883,12 +884,12 @@ OutputIterator split_connected_components_impl( for(int i=0; i + CGAL::Face_filtered_graph filter_graph(tm, i, pidmap, CGAL::parameters::face_index_map(fim.first) .halfedge_index_map(him.first) .vertex_index_map(vim.first)); - TriangleMesh new_graph; + PolygonMesh new_graph; CGAL::copy_face_graph(filter_graph, new_graph); *out++ = new_graph; } @@ -896,22 +897,51 @@ OutputIterator split_connected_components_impl( } }//internal -template -OutputIterator split_connected_components(TriangleMesh& tm, - OutputIterator out, +/*! + * \ingroup keep_connected_components_grp + * for each connected component of `pm`, a new `PolygonMesh` containing it will be outputted to `out`. + * + * \tparam PolygonMesh a model of `FaceListGraph` + * \tparam OutputIterator a model of `OutputIterator` + * holding objects of type `PolygonMesh`. + * + * \tparam NamedParameters a sequence of Named Parameters + * + * \param pm the polygon mesh + * \param out output iterator to be filled with extracted polygon meshes. + * \param np an optional sequence of Named Parameters among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamBegin{edge_is_constrained_map} a property map containing the constrained-or-not status of each edge of `pm` \cgalParamEnd + * \cgalParamBegin{face_index_map} + * a property map containing an index for each face initialized from 0 to `num_vertices(pm)` + * \cgalParamEnd + * \cgalParamBegin{vertex_index_map} + * a property map containing an index for each vertex initialized 0 to `num_vertices(pm)` + * \cgalParamEnd + * \cgalNPBegin{halfedge_index_map} + * a property map containing an index for each halfedge initialized 0 to `num_halfedges(pm)` + * \cgalNPEnd + * \cgalNamedParamsEnd + * + * \returns `out`. + */ +template +OutputIterator split_connected_components(PolygonMesh& pm, + OutputIterator out, const NamedParameters& np) { - typedef typename boost::mpl::if_c::value + typedef typename boost::mpl::if_c::value , CGAL::face_index_t ,CGAL::dynamic_face_property_t >::type FIM_def_tag; //or no _c ? - typedef typename boost::mpl::if_c::value + typedef typename boost::mpl::if_c::value , CGAL::halfedge_index_t ,CGAL::dynamic_halfedge_property_t >::type HIM_def_tag; //or no _c ? - typedef typename boost::mpl::if_c::value + typedef typename boost::mpl::if_c::value , boost::vertex_index_t ,CGAL::dynamic_vertex_property_t >::type VIM_def_tag; //or no _c ? @@ -919,26 +949,26 @@ OutputIterator split_connected_components(TriangleMesh& tm, typedef typename boost::lookup_named_param_def < internal_np::edge_is_constrained_t, NamedParameters, - internal::No_mark//default + internal::No_mark//default > ::type Ecm; Ecm ecm = boost::choose_param( boost::get_param(np, internal_np::edge_is_constrained), - internal::No_mark() ); + internal::No_mark() ); return internal::split_connected_components_impl( internal::get_map( get_param(np, internal_np::face_index), CGAL::dynamic_face_property_t(), - FIM_def_tag(), tm), + FIM_def_tag(), pm), internal::get_map( get_param(np, internal_np::halfedge_index), CGAL::dynamic_halfedge_property_t(), - HIM_def_tag(), tm), + HIM_def_tag(), pm), internal::get_map( get_param(np, internal_np::vertex_index), CGAL::dynamic_vertex_property_t(), - VIM_def_tag(), tm), - ecm, out, tm); + VIM_def_tag(), pm), + ecm, out, pm); }