Skip to content

Commit

Permalink
added the depth first iterator for outofcore octree
Browse files Browse the repository at this point in the history
added examples after the depth first iterator was written

modified the example to add data only to leaves; added octants.pcd for testing

refactoring: don't use num_children_ in outofcore --> getNumChildren ()

git-svn-id: svn+ssh://svn.pointclouds.org/pcl/trunk@7346 a9d63959-f2ad-4865-b262-bf0e56cfafb6
  • Loading branch information
stevefox committed Sep 29, 2012
1 parent a7fa05a commit 2d80ed7
Show file tree
Hide file tree
Showing 33 changed files with 2,381 additions and 701 deletions.
9 changes: 9 additions & 0 deletions examples/outofcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if (BUILD_outofcore)

PCL_SUBSYS_DEPEND (build ${SUBSYS_NAME} DEPS outofcore io common octree filters)

PCL_ADD_EXAMPLE (pcl_example_outofcore_with_lod FILES pcl_example_outofcore_with_lod.cpp LINK_WITH pcl_outofcore pcl_common pcl_io pcl_octree pcl_filters)

PCL_ADD_EXAMPLE (pcl_example_outofcore FILES pcl_example_outofcore.cpp LINK_WITH pcl_outofcore pcl_common pcl_io pcl_octree pcl_filters)

endif (BUILD_outofcore)
89 changes: 89 additions & 0 deletions examples/outofcore/pcl_example_outofcore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/

#include <pcl/io/pcd_io.h>
#include <pcl/console/print.h>

#include <pcl/outofcore/outofcore.h>
#include <pcl/outofcore/outofcore_impl.h>

#include <pcl/outofcore/OutofcoreIteratorBase.h>

#include <pcl/outofcore/OutofcoreDepthFirstIterator.h>
#include <pcl/outofcore/impl/OutofcoreDepthFirstIterator.hpp>

using namespace pcl::outofcore;

typedef OutofcoreOctreeBase<OutofcoreOctreeDiskContainer<pcl::PointXYZ>, pcl::PointXYZ> OctreeDisk;
typedef OutofcoreOctreeBaseNode<OutofcoreOctreeDiskContainer<pcl::PointXY>, pcl::PointXYZ> OctreeDiskNode;

int main (int argc, char** argv)
{
// pcl::console::setVerbosityLevel (pcl::console::L_VERBOSE);

int depth = 3;
Eigen::Vector3d min (-10.0, -10.0, -10.0);
Eigen::Vector3d max (10.0, 10.0, 10.0);
boost::filesystem::path file_location ("tree/tree.oct_idx");

OctreeDisk* octree;

octree = new OctreeDisk (depth, min, max, file_location, "ECEF");

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());

pcl::io::loadPCDFile (argv[1], *cloud);

octree->addPointCloud (cloud, false);

delete octree;

OctreeDisk octree2 (file_location, true);

//iterate over the octree, depth first
OutofcoreDepthFirstIterator<pcl::PointXYZ, pcl::outofcore::OutofcoreOctreeDiskContainer<pcl::PointXYZ> > it (octree2);
OctreeDisk::Iterator myit (octree2);

while ( *myit !=0 )
{
octree2.printBoundingBox (**myit);
myit++;
}

return (0);
}
49 changes: 49 additions & 0 deletions examples/outofcore/pcl_example_outofcore_with_lod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/

int main (int argc, char** argv)
{

//Find all PCD files located in argv[1] directory

//



return (0);
}
10 changes: 8 additions & 2 deletions outofcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(SUBSYS_NAME outofcore)
set(SUBSYS_DESC "Point cloud outofcore library")
set(SUBSYS_DEPS common io visualization filters)
set(SUBSYS_DEPS common io filters visualization octree)

set(build TRUE)
PCL_SUBSYS_OPTION(build ${SUBSYS_NAME} ${SUBSYS_DESC} ON)
Expand All @@ -12,11 +12,16 @@ if(build)
set(srcs
src/cJSON.cpp
src/outofcore_node_data.cpp
src/outofcore_base_data.cpp
)

set(incs
include/pcl/${SUBSYS_NAME}/boost.h
include/pcl/${SUBSYS_NAME}/metadata.h
include/pcl/${SUBSYS_NAME}/outofcore_base_data.h
include/pcl/${SUBSYS_NAME}/outofcore_node_data.h
include/pcl/${SUBSYS_NAME}/OutofcoreIteratorBase.h
include/pcl/${SUBSYS_NAME}/OutofcoreDepthFirstIterator.h
include/pcl/${SUBSYS_NAME}/boost.h
include/pcl/${SUBSYS_NAME}/cJSON.h
include/pcl/${SUBSYS_NAME}/octree_base.h
include/pcl/${SUBSYS_NAME}/octree_base_node.h
Expand All @@ -26,6 +31,7 @@ if(build)
)

set(impl_incs
include/pcl/${SUBSYS_NAME}/impl/OutofcoreDepthFirstIterator.hpp
include/pcl/${SUBSYS_NAME}/impl/octree_base.hpp
include/pcl/${SUBSYS_NAME}/impl/octree_base_node.hpp
include/pcl/${SUBSYS_NAME}/impl/octree_disk_container.hpp
Expand Down
69 changes: 69 additions & 0 deletions outofcore/include/pcl/outofcore/OutofcoreBreadthFirstIterator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: OutofcoreBreadthFirstIterator.h -1M 2012-08-24 19:37:13Z (local) $
*/

#ifndef PCL_OUTOFCORE_BFS_ITERATOR_BASE_H_
#define PCL_OUTOFCORE_ITERATOR_BASE_H_

#include <pcl/outofcore/OutofcoreIteratorBase.h>

namespace pcl
{
namespace outofcore
{
class OutofcoreBFSIterator : public OutofcoreIteratorBase
{
public:
OutofcoreBFSIterator (OutofcoreOctreeBase& outofcore_octree_arg) :
OutofcoreIteratorBase (outofcore_octree_arg)
{
}

~OutofcoreBFSIteratorBase ()
{
}

OutofcoreBFSIterator&
operator++(const OutofcoreBFSIterator &src);

};
}
}




84 changes: 84 additions & 0 deletions outofcore/include/pcl/outofcore/OutofcoreDepthFirstIterator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/

#ifndef PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_H_
#define PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_H_

#include <pcl/outofcore/OutofcoreIteratorBase.h>
namespace pcl
{
namespace outofcore
{
template<typename PointT, typename ContainerT>
class OutofcoreDepthFirstIterator : public OutofcoreIteratorBase<PointT, ContainerT>
{
public:
typedef typename pcl::outofcore::OutofcoreOctreeBase<ContainerT, PointT> OctreeDisk;
typedef typename pcl::outofcore::OutofcoreOctreeBaseNode<ContainerT, PointT> OctreeDiskNode;

typedef typename pcl::outofcore::OutofcoreOctreeBaseNode<ContainerT, PointT> LeafNode;
typedef typename pcl::outofcore::OutofcoreOctreeBaseNode<ContainerT, PointT> BranchNode;

explicit
OutofcoreDepthFirstIterator (OctreeDisk& octree_arg);

virtual
~OutofcoreDepthFirstIterator ();

OutofcoreDepthFirstIterator&
operator++ ();

inline OutofcoreDepthFirstIterator
operator++ (int)
{
OutofcoreDepthFirstIterator _Tmp = *this;
++*this;
return (_Tmp);
}

void
skipChildVoxels ();

protected:
unsigned char currentChildIdx_;
std::vector<std::pair<OctreeDiskNode*, unsigned char> > stack_;
};
}
}

#endif //PCL_OUTOFCORE_DEPTH_FIRST_ITERATOR_H_
Loading

0 comments on commit 2d80ed7

Please sign in to comment.