OctreeReduction.cpp
Go to the documentation of this file.
3 #include "lvr2/io/IOUtils.hpp"
4 
5 #include <vector>
6 
7 namespace lvr2
8 {
9 
11  PointBufferPtr &pointBuffer,
12  const double &voxelSize,
13  const size_t &minPointsPerVoxel)
14  : m_voxelSize(voxelSize),
15  m_minPointsPerVoxel(minPointsPerVoxel),
16  m_numPoints(pointBuffer->numPoints()),
17  m_pointBuffer(pointBuffer)
18 {
19  size_t n = pointBuffer->numPoints();
20  m_flags = new bool[n];
21  for (int i = 0; i < n; i++)
22  {
23  m_flags[i] = false;
24  }
25 
26  typename lvr2::Channel<float>::Optional pts_opt = pointBuffer->getChannel<float>("points");
27  if(pts_opt)
28  {
29  lvr2::Channel<float> points = *pts_opt;
30  AABB<float> boundingBox(points, n);
31 
32  #pragma omp parallel // allows "pragma omp task"
33  #pragma omp single // only execute every task once
34  createOctree(pointBuffer, 0, n, m_flags, boundingBox.min(), boundingBox.max(), 0);
35  }
36 }
37 
39  Vector3f *points,
40  const size_t &n0,
41  const double &voxelSize,
42  const size_t &minPointsPerVoxel) : m_voxelSize(voxelSize), m_minPointsPerVoxel(minPointsPerVoxel)
43 {
44 
45  m_flags = new bool[n0];
46  for (int i = 0; i < n0; i++)
47  {
48  m_flags[i] = false;
49  }
50 
51  AABB<float> boundingBox(points, n0);
52 
53 #pragma omp parallel // allows "pragma omp task"
54 #pragma omp single // only execute every task once
55  createOctree<Vector3f>(points, n0, m_flags, boundingBox.min(), boundingBox.max(), 0);
56 }
57 
59 {
60  std::vector<size_t> reducedIndices;
61  for (size_t i = 0; i < m_numPoints; i++)
62  {
63  if (!m_flags[i])
64  {
65  reducedIndices.push_back(i);
66  }
67  }
68 
69  return subSamplePointBuffer(m_pointBuffer, reducedIndices);
70 }
71 
73 {
74 }
75 
76 } // namespace lvr2
const Vector3< T > & max() const
Returns the "upper right" Corner of the Bounding Box, as in the largest x, y, z of the Point Cloud...
PointBufferPtr getReducedPoints()
OctreeReduction(PointBufferPtr &pointBuffer, const double &voxelSize, const size_t &minPointsPerVoxel)
std::shared_ptr< PointBuffer > PointBufferPtr
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
PointBufferPtr m_pointBuffer
PointBufferPtr subSamplePointBuffer(PointBufferPtr src, const size_t &n)
Computes a random sub-sampling of a point buffer by creating a uniform distribution over all point in...
Definition: IOUtils.cpp:405
boost::optional< Channel< T > > Optional
Definition: Channel.hpp:45
void createOctree(T *points, const int &n, bool *flagged, const T &min, const T &max, const int &level)
const Vector3< T > & min() const
Returns the "lower left" Corner of the Bounding Box, as in the smallest x, y, z of the Point Cloud...
A struct to calculate the Axis Aligned Bounding Box and Average Point of a Point Cloud.
Definition: AABB.hpp:49


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08