19 m_associatedCloud(cloud),
22 m_minPointCountPerCell(3),
23 m_maxPointCountPerCell(0) {
45 unsigned totalCount) {
55 sprintf(info,
"Points: %u", totalCount);
68 unsigned uiPercent =
static_cast<unsigned>(fPercent);
89 return new Leaf(
nullptr, fakePlaneEquation,
90 static_cast<ScalarType
>(-1));
94 ScalarType
error = -1;
109 return new Leaf(subset, planeEquation,
error);
120 dims = bbMax - bbMin;
124 uint8_t splitDim =
X_DIM;
125 if (dims.
y > dims.
x) splitDim =
Y_DIM;
126 if (dims.
z > dims.
u[splitDim]) splitDim =
Z_DIM;
130 for (
unsigned i = 0; i <
count; ++i) {
138 unsigned splitCount =
count / 2;
139 assert(splitCount >= 3);
149 assert(splitCount > 3);
157 assert(splitCount <
count - 3);
167 subset, planeEquation,
171 return new Leaf(subset, planeEquation,
error);
183 if (!leftSubset->
reserve(splitCount) ||
193 for (
unsigned i = 0; i <
count; ++i) {
195 if (P->
u[splitDim] < splitCoord) {
217 if ((leftChild->
isLeaf() &&
218 static_cast<Leaf*
>(leftChild)->
points ==
nullptr) ||
220 static_cast<Leaf*
>(rightChild)->
points ==
nullptr)) {
228 return new Leaf(subset, planeEquation,
error);
240 rightChild->
parent = node;
250 unsigned minPointCountPerCell ,
251 unsigned maxPointCountPerCell ,
267 }
catch (
const std::bad_alloc&) {
286 2 * minPointCountPerCell,
287 maxPointCountPerCell);
295 return (
m_root !=
nullptr);
302 : m_leaves(&leaves) {}
322 if (!
m_root)
return false;
326 }
catch (
const std::bad_alloc&) {
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Recursive visitor for TrueKdTree::getLeaves.
void visit(TrueKdTree::BaseNode *node)
GetLeavesVisitor(TrueKdTree::LeafVector &leaves)
TrueKdTree::LeafVector * m_leaves
virtual unsigned size() const =0
Returns the number of points.
A generic 3D point cloud with index-based and presistent access to points.
virtual void setInfo(const char *infoStr)=0
Notifies some information about the ongoing process.
virtual void setMethodTitle(const char *methodTitle)=0
Notifies the algorithm title.
virtual bool textCanBeEdited() const
Returns whether the dialog title and info can be updated or not.
virtual void update(float percent)=0
Notifies the algorithm progress.
const PointCoordinateType * getLSPlane()
Returns best interpolating plane equation (Least-square)
A very simple point cloud (no point duplication)
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax) override
Returns the cloud bounding box.
virtual GenericIndexedCloudPersist * getAssociatedCloud()
Returns the associated (source) cloud.
unsigned size() const override
Returns the number of points.
virtual unsigned getPointGlobalIndex(unsigned localIndex) const
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
const CCVector3 * getPoint(unsigned index) const override
Returns the ith point.
PointCoordinateType splitValue
double m_maxError
Max error for planarity-based split strategy (see m_errorMeasure)
unsigned m_maxPointCountPerCell
Max number of points per cell (speed-up)
BaseNode * m_root
Root node.
bool getLeaves(LeafVector &leaves) const
Returns all leaf nodes.
DistanceComputationTools::ERROR_MEASURES m_errorMeasure
Error measurement.
TrueKdTree(GenericIndexedCloudPersist *cloud)
Default constructor.
bool build(double maxError, DistanceComputationTools::ERROR_MEASURES errorMeasure=DistanceComputationTools::RMS, unsigned minPointCountPerCell=3, unsigned maxPointCountPerCell=0, GenericProgressCallback *progressCb=nullptr)
Builds KD-tree.
unsigned m_minPointCountPerCell
Min number of points per cell (speed-up)
BaseNode * split(ReferenceCloud *subset)
Recursive split process.
static const uint8_t X_DIM
std::vector< Leaf * > LeafVector
A vector of leaves.
static const uint8_t Z_DIM
GenericIndexedCloudPersist * m_associatedCloud
Associated cloud.
void clear()
Clears structure.
static const uint8_t Y_DIM
static std::vector< PointCoordinateType > s_sortedCoordsForSplit
static void UpdateProgress(unsigned increment)
static unsigned s_lastProgressCount
static GenericProgressCallback * s_progressCb
static void InitProgress(GenericProgressCallback *progressCb, unsigned totalCount)
static unsigned s_totalProgressCount
static unsigned s_lastProgress
__host__ __device__ int2 abs(int2 v)
static void error(char *msg)
Generic file read and write utility for python interface.