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
lvr2::AABB::min
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.
lvr2::OctreeReduction::OctreeReduction
OctreeReduction(PointBufferPtr &pointBuffer, const double &voxelSize, const size_t &minPointsPerVoxel)
Definition: OctreeReduction.cpp:10
lvr2::Channel::Optional
boost::optional< Channel< T > > Optional
Definition: Channel.hpp:45
lvr2::AABB
A struct to calculate the Axis Aligned Bounding Box and Average Point of a Point Cloud.
Definition: AABB.hpp:49
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
IOUtils.hpp
lvr2::OctreeReduction::m_flags
bool * m_flags
Definition: OctreeReduction.hpp:81
OctreeReduction.hpp
lvr2::Vector3f
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
Definition: MatrixTypes.hpp:118
lvr2::OctreeReduction::m_numPoints
size_t m_numPoints
Definition: OctreeReduction.hpp:80
lvr2::OctreeReduction::createOctree
void createOctree(T *points, const int &n, bool *flagged, const T &min, const T &max, const int &level)
lvr2::Channel< float >
lvr2::AABB::max
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.
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::OctreeReduction::m_pointBuffer
PointBufferPtr m_pointBuffer
Definition: OctreeReduction.hpp:83
lvr2::subSamplePointBuffer
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
AABB.hpp
lvr2::OctreeReduction::getReducedPoints
PointBufferPtr getReducedPoints()
Definition: OctreeReduction.cpp:58


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 Wed Mar 2 2022 00:37:24