set the initial size of the internal vector when using vector_property_map

This commit is contained in:
Sébastien Loriot 2020-05-15 18:03:40 +02:00
parent 7c4586be1b
commit 9f0ebc705b
8 changed files with 16 additions and 16 deletions

View File

@ -74,7 +74,7 @@ int main(int argc, char** argv)
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
// for details.
boost::vector_property_map<Vector, Face_index_map>
normals(get(CGAL::face_index, lcc));
normals(num_faces(lcc), get(CGAL::face_index, lcc));
calculate_face_normals(
lcc // Graph

View File

@ -82,7 +82,7 @@ int main(int argc, char** argv)
// http://www.boost.org/libs/property_map/doc/vector_property_map.html
// for details.
boost::vector_property_map<Vector, Face_index_map>
normals(get(CGAL::face_index, P));
normals(num_faces(P), get(CGAL::face_index, P));
calculate_face_normals(
P // Graph

View File

@ -387,7 +387,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh,
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
// vector_property_map
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fimap);
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(num_faces(pmesh), fimap);
std::size_t num = connected_components(pmesh, face_cc, np);
// Even if we do not want to keep anything we need to first
@ -518,7 +518,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh,
Output_iterator out = choose_parameter<Output_iterator>(get_parameter(np, internal_np::output_iterator));
// vector_property_map
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(fim);
boost::vector_property_map<std::size_t, FaceIndexMap> face_cc(num_faces(pmesh), fim);
std::size_t num = connected_components(pmesh, face_cc, np);
std::vector<Face_size> component_size(num, 0);
@ -595,10 +595,10 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh
for(std::size_t i : components_to_keep)
cc_to_keep.insert(i);
boost::vector_property_map<bool, VertexIndexMap> keep_vertex(vim);
for(vertex_descriptor v : vertices(pmesh)){
boost::vector_property_map<bool, VertexIndexMap> keep_vertex(num_vertices(pmesh), vim);
for(vertex_descriptor v : vertices(pmesh))
keep_vertex[v] = false;
}
for(face_descriptor f : faces(pmesh)){
if (cc_to_keep.find(get(fcm,f)) != cc_to_keep.end())
put(fcm, f, keep ? 1 : 0);
@ -821,7 +821,7 @@ void remove_connected_components(PolygonMesh& pmesh
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
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(num_faces(pmesh), fim);
connected_components(pmesh, face_cc, np);
std::vector<std::size_t> cc_to_remove;
@ -871,7 +871,7 @@ void keep_connected_components(PolygonMesh& pmesh
typedef typename CGAL::GetInitializedFaceIndexMap<PolygonMesh, CGAL_PMP_NP_CLASS>::type FaceIndexMap;
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(num_faces(pmesh), fim);
connected_components(pmesh, face_cc, np);
std::vector<std::size_t> cc_to_keep;

View File

@ -179,7 +179,7 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh,
return 0;
// 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(num_faces(tmesh), fim);
std::size_t num = connected_components(tmesh, face_cc, np);
#ifdef CGAL_PMP_DEBUG_SMALL_CC_REMOVAL

View File

@ -38,7 +38,7 @@ void mesh_with_id(const char* argv1, const bool save_output)
boost::vector_property_map<int,
boost::property_map<Mesh_with_id, CGAL::face_index_t>::type>
fccmap(get(CGAL::face_index,sm));
fccmap(num_faces(sm), get(CGAL::face_index,sm));
std::size_t num = PMP::connected_components(sm, fccmap);
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::property_map<Mesh, boost::face_external_index_t>::type>
fccmap(fim);
fccmap(num_faces(sm), fim);
std::size_t num = PMP::connected_components(sm, fccmap);
@ -133,7 +133,7 @@ void test_border_cases()
boost::vector_property_map<int,
boost::property_map<Mesh_with_id, boost::face_index_t>::type>
fccmap(get(boost::face_index,sm));
fccmap(num_faces(sm), get(boost::face_index,sm));
PMP::connected_components(sm, fccmap);
std::size_t nb_faces=num_faces(sm);

View File

@ -237,7 +237,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom
= get(boost::face_index, pmesh);
boost::vector_property_map<int,
boost::property_map<FaceGraph, boost::face_index_t>::type>
fccmap(fim);
fccmap(num_faces(pmesh),fim);
boost::property_map<FaceGraph, CGAL::face_patch_id_t<int> >::type pid
= get(CGAL::face_patch_id_t<int>(), pmesh);

View File

@ -273,7 +273,7 @@ public Q_SLOTS:
boost::vector_property_map<int,
boost::property_map<FaceGraph, boost::face_index_t>::type>
fccmap;
fccmap(num_faces(poly));
//get connected componant from the picked face
std::set<fg_face_descriptor> final_sel;

View File

@ -1606,7 +1606,7 @@ QString Scene_surface_mesh_item::computeStats(int type)
{
boost::vector_property_map<int,
boost::property_map<SMesh, boost::face_index_t>::type>
fccmap(get(boost::face_index, *(d->smesh_)));
fccmap(num_faces(*(d->smesh_)), get(boost::face_index, *(d->smesh_)));
return QString::number(CGAL::Polygon_mesh_processing::connected_components(*(d->smesh_), fccmap));
}
case NB_BORDER_EDGES: