40 #ifndef PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_H_
41 #define PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_H_
47 #include <pcl/outofcore/boost.h>
48 #include <pcl/outofcore/octree_abstract_node_container.h>
49 #include <pcl/io/pcd_io.h>
50 #include <pcl/PCLPointCloud2.h>
54 #define _fseeki64 fseeko
55 #elif defined __MINGW32__
56 #define _fseeki64 fseeko64
72 template<
typename Po
intT = pcl::Po
intXYZ>
179 return (filelen_ + writebuff_.size ());
187 return ((filelen_ == 0) && writebuff_.empty ());
192 flush (
const bool force_cache_dealloc)
194 flushWritebuff (force_cache_dealloc);
201 return (*disk_storage_filename_);
210 PCL_DEBUG (
"[Octree Disk Container] Removing the point data from disk, in file %s\n",disk_storage_filename_->c_str ());
211 boost::filesystem::remove (boost::filesystem::path (disk_storage_filename_->c_str ()));
223 if (boost::filesystem::exists (*disk_storage_filename_))
225 FILE* fxyz = fopen (path.string ().c_str (),
"w");
227 FILE* f = fopen (disk_storage_filename_->c_str (),
"rb");
230 uint64_t num =
size ();
232 char* loc =
reinterpret_cast<char*
> ( &p );
234 for (uint64_t i = 0; i < num; i++)
236 int seekret = _fseeki64 (f, i *
sizeof (
PointT), SEEK_SET);
238 assert (seekret == 0);
239 size_t readlen = fread (loc,
sizeof (
PointT), 1, f);
241 assert (readlen == 1);
244 std::stringstream ss;
247 ss << p.x <<
"\t" << p.y <<
"\t" << p.z <<
"\n";
249 fwrite (ss.str ().c_str (), 1, ss.str ().size (), fxyz);
251 int res = fclose (f);
280 flushWritebuff (
const bool force_cache_dealloc);
283 boost::shared_ptr<std::string> disk_storage_filename_;
293 const static uint64_t READ_BLOCK_SIZE_;
295 static const uint64_t WRITE_BUFF_MAX_;
297 static boost::mutex rng_mutex_;
298 static boost::mt19937 rand_gen_;
299 static boost::uuids::random_generator uuid_gen_;
305 #endif //PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_H_
boost::uint64_t getDataSize() const
Returns the number of points in the PCD file by reading the PCD header.
std::string & path()
Returns this objects path name.
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
~OutofcoreOctreeDiskContainer()
flushes write buffer, then frees memory
void readRange(const uint64_t start, const uint64_t count, AlignedPointTVector &dst)
Reads count points into memory from the disk container.
void flush(const bool force_cache_dealloc)
Exposed functionality for manually flushing the write buffer during tree creation.
OutofcoreOctreeDiskContainer()
Empty constructor creates disk container and sets filename from random uuid string.
bool empty() const
STL-like empty test.
void readRangeSubSample(const uint64_t start, const uint64_t count, const double percent, AlignedPointTVector &dst)
grab percent*count random points.
PointT operator[](uint64_t idx) const
provides random access to points based on a linear index
void insertRange(const AlignedPointTVector &src)
Inserts a vector of points into the disk data structure.
void push_back(const PointT &p)
Adds a single point to the buffer to be written to disk when the buffer grows sufficiently large...
static void getRandomUUIDString(std::string &s)
Generate a universally unique identifier (UUID)
int read(pcl::PCLPointCloud2::Ptr &output_cloud)
Reads the entire point contents from disk into output_cloud.
OutofcoreAbstractNodeContainer< PointT >::AlignedPointTVector AlignedPointTVector
void convertToXYZ(const boost::filesystem::path &path)
write points to disk as ascii
uint64_t size() const
Returns the total number of points for which this container is responsible, filelen_ + points in writ...
A point structure representing Euclidean xyz coordinates, and the RGB color.
void readRangeSubSample_bernoulli(const uint64_t start, const uint64_t count, const double percent, AlignedPointTVector &dst)
Use bernoulli trials to select points.
std::vector< PointT, Eigen::aligned_allocator< PointT > > AlignedPointTVector
Class responsible for serialization and deserialization of out of core point data.