FreeCAD C++
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MeshCore::MeshGrid Class Referenceabstract

#include <Mod/Mesh/App/Core/Grid.h>

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.

Public Member Functions

virtual ~MeshGrid (void)
 Destruction.
 
virtual void Attach (const MeshKernel &rclM)
 
virtual void Rebuild (unsigned long ulPerGrid=MESH_CT_GRID, unsigned long ulMaxGrid=MESH_MAX_GRIDS)
 
virtual void Rebuild (int iCtGridPerAxis=MESH_CT_GRID_PER_AXIS)
 
virtual void Rebuild (unsigned long ulX, unsigned long ulY, unsigned long ulZ)
 
virtual void GetGridLengths (float &rfLenX, float &rfLenY, float &rfLenZ) const
 
virtual void GetCtGrids (unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const
 
unsigned long GetIndexToPosition (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 
bool GetPositionToIndex (unsigned long id, unsigned long &ulX, unsigned long &ulY, unsigned long &ulZ) const
 
unsigned long GetCtElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 
virtual void Validate (const MeshKernel &rclM)=0
 
virtual bool Verify () const =0
 
bool CheckPosition (const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const
 
virtual void Position (const Base::Vector3f &rclPoint, unsigned long &rulX, unsigned long &rulY, unsigned long &rulZ) const
 
bool CheckPos (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 
void GetHull (unsigned long ulX, unsigned long ulY, unsigned long ulZ, unsigned long ulDistance, std::set< unsigned long > &raclInd) const
 
Search
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector< unsigned long > &raulElements, bool bDelDoubles=true) const
 
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::set< unsigned long > &raulElementss) const
 
virtual unsigned long Inside (const Base::BoundBox3f &rclBB, std::vector< unsigned long > &raulElements, const Base::Vector3f &rclOrg, float fMaxDist, bool bDelDoubles=true) const
 
void SearchNearestFromPoint (const Base::Vector3f &rclPt, std::set< unsigned long > &rclInd) const
 
Getters
unsigned long GetElements (unsigned long ulX, unsigned long ulY, unsigned long ulZ, std::set< unsigned long > &raclInd) const
 
unsigned long GetElements (const Base::Vector3f &rclPoint, std::vector< unsigned long > &aulFacets) const
 
Boundings
Base::BoundBox3f GetBoundBox (unsigned long ulX, unsigned long ulY, unsigned long ulZ) const
 
Base::BoundBox3f GetBoundBox (void) const
 
Base::BoundBox3f GetMeshBoundBox (void) const
 

Protected Member Functions

virtual void InitGrid (void)
 
virtual void Clear (void)
 
virtual void CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxGrids)
 
virtual void CalculateGridLength (int iCtGridPerAxis)
 
virtual void RebuildGrid (void)=0
 
virtual unsigned long HasElements (void) const =0
 
Construction
 MeshGrid (const MeshKernel &rclM)
 Construction.
 
 MeshGrid (void)
 Construction.
 

Protected Attributes

std::vector< std::vector< std::vector< std::set< unsigned long > > > > _aulGrid
 
const MeshKernel_pclMesh
 
unsigned long _ulCtElements
 
unsigned long _ulCtGridsX
 
unsigned long _ulCtGridsY
 
unsigned long _ulCtGridsZ
 
float _fGridLenX
 
float _fGridLenY
 
float _fGridLenZ
 
float _fMinX
 
float _fMinY
 
float _fMinZ
 

Member Function Documentation

◆ Attach()

virtual void MeshCore::MeshGrid::Attach ( const MeshKernel rclM)
virtual

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

◆ CalculateGridLength() [1/2]

virtual void MeshCore::MeshGrid::CalculateGridLength ( unsigned long  ulCtGrid,
unsigned long  ulMaxGrids 
)
protectedvirtual

Calculates the grid length dependent on maximum number of grids.

◆ CalculateGridLength() [2/2]

virtual void MeshCore::MeshGrid::CalculateGridLength ( int  iCtGridPerAxis)
protectedvirtual

Calculates the grid length dependent on the number of grids per axis.

◆ CheckPos()

bool MeshCore::MeshGrid::CheckPos ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const

Checks if this is a valid grid position.

◆ CheckPosition()

bool MeshCore::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.

◆ Clear()

virtual void MeshCore::MeshGrid::Clear ( void  )
protectedvirtual

Deletes the grid structure.

◆ GetBoundBox() [1/2]

Base::BoundBox3f MeshCore::MeshGrid::GetBoundBox ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
) const

Returns the bounding box of a given grid element.

◆ GetBoundBox() [2/2]

Base::BoundBox3f MeshCore::MeshGrid::GetBoundBox ( void  ) const

Returns the bounding box of the whole.

◆ GetCtElements()

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

Returns the number of elements in a given grid.

◆ GetCtGrids()

virtual void MeshCore::MeshGrid::GetCtGrids ( unsigned long &  rulX,
unsigned long &  rulY,
unsigned long &  rulZ 
) const
virtual

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

◆ GetElements()

unsigned long MeshCore::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.

◆ GetGridLengths()

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

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

◆ GetHull()

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

◆ GetIndexToPosition()

unsigned long MeshCore::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.

◆ GetMeshBoundBox()

Base::BoundBox3f MeshCore::MeshGrid::GetMeshBoundBox ( void  ) const

Returns an extended bounding box of the mesh object.

◆ GetPositionToIndex()

bool MeshCore::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.

◆ HasElements()

virtual unsigned long MeshCore::MeshGrid::HasElements ( void  ) const
protectedpure virtual

Returns the number of stored elements. Must be implemented in sub-classes.

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

◆ InitGrid()

virtual void MeshCore::MeshGrid::InitGrid ( void  )
protectedvirtual

Initializes the size of the internal structure.

◆ Inside() [1/3]

virtual unsigned long MeshCore::MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::vector< unsigned long > &  raulElements,
bool  bDelDoubles = true 
) const
virtual

Searches for elements lying in the intersection area of the grid and the bounding box.

◆ Inside() [2/3]

virtual unsigned long MeshCore::MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::set< unsigned long > &  raulElementss 
) const
virtual

Searches for elements lying in the intersection area of the grid and the bounding box.

◆ Inside() [3/3]

virtual unsigned long MeshCore::MeshGrid::Inside ( const Base::BoundBox3f rclBB,
std::vector< unsigned long > &  raulElements,
const Base::Vector3f rclOrg,
float  fMaxDist,
bool  bDelDoubles = true 
) const
virtual

Searches for elements lying in the intersection area of the grid and the bounding box.

◆ Position()

virtual void MeshCore::MeshGrid::Position ( const Base::Vector3f 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 the indices of the nearest grid element are taken.

◆ Rebuild() [1/3]

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

Rebuilds the grid structure.

◆ Rebuild() [2/3]

virtual void MeshCore::MeshGrid::Rebuild ( int  iCtGridPerAxis = MESH_CT_GRID_PER_AXIS)
virtual

Rebuilds the grid structure.

◆ Rebuild() [3/3]

virtual void MeshCore::MeshGrid::Rebuild ( unsigned long  ulX,
unsigned long  ulY,
unsigned long  ulZ 
)
virtual

Rebuilds the grid structure.

◆ RebuildGrid()

virtual void MeshCore::MeshGrid::RebuildGrid ( void  )
protectedpure virtual

Rebuilds the grid structure. Must be implemented in sub-classes.

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

◆ SearchNearestFromPoint()

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

◆ Validate()

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 MeshCore::MeshPointGrid, and MeshCore::MeshFacetGrid.

◆ Verify()

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

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

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

Member Data Documentation

◆ _aulGrid

std::vector<std::vector<std::vector<std::set<unsigned long> > > > MeshCore::MeshGrid::_aulGrid
protected

Grid data structure.

◆ _fGridLenX

float MeshCore::MeshGrid::_fGridLenX
protected

Length of grid elements in x.

◆ _fGridLenY

float MeshCore::MeshGrid::_fGridLenY
protected

Length of grid elements in y.

◆ _fGridLenZ

float MeshCore::MeshGrid::_fGridLenZ
protected

Length of grid elements in z.

◆ _fMinX

float MeshCore::MeshGrid::_fMinX
protected

Grid null position in x.

◆ _fMinY

float MeshCore::MeshGrid::_fMinY
protected

Grid null position in y.

◆ _fMinZ

float MeshCore::MeshGrid::_fMinZ
protected

Grid null position in z.

◆ _pclMesh

const MeshKernel* MeshCore::MeshGrid::_pclMesh
protected

The mesh kernel.

◆ _ulCtElements

unsigned long MeshCore::MeshGrid::_ulCtElements
protected

Number of grid elements for validation issues.

◆ _ulCtGridsX

unsigned long MeshCore::MeshGrid::_ulCtGridsX
protected

Number of grid elements in z.

◆ _ulCtGridsY

unsigned long MeshCore::MeshGrid::_ulCtGridsY
protected

Number of grid elements in z.

◆ _ulCtGridsZ

unsigned long MeshCore::MeshGrid::_ulCtGridsZ
protected

Number of grid elements in z.