48 #include <boost/uuid/random_generator.hpp> 50 #include <pcl/common/utils.h> 51 #include <pcl/outofcore/boost.h> 52 #include <pcl/outofcore/octree_abstract_node_container.h> 53 #include <pcl/io/pcd_io.h> 54 #include <pcl/PCLPointCloud2.h> 58 #define _fseeki64 fseeko 59 #elif defined __MINGW32__ 60 #define _fseeki64 fseeko64 76 template<
typename Po
intT = pcl::Po
intXYZ>
183 return (filelen_ + writebuff_.size ());
191 return ((filelen_ == 0) && writebuff_.empty ());
196 flush (
const bool force_cache_dealloc)
198 flushWritebuff (force_cache_dealloc);
205 return (disk_storage_filename_);
214 PCL_DEBUG (
"[Octree Disk Container] Removing the point data from disk, in file %s\n", disk_storage_filename_.c_str ());
215 boost::filesystem::remove (boost::filesystem::path (disk_storage_filename_.c_str ()));
227 if (boost::filesystem::exists (disk_storage_filename_))
229 FILE* fxyz = fopen (
path.string ().c_str (),
"we");
231 FILE* f = fopen (disk_storage_filename_.c_str (),
"rbe");
236 char* loc =
reinterpret_cast<char*
> ( &p );
240 int seekret = _fseeki64 (f, i *
sizeof (
PointT), SEEK_SET);
242 assert (seekret == 0);
243 std::size_t readlen = fread (loc,
sizeof (
PointT), 1, f);
245 assert (readlen == 1);
248 std::stringstream ss;
251 ss << p.x <<
"\t" << p.y <<
"\t" << p.z <<
"\n";
253 fwrite (ss.str ().c_str (), 1, ss.str ().size (), fxyz);
255 int res = fclose (f);
284 flushWritebuff (
const bool force_cache_dealloc);
287 std::string disk_storage_filename_;
301 static std::mutex rng_mutex_;
302 static boost::mt19937 rand_gen_;
303 static boost::uuids::basic_random_generator<boost::mt19937> uuid_gen_;
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
std::uint64_t getDataSize() const
Returns the number of points in the PCD file by reading the PCD header.
void readRangeSubSample(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &dst) override
grab percent*count random points.
void convertToXYZ(const boost::filesystem::path &path) override
write points to disk as ascii
bool empty() const override
STL-like empty test.
void insertRange(const AlignedPointTVector &src)
Inserts a vector of points into the disk data structure.
static void getRandomUUIDString(std::string &s)
Generate a universally unique identifier (UUID)
void flush(const bool force_cache_dealloc)
Exposed functionality for manually flushing the write buffer during tree creation.
std::string & path()
Returns this objects path name.
Class responsible for serialization and deserialization of out of core point data.
void ignore(const T &...)
Utility function to eliminate unused variable warnings.
typename OutofcoreAbstractNodeContainer< PointT >::AlignedPointTVector AlignedPointTVector
~OutofcoreOctreeDiskContainer()
flushes write buffer, then frees memory
void readRangeSubSample_bernoulli(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &dst)
Use bernoulli trials to select points.
PointT operator[](std::uint64_t idx) const override
provides random access to points based on a linear index
void push_back(const PointT &p)
Adds a single point to the buffer to be written to disk when the buffer grows sufficiently large...
OutofcoreOctreeDiskContainer()
Empty constructor creates disk container and sets filename from random uuid string.
void readRange(const std::uint64_t start, const std::uint64_t count, AlignedPointTVector &dst) override
Reads count points into memory from the disk container.
int read(pcl::PCLPointCloud2::Ptr &output_cloud)
Reads the entire point contents from disk into output_cloud.
A point structure representing Euclidean xyz coordinates, and the RGB color.
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
std::uint64_t size() const override
Returns the total number of points for which this container is responsible, filelen_ + points in writ...