47 #include <pcl/common/io.h>
48 #include <pcl/PCLPointCloud2.h>
50 #include <pcl/outofcore/octree_base.h>
51 #include <pcl/outofcore/octree_disk_container.h>
52 #include <pcl/outofcore/outofcore_node_data.h>
54 #include <pcl/octree/octree_nodes.h>
61 template<
typename ContainerT,
typename Po
intT>
62 class OutofcoreOctreeBaseNode;
64 template<
typename ContainerT,
typename Po
intT>
65 class OutofcoreOctreeBase;
68 template<
typename ContainerT,
typename Po
intT> OutofcoreOctreeBaseNode<ContainerT, PointT>*
72 template<
typename ContainerT,
typename Po
intT>
void
73 queryBBIntersects_noload (
const boost::filesystem::path &root_node,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const std::uint32_t query_depth, std::list<std::string> &bin_name);
76 template<
typename ContainerT,
typename Po
intT>
void
94 template<
typename ContainerT = OutofcoreOctreeDiskContainer<pcl::Po
intXYZ>,
typename Po
intT = pcl::Po
intXYZ>
104 queryBBIntersects_noload<ContainerT, PointT> (
const boost::filesystem::path &rootnode,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const std::uint32_t query_depth, std::list<std::string> &bin_name);
107 queryBBIntersects_noload<ContainerT, PointT> (
OutofcoreOctreeBaseNode<ContainerT, PointT>* current,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const std::uint32_t query_depth, std::list<std::string> &bin_name);
146 const boost::filesystem::path&
152 const boost::filesystem::path&
159 queryFrustum (
const double planes[24], std::list<std::string>& file_names);
162 queryFrustum (
const double planes[24], std::list<std::string>& file_names,
const std::uint32_t query_depth,
const bool skip_vfc_check =
false);
165 queryFrustum (
const double planes[24],
const Eigen::Vector3d &eye,
const Eigen::Matrix4d &view_projection_matrix, std::list<std::string>& file_names,
const std::uint32_t query_depth,
const bool skip_vfc_check =
false);
205 queryBBIntersects (
const Eigen::Vector3d &min_bb,
const Eigen::Vector3d &max_bb,
const std::uint32_t query_depth, std::list<std::string> &file_names);
217 virtual std::uint64_t
220 virtual std::uint64_t
221 addDataToLeaf (
const std::vector<const PointT*> &p,
const bool skip_bb_check =
true);
228 virtual std::uint64_t
232 virtual std::uint64_t
240 virtual std::uint64_t
267 PCL_THROW_EXCEPTION (
PCLException,
"Not implemented\n");
271 virtual inline std::size_t
298 virtual std::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);
A base class for all pcl exceptions which inherits from std::runtime_error.
Abstract octree node class
This code defines the octree used for point storage at Urban Robotics.
OutofcoreOctreeBaseNode Class internally representing nodes of an outofcore octree,...
std::size_t depth_
Depth in the tree, root is 0, root's children are 1, ...
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
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.
static const std::string node_index_basename
virtual std::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...
static const std::string node_index_extension
virtual std::uint64_t getDataSize() const
Gets the number of points available in the PCD file.
~OutofcoreOctreeBaseNode() override
Will recursively delete all children calling recFreeChildrein.
const boost::filesystem::path & getPCDFilename() const
void copyAllCurrentAndChildPointsRec_sub(std::list< PointT > &v, const double percent)
void loadFromFile(const boost::filesystem::path &path, OutofcoreOctreeBaseNode *super)
Loads the nodes metadata from the JSON file.
OutofcoreOctreeBaseNode & operator=(const OutofcoreOctreeBaseNode &rval)
Operator= is not implemented.
bool hasUnloadedChildren() const
Returns whether or not a node has unloaded children data.
void randomSample(const AlignedPointTVector &p, AlignedPointTVector &insertBuff, const bool skip_bb_check)
Randomly sample point data.
virtual std::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.
OutofcoreOctreeBase< ContainerT, PointT > * m_tree_
The tree we belong to.
static std::mutex rng_mutex_
Random number generator mutex.
virtual void queryBBIncludes_subsample(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, std::uint64_t query_depth, const double percent, AlignedPointTVector &v)
Recursively add points that fall into the queried bounding box up to the query_depth.
const boost::filesystem::path & getMetadataFilename() const
virtual std::size_t getNumChildren() const
Returns the total number of children on disk.
static const double sample_percent_
std::uint64_t num_children_
Number of children on disk.
virtual void queryBBIntersects(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const std::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...
void writeVPythonVisual(std::ofstream &file)
Write a python visual script to file.
OutofcoreOctreeBaseNode()
Empty constructor; sets pointers for children and for bounding boxes to 0.
static bool pointInBoundingBox(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const double x, const double y, const double z)
Tests whether x, y, and z fall within the input bounding box.
virtual std::size_t countNumChildren() const
Counts the number of child directories on disk; used to update num_children_.
void convertToXYZRecursive()
Recursively converts data files to ascii XZY files.
OutofcoreOctreeBaseNode * parent_
super-node
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.
std::shared_ptr< ContainerT > payload_
what holds the points.
virtual int read(pcl::PCLPointCloud2::Ptr &output_cloud)
OutofcoreOctreeBaseNode * root_node_
The root node of the tree we belong to.
std::uint64_t num_loaded_children_
Number of loaded children this node has.
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 saveIdx(bool recursive)
Save node's metadata to file.
void queryFrustum(const double planes[24], std::list< std::string > &file_names)
OutofcoreOctreeNodeMetadata::Ptr node_metadata_
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
OutofcoreOctreeBaseNode * deepCopy() const override
Pure virtual method to perform a deep copy of the octree.
void sortOctantIndices(const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< pcl::Indices > &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...
void getOccupiedVoxelCentersRecursive(AlignedPointTVector &voxel_centers, const std::size_t query_depth)
Gets a vector of occupied voxel centers.
std::vector< OutofcoreOctreeBaseNode * > children_
The children of this node.
static const std::string node_container_basename
std::uint64_t size() const
Number of points in the payload.
OutofcoreOctreeBaseNode(const OutofcoreOctreeBaseNode &rval)
no copy construction right now
static const std::string pcd_extension
Extension for this class to find the pcd files on disk.
virtual std::size_t getNumLoadedChildren() const
Count loaded children.
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)
static std::mt19937 rng_
Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator.
void subdividePoint(const PointT &point, std::vector< AlignedPointTVector > &c)
Subdivide a single point into a specific child node.
pcl::octree::node_type_t node_type_t
virtual std::size_t getDepth() const
virtual void loadChildren(bool recursive)
Load nodes child data creating new nodes for each.
virtual std::size_t countNumLoadedChildren() const
Counts the number of loaded children by testing the children_ array; used to update num_loaded_childr...
void flushToDiskRecursive()
std::uint64_t addDataAtMaxDepth(const AlignedPointTVector &p, const bool skip_bb_check=true)
Add data to the leaf when at max depth of tree.
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.
virtual OutofcoreOctreeBaseNode * getChildPtr(std::size_t index_arg) const
Returns a pointer to the child in octant index_arg.
virtual std::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
void saveMetadataToFile(const boost::filesystem::path &path)
Write JSON metadata for this node to file.
static const std::string node_container_extension
void recFreeChildren()
Method which recursively free children of this node.
virtual void queryBBIncludes(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, std::size_t query_depth, AlignedPointTVector &dst)
Recursively add points that fall into the queried bounding box up to the query_depth.
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...
void createChild(const std::size_t idx)
Creates child node idx.
virtual std::uint64_t addPointCloud(const pcl::PCLPointCloud2::Ptr &input_cloud, const bool skip_bb_check=false)
Add a single PCLPointCloud2 object into the octree.
node_type_t getNodeType() const override
Pure virtual method for retrieving the type of octree node (branch or leaf)
virtual void printBoundingBox(const std::size_t query_depth) const
Write the voxel size to stdout at query_depth.
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 queryBBIntersects_noload(const boost::filesystem::path &root_node, const Eigen::Vector3d &min, const Eigen::Vector3d &max, const std::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...
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
A point structure representing Euclidean xyz coordinates, and the RGB color.