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);
202 queryBBIntersects (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const boost::uint32_t query_depth, std::list<std::string> &file_names);
214 virtual boost::uint64_t
217 virtual boost::uint64_t
218 addDataToLeaf (
const std::vector<const PointT*> &p,
const bool skip_bb_check =
true);
225 virtual boost::uint64_t
229 virtual boost::uint64_t
237 virtual boost::uint64_t
267 PCL_THROW_EXCEPTION (
PCLException,
"Not implemented\n");
271 virtual inline size_t 298 virtual boost::uint64_t
418 inBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb)
const;
426 pointInBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const Eigen::Vector3d &point);
444 pointInBoundingBox (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const double x,
const double y,
const double z);
466 inline boost::uint64_t
531 enlargeToCube (Eigen::Vector3d &bb_min, Eigen::Vector3d &bb_max);
568 const static boost::uint32_t
rngseed = 0xAABBCCDD;
577 #endif //PCL_OUTOFCORE_OCTREE_BASE_NODE_H_ uint64_t num_children_
Number of children on disk.
OutofcoreOctreeBase< OutofcoreOctreeDiskContainer< PointT >, PointT > octree_disk
static const boost::uint32_t rngseed
Random number generator seed.
OutofcoreOctreeBaseNode * root_node_
The root node of the tree we belong to.
void subdividePoints(const AlignedPointTVector &p, std::vector< AlignedPointTVector > &c, const bool skip_bb_check)
Subdivide points to pass to child nodes.
void copyAllCurrentAndChildPointsRec(std::list< PointT > &v)
Copies points from this and all children into a single point container (std::list) ...
void flushToDiskRecursive()
A base class for all pcl exceptions which inherits from std::runtime_error.
OutofcoreOctreeBase< ContainerT, PointT > * m_tree_
The tree we belong to.
boost::uint64_t size() const
Number of points in the payload.
const boost::filesystem::path & getPCDFilename() const
virtual size_t countNumLoadedChildren() const
Counts the number of loaded chilren by testing the children_ array; used to update num_loaded_chilren...
virtual node_type_t getNodeType() const
Pure virtual method for receiving the type of octree node (branch or leaf)
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...
virtual OutofcoreOctreeBaseNode * deepCopy() const
Pure virtual method to perform a deep copy of the octree.
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...
static const double sample_percent_
std::vector< OutofcoreOctreeBaseNode * > children_
The children of this node.
virtual ~OutofcoreOctreeBaseNode()
Will recursively delete all children calling recFreeChildrein.
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.
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...
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.
static const std::string node_index_basename
void recFreeChildren()
Method which recursively free children of this node.
OutofcoreOctreeBaseNode()
Empty constructor; sets pointers for children and for bounding boxes to 0.
void getOccupiedVoxelCentersRecursive(AlignedPointTVector &voxel_centers, const size_t query_depth)
Gets a vector of occupied voxel centers.
void subdividePoint(const PointT &point, std::vector< AlignedPointTVector > &c)
Subdivide a single point into a specific child node.
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
OutofcoreOctreeBaseNode & operator=(const OutofcoreOctreeBaseNode &rval)
Operator= is not implemented.
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. ...
virtual void printBoundingBox(const size_t query_depth) const
Write the voxel size to stdout at query_depth.
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.
static boost::mutex rng_mutex_
Random number generator mutex.
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.
void createChild(const std::size_t idx)
Creates child node idx.
void queryFrustum(const double planes[24], std::list< std::string > &file_names)
void randomSample(const AlignedPointTVector &p, AlignedPointTVector &insertBuff, const bool skip_bb_check)
Randomly sample point data.
void writeVPythonVisual(std::ofstream &file)
Write a python visual script to file.
static boost::mt19937 rand_gen_
Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator...
boost::shared_ptr< ContainerT > payload_
what holds the points.
void loadFromFile(const boost::filesystem::path &path, OutofcoreOctreeBaseNode *super)
Loads the nodes metadata from the JSON file.
bool hasUnloadedChildren() const
Returns whether or not a node has unloaded children data.
void convertToXYZRecursive()
Recursively converts data files to ascii XZY files.
const boost::filesystem::path & getMetadataFilename() const
virtual void loadChildren(bool recursive)
Load nodes child data creating new nodes for each.
static const std::string pcd_extension
Extension for this class to find the pcd files on disk.
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...
static const std::string node_index_extension
static const std::string node_container_basename
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
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 saveIdx(bool recursive)
Save node's metadata to file.
OutofcoreOctreeBaseNode< OutofcoreOctreeDiskContainer< PointT >, PointT > octree_disk_node
virtual size_t getNumLoadedChildren() const
Count loaded chilren.
OutofcoreOctreeBaseNode Class internally representing nodes of an outofcore octree, with accessors to its data via the pcl::outofcore::OutofcoreOctreeDiskContainer class or pcl::outofcore::OutofcoreOctreeRamContainer class, whichever it is templated against.
OutofcoreOctreeBaseNode * parent_
super-node
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...
void copyAllCurrentAndChildPointsRec_sub(std::list< PointT > &v, const double percent)
static const std::string node_container_extension
boost::uint64_t addDataAtMaxDepth(const AlignedPointTVector &p, const bool skip_bb_check=true)
Add data to the leaf when at max depth of tree.
virtual OutofcoreOctreeBaseNode * getChildPtr(size_t index_arg) const
Returns a pointer to the child in octant index_arg.
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 int read(pcl::PCLPointCloud2::Ptr &output_cloud)
virtual size_t getDepth() const
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual boost::uint64_t getDataSize() const
Gets the number of points available in the PCD file.
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...
This code defines the octree used for point storage at Urban Robotics.
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.
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 countNumChildren() const
Counts the number of child directories on disk; used to update num_children_.
virtual size_t getNumChildren() const
Returns the total number of children on disk.
pcl::octree::node_type_t node_type_t
Abstract octree node class
uint64_t num_loaded_children_
Number of loaded children this node has.
size_t depth_
Depth in the tree, root is 0, root's children are 1, ...
void saveMetadataToFile(const boost::filesystem::path &path)
Write JSON metadata for this node to file.
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.
OutofcoreOctreeNodeMetadata::Ptr node_metadata_