Add connected_components without EdgeConstraintMap

This commit is contained in:
Andreas Fabri 2015-02-13 18:08:52 +01:00
parent 444793142b
commit 8277f73a2c
3 changed files with 30 additions and 5 deletions

View File

@ -61,7 +61,8 @@
## Other Classes and Functions ##
- `CGAL::Polygon_mesh_slicer`
- `CGAL::Polygon_Mesh_processing::keep_largest_connected_components()`
- `CGAL::Polygon_Mesh_processing::discover_connected_component()`
- `CGAL::Polygon_Mesh_processing::connected_component()`
- `CGAL::Polygon_Mesh_processing::connected_components()`
\todo remove FairWeightCalculator and replace it by a property map. Note that the default property map should be documented
\todo make template parameter names uniform in other packages using BGL. Here we chose PolygonMesh as template parameter.

View File

@ -49,7 +49,7 @@ int main(int, char* argv[])
Mesh::Property_map<face_descriptor,int> fccmap;
fccmap = sm.add_property_map<face_descriptor,int>("f:CC").first;
int num = CGAL::Polygon_mesh_processing::connected_components(sm,
Constraint<Mesh>(sm),
//Constraint<Mesh>(sm),
fccmap);
std::cerr << "The graph has " << num << " connected components (face connectivity)" << std::endl;

View File

@ -398,7 +398,8 @@ template <typename G>
struct No_constraint {
No_constraint() { }
No_constraint(G & g) : g(&g) { }
No_constraint(G & g)
: g(&g) { }
template <typename T>
bool operator[](const T & ) const {
@ -408,12 +409,13 @@ struct No_constraint {
G* g;
};
template <typename G, typename EdgeConstraintMap>
template <typename G, typename EdgeConstraintMap = No_constraint<G> >
struct No_border {
No_border()
{}
No_border(G & g, EdgeConstraintMap ecm) : g(&g), ecm(ecm)
No_border(G & g, EdgeConstraintMap ecm = EdgeConstraintMap())
: g(&g), ecm(ecm)
{ }
bool operator()(typename boost::graph_traits<G>::edge_descriptor e) const {
@ -427,6 +429,8 @@ struct No_border {
EdgeConstraintMap ecm;
};
}// namespace internal
@ -474,6 +478,26 @@ struct No_border {
return boost::connected_components(finite_dual, fim);
}
/*!
* \ingroup PkgPolygonMeshProcessing
* computes for each face the index of the connected components to which it belongs.
* Two faces are considered to be in the same connected component if they share an edge.
* \tparam PolygonMesh a model of `FaceGraph`
* \tparam FaceIndexMap the property map with the face index as value type, and the index of its connected component
* \returns the number of connected components.
*/
template <class PolygonMesh, class FaceIndexMap>
typename boost::graph_traits<PolygonMesh>::faces_size_type
connected_components(PolygonMesh& pmesh,
FaceIndexMap& fim)
{
typedef Dual<PolygonMesh> Dual;
typedef boost::filtered_graph<Dual, internal::No_border<PolygonMesh> > FiniteDual;
Dual dual(pmesh);
FiniteDual finite_dual(dual,internal::No_border<PolygonMesh>(pmesh));
return boost::connected_components(finite_dual, fim);
}
} // namespace Polygon_mesh_processing
} // namespace CGAL