Skip to content

Commit 6df5aa3

Browse files
committed
Replace repeated free-point scan with queue.
1 parent f1ad81a commit 6df5aa3

File tree

1 file changed

+14
-15
lines changed
  • surface/include/pcl/surface/impl

1 file changed

+14
-15
lines changed

surface/include/pcl/surface/impl/gp3.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <pcl/surface/gp3.h>
4242

4343
#include <algorithm>
44+
#include <deque>
4445

4546
/////////////////////////////////////////////////////////////////////////////////////////////
4647
template <typename PointInT> void
@@ -133,17 +134,25 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
133134
}
134135

135136
// Initializing
136-
int is_free=0, nr_parts=0, increase_nnn4fn=0, increase_nnn4s=0, increase_dist=0;
137+
int nr_parts=0, increase_nnn4fn=0, increase_nnn4s=0, increase_dist=0;
137138
angles_.resize(nnn_);
138139
std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > uvn_nn (nnn_);
139140
Eigen::Vector2f uvn_s;
140141
const double cos_eps_angle_ = std::cos(eps_angle_);
141142

143+
// Initialize queue with initial FREE points (avoid repeated scans)
144+
std::deque<int> free_queue;
145+
for (int i = 0; i < static_cast<int>(indices_->size()); ++i)
146+
if (state_[i] == FREE)
147+
free_queue.push_back(i);
148+
142149
// iterating through fringe points and finishing them until everything is done
143-
while (is_free != NONE)
150+
while (!free_queue.empty())
144151
{
145-
R_ = is_free;
146-
if (state_[R_] == FREE)
152+
R_ = free_queue.front();
153+
free_queue.pop_front();
154+
if (state_[R_] != FREE)
155+
continue;
147156
{
148157
state_[R_] = NONE;
149158
part_[R_] = part_index++;
@@ -172,7 +181,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
172181
// Projecting point onto the surface
173182
float dist = nc.dot (coords_[R_]);
174183
proj_qp_ = coords_[R_] - dist * nc;
175-
184+
176185
// Converting coords, calculating angles and saving the projected near boundary edges
177186
int nr_edge = 0;
178187
std::vector<doubleEdge> doubleEdges;
@@ -270,16 +279,6 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
270279
while (not_found);
271280
}
272281

273-
is_free = NONE;
274-
for (std::size_t temp = 0; temp < indices_->size (); temp++)
275-
{
276-
if (state_[temp] == FREE)
277-
{
278-
is_free = temp;
279-
break;
280-
}
281-
}
282-
283282
bool is_fringe = true;
284283
while (is_fringe)
285284
{

0 commit comments

Comments
 (0)