MeshCore::MeshGrid Class Reference

The MeshGrid allows to divide a global mesh object into smaller regions of elements (e.g. More...

#include <Grid.h>

Inheritance diagram for MeshCore::MeshGrid:
Inspection::MeshInspectGrid MeshCore::MeshFacetGrid MeshCore::MeshPointGrid

List of all members.

Public Member Functions

virtual void Attach (const MeshKernel &rclM)
 Attaches the mesh kernel to this grid, an already attached mesh gets detached.
bool CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Checks if this is a valid grid position.
bool CheckPosition (const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const
 Checks whether the point is inside the grid.
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.
virtual void GetGridLengths (float &rfLenX, float &rfLenY, float &rfLenZ) const
 Returns the lengths of the grid elements in x,y and z direction.
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 GetIndexToPosition (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Returns an index for the given grid position.
bool GetPositionToIndex (unsigned long id, unsigned long &ulX, unsigned long &ulY, unsigned long &ulZ) const
 Returns the grid position to the given index.
virtual void Position (const Base::Vector3f &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=MESH_CT_GRID_PER_AXIS)
 Rebuilds the grid structure.
virtual void Rebuild (unsigned long ulPerGrid=MESH_CT_GRID, unsigned long ulMaxGrid=MESH_MAX_GRIDS)
 Rebuilds the grid structure.
virtual void Validate (const MeshKernel &rclM)=0
 Validates the grid structure and rebuilds it if needed.
virtual bool Verify () const =0
 Verifies the grid structure and returns false if inconsistencies are found.
virtual ~MeshGrid (void)
 Destruction.
Boundings



Base::BoundBox3f GetBoundBox (void) const
 Returns the bounding box of the whole.
Base::BoundBox3f GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 Returns the bounding box of a given grid element.
Base::BoundBox3f GetMeshBoundBox (void) const
 Returns an extended bounding box of the mesh object.
Getters



unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector< unsigned long > &aulFacets) const
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.
Search



virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector< unsigned long > &raulElements, const Base::Vector3f &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::BoundBox3f &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::BoundBox3f &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::Vector3f &rclPt, std::set< unsigned long > &rclInd) const
 Searches for the nearest grids that contain elements from a point, the result are grid indices.

Protected Member Functions

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.
virtual void Clear (void)
 Deletes the grid structure.
virtual unsigned long HasElements (void) const =0
 Returns the number of stored elements.
virtual void InitGrid (void)
 Initializes the size of the internal structure.
virtual void RebuildGrid (void)=0
 Rebuilds the grid structure.
Construction



 MeshGrid (void)
 Construction.
 MeshGrid (const MeshKernel &rclM)
 Construction.

Protected Attributes

std::vector< std::vector
< std::vector< std::set
< unsigned long > > > > 
_aulGrid
 Grid data structure.
float _fGridLenX
 Length of grid elements in x.
float _fGridLenY
 Length of grid elements in y.
float _fGridLenZ
 Length of grid elements in z.
float _fMinX
 Grid null position in x.
float _fMinY
 Grid null position in y.
float _fMinZ
 Grid null position in z.
const MeshKernel_pclMesh
 The mesh 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 MeshGridIterator

Detailed Description

The MeshGrid allows to divide a global mesh object into smaller regions of elements (e.g.

facets, points or edges) 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.

Definition at line 55 of file Grid.h.


Constructor & Destructor Documentation

MeshGrid::MeshGrid ( const MeshKernel rclM  )  [protected]

Construction.

Definition at line 39 of file Grid.cpp.

MeshGrid::MeshGrid ( void   )  [protected]

Construction.

Definition at line 48 of file Grid.cpp.

virtual MeshCore::MeshGrid::~MeshGrid ( void   )  [inline, virtual]

Destruction.

Definition at line 68 of file Grid.h.


Member Function Documentation

void MeshGrid::Attach ( const MeshKernel rclM  )  [virtual]

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

The grid gets rebuilt automatically.

Definition at line 57 of file Grid.cpp.

References _pclMesh, and RebuildGrid().

Referenced by MeshCore::MeshPointGrid::Validate(), and MeshCore::MeshFacetGrid::Validate().

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

Checks if this is a valid grid position.

Definition at line 389 of file Grid.h.

References _ulCtGridsX, _ulCtGridsY, and _ulCtGridsZ.

Referenced by GetIndexToPosition(), GetPositionToIndex(), and MeshCore::MeshGridIterator::NextOnRay().

bool MeshGrid::CheckPosition ( const Base::Vector3f rclPoint,
unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const

Checks whether the point is inside the grid.

In case it is inside true is returned with the grid position, otherwise false is returned and the grid position is undefined.

Definition at line 232 of file Grid.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 GetElements().

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

Deletes the grid structure.

Definition at line 63 of file Grid.cpp.

References _aulGrid, and _pclMesh.

Base::BoundBox3f MeshCore::MeshGrid::GetBoundBox ( void   )  const [inline]
Base::BoundBox3f MeshCore::MeshGrid::GetBoundBox ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const [inline]

Returns the bounding box of a given grid element.

Definition at line 364 of file Grid.h.

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

Referenced by MeshCore::MeshGridIterator::InitOnRay(), and MeshCore::MeshGridIterator::NextOnRay().

unsigned long MeshCore::MeshGrid::GetCtElements ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const [inline]

Returns the number of elements in a given grid.

Definition at line 127 of file Grid.h.

virtual void MeshCore::MeshGrid::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 105 of file Grid.h.

Referenced by MeshCore::MeshEvalSelfIntersection::Evaluate(), and MeshCore::MeshEvalSelfIntersection::GetIntersections().

unsigned long MeshGrid::GetElements ( const Base::Vector3f rclPoint,
std::vector< unsigned long > &  aulFacets 
) const

Definition at line 599 of file Grid.cpp.

References _aulGrid, CheckPosition(), draftlibs::dxfLibrary::copy, and Sketcher::end.

unsigned long MeshGrid::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 586 of file Grid.cpp.

References _aulGrid.

Referenced by MeshCore::MeshPointGrid::FindElements(), MeshCore::MeshAlgorithm::FirstFacetToVertex(), Inspection::InspectNominalFastMesh::getDistance(), and GetHull().

virtual void MeshCore::MeshGrid::GetGridLengths ( float &  rfLenX,
float &  rfLenY,
float &  rfLenZ 
) const [inline, virtual]

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

Definition at line 102 of file Grid.h.

void MeshGrid::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.

Definition at line 536 of file Grid.cpp.

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

Referenced by Inspection::InspectNominalFastMesh::getDistance(), and SearchNearestFromPoint().

unsigned long MeshGrid::GetIndexToPosition ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const

Returns an index for the given grid position.

If the specified triple is not a valid grid position ULONG_MAX is returned. If the index is valid than its value is between zero and the number of grid elements. For each different grid position a different index is returned.

Definition at line 611 of file Grid.cpp.

References _ulCtGridsX, _ulCtGridsY, and CheckPos().

Base::BoundBox3f MeshCore::MeshGrid::GetMeshBoundBox ( void   )  const [inline]

Returns an extended bounding box of the mesh object.

Definition at line 381 of file Grid.h.

References _pclMesh, Base::BoundBox3< _Precision >::Enlarge(), MeshCore::MeshKernel::GetBoundBox(), and MESHGRID_BBOX_EXTENSION.

bool MeshGrid::GetPositionToIndex ( unsigned long  id,
unsigned long &  ulX,
unsigned long &  ulY,
unsigned long &  ulZ 
) const

Returns the grid position to the given index.

If the index is equal to or higher than the number of grid elements false is returned and the triple is set to ULONG_MAX.

Definition at line 618 of file Grid.cpp.

References _ulCtGridsX, _ulCtGridsY, and CheckPos().

virtual unsigned long MeshCore::MeshGrid::HasElements ( void   )  const [protected, pure virtual]

Returns the number of stored elements.

Must be implemented in sub-classes.

Implemented in Inspection::MeshInspectGrid, MeshCore::MeshFacetGrid, and MeshCore::MeshPointGrid.

Referenced by Rebuild().

void MeshGrid::InitGrid ( void   )  [protected, virtual]
unsigned long MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::vector< unsigned long > &  raulElements,
const Base::Vector3f rclOrg,
float  fMaxDist,
bool  bDelDoubles = true 
) const [virtual]
unsigned long MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::set< unsigned long > &  raulElementss 
) const [virtual]
unsigned long MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::vector< unsigned long > &  raulElements,
bool  bDelDoubles = true 
) const [virtual]
void MeshGrid::Position ( const Base::Vector3f rclPoint,
unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const [virtual]
void MeshGrid::Rebuild ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) [virtual]

Rebuilds the grid structure.

Definition at line 69 of file Grid.cpp.

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

void MeshGrid::Rebuild ( int  iCtGridPerAxis = MESH_CT_GRID_PER_AXIS  )  [virtual]

Rebuilds the grid structure.

Definition at line 85 of file Grid.cpp.

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

void MeshGrid::Rebuild ( unsigned long  ulPerGrid = MESH_CT_GRID,
unsigned long  ulMaxGrid = MESH_MAX_GRIDS 
) [virtual]

Rebuilds the grid structure.

Definition at line 78 of file Grid.cpp.

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

Referenced by MeshCore::MeshFacetGrid::MeshFacetGrid(), and MeshCore::MeshPointGrid::MeshPointGrid().

virtual void MeshCore::MeshGrid::RebuildGrid ( void   )  [protected, pure virtual]

Rebuilds the grid structure.

Must be implemented in sub-classes.

Implemented in Inspection::MeshInspectGrid, MeshCore::MeshFacetGrid, and MeshCore::MeshPointGrid.

Referenced by Attach(), and Rebuild().

void MeshGrid::SearchNearestFromPoint ( const Base::Vector3f rclPt,
std::set< unsigned long > &  rclInd 
) const
virtual void MeshCore::MeshGrid::Validate ( const MeshKernel rclM  )  [pure virtual]

Validates the grid structure and rebuilds it if needed.

Must be implemented in sub-classes.

Implemented in Inspection::MeshInspectGrid, MeshCore::MeshFacetGrid, and MeshCore::MeshPointGrid.

virtual bool MeshCore::MeshGrid::Verify (  )  const [pure virtual]

Verifies the grid structure and returns false if inconsistencies are found.

Implemented in Inspection::MeshInspectGrid, MeshCore::MeshFacetGrid, and MeshCore::MeshPointGrid.


Friends And Related Function Documentation

friend class MeshGridIterator [friend]

Definition at line 174 of file Grid.h.


Member Data Documentation

std::vector<std::vector<std::vector<std::set<unsigned long> > > > MeshCore::MeshGrid::_aulGrid [protected]
float MeshCore::MeshGrid::_fGridLenX [protected]
float MeshCore::MeshGrid::_fGridLenY [protected]
float MeshCore::MeshGrid::_fGridLenZ [protected]
float MeshCore::MeshGrid::_fMinX [protected]
float MeshCore::MeshGrid::_fMinY [protected]
float MeshCore::MeshGrid::_fMinZ [protected]
unsigned long MeshCore::MeshGrid::_ulCtElements [protected]
unsigned long MeshCore::MeshGrid::_ulCtGridsX [protected]
unsigned long MeshCore::MeshGrid::_ulCtGridsY [protected]
unsigned long MeshCore::MeshGrid::_ulCtGridsZ [protected]

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

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