46 #include <pcl/common/io.h> 47 #include <pcl/PCLPointCloud2.h> 49 #include <pcl/outofcore/boost.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>
64 template<
typename ContainerT,
typename Po
intT>
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);
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);
221 addDataToLeaf (
const std::vector<const PointT*> &p,
const bool skip_bb_check =
true);
267 PCL_THROW_EXCEPTION (
PCLException,
"Not implemented\n");
271 virtual inline std::size_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);
529 enlargeToCube (Eigen::Vector3d &bb_min, Eigen::Vector3d &bb_max);
virtual std::size_t countNumChildren() const
Counts the number of child directories on disk; used to update num_children_.
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
std::uint64_t size() const
Number of points in the payload.
virtual std::size_t getNumChildren() const
Returns the total number of children on disk.
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.
virtual std::size_t getNumLoadedChildren() const
Count loaded chilren.
void copyAllCurrentAndChildPointsRec(std::list< PointT > &v)
Copies points from this and all children into a single point container (std::list) ...
std::size_t depth_
Depth in the tree, root is 0, root's children are 1, ...
virtual OutofcoreOctreeBaseNode * getChildPtr(std::size_t index_arg) const
Returns a pointer to the child in octant index_arg.
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 flushToDiskRecursive()
A base class for all pcl exceptions which inherits from std::runtime_error.
OutofcoreOctreeBase< ContainerT, PointT > * m_tree_
The tree we belong to.
std::uint64_t addDataAtMaxDepth(const AlignedPointTVector &p, const bool skip_bb_check=true)
Add data to the leaf when at max depth of tree.
const boost::filesystem::path & getPCDFilename() const
pcl::octree::node_type_t node_type_t
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.
~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.
virtual void printBoundingBox(const std::size_t query_depth) const
Write the voxel size to stdout at 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...
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.
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 subdividePoint(const PointT &point, std::vector< AlignedPointTVector > &c)
Subdivide a single point into a specific child node.
virtual std::uint64_t getDataSize() const
Gets the number of points available in the PCD file.
OutofcoreOctreeBaseNode & operator=(const OutofcoreOctreeBaseNode &rval)
Operator= is not implemented.
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.
node_type_t getNodeType() const override
Pure virtual method for receiving the type of octree node (branch or leaf)
void writeVPythonVisual(std::ofstream &file)
Write a python visual script to file.
std::uint64_t num_loaded_children_
Number of loaded children this node has.
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.
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 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...
void convertToXYZRecursive()
Recursively converts data files to ascii XZY files.
const boost::filesystem::path & getMetadataFilename() const
void getOccupiedVoxelCentersRecursive(AlignedPointTVector &voxel_centers, const std::size_t query_depth)
Gets a vector of occupied voxel centers.
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. ...
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...
std::shared_ptr< ContainerT > payload_
what holds the points.
static const std::string node_index_extension
static const std::string node_container_basename
void saveIdx(bool recursive)
Save node's metadata to file.
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
virtual std::size_t getDepth() const
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...
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
OutofcoreOctreeBaseNode * deepCopy() const override
Pure virtual method to perform a deep copy of the octree.
void copyAllCurrentAndChildPointsRec_sub(std::list< PointT > &v, const double percent)
static const std::string node_container_extension
static std::mt19937 rng_
Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator...
virtual int read(pcl::PCLPointCloud2::Ptr &output_cloud)
A point structure representing Euclidean xyz coordinates, and the RGB color.
static std::mutex rng_mutex_
Random number generator mutex.
std::uint64_t num_children_
Number of children on disk.
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 std::size_t countNumLoadedChildren() const
Counts the number of loaded chilren by testing the children_ array; used to update num_loaded_chilren...
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
Abstract octree node class
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 saveMetadataToFile(const boost::filesystem::path &path)
Write JSON metadata for this node to file.
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...
OutofcoreOctreeNodeMetadata::Ptr node_metadata_