|
41 | 41 | #include <pcl/surface/gp3.h> |
42 | 42 |
|
43 | 43 | #include <algorithm> |
| 44 | +#include <deque> |
44 | 45 |
|
45 | 46 | ///////////////////////////////////////////////////////////////////////////////////////////// |
46 | 47 | template <typename PointInT> void |
@@ -133,17 +134,25 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p |
133 | 134 | } |
134 | 135 |
|
135 | 136 | // 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; |
137 | 138 | angles_.resize(nnn_); |
138 | 139 | std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > uvn_nn (nnn_); |
139 | 140 | Eigen::Vector2f uvn_s; |
140 | 141 | const double cos_eps_angle_ = std::cos(eps_angle_); |
141 | 142 |
|
| 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 | + |
142 | 149 | // iterating through fringe points and finishing them until everything is done |
143 | | - while (is_free != NONE) |
| 150 | + while (!free_queue.empty()) |
144 | 151 | { |
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; |
147 | 156 | { |
148 | 157 | state_[R_] = NONE; |
149 | 158 | part_[R_] = part_index++; |
@@ -172,7 +181,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p |
172 | 181 | // Projecting point onto the surface |
173 | 182 | float dist = nc.dot (coords_[R_]); |
174 | 183 | proj_qp_ = coords_[R_] - dist * nc; |
175 | | - |
| 184 | + |
176 | 185 | // Converting coords, calculating angles and saving the projected near boundary edges |
177 | 186 | int nr_edge = 0; |
178 | 187 | std::vector<doubleEdge> doubleEdges; |
@@ -270,16 +279,6 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p |
270 | 279 | while (not_found); |
271 | 280 | } |
272 | 281 |
|
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 | | - |
283 | 282 | bool is_fringe = true; |
284 | 283 | while (is_fringe) |
285 | 284 | { |
|
0 commit comments