40 #ifndef PCL_OUTOFCORE_OCTREE_BASE_NODE_H_
41 #define PCL_OUTOFCORE_OCTREE_BASE_NODE_H_
43 #include <pcl/common/io.h>
44 #include <pcl/PCLPointCloud2.h>
46 #include <pcl/outofcore/boost.h>
47 #include <pcl/outofcore/octree_base.h>
48 #include <pcl/outofcore/octree_disk_container.h>
49 #include <pcl/outofcore/outofcore_node_data.h>
51 #include <pcl/octree/octree_nodes.h>
58 template<
typename ContainerT,
typename Po
intT>
61 template<
typename ContainerT,
typename Po
intT>
69 template<
typename ContainerT,
typename Po
intT>
void
70 queryBBIntersects_noload (
const boost::filesystem::path &root_node,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const boost::uint32_t query_depth, std::list<std::string> &bin_name);
73 template<
typename ContainerT,
typename Po
intT>
void
91 template<
typename ContainerT = OutofcoreOctreeDiskContainer<pcl::Po
intXYZ>,
typename Po
intT = pcl::Po
intXYZ>
101 queryBBIntersects_noload<ContainerT, PointT> (
const boost::filesystem::path &rootnode,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const boost::uint32_t query_depth, std::list<std::string> &bin_name);
104 queryBBIntersects_noload<ContainerT, PointT> (
OutofcoreOctreeBaseNode<ContainerT, PointT>* current,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const boost::uint32_t query_depth, std::list<std::string> &bin_name);
143 const boost::filesystem::path&
149 const boost::filesystem::path&
156 queryFrustum (
const double planes[24], std::list<std::string>& file_names);
159 queryFrustum (
const double planes[24], std::list<std::string>& file_names,
const boost::uint32_t query_depth,
const bool skip_vfc_check =
false);
162 queryFrustum (
const double planes[24],
const Eigen::Vector3d &eye,
const Eigen::Matrix4d &view_projection_matrix, std::list<std::string>& file_names,
const boost::uint32_t query_depth,
const bool skip_vfc_check =
false);
201 queryBBIntersects (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const boost::uint32_t query_depth, std::list<std::string> &file_names);
213 virtual boost::uint64_t
216 virtual boost::uint64_t
217 addDataToLeaf (
const std::vector<const PointT*> &p,
const bool skip_bb_check =
true);
224 virtual boost::uint64_t
228 virtual boost::uint64_t
236 virtual boost::uint64_t
266 PCL_THROW_EXCEPTION (
PCLException,
"Not implemented\n");
270 virtual inline size_t
297 virtual boost::uint64_t
417 inBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb)
const;
425 pointInBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const Eigen::Vector3d &point);
440 pointInBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const double x,
const double y,
const double z);
462 inline boost::uint64_t
527 enlargeToCube (Eigen::Vector3d &bb_min, Eigen::Vector3d &bb_max);
564 const static boost::uint32_t
rngseed = 0xAABBCCDD;
573 #endif //PCL_OUTOFCORE_OCTREE_BASE_NODE_H_
static const boost::uint32_t rngseed
Random number generator seed.
virtual size_t getDepth() const
static boost::mutex rng_mutex_
Random number generator mutex.
OutofcoreOctreeBaseNode * parent_
super-node
void queryBBIntersects_noload(const boost::filesystem::path &root_node, const Eigen::Vector3d &min, const Eigen::Vector3d &max, const boost::uint32_t query_depth, std::list< std::string > &bin_name)
Non-class method which performs a bounding box query without loading any of the point cloud data from...
void createChild(const std::size_t idx)
Creates child node idx.
void recFreeChildren()
Method which recursively free children of this node.
static const std::string pcd_extension
Extension for this class to find the pcd files on disk.
void subdividePoints(const AlignedPointTVector &p, std::vector< AlignedPointTVector > &c, const bool skip_bb_check)
Subdivide points to pass to child nodes.
static const std::string node_container_extension
bool hasUnloadedChildren() const
Returns whether or not a node has unloaded children data.
virtual void queryBBIncludes_subsample(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, boost::uint64_t query_depth, const double percent, AlignedPointTVector &v)
Recursively add points that fall into the queried bounding box up to the query_depth.
boost::shared_ptr< OutofcoreOctreeNodeMetadata > Ptr
bool pointInBoundingBox(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const Eigen::Vector3d &point)
Tests whether point falls within the input bounding box.
virtual void printBoundingBox(const size_t query_depth) const
Write the voxel size to stdout at query_depth.
virtual void getBoundingBox(Eigen::Vector3d &min_bb, Eigen::Vector3d &max_bb) const
gets the minimum and maximum corner of the bounding box represented by this node
virtual size_t getNumLoadedChildren() const
Count loaded chilren.
void queryFrustum(const double planes[24], std::list< std::string > &file_names)
void getOccupiedVoxelCentersRecursive(AlignedPointTVector &voxel_centers, const size_t query_depth)
Gets a vector of occupied voxel centers.
virtual boost::uint64_t addDataToLeaf(const AlignedPointTVector &p, const bool skip_bb_check=true)
add point to this node if we are a leaf, or find the leaf below us that is supposed to take the point...
virtual boost::uint64_t addDataToLeaf_and_genLOD(const AlignedPointTVector &p, const bool skip_bb_check)
Recursively add points to the leaf and children subsampling LODs on the way down. ...
Abstract octree node class
uint64_t num_children_
Number of children on disk.
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
OutofcoreOctreeBaseNode & operator=(const OutofcoreOctreeBaseNode &rval)
Operator= is not implemented.
OutofcoreOctreeBaseNode Class internally representing nodes of an outofcore octree, with accessors to its data via the octree_disk_container class or octree_ram_container class, whichever it is templated against.
virtual size_t getNumChildren() const
Returns the total number of children on disk.
virtual void queryBBIntersects(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const boost::uint32_t query_depth, std::list< std::string > &file_names)
Recursive acquires PCD paths to any node with which the queried bounding box intersects (at query_dep...
static const std::string node_container_basename
virtual size_t countNumChildren() const
Counts the number of child directories on disk; used to update num_children_.
virtual boost::uint64_t addPointCloud(const pcl::PCLPointCloud2::Ptr &input_cloud, const bool skip_bb_check=false)
Add a single PCLPointCloud2 object into the octree.
OutofcoreOctreeBaseNode()
Empty constructor; sets pointers for children and for bounding boxes to 0.
std::vector< OutofcoreOctreeBaseNode * > children_
The children of this node.
void convertToXYZRecursive()
Recursively converts data files to ascii XZY files.
uint64_t num_loaded_children_
Number of loaded children this node has.
OutofcoreOctreeBase< OutofcoreOctreeDiskContainer< PointT >, PointT > octree_disk
void copyAllCurrentAndChildPointsRec_sub(std::list< PointT > &v, const double percent)
virtual OutofcoreOctreeBaseNode * getChildPtr(size_t index_arg) const
Returns a pointer to the child in octant index_arg.
virtual boost::uint64_t addPointCloud_and_genLOD(const pcl::PCLPointCloud2::Ptr input_cloud)
Add a single PCLPointCloud2 into the octree and build the subsampled LOD during construction; this me...
boost::shared_ptr< ContainerT > payload_
what holds the points.
virtual size_t countNumLoadedChildren() const
Counts the number of loaded chilren by testing the children_ array; used to update num_loaded_chilren...
boost::uint64_t size() const
Number of points in the payload.
virtual void queryBBIncludes(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, size_t query_depth, AlignedPointTVector &dst)
Recursively add points that fall into the queried bounding box up to the query_depth.
OutofcoreOctreeBase< ContainerT, PointT > * m_tree_
The tree we belong to.
virtual node_type_t getNodeType() const
Pure virtual method for receiving the type of octree node (branch or leaf)
pcl::octree::node_type_t node_type_t
static boost::mt19937 rand_gen_
Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator...
boost::uint64_t addDataAtMaxDepth(const AlignedPointTVector &p, const bool skip_bb_check=true)
Add data to the leaf when at max depth of tree.
void enlargeToCube(Eigen::Vector3d &bb_min, Eigen::Vector3d &bb_max)
Enlarges the shortest two sidelengths of the bounding box to a cubic shape; operation is done in plac...
OutofcoreOctreeNodeMetadata::Ptr node_metadata_
OutofcoreOctreeBaseNode< ContainerT, PointT > * makenode_norec(const boost::filesystem::path &path, OutofcoreOctreeBaseNode< ContainerT, PointT > *super)
Non-class function which creates a single child leaf; used with queryBBIntersects_noload to avoid loa...
void saveMetadataToFile(const boost::filesystem::path &path)
Write JSON metadata for this node to file.
size_t depth_
Depth in the tree, root is 0, root's children are 1, ...
void writeVPythonVisual(std::ofstream &file)
Write a python visual script to file.
void subdividePoint(const PointT &point, std::vector< AlignedPointTVector > &c)
Subdivide a single point into a specific child node.
bool inBoundingBox(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb) const
Tests whether the input bounding box falls inclusively within this node's bounding box...
static const double sample_percent_
void saveIdx(bool recursive)
Save node's metadata to file.
const boost::filesystem::path & getMetadataFilename() const
void randomSample(const AlignedPointTVector &p, AlignedPointTVector &insertBuff, const bool skip_bb_check)
Randomly sample point data.
void flushToDiskRecursive()
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
A base class for all pcl exceptions which inherits from std::runtime_error.
virtual boost::uint64_t getDataSize() const
Gets the number of points available in the PCD file.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void sortOctantIndices(const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< std::vector< int > > &indices, const Eigen::Vector3d &mid_xyz)
Sorts the indices based on x,y,z fields and pushes the index into the proper octant's vector; This co...
virtual int read(pcl::PCLPointCloud2::Ptr &output_cloud)
void loadFromFile(const boost::filesystem::path &path, OutofcoreOctreeBaseNode *super)
Loads the nodes metadata from the JSON file.
OutofcoreOctreeBaseNode * root_node_
The root node of the tree we belong to.
OutofcoreOctreeBaseNode< OutofcoreOctreeDiskContainer< PointT >, PointT > octree_disk_node
virtual void loadChildren(bool recursive)
Load nodes child data creating new nodes for each.
void init_root_node(const Eigen::Vector3d &bb_min, const Eigen::Vector3d &bb_max, OutofcoreOctreeBase< ContainerT, PointT > *const tree, const boost::filesystem::path &rootname)
Create root node and directory.
static const std::string node_index_basename
static const std::string node_index_extension
virtual OutofcoreOctreeBaseNode * deepCopy() const
Pure virtual method to perform a deep copy of the octree.
This code defines the octree used for point storage at Urban Robotics.
virtual ~OutofcoreOctreeBaseNode()
Will recursively delete all children calling recFreeChildrein.
bool intersectsWithBoundingBox(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb) const
Tests whether the input bounding box intersects with the current node's bounding box.
void copyAllCurrentAndChildPointsRec(std::list< PointT > &v)
Copies points from this and all children into a single point container (std::list) ...
const boost::filesystem::path & getPCDFilename() const