Points::PointsGrid Class Reference

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>

List of all members.

Public Member Functions

virtual void Attach (const PointKernel &rclM)
 Attaches the point kernel to this grid, an already attached point cloud gets detached.
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.
unsigned long GetCtElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Returns the number of elements in a given grid.
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.
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.
virtual void GetGridLengths (double &rfLenX, double &rfLenY, double &rfLenZ) const
 Returns the lengths of the grid elements in x,y and z direction.
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.
virtual void Rebuild (unsigned long ulX, unsigned long ulY, unsigned long ulZ)
 Rebuilds the grid structure.
virtual void Rebuild (int iCtGridPerAxis=POINTS_CT_GRID_PER_AXIS)
 Rebuilds the grid structure.
virtual void Rebuild (unsigned long ulPerGrid=POINTS_CT_GRID, unsigned long ulMaxGrid=POINTS_MAX_GRIDS)
 Rebuilds the grid structure.
virtual void Validate (void)
 Validates the grid structure and rebuilds it if needed.
virtual void Validate (const PointKernel &rclM)
 Validates the grid structure and rebuilds it if needed.
virtual bool Verify () const
 Verifies the grid structure and returns false if inconsistencies are found.
Boundings



Base::BoundBox3d GetBoundBox (void) const
 Returns the bounding box of the whole.
Base::BoundBox3d GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Returns the bounding box of a given grid element.
Search



virtual unsigned long InSide (const Base::BoundBox3d &rclBB, std::vector< unsigned long > &raulElements, const Base::Vector3d &rclOrg, float fMaxDist, bool bDelDoubles=true) const
 Searches for elements lying in the intersection area of the grid and the bounding box.
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.
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.
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.
Construction



 PointsGrid (const PointKernel &rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ)
 Construction.
 PointsGrid (const PointKernel &rclM, double fGridLen)
 Construction.
 PointsGrid (const PointKernel &rclM, int iCtGridPerAxis)
 Construction.
 PointsGrid (void)
 Construction.
 PointsGrid (const PointKernel &rclM)
 Construction.
virtual ~PointsGrid (void)
 Destruction.

Protected Member Functions

void AddPoint (const Base::Vector3d &rclPt, unsigned long ulPtIndex, float fEpsilon=0.0f)
 Adds a new point element to the grid structure.
virtual void CalculateGridLength (int iCtGridPerAxis)
 Calculates the grid length dependent on the number of grids per axis.
virtual void CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids)
 Calculates the grid length dependent on maximum number of grids.
bool CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Checks if this is a valid grid position.
virtual void Clear (void)
 Deletes the grid structure.
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.
unsigned long HasElements (void) const
 Returns the number of stored elements.
virtual void InitGrid (void)
 Initializes the size of the internal structure.
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.
virtual void RebuildGrid (void)
 Rebuilds the grid structure.

Protected Attributes

std::vector< std::vector
< std::vector< std::set
< unsigned long > > > > 
_aulGrid
 Grid data structure.
double _fGridLenX
 Length of grid elements in x.
double _fGridLenY
 Length of grid elements in y.
double _fGridLenZ
 Length of grid elements in z.
double _fMinX
 Grid null position in x.
double _fMinY
 Grid null position in y.
double _fMinZ
 Grid null position in z.
const PointKernel_pclPoints
 The point kernel.
unsigned long _ulCtElements
 Number of grid elements for validation issues.
unsigned long _ulCtGridsX
 Number of grid elements in z.
unsigned long _ulCtGridsY
 Number of grid elements in z.
unsigned long _ulCtGridsZ
 Number of grid elements in z.

Friends

class PointsGridIterator
class PointsGridIteratorStatistic

Detailed Description

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.

Author:
Werner Mayer

Definition at line 49 of file PointsGrid.h.


Constructor & Destructor Documentation

PointsGrid::PointsGrid ( const PointKernel rclM  ) 

Construction.

Definition at line 36 of file PointsGrid.cpp.

References RebuildGrid().

PointsGrid::PointsGrid ( void   ) 

Construction.

Definition at line 46 of file PointsGrid.cpp.

PointsGrid::PointsGrid ( const PointKernel rclM,
int  iCtGridPerAxis 
)

Construction.

Definition at line 65 of file PointsGrid.cpp.

References Rebuild().

PointsGrid::PointsGrid ( const PointKernel rclM,
double  fGridLen 
)
PointsGrid::PointsGrid ( const PointKernel rclM,
unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
)

Construction.

Definition at line 55 of file PointsGrid.cpp.

References Rebuild().

virtual Points::PointsGrid::~PointsGrid ( void   )  [inline, virtual]

Destruction.

Definition at line 65 of file PointsGrid.h.


Member Function Documentation

void PointsGrid::AddPoint ( const Base::Vector3d rclPt,
unsigned long  ulPtIndex,
float  fEpsilon = 0.0f 
) [protected]

Adds a new point element to the grid structure.

rclPt is the geometric point and ulPtIndex the corresponding index in the point kernel.

Definition at line 624 of file PointsGrid.cpp.

References _aulGrid, _ulCtGridsX, _ulCtGridsY, _ulCtGridsZ, Pos(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

Referenced by RebuildGrid().

void PointsGrid::Attach ( const PointKernel rclM  )  [virtual]

Attaches the point kernel to this grid, an already attached point cloud gets detached.

The grid gets rebuilt automatically.

Definition at line 90 of file PointsGrid.cpp.

References _pclPoints, and RebuildGrid().

Referenced by Validate().

void PointsGrid::CalculateGridLength ( int  iCtGridPerAxis  )  [protected, virtual]
void PointsGrid::CalculateGridLength ( unsigned long  ulCtGrid,
unsigned long  ulMaxGrids 
) [protected, virtual]
bool Points::PointsGrid::CheckPos ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const [inline, protected]

Checks if this is a valid grid position.

Definition at line 263 of file PointsGrid.h.

References _ulCtGridsX, _ulCtGridsY, and _ulCtGridsZ.

Referenced by Points::PointsGridIterator::NextOnRay().

void PointsGrid::Clear ( void   )  [protected, virtual]

Deletes the grid structure.

Definition at line 96 of file PointsGrid.cpp.

References _aulGrid, and _pclPoints.

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.

Definition at line 694 of file PointsGrid.cpp.

References _ulCtGridsX, _ulCtGridsY, _ulCtGridsZ, GetElements(), and Pos().

Base::BoundBox3d Points::PointsGrid::GetBoundBox ( void   )  const [inline]

Returns the bounding box of the whole.

Definition at line 257 of file PointsGrid.h.

References _fGridLenX, _fGridLenY, _fGridLenZ, _fMinX, _fMinY, _fMinZ, _ulCtGridsX, _ulCtGridsY, and _ulCtGridsZ.

Referenced by InSide(), and SearchNearestFromPoint().

Base::BoundBox3d Points::PointsGrid::GetBoundBox ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const [inline]

Returns the bounding box of a given grid element.

Definition at line 246 of file PointsGrid.h.

References _fGridLenX, _fGridLenY, _fGridLenZ, _fMinX, _fMinY, and _fMinZ.

Referenced by Points::PointsGridIterator::InitOnRay(), and Points::PointsGridIterator::NextOnRay().

unsigned long Points::PointsGrid::GetCtElements ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const [inline]

Returns the number of elements in a given grid.

Definition at line 107 of file PointsGrid.h.

virtual void Points::PointsGrid::GetCtGrids ( unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const [inline, virtual]

Returns the number of grid elements in x,y and z direction.

Definition at line 96 of file PointsGrid.h.

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.

Definition at line 611 of file PointsGrid.cpp.

References _aulGrid.

Referenced by FindElements(), Inspection::InspectNominalPoints::getDistance(), and GetHull().

virtual void Points::PointsGrid::GetGridLengths ( double &  rfLenX,
double &  rfLenY,
double &  rfLenZ 
) const [inline, virtual]

Returns the lengths of the grid elements in x,y and z direction.

Definition at line 93 of file PointsGrid.h.

void PointsGrid::GetHull ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ,
unsigned long  ulDistance,
std::set< unsigned long > &  raclInd 
) const [protected]

Get the indices of all elements lying in the grids around a given grid with distance ulDistance.

Definition at line 561 of file PointsGrid.cpp.

References _ulCtGridsX, _ulCtGridsY, _ulCtGridsZ, GetElements(), and Py::int.

Referenced by SearchNearestFromPoint().

unsigned long Points::PointsGrid::HasElements ( void   )  const [inline, protected]

Returns the number of stored elements.

Definition at line 137 of file PointsGrid.h.

Referenced by Rebuild().

void PointsGrid::InitGrid ( void   )  [protected, virtual]
unsigned long PointsGrid::InSide ( const Base::BoundBox3d rclBB,
std::vector< unsigned long > &  raulElements,
const Base::Vector3d rclOrg,
float  fMaxDist,
bool  bDelDoubles = true 
) const [virtual]
unsigned long PointsGrid::InSide ( const Base::BoundBox3d rclBB,
std::set< unsigned long > &  raulElementss 
) const [virtual]
unsigned long PointsGrid::InSide ( const Base::BoundBox3d rclBB,
std::vector< unsigned long > &  raulElements,
bool  bDelDoubles = true 
) const [virtual]
void PointsGrid::Pos ( const Base::Vector3d rclPoint,
unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const [protected]

Returns the grid numbers to the given point rclPoint.

Definition at line 687 of file PointsGrid.cpp.

References _fGridLenX, _fGridLenY, _fGridLenZ, _fMinX, _fMinY, _fMinZ, Py::long, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

Referenced by AddPoint(), and FindElements().

void PointsGrid::Position ( const Base::Vector3d rclPoint,
unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const [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.

Definition at line 265 of file PointsGrid.cpp.

References _fGridLenX, _fGridLenY, _fGridLenZ, _fMinX, _fMinY, _fMinZ, _ulCtGridsX, _ulCtGridsY, _ulCtGridsZ, Py::long, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

Referenced by Inspection::InspectNominalPoints::getDistance(), Points::PointsGridIterator::InitOnRay(), InSide(), and SearchNearestFromPoint().

void PointsGrid::Rebuild ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) [virtual]

Rebuilds the grid structure.

Definition at line 102 of file PointsGrid.cpp.

References _ulCtElements, _ulCtGridsX, _ulCtGridsY, _ulCtGridsZ, HasElements(), and RebuildGrid().

void PointsGrid::Rebuild ( int  iCtGridPerAxis = POINTS_CT_GRID_PER_AXIS  )  [virtual]

Rebuilds the grid structure.

Definition at line 118 of file PointsGrid.cpp.

References _ulCtElements, CalculateGridLength(), HasElements(), and RebuildGrid().

void PointsGrid::Rebuild ( unsigned long  ulPerGrid = POINTS_CT_GRID,
unsigned long  ulMaxGrid = POINTS_MAX_GRIDS 
) [virtual]

Rebuilds the grid structure.

Definition at line 111 of file PointsGrid.cpp.

References _ulCtElements, CalculateGridLength(), HasElements(), and RebuildGrid().

Referenced by PointsGrid().

void PointsGrid::RebuildGrid ( void   )  [protected, virtual]
void PointsGrid::SearchNearestFromPoint ( const Base::Vector3d rclPt,
std::set< unsigned long > &  rclInd 
) const
void PointsGrid::Validate ( void   )  [virtual]

Validates the grid structure and rebuilds it if needed.

Definition at line 640 of file PointsGrid.cpp.

References _pclPoints, _ulCtElements, RebuildGrid(), and Points::PointKernel::size().

void PointsGrid::Validate ( const PointKernel rclM  )  [virtual]

Validates the grid structure and rebuilds it if needed.

Definition at line 632 of file PointsGrid.cpp.

References _pclPoints, _ulCtElements, Attach(), RebuildGrid(), and Points::PointKernel::size().

bool PointsGrid::Verify (  )  const [virtual]

Friends And Related Function Documentation

friend class PointsGridIterator [friend]

Definition at line 157 of file PointsGrid.h.

friend class PointsGridIteratorStatistic [friend]

Definition at line 158 of file PointsGrid.h.


Member Data Documentation

std::vector<std::vector<std::vector<std::set<unsigned long> > > > Points::PointsGrid::_aulGrid [protected]
double Points::PointsGrid::_fGridLenX [protected]

Length of grid elements in x.

Definition at line 149 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

double Points::PointsGrid::_fGridLenY [protected]

Length of grid elements in y.

Definition at line 150 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

double Points::PointsGrid::_fGridLenZ [protected]

Length of grid elements in z.

Definition at line 151 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

double Points::PointsGrid::_fMinX [protected]

Grid null position in x.

Definition at line 152 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

double Points::PointsGrid::_fMinY [protected]

Grid null position in y.

Definition at line 153 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

double Points::PointsGrid::_fMinZ [protected]

Grid null position in z.

Definition at line 154 of file PointsGrid.h.

Referenced by GetBoundBox(), InitGrid(), Pos(), and Position().

The point kernel.

Definition at line 144 of file PointsGrid.h.

Referenced by Attach(), CalculateGridLength(), Clear(), InitGrid(), PointsGrid(), RebuildGrid(), Validate(), and Verify().

unsigned long Points::PointsGrid::_ulCtElements [protected]

Number of grid elements for validation issues.

Definition at line 145 of file PointsGrid.h.

Referenced by CalculateGridLength(), Rebuild(), RebuildGrid(), Validate(), and Verify().

unsigned long Points::PointsGrid::_ulCtGridsX [protected]

Number of grid elements in z.

Definition at line 146 of file PointsGrid.h.

Referenced by AddPoint(), CalculateGridLength(), CheckPos(), FindElements(), GetBoundBox(), GetHull(), InitGrid(), Position(), Rebuild(), and SearchNearestFromPoint().

unsigned long Points::PointsGrid::_ulCtGridsY [protected]

Number of grid elements in z.

Definition at line 147 of file PointsGrid.h.

Referenced by AddPoint(), CalculateGridLength(), CheckPos(), FindElements(), GetBoundBox(), GetHull(), InitGrid(), Position(), Rebuild(), and SearchNearestFromPoint().

unsigned long Points::PointsGrid::_ulCtGridsZ [protected]

Number of grid elements in z.

Definition at line 148 of file PointsGrid.h.

Referenced by AddPoint(), CalculateGridLength(), CheckPos(), FindElements(), GetBoundBox(), GetHull(), InitGrid(), Position(), Rebuild(), and SearchNearestFromPoint().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:02:42 2011 for FreeCAD by  doxygen 1.6.1