mirror of https://github.com/CGAL/cgal
Merge pull request #4728 from sloriot/PMP-cc_cleanup
Clean in connected components
This commit is contained in:
commit
10ba34719e
|
|
@ -74,7 +74,7 @@ int main(int argc, char** argv)
|
||||||
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
|
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
|
||||||
// for details.
|
// for details.
|
||||||
boost::vector_property_map<Vector, Face_index_map>
|
boost::vector_property_map<Vector, Face_index_map>
|
||||||
normals(get(CGAL::face_index, lcc));
|
normals(static_cast<unsigned>(num_faces(lcc)), get(CGAL::face_index, lcc));
|
||||||
|
|
||||||
calculate_face_normals(
|
calculate_face_normals(
|
||||||
lcc // Graph
|
lcc // Graph
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||||
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
|
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
|
||||||
// for details.
|
// for details.
|
||||||
boost::vector_property_map<Vector, Face_index_map>
|
boost::vector_property_map<Vector, Face_index_map>
|
||||||
normals(get(CGAL::face_index, P));
|
normals(static_cast<unsigned>(num_faces(P)), get(CGAL::face_index, P));
|
||||||
|
|
||||||
calculate_face_normals(
|
calculate_face_normals(
|
||||||
P // Graph
|
P // Graph
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh,
|
||||||
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
|
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
|
||||||
|
|
||||||
// vector_property_map
|
// vector_property_map
|
||||||
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fimap);
|
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(static_cast<unsigned>(num_faces(pmesh)), fimap);
|
||||||
std::size_t num = connected_components(pmesh, face_cc, np);
|
std::size_t num = connected_components(pmesh, face_cc, np);
|
||||||
|
|
||||||
// Even if we do not want to keep anything we need to first
|
// Even if we do not want to keep anything we need to first
|
||||||
|
|
@ -594,7 +594,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh,
|
||||||
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
|
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
|
||||||
|
|
||||||
// vector_property_map
|
// vector_property_map
|
||||||
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fim);
|
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(static_cast<unsigned>(num_faces(pmesh)), fim);
|
||||||
std::size_t num = connected_components(pmesh, face_cc, np);
|
std::size_t num = connected_components(pmesh, face_cc, np);
|
||||||
std::vector<Face_size> component_size(num, 0);
|
std::vector<Face_size> component_size(num, 0);
|
||||||
|
|
||||||
|
|
@ -655,14 +655,12 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
{
|
{
|
||||||
using parameters::choose_parameter;
|
using parameters::choose_parameter;
|
||||||
using parameters::get_parameter;
|
using parameters::get_parameter;
|
||||||
|
using parameters::is_default_parameter;
|
||||||
|
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
|
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::face_iterator face_iterator;
|
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
|
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::vertex_iterator vertex_iterator;
|
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
|
typedef typename boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::edge_descriptor edge_descriptor;
|
typedef typename boost::graph_traits<PolygonMesh>::edge_descriptor edge_descriptor;
|
||||||
typedef typename boost::graph_traits<PolygonMesh>::edge_iterator edge_iterator;
|
|
||||||
|
|
||||||
typedef typename GetInitializedVertexIndexMap<PolygonMesh, NamedParameters>::type VertexIndexMap;
|
typedef typename GetInitializedVertexIndexMap<PolygonMesh, NamedParameters>::type VertexIndexMap;
|
||||||
VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np);
|
VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np);
|
||||||
|
|
@ -671,10 +669,10 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
for(std::size_t i : components_to_keep)
|
for(std::size_t i : components_to_keep)
|
||||||
cc_to_keep.insert(i);
|
cc_to_keep.insert(i);
|
||||||
|
|
||||||
boost::vector_property_map<bool, VertexIndexMap> keep_vertex(vim);
|
boost::vector_property_map<bool, VertexIndexMap> keep_vertex(static_cast<unsigned>(num_vertices(pmesh)), vim);
|
||||||
for(vertex_descriptor v : vertices(pmesh)){
|
for(vertex_descriptor v : vertices(pmesh))
|
||||||
keep_vertex[v] = false;
|
keep_vertex[v] = false;
|
||||||
}
|
|
||||||
for(face_descriptor f : faces(pmesh)){
|
for(face_descriptor f : faces(pmesh)){
|
||||||
if (cc_to_keep.find(get(fcm,f)) != cc_to_keep.end())
|
if (cc_to_keep.find(get(fcm,f)) != cc_to_keep.end())
|
||||||
put(fcm, f, keep ? 1 : 0);
|
put(fcm, f, keep ? 1 : 0);
|
||||||
|
|
@ -691,11 +689,9 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edge_iterator eb, ee;
|
std::vector<edge_descriptor> edges_to_remove;
|
||||||
for (boost::tie(eb, ee) = edges(pmesh); eb != ee;)
|
for (edge_descriptor e : edges(pmesh))
|
||||||
{
|
{
|
||||||
edge_descriptor e = *eb;
|
|
||||||
++eb;
|
|
||||||
vertex_descriptor v = source(e, pmesh);
|
vertex_descriptor v = source(e, pmesh);
|
||||||
vertex_descriptor w = target(e, pmesh);
|
vertex_descriptor w = target(e, pmesh);
|
||||||
halfedge_descriptor h = halfedge(e, pmesh);
|
halfedge_descriptor h = halfedge(e, pmesh);
|
||||||
|
|
@ -703,7 +699,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
if (!keep_vertex[v] && !keep_vertex[w]){
|
if (!keep_vertex[v] && !keep_vertex[w]){
|
||||||
// don't care about connectivity
|
// don't care about connectivity
|
||||||
// As vertices are not kept the faces and vertices will be removed later
|
// As vertices are not kept the faces and vertices will be removed later
|
||||||
remove_edge(e, pmesh);
|
edges_to_remove.push_back(e);
|
||||||
}
|
}
|
||||||
else if (keep_vertex[v] && keep_vertex[w]){
|
else if (keep_vertex[v] && keep_vertex[w]){
|
||||||
face_descriptor fh = face(h, pmesh), ofh = face(oh, pmesh);
|
face_descriptor fh = face(h, pmesh), ofh = face(oh, pmesh);
|
||||||
|
|
@ -736,7 +732,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
// shortcut the next pointers as e will be removed
|
// shortcut the next pointers as e will be removed
|
||||||
set_next(prev(h, pmesh), next(oh, pmesh), pmesh);
|
set_next(prev(h, pmesh), next(oh, pmesh), pmesh);
|
||||||
set_next(prev(oh, pmesh), next(h, pmesh), pmesh);
|
set_next(prev(oh, pmesh), next(h, pmesh), pmesh);
|
||||||
remove_edge(e, pmesh);
|
edges_to_remove.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (keep_vertex[v]){
|
else if (keep_vertex[v]){
|
||||||
|
|
@ -744,7 +740,7 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
set_halfedge(v, prev(h, pmesh), pmesh);
|
set_halfedge(v, prev(h, pmesh), pmesh);
|
||||||
}
|
}
|
||||||
set_next(prev(h, pmesh), next(oh, pmesh), pmesh);
|
set_next(prev(h, pmesh), next(oh, pmesh), pmesh);
|
||||||
remove_edge(e, pmesh);
|
edges_to_remove.push_back(e);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CGAL_assertion(keep_vertex[w]);
|
CGAL_assertion(keep_vertex[w]);
|
||||||
|
|
@ -752,26 +748,40 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
|
||||||
set_halfedge(w, prev(oh, pmesh), pmesh);
|
set_halfedge(w, prev(oh, pmesh), pmesh);
|
||||||
}
|
}
|
||||||
set_next(prev(oh, pmesh), next(h, pmesh), pmesh);
|
set_next(prev(oh, pmesh), next(h, pmesh), pmesh);
|
||||||
remove_edge(e, pmesh);
|
edges_to_remove.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (edge_descriptor e : edges_to_remove)
|
||||||
|
remove_edge(e, pmesh);
|
||||||
|
|
||||||
face_iterator fb, fe;
|
|
||||||
// We now can remove all vertices and faces not marked as kept
|
// We now can remove all vertices and faces not marked as kept
|
||||||
for (boost::tie(fb, fe) = faces(pmesh); fb != fe;){
|
std::vector<face_descriptor> faces_to_remove;
|
||||||
face_descriptor f = *fb;
|
for (face_descriptor f : faces(pmesh))
|
||||||
++fb;
|
if (get(fcm,f) != 1)
|
||||||
if (get(fcm,f) != 1){
|
faces_to_remove.push_back(f);
|
||||||
remove_face(f, pmesh);
|
for (face_descriptor f : faces_to_remove)
|
||||||
}
|
remove_face(f, pmesh);
|
||||||
}
|
|
||||||
vertex_iterator b, e;
|
std::vector<vertex_descriptor> vertices_to_remove;
|
||||||
for (boost::tie(b, e) = vertices(pmesh); b != e;){
|
for(vertex_descriptor v: vertices(pmesh))
|
||||||
vertex_descriptor v = *b;
|
if (!keep_vertex[v])
|
||||||
++b;
|
vertices_to_remove.push_back(v);
|
||||||
if (!keep_vertex[v]){
|
if ( is_default_parameter(get_parameter(np, internal_np::vertex_is_constrained)) )
|
||||||
|
for (vertex_descriptor v : vertices_to_remove)
|
||||||
remove_vertex(v, pmesh);
|
remove_vertex(v, pmesh);
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_is_constrained_t,
|
||||||
|
NamedParameters,
|
||||||
|
Static_boolean_property_map<vertex_descriptor, false> // default (not used)
|
||||||
|
>::type Vertex_map;
|
||||||
|
Vertex_map is_cst = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
||||||
|
Static_boolean_property_map<vertex_descriptor, false>());
|
||||||
|
for (vertex_descriptor v : vertices_to_remove)
|
||||||
|
if (!get(is_cst, v))
|
||||||
|
remove_vertex(v, pmesh);
|
||||||
|
else
|
||||||
|
set_halfedge(v, boost::graph_traits<PolygonMesh>::null_halfedge(), pmesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -924,7 +934,7 @@ void remove_connected_components(PolygonMesh& pmesh
|
||||||
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
|
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
|
||||||
FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np);
|
FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np);
|
||||||
|
|
||||||
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fim);
|
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(static_cast<unsigned>(num_faces(pmesh)), fim);
|
||||||
connected_components(pmesh, face_cc, np);
|
connected_components(pmesh, face_cc, np);
|
||||||
|
|
||||||
std::vector<std::size_t> cc_to_remove;
|
std::vector<std::size_t> cc_to_remove;
|
||||||
|
|
@ -991,7 +1001,7 @@ void keep_connected_components(PolygonMesh& pmesh
|
||||||
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
|
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
|
||||||
FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np);
|
FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np);
|
||||||
|
|
||||||
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fim);
|
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(static_cast<unsigned>(num_faces(pmesh)), fim);
|
||||||
connected_components(pmesh, face_cc, np);
|
connected_components(pmesh, face_cc, np);
|
||||||
|
|
||||||
std::vector<std::size_t> cc_to_keep;
|
std::vector<std::size_t> cc_to_keep;
|
||||||
|
|
@ -1043,13 +1053,6 @@ void keep_connected_components(PolygonMesh& pmesh
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename G>
|
|
||||||
struct No_mark
|
|
||||||
{
|
|
||||||
friend bool get(No_mark<G>, typename boost::graph_traits<G>::edge_descriptor) { return false; }
|
|
||||||
friend void put(No_mark<G>, typename boost::graph_traits<G>::edge_descriptor, bool) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
template < class PolygonMesh, class PolygonMeshRange,
|
template < class PolygonMesh, class PolygonMeshRange,
|
||||||
class FIMap, class VIMap,
|
class FIMap, class VIMap,
|
||||||
class HIMap, class Ecm, class NamedParameters >
|
class HIMap, class Ecm, class NamedParameters >
|
||||||
|
|
@ -1168,17 +1171,19 @@ void split_connected_components(const PolygonMesh& pmesh,
|
||||||
PolygonMeshRange& cc_meshes,
|
PolygonMeshRange& cc_meshes,
|
||||||
const NamedParameters& np)
|
const NamedParameters& np)
|
||||||
{
|
{
|
||||||
|
typedef Static_boolean_property_map<
|
||||||
|
typename boost::graph_traits<PolygonMesh>::edge_descriptor, false> Default_ecm;
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
internal_np::edge_is_constrained_t,
|
internal_np::edge_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
internal::No_mark<PolygonMesh>//default
|
Default_ecm//default
|
||||||
> ::type Ecm;
|
> ::type Ecm;
|
||||||
|
|
||||||
using parameters::choose_parameter;
|
using parameters::choose_parameter;
|
||||||
using parameters::get_parameter;
|
using parameters::get_parameter;
|
||||||
|
|
||||||
Ecm ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
Ecm ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
||||||
internal::No_mark<PolygonMesh>());
|
Default_ecm());
|
||||||
|
|
||||||
internal::split_connected_components_impl(CGAL::get_initialized_face_index_map(pmesh, np),
|
internal::split_connected_components_impl(CGAL::get_initialized_face_index_map(pmesh, np),
|
||||||
CGAL::get_initialized_halfedge_index_map(pmesh, np),
|
CGAL::get_initialized_halfedge_index_map(pmesh, np),
|
||||||
|
|
|
||||||
|
|
@ -1528,7 +1528,7 @@ private:
|
||||||
|
|
||||||
// update status using constrained edge map
|
// update status using constrained edge map
|
||||||
if (!boost::is_same<EdgeIsConstrainedMap,
|
if (!boost::is_same<EdgeIsConstrainedMap,
|
||||||
Constant_property_map<edge_descriptor, bool> >::value)
|
Static_boolean_property_map<edge_descriptor, false> >::value)
|
||||||
{
|
{
|
||||||
for(edge_descriptor e : edges(mesh_))
|
for(edge_descriptor e : edges(mesh_))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,10 @@ std::size_t make_umbrella_manifold(typename boost::graph_traits<PolygonMesh>::ha
|
||||||
|
|
||||||
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_is_constrained_t,
|
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<vertex_descriptor, bool> // default (no constraint pmap)
|
Static_boolean_property_map<vertex_descriptor, false> // default (no constraint pmap)
|
||||||
>::type VerticesMap;
|
>::type VerticesMap;
|
||||||
VerticesMap cmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
VerticesMap cmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
||||||
Constant_property_map<vertex_descriptor, bool>(false));
|
Static_boolean_property_map<vertex_descriptor, false>());
|
||||||
|
|
||||||
std::size_t nb_new_vertices = 0;
|
std::size_t nb_new_vertices = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1281,7 +1281,7 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np)
|
||||||
CGAL_precondition(is_closed(tm));
|
CGAL_precondition(is_closed(tm));
|
||||||
CGAL_precondition(is_triangle_mesh(tm));
|
CGAL_precondition(is_triangle_mesh(tm));
|
||||||
|
|
||||||
Static_property_map<face_descriptor, std::size_t> vidmap(0); // dummy map not used
|
Constant_property_map<face_descriptor, std::size_t> vidmap(0); // dummy map not used
|
||||||
std::size_t res =
|
std::size_t res =
|
||||||
volume_connected_components(tm, vidmap, np.do_orientation_tests(true)
|
volume_connected_components(tm, vidmap, np.do_orientation_tests(true)
|
||||||
.i_used_as_a_predicate(true));
|
.i_used_as_a_predicate(true));
|
||||||
|
|
@ -1370,7 +1370,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm,
|
||||||
std::vector<std::size_t> face_cc(num_faces(tm), std::size_t(-1));
|
std::vector<std::size_t> face_cc(num_faces(tm), std::size_t(-1));
|
||||||
std::vector<std::size_t> nesting_levels;
|
std::vector<std::size_t> nesting_levels;
|
||||||
std::vector<bool> is_cc_outward_oriented;
|
std::vector<bool> is_cc_outward_oriented;
|
||||||
Static_property_map<face_descriptor, std::size_t> vidmap(0); // dummy map not used
|
Constant_property_map<face_descriptor, std::size_t> vidmap(0); // dummy map not used
|
||||||
|
|
||||||
volume_connected_components(tm, vidmap,
|
volume_connected_components(tm, vidmap,
|
||||||
parameters::vertex_point_map(vpm)
|
parameters::vertex_point_map(vpm)
|
||||||
|
|
|
||||||
|
|
@ -182,10 +182,10 @@ void random_perturbation(VertexRange vertices
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
internal_np::vertex_is_constrained_t,
|
internal_np::vertex_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<vertex_descriptor, bool> // default
|
Static_boolean_property_map<vertex_descriptor, false> // default
|
||||||
> ::type VCMap;
|
> ::type VCMap;
|
||||||
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
||||||
Constant_property_map<vertex_descriptor, bool>(false));
|
Static_boolean_property_map<vertex_descriptor, false>());
|
||||||
|
|
||||||
unsigned int seed = choose_parameter(get_parameter(np, internal_np::random_seed), -1);
|
unsigned int seed = choose_parameter(get_parameter(np, internal_np::random_seed), -1);
|
||||||
bool do_project = choose_parameter(get_parameter(np, internal_np::do_project), true);
|
bool do_project = choose_parameter(get_parameter(np, internal_np::do_project), true);
|
||||||
|
|
|
||||||
|
|
@ -214,18 +214,18 @@ void isotropic_remeshing(const FaceRange& faces
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
internal_np::edge_is_constrained_t,
|
internal_np::edge_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<edge_descriptor, bool> // default (no constraint pmap)
|
Static_boolean_property_map<edge_descriptor, false> // default (no constraint pmap)
|
||||||
> ::type ECMap;
|
> ::type ECMap;
|
||||||
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
||||||
Constant_property_map<edge_descriptor, bool>(false));
|
Static_boolean_property_map<edge_descriptor, false>());
|
||||||
|
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
internal_np::vertex_is_constrained_t,
|
internal_np::vertex_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<vertex_descriptor, bool> // default (no constraint pmap)
|
Static_boolean_property_map<vertex_descriptor, false> // default (no constraint pmap)
|
||||||
> ::type VCMap;
|
> ::type VCMap;
|
||||||
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
||||||
Constant_property_map<vertex_descriptor, bool>(false));
|
Static_boolean_property_map<vertex_descriptor, false>());
|
||||||
|
|
||||||
bool protect = choose_parameter(get_parameter(np, internal_np::protect_constraints), false);
|
bool protect = choose_parameter(get_parameter(np, internal_np::protect_constraints), false);
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
|
|
@ -405,18 +405,18 @@ void split_long_edges(const EdgeRange& edges
|
||||||
typedef typename internal_np::Lookup_named_param_def <
|
typedef typename internal_np::Lookup_named_param_def <
|
||||||
internal_np::edge_is_constrained_t,
|
internal_np::edge_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<edge_descriptor, bool> // default (no constraint pmap)
|
Static_boolean_property_map<edge_descriptor, false> // default (no constraint pmap)
|
||||||
> ::type ECMap;
|
> ::type ECMap;
|
||||||
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
||||||
Constant_property_map<edge_descriptor, bool>(false));
|
Static_boolean_property_map<edge_descriptor, false>());
|
||||||
|
|
||||||
typename internal::Incremental_remesher<PM, VPMap, GT, ECMap,
|
typename internal::Incremental_remesher<PM, VPMap, GT, ECMap,
|
||||||
Constant_property_map<vertex_descriptor, bool>, // no constraint pmap
|
Static_boolean_property_map<vertex_descriptor, false>, // no constraint pmap
|
||||||
internal::Connected_components_pmap<PM, FIMap>,
|
internal::Connected_components_pmap<PM, FIMap>,
|
||||||
FIMap
|
FIMap
|
||||||
>
|
>
|
||||||
remesher(pmesh, vpmap, gt, false/*protect constraints*/, ecmap,
|
remesher(pmesh, vpmap, gt, false/*protect constraints*/, ecmap,
|
||||||
Constant_property_map<vertex_descriptor, bool>(false),
|
Static_boolean_property_map<vertex_descriptor, false>(),
|
||||||
internal::Connected_components_pmap<PM, FIMap>(faces(pmesh), pmesh, ecmap, fimap, false),
|
internal::Connected_components_pmap<PM, FIMap>(faces(pmesh), pmesh, ecmap, fimap, false),
|
||||||
fimap,
|
fimap,
|
||||||
false/*need aabb_tree*/);
|
false/*need aabb_tree*/);
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Compute the connected components only once
|
// Compute the connected components only once
|
||||||
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fim);
|
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(static_cast<unsigned>(num_faces(tmesh)), fim);
|
||||||
std::size_t num = connected_components(tmesh, face_cc, np);
|
std::size_t num = connected_components(tmesh, face_cc, np);
|
||||||
|
|
||||||
#ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL
|
#ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL
|
||||||
|
|
|
||||||
|
|
@ -353,17 +353,17 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
|
||||||
typedef typename boost::graph_traits<TriangleMesh>::edge_descriptor edge_descriptor;
|
typedef typename boost::graph_traits<TriangleMesh>::edge_descriptor edge_descriptor;
|
||||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||||
|
|
||||||
typedef Constant_property_map<vertex_descriptor, bool> Default_VCM;
|
typedef Static_boolean_property_map<vertex_descriptor, false> Default_VCM;
|
||||||
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_is_constrained_t,
|
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Default_VCM>::type VCM;
|
Default_VCM>::type VCM;
|
||||||
VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM(false));
|
VCM vcm_np = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), Default_VCM());
|
||||||
|
|
||||||
typedef Constant_property_map<edge_descriptor, bool> Default_ECM;
|
typedef Static_boolean_property_map<edge_descriptor, false> Default_ECM;
|
||||||
typedef typename internal_np::Lookup_named_param_def<internal_np::edge_is_constrained_t,
|
typedef typename internal_np::Lookup_named_param_def<internal_np::edge_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Default_ECM>::type ECM;
|
Default_ECM>::type ECM;
|
||||||
ECM ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), Default_ECM(false));
|
ECM ecm = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), Default_ECM());
|
||||||
|
|
||||||
typedef typename GetVertexPointMap<TriangleMesh, NamedParameters>::const_type VPM;
|
typedef typename GetVertexPointMap<TriangleMesh, NamedParameters>::const_type VPM;
|
||||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ void smooth_mesh(const FaceRange& faces,
|
||||||
|
|
||||||
typedef typename internal_np::Lookup_named_param_def<internal_np::edge_is_constrained_t,
|
typedef typename internal_np::Lookup_named_param_def<internal_np::edge_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<edge_descriptor, bool> // default
|
Static_boolean_property_map<edge_descriptor, false> // default
|
||||||
> ::type ECMap;
|
> ::type ECMap;
|
||||||
|
|
||||||
typedef internal::Area_smoother<TriangleMesh, VertexPointMap, GeomTraits> Area_optimizer;
|
typedef internal::Area_smoother<TriangleMesh, VertexPointMap, GeomTraits> Area_optimizer;
|
||||||
|
|
@ -218,7 +218,7 @@ void smooth_mesh(const FaceRange& faces,
|
||||||
}
|
}
|
||||||
|
|
||||||
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained),
|
||||||
Constant_property_map<edge_descriptor, bool>(false));
|
Static_boolean_property_map<edge_descriptor, false>());
|
||||||
|
|
||||||
// a constrained edge has constrained extremities
|
// a constrained edge has constrained extremities
|
||||||
for(face_descriptor f : faces)
|
for(face_descriptor f : faces)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ void smooth_shape(const FaceRange& faces,
|
||||||
typedef typename internal_np::Lookup_named_param_def<
|
typedef typename internal_np::Lookup_named_param_def<
|
||||||
internal_np::vertex_is_constrained_t,
|
internal_np::vertex_is_constrained_t,
|
||||||
NamedParameters,
|
NamedParameters,
|
||||||
Constant_property_map<vertex_descriptor, bool> >::type VCMap;
|
Static_boolean_property_map<vertex_descriptor, false> >::type VCMap;
|
||||||
|
|
||||||
using parameters::choose_parameter;
|
using parameters::choose_parameter;
|
||||||
using parameters::get_parameter;
|
using parameters::get_parameter;
|
||||||
|
|
@ -124,7 +124,7 @@ void smooth_shape(const FaceRange& faces,
|
||||||
VertexPointMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
VertexPointMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||||
get_property_map(CGAL::vertex_point, tmesh));
|
get_property_map(CGAL::vertex_point, tmesh));
|
||||||
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained),
|
||||||
Constant_property_map<vertex_descriptor, bool>(false));
|
Static_boolean_property_map<vertex_descriptor, false>());
|
||||||
const unsigned int nb_iterations = choose_parameter(get_parameter(np, internal_np::number_of_iterations), 1);
|
const unsigned int nb_iterations = choose_parameter(get_parameter(np, internal_np::number_of_iterations), 1);
|
||||||
|
|
||||||
#if defined(CGAL_EIGEN3_ENABLED)
|
#if defined(CGAL_EIGEN3_ENABLED)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ void mesh_with_id(const char* argv1, const bool save_output)
|
||||||
|
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<Mesh_with_id, CGAL::face_index_t>::type>
|
boost::property_map<Mesh_with_id, CGAL::face_index_t>::type>
|
||||||
fccmap(get(CGAL::face_index,sm));
|
fccmap(static_cast<unsigned>(num_faces(sm)), get(CGAL::face_index,sm));
|
||||||
|
|
||||||
std::size_t num = PMP::connected_components(sm, fccmap);
|
std::size_t num = PMP::connected_components(sm, fccmap);
|
||||||
if (strcmp(argv1, "data/blobby_3cc.off") == 0)
|
if (strcmp(argv1, "data/blobby_3cc.off") == 0)
|
||||||
|
|
@ -92,7 +92,7 @@ void mesh_no_id(const char* argv1, const bool save_output)
|
||||||
|
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<Mesh, boost::face_external_index_t>::type>
|
boost::property_map<Mesh, boost::face_external_index_t>::type>
|
||||||
fccmap(fim);
|
fccmap(static_cast<unsigned>(num_faces(sm)), fim);
|
||||||
|
|
||||||
std::size_t num = PMP::connected_components(sm, fccmap);
|
std::size_t num = PMP::connected_components(sm, fccmap);
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ void test_border_cases()
|
||||||
|
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<Mesh_with_id, boost::face_index_t>::type>
|
boost::property_map<Mesh_with_id, boost::face_index_t>::type>
|
||||||
fccmap(get(boost::face_index,sm));
|
fccmap(static_cast<unsigned>(num_faces(sm)), get(boost::face_index,sm));
|
||||||
|
|
||||||
PMP::connected_components(sm, fccmap);
|
PMP::connected_components(sm, fccmap);
|
||||||
std::size_t nb_faces=num_faces(sm);
|
std::size_t nb_faces=num_faces(sm);
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ public Q_SLOTS:
|
||||||
*selection_item->polyhedron(),
|
*selection_item->polyhedron(),
|
||||||
selection_item->constrained_edges_pmap(),
|
selection_item->constrained_edges_pmap(),
|
||||||
get(CGAL::vertex_point, *selection_item->polyhedron()),
|
get(CGAL::vertex_point, *selection_item->polyhedron()),
|
||||||
CGAL::Static_property_map<face_descriptor, std::size_t>(1),
|
CGAL::Constant_property_map<face_descriptor, std::size_t>(1),
|
||||||
4. / 3. * target_length))
|
4. / 3. * target_length))
|
||||||
{
|
{
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
@ -578,7 +578,7 @@ public Q_SLOTS:
|
||||||
pmesh,
|
pmesh,
|
||||||
ecm,
|
ecm,
|
||||||
get(CGAL::vertex_point, pmesh),
|
get(CGAL::vertex_point, pmesh),
|
||||||
CGAL::Static_property_map<face_descriptor, std::size_t>(1),
|
CGAL::Constant_property_map<face_descriptor, std::size_t>(1),
|
||||||
4. / 3. * target_length))
|
4. / 3. * target_length))
|
||||||
{
|
{
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom
|
||||||
= get(boost::face_index, pmesh);
|
= get(boost::face_index, pmesh);
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<FaceGraph, boost::face_index_t>::type>
|
boost::property_map<FaceGraph, boost::face_index_t>::type>
|
||||||
fccmap(fim);
|
fccmap(static_cast<unsigned>(num_faces(pmesh)),fim);
|
||||||
boost::property_map<FaceGraph, CGAL::face_patch_id_t<int> >::type pid
|
boost::property_map<FaceGraph, CGAL::face_patch_id_t<int> >::type pid
|
||||||
= get(CGAL::face_patch_id_t<int>(), pmesh);
|
= get(CGAL::face_patch_id_t<int>(), pmesh);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<FaceGraph, boost::face_index_t>::type>
|
boost::property_map<FaceGraph, boost::face_index_t>::type>
|
||||||
fccmap;
|
fccmap(static_cast<unsigned>(num_faces(poly)));
|
||||||
|
|
||||||
//get connected componant from the picked face
|
//get connected componant from the picked face
|
||||||
std::set<fg_face_descriptor> final_sel;
|
std::set<fg_face_descriptor> final_sel;
|
||||||
|
|
|
||||||
|
|
@ -1629,7 +1629,7 @@ QString Scene_surface_mesh_item::computeStats(int type)
|
||||||
{
|
{
|
||||||
boost::vector_property_map<int,
|
boost::vector_property_map<int,
|
||||||
boost::property_map<SMesh, boost::face_index_t>::type>
|
boost::property_map<SMesh, boost::face_index_t>::type>
|
||||||
fccmap(get(boost::face_index, *(d->smesh_)));
|
fccmap(static_cast<unsigned>(num_faces(*(d->smesh_))), get(boost::face_index, *(d->smesh_)));
|
||||||
return QString::number(CGAL::Polygon_mesh_processing::connected_components(*(d->smesh_), fccmap));
|
return QString::number(CGAL::Polygon_mesh_processing::connected_components(*(d->smesh_), fccmap));
|
||||||
}
|
}
|
||||||
case NB_BORDER_EDGES:
|
case NB_BORDER_EDGES:
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(Plane_3)
|
||||||
template <class Gt, class I, CGAL_HDS_PARAM_, class A>
|
template <class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||||
struct Get_static_property_map {
|
struct Get_static_property_map {
|
||||||
typedef boost::graph_traits<CGAL::Polyhedron_3<Gt,I,HDS,A> > Graph_traits;
|
typedef boost::graph_traits<CGAL::Polyhedron_3<Gt,I,HDS,A> > Graph_traits;
|
||||||
typedef CGAL::Static_property_map<typename Graph_traits::face_descriptor,
|
typedef CGAL::Constant_property_map<typename Graph_traits::face_descriptor,
|
||||||
std::pair<int,int> > type;
|
std::pair<int,int> > type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
|
||||||
|
|
@ -37,33 +37,28 @@ namespace CGAL {
|
||||||
|
|
||||||
/// \cond SKIP_DOXYGEN
|
/// \cond SKIP_DOXYGEN
|
||||||
|
|
||||||
/// This class is almost the same as boost::static_property_map
|
/// A boolean property map return a const value at compile time
|
||||||
/// The difference is that it is writable, although put() does nothing
|
template <typename Key, bool default_value>
|
||||||
template <typename K, typename V>
|
class Static_boolean_property_map
|
||||||
class Static_property_map
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef K key_type;
|
typedef Key key_type;
|
||||||
typedef V value_type;
|
typedef bool value_type;
|
||||||
typedef const V& reference;
|
typedef bool reference;
|
||||||
typedef boost::read_write_property_map_tag category;
|
typedef boost::read_write_property_map_tag category;
|
||||||
|
|
||||||
private:
|
|
||||||
V v;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Static_property_map(V pv)
|
|
||||||
:v(pv){}
|
|
||||||
inline friend
|
inline friend
|
||||||
value_type
|
value_type
|
||||||
get(const Static_property_map& pm, const key_type&)
|
get(Static_boolean_property_map, const key_type&)
|
||||||
{
|
{
|
||||||
return pm.v;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend
|
inline friend
|
||||||
void
|
void
|
||||||
put(Static_property_map&, const key_type&, const value_type&)
|
put(Static_boolean_property_map, const key_type&, const value_type&)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ struct property_map<CGAL::Surface_mesh<P>, CGAL::face_patch_id_t<void> >
|
||||||
|
|
||||||
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor face_descriptor;
|
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor face_descriptor;
|
||||||
|
|
||||||
typedef CGAL::Static_property_map<typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor,std::pair<int,int> > type;
|
typedef CGAL::Constant_property_map<typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor,std::pair<int,int> > type;
|
||||||
typedef type const_type;
|
typedef type const_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -111,7 +111,7 @@ template <typename P>
|
||||||
CGAL_PROPERTY_SURFACE_MESH_RETURN_TYPE(CGAL::face_patch_id_t<void>)
|
CGAL_PROPERTY_SURFACE_MESH_RETURN_TYPE(CGAL::face_patch_id_t<void>)
|
||||||
inline get(CGAL::face_patch_id_t<void>, const Surface_mesh<P> &)
|
inline get(CGAL::face_patch_id_t<void>, const Surface_mesh<P> &)
|
||||||
{
|
{
|
||||||
typedef CGAL::Static_property_map<typename boost::graph_traits<Surface_mesh<P> >::face_descriptor,std::pair<int,int> > Pmap;
|
typedef CGAL::Constant_property_map<typename boost::graph_traits<Surface_mesh<P> >::face_descriptor,std::pair<int,int> > Pmap;
|
||||||
|
|
||||||
return Pmap(std::make_pair(0,1));
|
return Pmap(std::make_pair(0,1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue