Skip to content

Commit

Permalink
Merge pull request #2840 from SunBlack/range_based_loops_geometry
Browse files Browse the repository at this point in the history
Transform classic loops to range-based for loops in module geometry
  • Loading branch information
SergioRAgostinho authored Feb 15, 2019
2 parents 517e397 + 07ded98 commit 6d25318
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions geometry/include/pcl/geometry/mesh_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,9 @@ namespace pcl

const FaceIndex idx_face (static_cast <int> (this->sizeFaces () - 1));

for (HalfEdgeIndices::const_iterator it=inner_he.begin (); it!=inner_he.end (); ++it)
for (const auto &idx_half_edge : inner_he)
{
this->setFaceIndex (*it, idx_face);
this->setFaceIndex (idx_half_edge, idx_face);
}

return (idx_face);
Expand Down
11 changes: 5 additions & 6 deletions geometry/include/pcl/geometry/mesh_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ namespace pcl
{
typedef HalfEdgeMeshT HalfEdgeMesh;
typedef typename HalfEdgeMesh::VertexDataCloud VertexDataCloud;
typedef typename HalfEdgeMesh::VertexIndex VertexIndex;
typedef typename HalfEdgeMesh::VertexIndices VertexIndices;

BOOST_STATIC_ASSERT (HalfEdgeMesh::HasVertexData::value); // Output mesh must have data associated with the vertices!
Expand All @@ -101,22 +100,22 @@ namespace pcl
half_edge_mesh.reserveEdges (3 * face_vertex_mesh.polygons.size ());
half_edge_mesh.reserveFaces ( face_vertex_mesh.polygons.size ());

for (typename VertexDataCloud::const_iterator it=vertices.begin (); it!=vertices.end (); ++it)
for (const auto &vertex : vertices)
{
half_edge_mesh.addVertex (*it);
half_edge_mesh.addVertex (vertex);
}

assert (half_edge_mesh.sizeVertices () == vertices.size ());

int count_not_added = 0;
VertexIndices vi;
vi.reserve (3); // Minimum number (triangle)
for (size_t i=0; i<face_vertex_mesh.polygons.size (); ++i)
for (const auto &polygon : face_vertex_mesh.polygons)
{
vi.clear ();
for (size_t j=0; j<face_vertex_mesh.polygons [i].vertices.size (); ++j)
for (const unsigned int vertex : polygon.vertices)
{
vi.push_back (VertexIndex (face_vertex_mesh.polygons [i].vertices [j]));
vi.emplace_back (vertex);
}

if (!half_edge_mesh.addFace (vi).isValid ())
Expand Down

0 comments on commit 6d25318

Please sign in to comment.