The PointsGrid allows to divide a global point cloud into smaller regions of elements depending on the resolution of the grid. More...
#include <PointsGrid.h>
Public Member Functions | |
Construction | |
PointsGrid (const PointKernel &rclM) | |
Construction. More... | |
PointsGrid () | |
Construction. More... | |
PointsGrid (const PointKernel &rclM, int iCtGridPerAxis) | |
Construction. More... | |
PointsGrid (const PointKernel &rclM, double fGridLen) | |
Construction. More... | |
PointsGrid (const PointKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ) | |
Construction. More... | |
virtual | ~PointsGrid () |
Destruction. More... | |
virtual void | Attach (const PointKernel &rclM) |
Attaches the point kernel to this grid, an already attached point cloud gets detached. More... | |
virtual void | Rebuild (unsigned long ulPerGrid=POINTS_CT_GRID, unsigned long ulMaxGrid=POINTS_MAX_GRIDS) |
Rebuilds the grid structure. More... | |
virtual void | Rebuild (int iCtGridPerAxis=POINTS_CT_GRID_PER_AXIS) |
Rebuilds the grid structure. More... | |
virtual void | Rebuild (unsigned long ulX, unsigned long ulY, unsigned long ulZ) |
Rebuilds the grid structure. More... | |
Search | |
virtual unsigned long | InSide (const Base::BoundBox3d &rclBB, std::vector< unsigned long > &raulElements, bool bDelDoubles=true) const |
Searches for elements lying in the intersection area of the grid and the bounding box. More... | |
virtual unsigned long | InSide (const Base::BoundBox3d &rclBB, std::set< unsigned long > &raulElementss) const |
Searches for elements lying in the intersection area of the grid and the bounding box. More... | |
virtual unsigned long | InSide (const Base::BoundBox3d &rclBB, std::vector< unsigned long > &raulElements, const Base::Vector3d &rclOrg, double fMaxDist, bool bDelDoubles=true) const |
Searches for elements lying in the intersection area of the grid and the bounding box. More... | |
void | SearchNearestFromPoint (const Base::Vector3d &rclPt, std::set< unsigned long > &rclInd) const |
Searches for the nearest grids that contain elements from a point, the result are grid indices. More... | |
virtual void | GetGridLengths (double &rfLenX, double &rfLenY, double &rfLenZ) const |
Returns the lengths of the grid elements in x,y and z direction. More... | |
virtual void | GetCtGrids (unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const |
Returns the number of grid elements in x,y and z direction. More... | |
Boundings | |
class | PointsGridIterator |
class | PointsGridIteratorStatistic |
Base::BoundBox3d | GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const |
Returns the bounding box of a given grid element. More... | |
Base::BoundBox3d | GetBoundBox () const |
Returns the bounding box of the whole. More... | |
unsigned long | GetCtElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const |
Returns the number of elements in a given grid. More... | |
unsigned long | FindElements (const Base::Vector3d &rclPoint, std::set< unsigned long > &aulElements) const |
Finds all points that lie in the same grid as the point rclPoint. More... | |
virtual void | Validate (const PointKernel &rclM) |
Validates the grid structure and rebuilds it if needed. More... | |
virtual void | Validate () |
Validates the grid structure and rebuilds it if needed. More... | |
virtual bool | Verify () const |
Verifies the grid structure and returns false if inconsistencies are found. More... | |
virtual void | Position (const Base::Vector3d &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const |
Returns the indices of the grid this point lies in. More... | |
unsigned long | GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set< unsigned long > &raclInd) const |
Returns the indices of the elements in the given grid. More... | |
bool | CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const |
Checks if this is a valid grid position. More... | |
virtual void | InitGrid () |
Initializes the size of the internal structure. More... | |
virtual void | Clear () |
Deletes the grid structure. More... | |
virtual void | CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids) |
Calculates the grid length dependent on maximum number of grids. More... | |
virtual void | CalculateGridLength (int iCtGridPerAxis) |
Calculates the grid length dependent on the number of grids per axis. More... | |
virtual void | RebuildGrid () |
Rebuilds the grid structure. More... | |
unsigned long | HasElements () const |
Returns the number of stored elements. More... | |
void | GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set< unsigned long > &raclInd) const |
Get the indices of all elements lying in the grids around a given grid with distance ulDistance. More... | |
void | AddPoint (const Base::Vector3d &rclPt, unsigned long ulPtIndex, float fEpsilon=0.0f) |
Adds a new point element to the grid structure. More... | |
void | Pos (const Base::Vector3d &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const |
Returns the grid numbers to the given point rclPoint. More... | |
The PointsGrid allows to divide a global point cloud into smaller regions of elements depending on the resolution of the grid.
All grid elements in the grid structure have the same size.
Grids can be used within algorithms to avoid to iterate through all elements, so grids can speed up algorithms dramatically.
PointsGrid::PointsGrid | ( | const PointKernel & | rclM | ) |
Construction.
References RebuildGrid().
PointsGrid::PointsGrid | ( | ) |
Construction.
PointsGrid::PointsGrid | ( | const PointKernel & | rclM, |
int | iCtGridPerAxis | ||
) |
Construction.
References Rebuild().
PointsGrid::PointsGrid | ( | const PointKernel & | rclM, |
double | fGridLen | ||
) |
PointsGrid::PointsGrid | ( | const PointKernel & | rclM, |
unsigned long | ulX, | ||
unsigned long | ulY, | ||
unsigned long | ulZ | ||
) |
Construction.
References Rebuild().
|
virtual |
Destruction.
|
protected |
Adds a new point element to the grid structure.
rclPt is the geometric point and ulPtIndex the corresponding index in the point kernel.
References Pos(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by RebuildGrid().
|
virtual |
Attaches the point kernel to this grid, an already attached point cloud gets detached.
The grid gets rebuilt automatically.
References RebuildGrid().
Referenced by Validate().
|
protectedvirtual |
Calculates the grid length dependent on the number of grids per axis.
References Base::BoundBox3< _Precision >::Add(), Base::BoundBox3< _Precision >::CalcDiagonalLength(), CalculateGridLength(), Base::BoundBox3< _Precision >::LengthX(), Base::BoundBox3< _Precision >::LengthY(), and Base::BoundBox3< _Precision >::LengthZ().
|
protectedvirtual |
Calculates the grid length dependent on maximum number of grids.
References Base::BoundBox3< _Precision >::Add(), Base::BoundBox3< _Precision >::LengthX(), Base::BoundBox3< _Precision >::LengthY(), and Base::BoundBox3< _Precision >::LengthZ().
Referenced by CalculateGridLength(), InitGrid(), and Rebuild().
|
protected |
Checks if this is a valid grid position.
|
protectedvirtual |
Deletes the grid structure.
unsigned long PointsGrid::FindElements | ( | const Base::Vector3d & | rclPoint, |
std::set< unsigned long > & | aulElements | ||
) | const |
Finds all points that lie in the same grid as the point rclPoint.
References GetElements(), and Pos().
Base::BoundBox3d Points::PointsGrid::GetBoundBox | ( | ) | const |
Returns the bounding box of the whole.
Referenced by InSide(), and SearchNearestFromPoint().
Base::BoundBox3d Points::PointsGrid::GetBoundBox | ( | unsigned long | ulX, |
unsigned long | ulY, | ||
unsigned long | ulZ | ||
) | const |
Returns the bounding box of a given grid element.
unsigned long Points::PointsGrid::GetCtElements | ( | unsigned long | ulX, |
unsigned long | ulY, | ||
unsigned long | ulZ | ||
) | const |
Returns the number of elements in a given grid.
|
virtual |
Returns the number of grid elements in x,y and z direction.
unsigned long PointsGrid::GetElements | ( | unsigned long | ulX, |
unsigned long | ulY, | ||
unsigned long | ulZ, | ||
std::set< unsigned long > & | raclInd | ||
) | const |
Returns the indices of the elements in the given grid.
Referenced by FindElements(), and GetHull().
|
virtual |
Returns the lengths of the grid elements in x,y and z direction.
|
protected |
Get the indices of all elements lying in the grids around a given grid with distance ulDistance.
References GetElements().
Referenced by SearchNearestFromPoint().
|
protected |
Returns the number of stored elements.
Referenced by Rebuild().
|
protectedvirtual |
Initializes the size of the internal structure.
References Base::BoundBox3< _Precision >::Add(), CalculateGridLength(), Base::BoundBox3< _Precision >::LengthX(), Base::BoundBox3< _Precision >::LengthY(), Base::BoundBox3< _Precision >::LengthZ(), Base::BoundBox3< _Precision >::MinX, Base::BoundBox3< _Precision >::MinY, and Base::BoundBox3< _Precision >::MinZ.
Referenced by RebuildGrid().
|
virtual |
Searches for elements lying in the intersection area of the grid and the bounding box.
References Base::BoundBox3< _Precision >::MaxX, Base::BoundBox3< _Precision >::MaxY, Base::BoundBox3< _Precision >::MaxZ, Base::BoundBox3< _Precision >::MinX, Base::BoundBox3< _Precision >::MinY, Base::BoundBox3< _Precision >::MinZ, and Position().
|
virtual |
Searches for elements lying in the intersection area of the grid and the bounding box.
References Base::BoundBox3< _Precision >::MaxX, Base::BoundBox3< _Precision >::MaxY, Base::BoundBox3< _Precision >::MaxZ, Base::BoundBox3< _Precision >::MinX, Base::BoundBox3< _Precision >::MinY, Base::BoundBox3< _Precision >::MinZ, and Position().
|
virtual |
Searches for elements lying in the intersection area of the grid and the bounding box.
References Base::BoundBox3< _Precision >::CalcDiagonalLength(), Base::DistanceP2(), GetBoundBox(), Base::BoundBox3< _Precision >::MaxX, Base::BoundBox3< _Precision >::MaxY, Base::BoundBox3< _Precision >::MaxZ, Base::BoundBox3< _Precision >::MinX, Base::BoundBox3< _Precision >::MinY, Base::BoundBox3< _Precision >::MinZ, and Position().
|
protected |
Returns the grid numbers to the given point rclPoint.
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by AddPoint(), and FindElements().
|
virtual |
Returns the indices of the grid this point lies in.
If the point is outside the grid then the indices of the nearest grid element are taken.
References Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.
Referenced by InSide(), and SearchNearestFromPoint().
|
virtual |
Rebuilds the grid structure.
References CalculateGridLength(), HasElements(), and RebuildGrid().
|
virtual |
Rebuilds the grid structure.
References CalculateGridLength(), HasElements(), and RebuildGrid().
Referenced by PointsGrid().
|
virtual |
Rebuilds the grid structure.
References HasElements(), and RebuildGrid().
|
protectedvirtual |
Rebuilds the grid structure.
References AddPoint(), and InitGrid().
Referenced by Attach(), PointsGrid(), Rebuild(), and Validate().
void PointsGrid::SearchNearestFromPoint | ( | const Base::Vector3d & | rclPt, |
std::set< unsigned long > & | rclInd | ||
) | const |
Searches for the nearest grids that contain elements from a point, the result are grid indices.
References Base::BoundBox3< double >::BACK, Base::BoundBox3< double >::BOTTOM, Base::BoundBox3< double >::FRONT, GetBoundBox(), Base::BoundBox3< _Precision >::GetCenter(), GetHull(), Base::BoundBox3< _Precision >::GetSideFromRay(), Base::BoundBox3< _Precision >::IsInBox(), Base::BoundBox3< double >::LEFT, Position(), Base::BoundBox3< double >::RIGHT, and Base::BoundBox3< double >::TOP.
|
virtual |
Validates the grid structure and rebuilds it if needed.
References RebuildGrid().
|
virtual |
Validates the grid structure and rebuilds it if needed.
References Attach(), RebuildGrid(), and Points::PointKernel::size().
|
virtual |
Verifies the grid structure and returns false if inconsistencies are found.
References Points::PointsGridIterator::GetBoundBox(), Points::PointsGridIterator::GetElements(), Points::PointsGridIterator::Init(), Base::BoundBox3< _Precision >::IsInBox(), Points::PointsGridIterator::More(), and Points::PointsGridIterator::Next().
|
friend |
|
friend |