Skip to content

Commit

Permalink
Merge pull request #2812 from SunBlack/ORROctreeZProjection_build_ran…
Browse files Browse the repository at this point in the history
…ge_based_loop

Use range-based loop in ORROctreeZProjection::build
  • Loading branch information
SergioRAgostinho authored Jan 31, 2019
2 parents b264eda + 5636d0b commit ee3fe6f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions recognition/src/ransac_based/orr_octree_zprojection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*/

#include <pcl/recognition/ransac_based/orr_octree_zprojection.h>
#include <array>
#include <vector>

using namespace std;
Expand Down Expand Up @@ -99,23 +100,24 @@ pcl::recognition::ORROctreeZProjection::build (const ORROctree& input, float eps
// Compute the bounding box of the full leaves
const vector<ORROctree::Node*>& full_leaves = input.getFullLeaves ();
vector<ORROctree::Node*>::const_iterator fl_it = full_leaves.begin ();
float full_leaves_bounds[4];
std::array<float, 4> full_leaves_bounds;

if ( full_leaves.empty() )
return;

// The initialization run
full_leaves_bounds[0] = (*fl_it)->getBounds ()[0];
full_leaves_bounds[1] = (*fl_it)->getBounds ()[1];
full_leaves_bounds[2] = (*fl_it)->getBounds ()[2];
full_leaves_bounds[3] = (*fl_it)->getBounds ()[3];
full_leaves_bounds[0] = std::numeric_limits<float>::infinity();
full_leaves_bounds[1] = -std::numeric_limits<float>::infinity();
full_leaves_bounds[2] = std::numeric_limits<float>::infinity();
full_leaves_bounds[3] = -std::numeric_limits<float>::infinity();

for ( ++fl_it ; fl_it != full_leaves.end () ; ++fl_it )
for (const auto& leave : full_leaves)
{
if ( (*fl_it)->getBounds ()[0] < full_leaves_bounds[0] ) full_leaves_bounds[0] = (*fl_it)->getBounds ()[0];
if ( (*fl_it)->getBounds ()[1] > full_leaves_bounds[1] ) full_leaves_bounds[1] = (*fl_it)->getBounds ()[1];
if ( (*fl_it)->getBounds ()[2] < full_leaves_bounds[2] ) full_leaves_bounds[2] = (*fl_it)->getBounds ()[2];
if ( (*fl_it)->getBounds ()[3] > full_leaves_bounds[3] ) full_leaves_bounds[3] = (*fl_it)->getBounds ()[3];
const auto bounds = leave->getBounds ();
if ( bounds[0] < full_leaves_bounds[0] ) full_leaves_bounds[0] = bounds[0];
if ( bounds[1] > full_leaves_bounds[1] ) full_leaves_bounds[1] = bounds[1];
if ( bounds[2] < full_leaves_bounds[2] ) full_leaves_bounds[2] = bounds[2];
if ( bounds[3] > full_leaves_bounds[3] ) full_leaves_bounds[3] = bounds[3];
}

// Make some initializations
Expand Down

0 comments on commit ee3fe6f

Please sign in to comment.