Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix octree adjacency bounding box calculation #332

Merged
merged 3 commits into from
Oct 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,28 @@ template<typename PointT, typename LeafContainerT, typename BranchContainerT> vo
pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>::addPointsFromInputCloud ()
{
//double t1,t2;
float minX = std::numeric_limits<float>::max (), minY = std::numeric_limits<float>::max (), minZ = std::numeric_limits<float>::max ();
float maxX = std::numeric_limits<float>::min (), maxY = std::numeric_limits<float>::min (), maxZ = std::numeric_limits<float>::min ();

for (int i = 0; i < input_->size (); ++i)
{
PointT temp (input_->points[i]);
if (transform_func_) //Search for point with
transform_func_ (temp);
if (temp.x < minX)
minX = temp.x;
if (temp.y < minY)
minY = temp.y;
if (temp.z < minZ)
minZ = temp.z;
if (temp.x > maxX)
maxX = temp.x;
if (temp.y > maxY)
maxY = temp.y;
if (temp.z > maxZ)
maxZ = temp.z;
}
this->defineBoundingBox (minX, minY, minZ, maxX, maxY, maxZ);
//t1 = timer_.getTime ();
OctreePointCloud<PointT, LeafContainerT, BranchContainerT>::addPointsFromInputCloud ();

Expand Down Expand Up @@ -125,7 +146,6 @@ pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>
key_arg.x = static_cast<unsigned int> ((temp.x - this->min_x_) / this->resolution_);
key_arg.y = static_cast<unsigned int> ((temp.y - this->min_y_) / this->resolution_);
key_arg.z = static_cast<unsigned int> ((temp.z - this->min_z_) / this->resolution_);

}
else
{
Expand All @@ -147,24 +167,14 @@ pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>
const PointT& point = this->input_->points[pointIdx_arg];
if (!pcl::isFinite (point))
return;

if (transform_func_)
{
PointT temp (point);
transform_func_ (temp);
this->adoptBoundingBoxToPoint (temp);
}
else
this->adoptBoundingBoxToPoint (point);


// generate key
this->genOctreeKeyforPoint (point, key);
// add point to octree at key
LeafContainerT* container = this->createLeaf(key);
container->addPoint (point);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT, typename LeafContainerT, typename BranchContainerT> void
pcl::octree::OctreePointCloudAdjacency<PointT, LeafContainerT, BranchContainerT>::computeNeighbors (OctreeKey &key_arg, LeafContainerT* leaf_container)
Expand Down
27 changes: 23 additions & 4 deletions octree/include/pcl/octree/octree_pointcloud_adjacency.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,23 @@ namespace pcl
typedef typename OctreePointCloudT::BranchNode BranchNode;

typedef pcl::PointCloud<PointT> CloudT;

typedef pcl::PointCloud<PointT> PointCloud;
typedef boost::shared_ptr<PointCloud> PointCloudPtr;
typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr;

// public typedefs
typedef boost::shared_ptr<std::vector<int> > IndicesPtr;
typedef boost::shared_ptr<const std::vector<int> > IndicesConstPtr;
//So we can access input
using OctreePointCloudT::input_;
using OctreePointCloudT::resolution_;

using OctreePointCloudT::min_x_;
using OctreePointCloudT::min_y_;
using OctreePointCloudT::min_z_;
using OctreePointCloudT::max_x_;
using OctreePointCloudT::max_y_;
using OctreePointCloudT::max_z_;

// iterators are friends
friend class OctreeIteratorBase<OctreeAdjacencyT> ;
friend class OctreeDepthFirstIterator<OctreeAdjacencyT> ;
Expand Down Expand Up @@ -150,7 +162,7 @@ namespace pcl
*/
void
addPointsFromInputCloud ();

/** \brief Gets the leaf container for a given point
* \param[in] point_arg Point to search for
* \returns Pointer to the leaf container - null if no leaf container found
Expand Down Expand Up @@ -207,7 +219,14 @@ namespace pcl
void
genOctreeKeyforPoint (const PointT& point_arg,OctreeKey & key_arg) const;

private:
private:
/** \brief Add point at given index from input point cloud to octree. Index will be also added to indices vector. -- This functionality is not enabled for adjacency octree
*/
OctreePointCloudT::addPointFromCloud;

/** \brief Add point simultaneously to octree and input point cloud. -- This functionality is not enabled for adjacency octree
*/
OctreePointCloudT::addPointToCloud;

StopWatch timer_;

Expand Down