42 #include <pcl/outofcore/boost.h>
43 #include <pcl/common/io.h>
46 #include <pcl/outofcore/octree_base_node.h>
47 #include <pcl/outofcore/octree_disk_container.h>
48 #include <pcl/outofcore/octree_ram_container.h>
51 #include <pcl/outofcore/outofcore_iterator_base.h>
52 #include <pcl/outofcore/outofcore_breadth_first_iterator.h>
53 #include <pcl/outofcore/outofcore_depth_first_iterator.h>
54 #include <pcl/outofcore/impl/outofcore_breadth_first_iterator.hpp>
55 #include <pcl/outofcore/impl/outofcore_depth_first_iterator.hpp>
58 #include <pcl/outofcore/metadata.h>
59 #include <pcl/outofcore/outofcore_base_data.h>
61 #include <pcl/filters/filter.h>
62 #include <pcl/filters/random_sample.h>
64 #include <pcl/PCLPointCloud2.h>
66 #include <shared_mutex>
149 template<
typename ContainerT = OutofcoreOctreeDiskContainer<pcl::Po
intXYZ>,
typename Po
intT = pcl::Po
intXYZ>
178 using Ptr = shared_ptr<OutofcoreOctreeBase<ContainerT, PointT> >;
179 using ConstPtr = shared_ptr<const OutofcoreOctreeBase<ContainerT, PointT> >;
219 OutofcoreOctreeBase (
const Eigen::Vector3d& min,
const Eigen::Vector3d& max,
const double resolution_arg,
const boost::filesystem::path &root_node_name,
const std::string &coord_sys);
234 OutofcoreOctreeBase (
const std::uint64_t max_depth,
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const boost::filesystem::path &root_node_name,
const std::string &coord_sys);
301 queryFrustum (
const double *planes, std::list<std::string>& file_names)
const;
304 queryFrustum (
const double *planes, std::list<std::string>& file_names,
const std::uint32_t query_depth)
const;
307 queryFrustum (
const double *planes,
const Eigen::Vector3d &eye,
const Eigen::Matrix4d &view_projection_matrix,
308 std::list<std::string>& file_names,
const std::uint32_t query_depth)
const;
323 queryBBIntersects (
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const std::uint32_t query_depth, std::list<std::string> &bin_name)
const;
383 queryBoundingBox (
const Eigen::Vector3d &min,
const Eigen::Vector3d &max,
const int query_depth, std::list<std::string> &filenames)
const
399 getBoundingBox (Eigen::Vector3d &min, Eigen::Vector3d &max)
const;
408 return (
metadata_->getLODPoints (depth_index));
420 queryBoundingBoxNumPoints (
const Eigen::Vector3d& min,
const Eigen::Vector3d& max,
const int query_depth,
bool load_from_disk =
true);
426 inline const std::vector<std::uint64_t>&
472 return (
metadata_->getCoordinateSystem ());
512 getOccupiedVoxelCenters(std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &voxel_centers, std::size_t query_depth)
const;
559 return (sample_percent_);
567 this->sample_percent_ = std::fabs (sample_percent_arg) > 1.0 ? 1.0 : std::fabs (sample_percent_arg);
572 init (
const std::uint64_t& depth,
const Eigen::Vector3d& min,
const Eigen::Vector3d& max,
const boost::filesystem::path& root_name,
const std::string& coord_sys);
640 const static std::uint64_t
LOAD_COUNT_ =
static_cast<std::uint64_t
>(2e9);
646 enlargeToCube (Eigen::Vector3d &bb_min, Eigen::Vector3d &bb_max);
650 calculateDepth (
const Eigen::Vector3d& min_bb,
const Eigen::Vector3d& max_bb,
const double leaf_resolution);
652 double sample_percent_;
shared_ptr< OutofcoreOctreeBase< ContainerT, pcl::PointXYZRGB > > Ptr
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
void queryBBIncludes(const Eigen::Vector3d &min, const Eigen::Vector3d &max, const std::uint64_t query_depth, AlignedPointTVector &dst) const
Get Points in BB, only points inside BB.
std::uint64_t getNumPointsAtDepth(const std::uint64_t &depth_index) const
Get number of points at specified LOD.
void DeAllocEmptyNodeCache()
Flush empty nodes only.
void queryFrustum(const double *planes, std::list< std::string > &file_names) const
void setLODFilter(const pcl::Filter< pcl::PCLPointCloud2 >::Ptr &filter_arg)
Sets the filter to use when building the levels of depth.
std::string node_container_extension_
void getOccupiedVoxelCenters(std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > &voxel_centers) const
Returns the voxel centers of all occupied/existing leaves of the tree.
shared_ptr< PointCloud< PointT > > Ptr
void flushToDisk()
Flush all nodes' cache.
double getVoxelSideLength() const
Gets the smallest (assumed) cubic voxel side lengths.
std::uint64_t getTreeDepth() const
std::string node_index_extension_
void getOccupiedVoxelCenters(AlignedPointTVector &voxel_centers, std::size_t query_depth) const
Returns the voxel centers of all existing voxels at query_depth.
shared_ptr< const std::vector< int > > IndicesConstPtr
OutofcoreOctreeBaseMetadata::Ptr metadata_
std::string node_container_basename_
OutofcoreOctreeBase(const boost::filesystem::path &root_node_name, const bool load_all)
Load an existing tree.
virtual void queryBoundingBox(const Eigen::Vector3d &min, const Eigen::Vector3d &max, const int query_depth, const pcl::PCLPointCloud2::Ptr &dst_blob, double percent=1.0)
Query all points falling within the input bounding box at query_depth and return a PCLPointCloud2 obj...
void writeVPythonVisual(const boost::filesystem::path filename)
Write a python script using the vpython module containing all the bounding boxes. ...
std::string node_index_basename_
std::uint64_t queryBoundingBoxNumPoints(const Eigen::Vector3d &min, const Eigen::Vector3d &max, const int query_depth, bool load_from_disk=true)
Queries the number of points in a bounding box.
void setSamplePercent(const double sample_percent_arg)
Sets the sampling percent for constructing LODs.
typename PointCloud::ConstPtr PointCloudConstPtr
void convertToXYZ()
Save each .bin file as an XYZ file.
void printBoundingBox() const
Prints size of the bounding boxes to stdou.
void flushToDiskLazy()
Flush all non leaf nodes' cache.
std::uint64_t addDataToLeaf_and_genLOD(AlignedPointTVector &p)
Recursively add points to the tree subsampling LODs on the way.
void saveToFile()
Write octree definition ".octree" (defined by octree_extension_) to disk.
OutofcoreOctreeBaseNode< ContainerT, PointT > BranchNode
Filter represents the base filter class.
std::uint64_t getDepth() const
Get number of LODs, which is the height of the tree.
std::uint64_t addPointCloud(PointCloudConstPtr point_cloud)
Copies the points from the point_cloud falling within the bounding box of the octree to the out-of-co...
void buildLODRecursive(const std::vector< BranchNode * > ¤t_branch)
recursive portion of lod builder
std::uint64_t addDataToLeaf(const AlignedPointTVector &p)
Recursively add points to the tree.
static const std::uint64_t LOAD_COUNT_
void getOccupiedVoxelCenters(AlignedPointTVector &voxel_centers) const
Gets the voxel centers of all occupied/existing leaves of the tree.
void init(const std::uint64_t &depth, const Eigen::Vector3d &min, const Eigen::Vector3d &max, const boost::filesystem::path &root_name, const std::string &coord_sys)
void buildLOD()
Generate multi-resolution LODs for the tree, which are a uniform random sampling all child leafs belo...
bool getBinDimension(double &x, double &y) const
Computes the expected voxel dimensions at the leaves.
static const std::string TREE_EXTENSION_
defined as ".octree" to append to treepath files
void queryBBIncludes_subsample(const Eigen::Vector3d &min, const Eigen::Vector3d &max, std::uint64_t query_depth, const double percent, AlignedPointTVector &dst) const
Returns a random subsample of points within the given bounding box at query_depth.
std::vector< pcl::PointXYZRGB, Eigen::aligned_allocator< pcl::PointXYZRGB > > AlignedPointTVector
const std::vector< std::uint64_t > & getNumPointsVector() const
Get number of points at each LOD.
bool getBoundingBox(Eigen::Vector3d &min, Eigen::Vector3d &max) const
Get the overall bounding box of the outofcore octree; this is the same as the bounding box of the roo...
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.
OutofcoreNodeType * getBranchChildPtr(const BranchNode &branch_arg, unsigned char childIdx_arg) const
virtual ~OutofcoreOctreeBase()
pcl::Filter< pcl::PCLPointCloud2 >::Ptr getLODFilter()
const std::string & getCoordSystem() const
Get coordinate system tag from the JSON metadata file.
Abstract octree iterator class.
OutofcoreNodeType * root_node_
Pointer to the root node of the octree data structure.
static const int OUTOFCORE_VERSION_
std::shared_timed_mutex read_write_mutex_
shared mutex for controlling read/write access to disk
shared_ptr< const PointCloud< PointT > > ConstPtr
typename PointCloud::Ptr PointCloudPtr
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual void queryBoundingBox(const Eigen::Vector3d &min, const Eigen::Vector3d &max, const int query_depth, std::list< std::string > &filenames) const
Returns list of pcd files from nodes whose bounding boxes intersect with the input bounding box...
void queryBBIntersects(const Eigen::Vector3d &min, const Eigen::Vector3d &max, const std::uint32_t query_depth, std::list< std::string > &bin_name) const
Get a list of file paths at query_depth that intersect with your bounding box specified by min and ma...
OutofcoreNodeType * getRootNode()
This code defines the octree used for point storage at Urban Robotics.
std::uint64_t addPointCloud_and_genLOD(pcl::PCLPointCloud2::Ptr &input_cloud)
Recursively add points to the tree.
RandomSample applies a random sampling with uniform probability.
shared_ptr< std::vector< int > > IndicesPtr
OutofcoreOctreeBaseNode< ContainerT, PointT > OutofcoreNodeType
double getSamplePercent() const
Returns the sample_percent_ used when constructing the LOD.
void incrementPointsInLOD(std::uint64_t depth, std::uint64_t inc)
Increment current depths (LOD for branch nodes) point count; called by addDataAtMaxDepth in Outofcore...
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...
bool checkExtension(const boost::filesystem::path &path_name)
Auxiliary function to validate path_name extension is .octree.
shared_ptr< const OutofcoreOctreeBase< ContainerT, pcl::PointXYZRGB > > ConstPtr
OutofcoreOctreeBase & operator=(OutofcoreOctreeBase &rval)