Point Cloud Library (PCL)  1.11.0-dev
octree_disk_container.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  * Copyright (c) 2012, Urban Robotics, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of Willow Garage, Inc. nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id: octree_disk_container.hpp 6927M 2012-08-24 17:01:57Z (local) $
38  */
39 
40 #ifndef PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_IMPL_H_
41 #define PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_IMPL_H_
42 
43 // C++
44 #include <sstream>
45 #include <cassert>
46 #include <ctime>
47 
48 // Boost
49 #include <pcl/outofcore/boost.h>
50 #include <boost/random/bernoulli_distribution.hpp>
51 #include <boost/random/uniform_int.hpp>
52 #include <boost/uuid/uuid_io.hpp>
53 
54 // PCL
55 #include <pcl/common/utils.h> // pcl::utils::ignore
56 #include <pcl/io/pcd_io.h>
57 #include <pcl/point_types.h>
58 #include <pcl/PCLPointCloud2.h>
59 
60 // PCL (Urban Robotics)
61 #include <pcl/outofcore/octree_disk_container.h>
62 
63 //allows operation on POSIX
64 #if !defined _WIN32
65 #define _fseeki64 fseeko
66 #elif defined __MINGW32__
67 #define _fseeki64 fseeko64
68 #endif
69 
70 namespace pcl
71 {
72  namespace outofcore
73  {
74  template<typename PointT>
75  std::mutex OutofcoreOctreeDiskContainer<PointT>::rng_mutex_;
76 
77  template<typename PointT> boost::mt19937
78  OutofcoreOctreeDiskContainer<PointT>::rand_gen_ (static_cast<unsigned int> (std::time(nullptr)));
79 
80  template<typename PointT>
81  boost::uuids::basic_random_generator<boost::mt19937> OutofcoreOctreeDiskContainer<PointT>::uuid_gen_ (&rand_gen_);
82 
83  template<typename PointT>
85  template<typename PointT>
87 
88  template<typename PointT> void
90  {
91  boost::uuids::uuid u;
92  {
93  std::lock_guard<std::mutex> lock (rng_mutex_);
94  u = uuid_gen_ ();
95  }
96 
97  std::stringstream ss;
98  ss << u;
99  s = ss.str ();
100  }
101  ////////////////////////////////////////////////////////////////////////////////
102 
103  template<typename PointT>
105  : filelen_ (0)
106  , writebuff_ (0)
107  {
108  getRandomUUIDString (disk_storage_filename_);
109  filelen_ = 0;
110  }
111  ////////////////////////////////////////////////////////////////////////////////
112 
113  template<typename PointT>
115  : filelen_ (0)
116  , writebuff_ (0)
117  {
118  if (boost::filesystem::exists (path))
119  {
120  if (boost::filesystem::is_directory (path))
121  {
122  std::string uuid;
123  getRandomUUIDString (uuid);
124  boost::filesystem::path filename (uuid);
125  boost::filesystem::path file = path / filename;
126 
127  disk_storage_filename_ = file.string ();
128  }
129  else
130  {
131  std::uint64_t len = boost::filesystem::file_size (path);
132 
133  disk_storage_filename_ = path.string ();
134 
135  filelen_ = len / sizeof(PointT);
136 
137  pcl::PCLPointCloud2 cloud_info;
138  Eigen::Vector4f origin;
139  Eigen::Quaternionf orientation;
140  int pcd_version;
141  int data_type;
142  unsigned int data_index;
143 
144  //read the header of the pcd file and get the number of points
145  PCDReader reader;
146  reader.readHeader (disk_storage_filename_, cloud_info, origin, orientation, pcd_version, data_type, data_index, 0);
147 
148  filelen_ = cloud_info.width * cloud_info.height;
149  }
150  }
151  else //path doesn't exist
152  {
153  disk_storage_filename_ = path.string ();
154  filelen_ = 0;
155  }
156  }
157  ////////////////////////////////////////////////////////////////////////////////
158 
159  template<typename PointT>
161  {
162  flushWritebuff (true);
163  }
164  ////////////////////////////////////////////////////////////////////////////////
165 
166  template<typename PointT> void
167  OutofcoreOctreeDiskContainer<PointT>::flushWritebuff (const bool force_cache_dealloc)
168  {
169  if (!writebuff_.empty ())
170  {
171  //construct the point cloud for this node
173 
174  cloud->width = static_cast<std::uint32_t> (writebuff_.size ());
175  cloud->height = 1;
176 
177  cloud->points = writebuff_;
178 
179  //write data to a pcd file
180  pcl::PCDWriter writer;
181 
182 
183  PCL_WARN ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] Flushing writebuffer in a dangerous way to file %s. This might overwrite data in destination file\n", __FUNCTION__, disk_storage_filename_.c_str ());
184 
185  // Write ascii for now to debug
186  int res = writer.writeBinaryCompressed (disk_storage_filename_, *cloud);
187  pcl::utils::ignore(res);
188  assert (res == 0);
189  if (force_cache_dealloc)
190  {
191  writebuff_.resize (0);
192  }
193  }
194  }
195  ////////////////////////////////////////////////////////////////////////////////
196 
197  template<typename PointT> PointT
199  {
200  PCL_THROW_EXCEPTION (PCLException, "[pcl::outofcore::OutofcoreOctreeDiskContainer] Not implemented for use with PCL library\n");
201 
202  //if the index is on disk
203  if (idx < filelen_)
204  {
205 
206  PointT temp;
207  //open our file
208  FILE* f = fopen (disk_storage_filename_.c_str (), "rbe");
209  assert (f != NULL);
210 
211  //seek the right length;
212  int seekret = _fseeki64 (f, idx * sizeof(PointT), SEEK_SET);
213  pcl::utils::ignore(seekret);
214  assert (seekret == 0);
215 
216  std::size_t readlen = fread (&temp, 1, sizeof(PointT), f);
217  pcl::utils::ignore(readlen);
218  assert (readlen == sizeof (PointT));
219 
220  int res = fclose (f);
221  pcl::utils::ignore(res);
222  assert (res == 0);
223 
224  return (temp);
225  }
226  //otherwise if the index is still in the write buffer
227  if (idx < (filelen_ + writebuff_.size ()))
228  {
229  idx -= filelen_;
230  return (writebuff_[idx]);
231  }
232 
233  //else, throw out of range exception
234  PCL_THROW_EXCEPTION (PCLException, "[pcl::outofcore:OutofcoreOctreeDiskContainer] Index is out of range");
235  }
236 
237  ////////////////////////////////////////////////////////////////////////////////
238  template<typename PointT> void
240  {
241  if (count == 0)
242  {
243  return;
244  }
245 
246  if ((start + count) > size ())
247  {
248  PCL_ERROR ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] Indices out of range; start + count exceeds the size of the stored points\n", __FUNCTION__);
249  PCL_THROW_EXCEPTION (PCLException, "[pcl::outofcore::OutofcoreOctreeDiskContainer] Outofcore Octree Exception: Read indices exceed range");
250  }
251 
252  pcl::PCDReader reader;
254 
255  int res = reader.read (disk_storage_filename_, *cloud);
256  pcl::utils::ignore(res);
257  assert (res == 0);
258 
259  for (std::size_t i=0; i < cloud->points.size (); i++)
260  dst.push_back (cloud->points[i]);
261 
262  }
263  ////////////////////////////////////////////////////////////////////////////////
264 
265  template<typename PointT> void
267  {
268  if (count == 0)
269  {
270  return;
271  }
272 
273  dst.clear ();
274 
275  std::uint64_t filestart = 0;
276  std::uint64_t filecount = 0;
277 
278  std::int64_t buffstart = -1;
279  std::int64_t buffcount = -1;
280 
281  if (start < filelen_)
282  {
283  filestart = start;
284  }
285 
286  if ((start + count) <= filelen_)
287  {
288  filecount = count;
289  }
290  else
291  {
292  filecount = filelen_ - start;
293 
294  buffstart = 0;
295  buffcount = count - filecount;
296  }
297 
298  if (buffcount > 0)
299  {
300  {
301  std::lock_guard<std::mutex> lock (rng_mutex_);
302  boost::bernoulli_distribution<double> buffdist (percent);
303  boost::variate_generator<boost::mt19937&, boost::bernoulli_distribution<double> > buffcoin (rand_gen_, buffdist);
304 
305  for (std::size_t i = buffstart; i < static_cast<std::uint64_t> (buffcount); i++)
306  {
307  if (buffcoin ())
308  {
309  dst.push_back (writebuff_[i]);
310  }
311  }
312  }
313  }
314 
315  if (filecount > 0)
316  {
317  //pregen and then sort the offsets to reduce the amount of seek
318  std::vector < std::uint64_t > offsets;
319  {
320  std::lock_guard<std::mutex> lock (rng_mutex_);
321 
322  boost::bernoulli_distribution<double> filedist (percent);
323  boost::variate_generator<boost::mt19937&, boost::bernoulli_distribution<double> > filecoin (rand_gen_, filedist);
324  for (std::uint64_t i = filestart; i < (filestart + filecount); i++)
325  {
326  if (filecoin ())
327  {
328  offsets.push_back (i);
329  }
330  }
331  }
332  std::sort (offsets.begin (), offsets.end ());
333 
334  FILE* f = fopen (disk_storage_filename_.c_str (), "rbe");
335  assert (f != NULL);
336  PointT p;
337  char* loc = reinterpret_cast<char*> (&p);
338 
339  std::uint64_t filesamp = offsets.size ();
340  for (std::uint64_t i = 0; i < filesamp; i++)
341  {
342  int seekret = _fseeki64 (f, offsets[i] * static_cast<std::uint64_t> (sizeof(PointT)), SEEK_SET);
343  pcl::utils::ignore(seekret);
344  assert (seekret == 0);
345  std::size_t readlen = fread (loc, sizeof(PointT), 1, f);
346  pcl::utils::ignore(readlen);
347  assert (readlen == 1);
348 
349  dst.push_back (p);
350  }
351 
352  fclose (f);
353  }
354  }
355  ////////////////////////////////////////////////////////////////////////////////
356 
357 //change this to use a weighted coin flip, to allow sparse sampling of small clouds (eg the bernoulli above)
358  template<typename PointT> void
360  {
361  if (count == 0)
362  {
363  return;
364  }
365 
366  dst.clear ();
367 
368  std::uint64_t filestart = 0;
369  std::uint64_t filecount = 0;
370 
371  std::int64_t buffcount = -1;
372 
373  if (start < filelen_)
374  {
375  filestart = start;
376  }
377 
378  if ((start + count) <= filelen_)
379  {
380  filecount = count;
381  }
382  else
383  {
384  filecount = filelen_ - start;
385  buffcount = count - filecount;
386  }
387 
388  std::uint64_t filesamp = static_cast<std::uint64_t> (percent * static_cast<double> (filecount));
389 
390  std::uint64_t buffsamp = (buffcount > 0) ? (static_cast<std::uint64_t > (percent * static_cast<double> (buffcount))) : 0;
391 
392  if ((filesamp == 0) && (buffsamp == 0) && (size () > 0))
393  {
394  //std::cerr << "would not add points to LOD, falling back to bernoulli";
395  readRangeSubSample_bernoulli (start, count, percent, dst);
396  return;
397  }
398 
399  if (buffcount > 0)
400  {
401  {
402  std::lock_guard<std::mutex> lock (rng_mutex_);
403 
404  boost::uniform_int < std::uint64_t > buffdist (0, buffcount - 1);
405  boost::variate_generator<boost::mt19937&, boost::uniform_int<std::uint64_t> > buffdie (rand_gen_, buffdist);
406 
407  for (std::uint64_t i = 0; i < buffsamp; i++)
408  {
409  std::uint64_t buffstart = buffdie ();
410  dst.push_back (writebuff_[buffstart]);
411  }
412  }
413  }
414 
415  if (filesamp > 0)
416  {
417  //pregen and then sort the offsets to reduce the amount of seek
418  std::vector < std::uint64_t > offsets;
419  {
420  std::lock_guard<std::mutex> lock (rng_mutex_);
421 
422  offsets.resize (filesamp);
423  boost::uniform_int < std::uint64_t > filedist (filestart, filestart + filecount - 1);
424  boost::variate_generator<boost::mt19937&, boost::uniform_int<std::uint64_t> > filedie (rand_gen_, filedist);
425  for (std::uint64_t i = 0; i < filesamp; i++)
426  {
427  std::uint64_t _filestart = filedie ();
428  offsets[i] = _filestart;
429  }
430  }
431  std::sort (offsets.begin (), offsets.end ());
432 
433  FILE* f = fopen (disk_storage_filename_.c_str (), "rbe");
434  assert (f != NULL);
435  PointT p;
436  char* loc = reinterpret_cast<char*> (&p);
437  for (std::uint64_t i = 0; i < filesamp; i++)
438  {
439  int seekret = _fseeki64 (f, offsets[i] * static_cast<std::uint64_t> (sizeof(PointT)), SEEK_SET);
440  pcl::utils::ignore(seekret);
441  assert (seekret == 0);
442  std::size_t readlen = fread (loc, sizeof(PointT), 1, f);
443  pcl::utils::ignore(readlen);
444  assert (readlen == 1);
445 
446  dst.push_back (p);
447  }
448  int res = fclose (f);
449  pcl::utils::ignore(res);
450  assert (res == 0);
451  }
452  }
453  ////////////////////////////////////////////////////////////////////////////////
454 
455  template<typename PointT> void
457  {
458  writebuff_.push_back (p);
459  if (writebuff_.size () > WRITE_BUFF_MAX_)
460  {
461  flushWritebuff (false);
462  }
463  }
464  ////////////////////////////////////////////////////////////////////////////////
465 
466  template<typename PointT> void
468  {
469  const std::uint64_t count = src.size ();
470 
471  typename pcl::PointCloud<PointT>::Ptr tmp_cloud (new pcl::PointCloud<PointT> ());
472 
473  // If there's a pcd file with data
474  if (boost::filesystem::exists (disk_storage_filename_))
475  {
476  // Open the existing file
477  pcl::PCDReader reader;
478  int res = reader.read (disk_storage_filename_, *tmp_cloud);
479  pcl::utils::ignore(res);
480  assert (res == 0);
481  }
482  // Otherwise create the point cloud which will be saved to the pcd file for the first time
483  else
484  {
485  tmp_cloud->width = static_cast<std::uint32_t> (count + writebuff_.size ());
486  tmp_cloud->height = 1;
487  }
488 
489  for (std::size_t i = 0; i < src.size (); i++)
490  tmp_cloud->points.push_back (src[i]);
491 
492  // If there are any points in the write cache writebuff_, a different write cache than this one, concatenate
493  for (std::size_t i = 0; i < writebuff_.size (); i++)
494  {
495  tmp_cloud->points.push_back (writebuff_[i]);
496  }
497 
498  //assume unorganized point cloud
499  tmp_cloud->width = static_cast<std::uint32_t> (tmp_cloud->points.size ());
500 
501  //save and close
502  PCDWriter writer;
503 
504  int res = writer.writeBinaryCompressed (disk_storage_filename_, *tmp_cloud);
505  pcl::utils::ignore(res);
506  assert (res == 0);
507  }
508 
509  ////////////////////////////////////////////////////////////////////////////////
510 
511  template<typename PointT> void
513  {
515 
516  //if there's a pcd file with data associated with this node, read the data, concatenate, and resave
517  if (boost::filesystem::exists (disk_storage_filename_))
518  {
519  //open the existing file
520  pcl::PCDReader reader;
521  int res = reader.read (disk_storage_filename_, *tmp_cloud);
522  pcl::utils::ignore(res);
523  assert (res == 0);
524  pcl::PCDWriter writer;
525  PCL_DEBUG ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] Concatenating point cloud from %s to new cloud\n", __FUNCTION__, disk_storage_filename_.c_str ());
526 
527  std::size_t previous_num_pts = tmp_cloud->width*tmp_cloud->height + input_cloud->width*input_cloud->height;
528  //Concatenate will fail if the fields in input_cloud do not match the fields in the PCD file.
529  pcl::concatenate (*tmp_cloud, *input_cloud, *tmp_cloud);
530  std::size_t res_pts = tmp_cloud->width*tmp_cloud->height;
531 
532  pcl::utils::ignore(previous_num_pts);
533  pcl::utils::ignore(res_pts);
534 
535  assert (previous_num_pts == res_pts);
536 
537  writer.writeBinaryCompressed (disk_storage_filename_, *tmp_cloud);
538 
539  }
540  else //otherwise create the point cloud which will be saved to the pcd file for the first time
541  {
542  pcl::PCDWriter writer;
543  int res = writer.writeBinaryCompressed (disk_storage_filename_, *input_cloud);
544  pcl::utils::ignore(res);
545  assert (res == 0);
546  }
547 
548  }
549 
550  ////////////////////////////////////////////////////////////////////////////////
551 
552  template<typename PointT> void
554  {
555  pcl::PCDReader reader;
556 
557  Eigen::Vector4f origin;
558  Eigen::Quaternionf orientation;
559 
560  if (boost::filesystem::exists (disk_storage_filename_))
561  {
562 // PCL_INFO ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] Reading points from disk from %s.\n", __FUNCTION__ , disk_storage_filename_->c_str ());
563  int pcd_version;
564  int res = reader.read (disk_storage_filename_, *dst, origin, orientation, pcd_version);
565  pcl::utils::ignore(res);
566  assert (res != -1);
567  }
568  else
569  {
570  PCL_ERROR ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] File %s does not exist in node.\n", __FUNCTION__, disk_storage_filename_.c_str ());
571  }
572  }
573 
574  ////////////////////////////////////////////////////////////////////////////////
575 
576  template<typename PointT> int
578  {
579  pcl::PCLPointCloud2::Ptr temp_output_cloud (new pcl::PCLPointCloud2 ());
580 
581  if (boost::filesystem::exists (disk_storage_filename_))
582  {
583 // PCL_INFO ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] Reading points from disk from %s.\n", __FUNCTION__ , disk_storage_filename_->c_str ());
584  int res = pcl::io::loadPCDFile (disk_storage_filename_, *temp_output_cloud);
585  pcl::utils::ignore(res);
586  assert (res != -1);
587  if(res == -1)
588  return (-1);
589  }
590  else
591  {
592  PCL_ERROR ("[pcl::outofcore::OutofcoreOctreeDiskContainer::%s] File %s does not exist in node.\n", __FUNCTION__, disk_storage_filename_.c_str ());
593  return (-1);
594  }
595 
596  if(output_cloud.get () != nullptr)
597  {
598  pcl::concatenate (*output_cloud, *temp_output_cloud, *output_cloud);
599  }
600  else
601  {
602  output_cloud = temp_output_cloud;
603  }
604  return (0);
605  }
606 
607  ////////////////////////////////////////////////////////////////////////////////
608 
609  template<typename PointT> void
611  {
612 // PCL_THROW_EXCEPTION (PCLException, "[pcl::outofcore::OutofcoreOctreeDiskContainer] Deprecated\n");
613  //copy the handles to a continuous block
614  PointT* arr = new PointT[count];
615 
616  //copy from start of array, element by element
617  for (std::size_t i = 0; i < count; i++)
618  {
619  arr[i] = *(start[i]);
620  }
621 
622  insertRange (arr, count);
623  delete[] arr;
624  }
625 
626  ////////////////////////////////////////////////////////////////////////////////
627 
628  template<typename PointT> void
630  {
631  typename pcl::PointCloud<PointT>::Ptr tmp_cloud (new pcl::PointCloud<PointT> ());
632 
633  // If there's a pcd file with data, read it in from disk for appending
634  if (boost::filesystem::exists (disk_storage_filename_))
635  {
636  pcl::PCDReader reader;
637  // Open it
638  int res = reader.read (disk_storage_filename_, *tmp_cloud);
639  pcl::utils::ignore(res);
640  assert (res == 0);
641  }
642  else //otherwise create the pcd file
643  {
644  tmp_cloud->width = static_cast<std::uint32_t> (count) + static_cast<std::uint32_t> (writebuff_.size ());
645  tmp_cloud->height = 1;
646  }
647 
648  // Add any points in the cache
649  for (std::size_t i = 0; i < writebuff_.size (); i++)
650  {
651  tmp_cloud->points.push_back (writebuff_ [i]);
652  }
653 
654  //add the new points passed with this function
655  for (std::size_t i = 0; i < count; i++)
656  {
657  tmp_cloud->points.push_back (*(start + i));
658  }
659 
660  tmp_cloud->width = static_cast<std::uint32_t> (tmp_cloud->points.size ());
661  tmp_cloud->height = 1;
662 
663  //save and close
664  PCDWriter writer;
665 
666  int res = writer.writeBinaryCompressed (disk_storage_filename_, *tmp_cloud);
667  pcl::utils::ignore(res);
668  assert (res == 0);
669  }
670  ////////////////////////////////////////////////////////////////////////////////
671 
672  template<typename PointT> std::uint64_t
674  {
675  pcl::PCLPointCloud2 cloud_info;
676  Eigen::Vector4f origin;
677  Eigen::Quaternionf orientation;
678  int pcd_version;
679  int data_type;
680  unsigned int data_index;
681 
682  //read the header of the pcd file and get the number of points
683  PCDReader reader;
684  reader.readHeader (disk_storage_filename_, cloud_info, origin, orientation, pcd_version, data_type, data_index, 0);
685 
686  std::uint64_t total_points = cloud_info.width * cloud_info.height + writebuff_.size ();
687 
688  return (total_points);
689  }
690  ////////////////////////////////////////////////////////////////////////////////
691 
692  }//namespace outofcore
693 }//namespace pcl
694 
695 #endif //PCL_OUTOFCORE_OCTREE_DISK_CONTAINER_IMPL_H_
pcl::outofcore::OutofcoreOctreeDiskContainer::read
int read(pcl::PCLPointCloud2::Ptr &output_cloud)
Reads the entire point contents from disk into output_cloud.
Definition: octree_disk_container.hpp:577
pcl
Definition: convolution.h:46
point_types.h
pcl::uint32_t
std::uint32_t uint32_t
Definition: types.h:58
pcl::PointCloud::height
std::uint32_t height
The point cloud height (if organized as an image-structure).
Definition: point_cloud.h:416
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:411
pcl::outofcore::OutofcoreOctreeDiskContainer::operator[]
PointT operator[](std::uint64_t idx) const override
provides random access to points based on a linear index
Definition: octree_disk_container.hpp:198
pcl::outofcore::OutofcoreOctreeDiskContainer::readRangeSubSample
void readRangeSubSample(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &dst) override
grab percent*count random points.
Definition: octree_disk_container.hpp:359
pcl::PCLPointCloud2::Ptr
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
Definition: PCLPointCloud2.h:34
pcl::outofcore::OutofcoreOctreeDiskContainer::OutofcoreOctreeDiskContainer
OutofcoreOctreeDiskContainer()
Empty constructor creates disk container and sets filename from random uuid string.
Definition: octree_disk_container.hpp:104
pcl::PCDWriter::writeBinaryCompressed
int writeBinaryCompressed(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity())
Save point cloud data to a PCD file containing n-D points, in BINARY_COMPRESSED format.
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:53
pcl::outofcore::OutofcoreOctreeDiskContainer::readRangeSubSample_bernoulli
void readRangeSubSample_bernoulli(const std::uint64_t start, const std::uint64_t count, const double percent, AlignedPointTVector &dst)
Use bernoulli trials to select points.
Definition: octree_disk_container.hpp:266
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:628
pcl::outofcore::OutofcoreOctreeDiskContainer::readRange
void readRange(const std::uint64_t start, const std::uint64_t count, AlignedPointTVector &dst) override
Reads count points into memory from the disk container.
Definition: octree_disk_container.hpp:239
pcl::PointCloud::width
std::uint32_t width
The point cloud width (if organized as an image-structure).
Definition: point_cloud.h:414
pcl::outofcore::OutofcoreOctreeDiskContainer::getRandomUUIDString
static void getRandomUUIDString(std::string &s)
Generate a universally unique identifier (UUID)
Definition: octree_disk_container.hpp:89
pcl::outofcore::OutofcoreOctreeDiskContainer::path
std::string & path()
Returns this objects path name.
Definition: octree_disk_container.h:203
pcl::outofcore::OutofcoreOctreeDiskContainer::~OutofcoreOctreeDiskContainer
~OutofcoreOctreeDiskContainer()
flushes write buffer, then frees memory
Definition: octree_disk_container.hpp:160
pcl::int64_t
std::int64_t int64_t
Definition: types.h:61
pcl::outofcore::OutofcoreOctreeDiskContainer
Class responsible for serialization and deserialization of out of core point data.
Definition: octree_disk_container.h:77
pcl::outofcore::OutofcoreOctreeDiskContainer::AlignedPointTVector
typename OutofcoreAbstractNodeContainer< PointT >::AlignedPointTVector AlignedPointTVector
Definition: octree_disk_container.h:81
pcl::outofcore::OutofcoreOctreeDiskContainer::push_back
void push_back(const PointT &p)
Adds a single point to the buffer to be written to disk when the buffer grows sufficiently large,...
Definition: octree_disk_container.hpp:456
pcl::PCLPointCloud2
Definition: PCLPointCloud2.h:15
pcl::outofcore::rand_gen_
boost::uuids::basic_random_generator< boost::mt19937 > OutofcoreOctreeDiskContainer< PointT >::uuid_gen_ & rand_gen_
Definition: octree_disk_container.hpp:81
pcl::PCLException
A base class for all pcl exceptions which inherits from std::runtime_error.
Definition: exceptions.h:64
pcl::utils::ignore
void ignore(const T &)
Utility function to eliminate unused variable warnings.
Definition: utils.h:62
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:429
pcl::concatenate
PCL_EXPORTS bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
Concatenate two pcl::PointCloud<PointT>
Definition: io.h:282
pcl::PCLPointCloud2::height
std::uint32_t height
Definition: PCLPointCloud2.h:19
pcl::io::loadPCDFile
int loadPCDFile(const std::string &file_name, pcl::PCLPointCloud2 &cloud)
Load a PCD v.6 file into a templated PointCloud type.
Definition: pcd_io.h:620
pcl::PCDReader
Point Cloud Data (PCD) file format reader.
Definition: pcd_io.h:53
pcl::PCLPointCloud2::width
std::uint32_t width
Definition: PCLPointCloud2.h:20
pcl::outofcore::OutofcoreOctreeDiskContainer::getDataSize
std::uint64_t getDataSize() const
Returns the number of points in the PCD file by reading the PCD header.
Definition: octree_disk_container.hpp:673
pcl::outofcore::OutofcoreOctreeDiskContainer::insertRange
void insertRange(const AlignedPointTVector &src)
Inserts a vector of points into the disk data structure.
Definition: octree_disk_container.hpp:467
pcl::PCDReader::read
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, const int offset=0) override
Read a point cloud data from a PCD file and store it into a pcl/PCLPointCloud2.
pcl::PCDWriter
Point Cloud Data (PCD) file format writer.
Definition: pcd_io.h:296
pcl::PCDReader::readHeader
int readHeader(std::istream &binary_istream, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version, int &data_type, unsigned int &data_idx)
Read a point cloud data header from a PCD-formatted, binary istream.
pcl::uint64_t
std::uint64_t uint64_t
Definition: types.h:60