![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <CVKdTree.h>
Classes | |
| struct | KdCell |
| A KDTre cell struct. More... | |
Public Member Functions | |
| KDTree () | |
| Default constructor. More... | |
| virtual | ~KDTree () |
| Destructor. More... | |
| bool | buildFromCloud (GenericIndexedCloud *cloud, GenericProgressCallback *progressCb=nullptr) |
| Builds the KD-tree. More... | |
| GenericIndexedCloud * | getAssociatedCloud () const |
| Gets the point cloud from which the tree has been build. More... | |
| bool | findNearestNeighbour (const PointCoordinateType *queryPoint, unsigned &nearestPointIndex, ScalarType maxDist) |
| Nearest point search. More... | |
| bool | findNearestNeighbourWithMaxDist (const PointCoordinateType *queryPoint, ScalarType maxDist) |
| Optimized version of findNearestNeighbour with a maximum distance. More... | |
| unsigned | radiusSearch (const PointCoordinateType *queryPoint, ScalarType distance, ScalarType tolerance, std::vector< unsigned > &pointndexes) |
| bool | findPointBelowDistance (const PointCoordinateType *queryPoint, ScalarType maxDist) |
| Optimized version of nearest point search method. More... | |
| unsigned | findPointsLyingToDistance (const PointCoordinateType *queryPoint, ScalarType distance, ScalarType tolerance, std::vector< unsigned > &points) |
Protected Member Functions | |
| KdCell * | buildSubTree (unsigned first, unsigned last, KdCell *father, unsigned &nbBuildCell, GenericProgressCallback *progressCb=nullptr) |
| Builds a sub tree. More... | |
| void | deleteSubTree (KdCell *cell) |
| Deletes a sub tree. More... | |
| void | updateInsideBoundingBox (KdCell *cell) |
| void | updateOutsideBoundingBox (KdCell *cell) |
| ScalarType | pointToCellSquareDistance (const PointCoordinateType *queryPoint, KdCell *cell) |
| Computes the distance between a point and a cell inside bounding box. More... | |
| ScalarType | insidePointToCellDistance (const PointCoordinateType *queryPoint, KdCell *cell) |
| void | pointToCellDistances (const PointCoordinateType *queryPoint, KdCell *cell, ScalarType &min, ScalarType &max) |
| int | checkNearerPointInSubTree (const PointCoordinateType *queryPoint, ScalarType &maxSqrDist, KdCell *cell) |
| bool | checkDistantPointInSubTree (const PointCoordinateType *queryPoint, ScalarType &maxSqrDist, KdCell *cell) |
| void | distanceScanTree (const PointCoordinateType *queryPoint, ScalarType distance, ScalarType tolerance, KdCell *cell, std::vector< unsigned > &localArray) |
Protected Attributes | |
| KdCell * | m_root |
| Tree root. More... | |
| std::vector< unsigned > | m_indexes |
| Point indexes. More... | |
| GenericIndexedCloud * | m_associatedCloud |
| Associated cloud. More... | |
| unsigned | m_cellCount |
| Number of cells. More... | |
A Kd Tree Class which implements functions related to point to point distance
| KDTree::KDTree | ( | ) |
Default constructor.
|
virtual |
Destructor.
References deleteSubTree(), and m_root.
| bool KDTree::buildFromCloud | ( | GenericIndexedCloud * | cloud, |
| GenericProgressCallback * | progressCb = nullptr |
||
| ) |
Builds the KD-tree.
| cloud | the point cloud from which to buil the KDtree |
| progressCb | the client method can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) |
References buildSubTree(), m_associatedCloud, m_cellCount, m_indexes, m_root, cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericCloud::size(), cloudViewer::GenericProgressCallback::start(), cloudViewer::GenericProgressCallback::stop(), cloudViewer::GenericProgressCallback::textCanBeEdited(), and cloudViewer::GenericProgressCallback::update().
Referenced by define_KdTree(), cloudViewer::FPCSRegistrationTools::FindCongruentBases(), and cloudViewer::FPCSRegistrationTools::RegisterClouds().
|
protected |
Builds a sub tree.
| first | first index |
| last | last index |
| father | father cell |
| nbBuildCell | nbBuildCell |
| progressCb | the client method can get some notification of the process progress through this callback mechanism (see GenericProgressCallback) |
References ComparisonX(), ComparisonY(), ComparisonZ(), cloudViewer::KDTree::KdCell::cuttingCoordinate, cloudViewer::KDTree::KdCell::cuttingDim, deleteSubTree(), cloudViewer::KDTree::KdCell::father, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_cellCount, m_indexes, cloudViewer::KDTree::KdCell::nbPoints, s_comparisonCloud, cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, cloudViewer::GenericProgressCallback::update(), updateInsideBoundingBox(), and updateOutsideBoundingBox().
Referenced by buildFromCloud().
|
protected |
Checks if there is a point in KdCell that is less than minDist-apart from the query point, starting from cell cell Optimiszed version of CheckNearerPointInSubTree since we don't want to find the nearest point, but only check if there is a point that is close enough
| queryPoint | the query Point coordinates |
| maxSqrDist | square of the maximal distance from querypoint |
| cell | kdtree-cell from which to start the research |
References cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, cloudViewer::KDTree::KdCell::nbPoints, pointToCellSquareDistance(), cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance2().
Referenced by findNearestNeighbourWithMaxDist(), and findPointBelowDistance().
|
protected |
Checks if there is a point in KdCell that is less than minDist-apart from the query point, starting from cell cell
| queryPoint | the query Point coordinates |
| maxSqrDist | square of the maximal distance from querypoint |
| cell | kdtree-cell from which to start the research |
References a, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, cloudViewer::KDTree::KdCell::nbPoints, pointToCellSquareDistance(), cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance2().
Referenced by findNearestNeighbour().
|
protected |
Deletes a sub tree.
References cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::leSon, and m_cellCount.
Referenced by buildSubTree(), and ~KDTree().
|
protected |
Recursive function which store every point lying to a given distance from the query point
| queryPoint | the query point coordinates | |
| distance | the wished distance from the query point | |
| tolerance | tolerance for resulting points : p is in resulting array if ||p-queryPoint||<=tolerance | |
| cell | current cell to explore (used for recursion) | |
| [out] | localArray | output of the algorithm. Resulting points m_indexes in associatedCloud are stored in this array |
References Utils::distance(), cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, cloudViewer::KDTree::KdCell::nbPoints, pointToCellDistances(), cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance().
Referenced by findPointsLyingToDistance(), and radiusSearch().
| bool KDTree::findNearestNeighbour | ( | const PointCoordinateType * | queryPoint, |
| unsigned & | nearestPointIndex, | ||
| ScalarType | maxDist | ||
| ) |
Nearest point search.
| queryPoint | coordinates of the query point from which we want the nearest point in the tree |
| nearestPointIndex | [out] index of the point that lies the nearest from query Point. Corresponding coordinates can be retrieved using getAssociatedCloud()->getPoint(nearestPointIndex) |
| maxDist | distance above which the function doesn't consider points |
References a, checkNearerPointInSubTree(), cloudViewer::KDTree::KdCell::cuttingCoordinate, cloudViewer::KDTree::KdCell::cuttingDim, cloudViewer::KDTree::KdCell::father, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, insidePointToCellDistance(), cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, m_root, cloudViewer::KDTree::KdCell::nbPoints, cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance2().
Referenced by cloudViewer::FPCSRegistrationTools::FindCongruentBases().
| bool KDTree::findNearestNeighbourWithMaxDist | ( | const PointCoordinateType * | queryPoint, |
| ScalarType | maxDist | ||
| ) |
Optimized version of findNearestNeighbour with a maximum distance.
Only checks if there is a point p into the tree such that ||p-queryPoint||<=maxDist (see FindNearestNeighbour())
References checkDistantPointInSubTree(), cloudViewer::KDTree::KdCell::cuttingCoordinate, cloudViewer::KDTree::KdCell::cuttingDim, cloudViewer::KDTree::KdCell::father, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, insidePointToCellDistance(), cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, m_root, cloudViewer::KDTree::KdCell::nbPoints, cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance2().
| bool KDTree::findPointBelowDistance | ( | const PointCoordinateType * | queryPoint, |
| ScalarType | maxDist | ||
| ) |
Optimized version of nearest point search method.
Only checks if there is a point p into the tree such that ||p-queryPoint||<=maxDist (see FindNearestNeighbour())
References checkDistantPointInSubTree(), cloudViewer::KDTree::KdCell::cuttingCoordinate, cloudViewer::KDTree::KdCell::cuttingDim, cloudViewer::KDTree::KdCell::father, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, insidePointToCellDistance(), cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, m_root, cloudViewer::KDTree::KdCell::nbPoints, cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::u, and Vector3Tpl< PointCoordinateType >::vdistance2().
Referenced by cloudViewer::FPCSRegistrationTools::ComputeRegistrationScore().
| unsigned KDTree::findPointsLyingToDistance | ( | const PointCoordinateType * | queryPoint, |
| ScalarType | distance, | ||
| ScalarType | tolerance, | ||
| std::vector< unsigned > & | points | ||
| ) |
Searches for the points that lie to a given distance (up to a tolerance) from a query point
| queryPoint | query point coordinates |
| distance | distance wished between the query point and resulting points |
| tolerance | error allowed by the function : each resulting point p is such that distance-tolerance<=||p-queryPoint||<=distance+tolerance |
| points | [out] array of point m_indexes. Each point stored in this array lie to distance (up to tolerance) from queryPoint |
References Utils::distance(), distanceScanTree(), m_root, and points.
Referenced by cloudViewer::FPCSRegistrationTools::FindCongruentBases().
|
inline |
Gets the point cloud from which the tree has been build.
Referenced by define_KdTree(), and cloudViewer::FPCSRegistrationTools::FindCongruentBases().
|
protected |
Computes the distance between a point and the outside bounding box of the cell in which it lies.
| queryPoint | the query point coordinates |
| cell | the cell containting the query point |
References cloudViewer::KDTree::KdCell::boundsMask, cloudViewer::KDTree::KdCell::outbbmax, cloudViewer::KDTree::KdCell::outbbmin, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by findNearestNeighbour(), findNearestNeighbourWithMaxDist(), and findPointBelowDistance().
|
protected |
Computes the distances (min & max) between a point and a cell inside bounding box
| queryPoint | the query point coordinates |
| cell | the cell from which we want to compute the distance |
| min | [out] the minimal distance between the query point and the inside bounding box of cell |
| max | [out] the maximal distance between the query point and the inside bounding box of cell |
References cloudViewer::KDTree::KdCell::inbbmax, cloudViewer::KDTree::KdCell::inbbmin, pointToCellSquareDistance(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by distanceScanTree().
|
protected |
Computes the distance between a point and a cell inside bounding box.
| queryPoint | queryPoint coordinates |
| cell | the cell from which we want to compute the distance |
References cloudViewer::KDTree::KdCell::inbbmax, cloudViewer::KDTree::KdCell::inbbmin, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by checkDistantPointInSubTree(), checkNearerPointInSubTree(), and pointToCellDistances().
| unsigned KDTree::radiusSearch | ( | const PointCoordinateType * | queryPoint, |
| ScalarType | distance, | ||
| ScalarType | tolerance, | ||
| std::vector< unsigned > & | pointndexes | ||
| ) |
Searches for the points that lie at a given distance (+/-tolerance) from a query point
| queryPoint | query point coordinates | |
| distance | distance wished between the query point and resulting points | |
| tolerance | distance tolerance: p is selected if distance-tolerance<=||p-queryPoint||<=distance+tolerance | |
| [out] | pointndexes | array of point indexes |
References Utils::distance(), distanceScanTree(), and m_root.
|
protected |
Computes a cell inside bounding box using the sons ones. The sons bounding boxes have to be up to date considering the points they contain.
References cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::KDTree::KdCell::gSon, cloudViewer::KDTree::KdCell::inbbmax, cloudViewer::KDTree::KdCell::inbbmin, cloudViewer::KDTree::KdCell::leSon, m_associatedCloud, m_indexes, cloudViewer::KDTree::KdCell::nbPoints, cloudViewer::KDTree::KdCell::startingPointIndex, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by buildSubTree().
|
protected |
Computes a cell outside bounding box using the father one and the cutting plane.
References cloudViewer::KDTree::KdCell::boundsMask, cloudViewer::KDTree::KdCell::cuttingCoordinate, cloudViewer::KDTree::KdCell::cuttingDim, cloudViewer::KDTree::KdCell::father, cloudViewer::GenericIndexedCloud::getPoint(), m_associatedCloud, m_indexes, cloudViewer::KDTree::KdCell::outbbmax, cloudViewer::KDTree::KdCell::outbbmin, cloudViewer::KDTree::KdCell::startingPointIndex, and Tuple3Tpl< Type >::u.
Referenced by buildSubTree().
|
protected |
|
protected |
Number of cells.
Referenced by buildFromCloud(), buildSubTree(), and deleteSubTree().
|
protected |
|
protected |
Tree root.
Referenced by buildFromCloud(), findNearestNeighbour(), findNearestNeighbourWithMaxDist(), findPointBelowDistance(), findPointsLyingToDistance(), radiusSearch(), and ~KDTree().