42 using namespace Eigen;
53 while (l < r && points[l](axis) < splitValue)
57 while (r > l && points[r](axis) >= splitValue)
87 if (max[axis] - min[axis] <= voxelSize)
91 double minDist = (points[closest] - center).squaredNorm();
92 for (
int i = 1; i < n; i++)
94 double dist = (points[i] - center).squaredNorm();
102 for (
int i = 0; i < n; i++)
104 flagged[i] = i != closest;
109 int l =
splitPoints(points, n, axis, center[axis]);
114 lMax[axis] = center[axis];
115 rMin[axis] = center[axis];
120 createOctree(points , l , flagged , lMin, lMax, level + 1, voxelSize, maxLeafSize);
123 if (n - l > maxLeafSize)
126 createOctree(points + l, n - l, flagged + l, rMin, rMax, level + 1, voxelSize, maxLeafSize);
132 bool* flagged =
new bool[n];
133 for (
int i = 0; i < n; i++)
140 #pragma omp parallel // allows "pragma omp task" 141 #pragma omp single // only execute every task once 142 createOctree(points, n, flagged, boundingBox.
min(), boundingBox.
max(), 0, voxelSize, maxLeafSize);
155 points[i] = points[n];
156 flagged[i] = flagged[n];
int splitPoints(Vector3f *points, int n, int axis, double splitValue)
Sorts a Point array so that all Points smaller than splitValue are on the left.
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...
int octreeReduce(Vector3f *points, int n, double voxelSize, int maxLeafSize)
Reduces a Point Cloud using an Octree with a minimum Voxel size.
__kf_hdevice__ void swap(T &a, T &b)
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
void createOctree(Vector3f *points, int n, bool *flagged, const Vector3f &min, const Vector3f &max, int level, double voxelSize, int maxLeafSize)
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.