@@ -181,7 +181,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
181181 // searchForNeighbors ((*indices_)[R_], nnIdx, sqrDists);
182182 // tree_->nearestKSearch ((*input_)[(*indices_)[R_]], nnn_, nnIdx, sqrDists);
183183 tree_->nearestKSearch (indices_->at (R_), nnn_, nnIdx, sqrDists);
184- double sqr_dist_threshold = (std::min)(sqr_max_edge, sqr_mu * sqrDists[1 ]);
184+ const double sqr_dist_threshold = (std::min)(sqr_max_edge, sqr_mu * sqrDists[1 ]);
185185
186186 // Search tree returns indices into the original cloud, but we are working with indices. TODO: make that optional!
187187 for (int i = 1 ; i < nnn_; i++)
@@ -199,7 +199,8 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
199199
200200 // Converting coords, calculating angles and saving the projected near boundary edges
201201 int nr_edge = 0 ;
202- std::vector<doubleEdge> doubleEdges;
202+ double_edges_.clear ();
203+ double_edges_.reserve (nnn_);
203204 for (int i = 1 ; i < nnn_; i++) // nearest neighbor with index 0 is the query point R_ itself
204205 {
205206 // Transforming coordinates
@@ -230,7 +231,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
230231 tmp_ = coords_[sfn_[nnIdx[i]]] - proj_qp_;
231232 e.second [0 ] = tmp_.dot (u_);
232233 e.second [1 ] = tmp_.dot (v_);
233- doubleEdges .push_back (e);
234+ double_edges_ .push_back (e);
234235 }
235236 }
236237 angles_[0 ].visible = false ;
@@ -242,12 +243,12 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
242243 bool visibility = true ;
243244 for (int j = 0 ; j < nr_edge; j++)
244245 {
245- if (ffn_[nnIdx[doubleEdges [j].index ]] != nnIdx[i])
246- visibility = isVisible (uvn_nn[i], uvn_nn[doubleEdges [j].index ], doubleEdges [j].first , Eigen::Vector2f::Zero ());
246+ if (ffn_[nnIdx[double_edges_ [j].index ]] != nnIdx[i])
247+ visibility = isVisible (uvn_nn[i], uvn_nn[double_edges_ [j].index ], double_edges_ [j].first , Eigen::Vector2f::Zero ());
247248 if (!visibility)
248249 break ;
249- if (sfn_[nnIdx[doubleEdges [j].index ]] != nnIdx[i])
250- visibility = isVisible (uvn_nn[i], uvn_nn[doubleEdges [j].index ], doubleEdges [j].second , Eigen::Vector2f::Zero ());
250+ if (sfn_[nnIdx[double_edges_ [j].index ]] != nnIdx[i])
251+ visibility = isVisible (uvn_nn[i], uvn_nn[double_edges_ [j].index ], double_edges_ [j].second , Eigen::Vector2f::Zero ());
251252 if (!visibility)
252253 break ;
253254 }
@@ -328,13 +329,11 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
328329 // std::cerr << R_ << " [" << indices_->at (R_) << "] " << i << ": " << nnIdx[i] << " / " << point2index[nnIdx[i]] << std::endl;
329330 nnIdx[i] = point2index[nnIdx[i]];
330331 }
331-
332- // Locating FFN and SFN to adapt distance threshold
333- double sqr_source_dist = (coords_[R_] - coords_[source_[R_]]).squaredNorm ();
334- double sqr_ffn_dist = (coords_[R_] - coords_[ffn_[R_]]).squaredNorm ();
335- double sqr_sfn_dist = (coords_[R_] - coords_[sfn_[R_]]).squaredNorm ();
336- double max_sqr_fn_dist = (std::max)(sqr_ffn_dist, sqr_sfn_dist);
337- double sqr_dist_threshold = (std::min)(sqr_max_edge, sqr_mu * sqrDists[1 ]); // sqr_mu * sqr_avg_conn_dist);
332+ const double sqr_source_dist = (coords_[R_] - coords_[source_[R_]]).squaredNorm ();
333+ const double sqr_ffn_dist = (coords_[R_] - coords_[ffn_[R_]]).squaredNorm ();
334+ const double sqr_sfn_dist = (coords_[R_] - coords_[sfn_[R_]]).squaredNorm ();
335+ const double max_sqr_fn_dist = (std::max)(sqr_ffn_dist, sqr_sfn_dist);
336+ const double sqr_dist_threshold = (std::min)(sqr_max_edge, sqr_mu * sqrDists[1 ]);
338337 if (max_sqr_fn_dist > sqrDists[nnn_-1 ])
339338 {
340339 if (0 == increase_nnn4fn)
@@ -343,7 +342,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
343342 state_[R_] = BOUNDARY;
344343 continue ;
345344 }
346- double max_sqr_fns_dist = (std::max)(sqr_source_dist, max_sqr_fn_dist);
345+ const double max_sqr_fns_dist = (std::max)(sqr_source_dist, max_sqr_fn_dist);
347346 if (max_sqr_fns_dist > sqrDists[nnn_-1 ])
348347 {
349348 if (0 == increase_nnn4s)
@@ -357,8 +356,9 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
357356
358357 // Converting coords, calculating angles and saving the projected near boundary edges
359358 int nr_edge = 0 ;
360- std::vector<doubleEdge> doubleEdges;
361- for (int i = 1 ; i < nnn_; i++) // nearest neighbor with index 0 is the query point R_ itself
359+ double_edges_.clear ();
360+ double_edges_.reserve (nnn_);
361+ for (int i = 1 ; i < nnn_; ++i) // nearest neighbor with index 0 is the query point R_ itself
362362 {
363363 tmp_ = coords_[nnIdx[i]] - proj_qp_;
364364 uvn_nn[i][0 ] = tmp_.dot (u_);
@@ -407,7 +407,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
407407 tmp_ = coords_[sfn_[nnIdx[i]]] - proj_qp_;
408408 e.second [0 ] = tmp_.dot (u_);
409409 e.second [1 ] = tmp_.dot (v_);
410- doubleEdges .push_back (e);
410+ double_edges_ .push_back (e);
411411 // Pruning by visibility criterion
412412 if ((state_[nnIdx[i]] == FRINGE) && (ffn_[R_] != nnIdx[i]) && (sfn_[R_] != nnIdx[i]))
413413 {
@@ -469,17 +469,17 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
469469 bool visibility = true ;
470470 for (int j = 0 ; j < nr_edge; j++)
471471 {
472- if (doubleEdges [j].index != i)
472+ if (double_edges_ [j].index != i)
473473 {
474- const auto & f = ffn_[nnIdx[doubleEdges [j].index ]];
474+ const auto & f = ffn_[nnIdx[double_edges_ [j].index ]];
475475 if ((f != nnIdx[i]) && (f != R_))
476- visibility = isVisible (uvn_nn[i], uvn_nn[doubleEdges [j].index ], doubleEdges [j].first , Eigen::Vector2f::Zero ());
476+ visibility = isVisible (uvn_nn[i], uvn_nn[double_edges_ [j].index ], double_edges_ [j].first , Eigen::Vector2f::Zero ());
477477 if (!visibility)
478478 break ;
479479
480- const auto & s = sfn_[nnIdx[doubleEdges [j].index ]];
480+ const auto & s = sfn_[nnIdx[double_edges_ [j].index ]];
481481 if ((s != nnIdx[i]) && (s != R_))
482- visibility = isVisible (uvn_nn[i], uvn_nn[doubleEdges [j].index ], doubleEdges [j].second , Eigen::Vector2f::Zero ());
482+ visibility = isVisible (uvn_nn[i], uvn_nn[double_edges_ [j].index ], double_edges_ [j].second , Eigen::Vector2f::Zero ());
483483 if (!visibility)
484484 break ;
485485 }
0 commit comments