Version: 9.12.0
SMDS_ElementFactory Class Reference

Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to elements: element ID, element VTK ID, sub-mesh ID, position on shape. More...

#include <SMDS_ElementFactory.hxx>

Inheritance diagram for SMDS_ElementFactory:

Public Member Functions

 SMDS_ElementFactory (SMDS_Mesh *mesh, const bool isNodal=false)
 Create a factory of cells or nodes in a given mesh. More...
 
virtual ~SMDS_ElementFactory ()
 Destructor. More...
 
smIdType GetFreeID ()
 Return minimal ID of a non-used element. More...
 
smIdType GetMaxID ()
 Return maximal ID of an used element. More...
 
smIdType GetMinID ()
 Return minimal ID of an used element. More...
 
SMDS_MeshElementNewElement (const smIdType id)
 Return an element by ID. NULL if the element with the given ID is already used. More...
 
SMDS_MeshCellNewCell (const smIdType id)
 Return a SMDS_MeshCell by ID. NULL if the cell with the given ID is already used. More...
 
const SMDS_MeshElementFindElement (const smIdType id) const
 Return an used element by ID. NULL if the element with the given ID is not yet used. More...
 
smIdType NbUsedElements () const
 Return a number of used elements. More...
 
template<class ElemIterator >
boost::shared_ptr< ElemIterator > GetIterator (SMDS_MeshElement::Filter *filter, size_t nbElemsToReturn=-1)
 Return an iterator on all element filtered using a given filter. More...
 
template<class ElemIterator >
boost::shared_ptr< ElemIterator > GetShapeIterator (int shapeID, size_t nbElemsToReturn, const SMDS_MeshElement *sm1stElem)
 Return an iterator on all element assigned to a given shape. More...
 
void SetAllNotMarked ()
 Clear marked flag of all elements. More...
 
void Free (const SMDS_MeshElement *)
 Mark the element as non-used. More...
 
smIdType FromVtkToSmds (vtkIdType vtkID)
 Return an SMDS ID by a Vtk one. More...
 
virtual void Clear ()
 De-allocate all elements. More...
 
virtual void Compact (std::vector< smIdType > &idCellsOldToNew)
 Remove unused elements located not at the end of the last chunk. More...
 
virtual bool CompactChangePointers ()
 Return true if Compact() will change IDs of elements. More...
 

Static Public Member Functions

static int ChunkSize ()
 Return a number of elements in a chunk. More...
 

Protected Attributes

bool myIsNodal
 
SMDS_MeshmyMesh
 
TChunkVector myChunks
 
TChunkPtrSet myChunksWithUnused
 
std::vector< vtkIdType > myVtkIDs
 
std::vector< smIdType > mySmdsIDs
 
smIdType myNbUsedElements
 

Friends

class SMDS_ElementChunk
 

Detailed Description

Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to elements: element ID, element VTK ID, sub-mesh ID, position on shape.

Elements are allocated by chunks, so there are used and non-used elements

Constructor & Destructor Documentation

◆ SMDS_ElementFactory()

SMDS_ElementFactory::SMDS_ElementFactory ( SMDS_Mesh mesh,
const bool  isNodal = false 
)

Create a factory of cells or nodes in a given mesh.

◆ ~SMDS_ElementFactory()

SMDS_ElementFactory::~SMDS_ElementFactory ( )
virtual

Destructor.

References myChunks, and myChunksWithUnused.

Member Function Documentation

◆ ChunkSize()

int SMDS_ElementFactory::ChunkSize ( )
static

Return a number of elements in a chunk.

Returns
int - chunk size

Referenced by GetShapeIterator(), and _RangeSet< RANGE >::Size().

◆ Clear()

void SMDS_ElementFactory::Clear ( )
virtual

De-allocate all elements.

Reimplemented in SMDS_NodeFactory.

References myChunks, myChunksWithUnused, myNbUsedElements, mySmdsIDs, and myVtkIDs.

Referenced by SMDS_NodeFactory::Clear(), and SMDS_Mesh::Clear().

◆ Compact()

void SMDS_ElementFactory::Compact ( std::vector< smIdType > &  theVtkIDsNewToOld)
virtual

Remove unused elements located not at the end of the last chunk.

Minimize allocated memory

Parameters
[out]theVtkIDsNewToOld- theVtkIDsNewToOld[ new VtkID ] = old VtkID

Reimplemented in SMDS_NodeFactory.

References FindElement(), Free(), GetMaxID(), SMDS_MeshElement::GetShapeID(), SMDS_MeshElement::GetVtkID(), myChunks, myChunksWithUnused, mySmdsIDs, myVtkIDs, NbUsedElements(), and NewElement().

Referenced by SMDS_Mesh::CompactMesh().

◆ CompactChangePointers()

bool SMDS_ElementFactory::CompactChangePointers ( )
virtual

◆ FindElement()

const SMDS_MeshElement * SMDS_ElementFactory::FindElement ( const smIdType  id) const

Return an used element by ID. NULL if the element with the given ID is not yet used.

Return an used element by ID.

NULL if the element with the given ID is not yet used

Parameters
[in]id- element ID
Returns
const SMDS_MeshElement* - element pointer

References SMDS_MeshElement::IsNull(), and myChunks.

Referenced by Compact(), SMDS_NodeFactory::Compact(), SMDS_Mesh::Contains(), SMDS_Mesh::FindElement(), SMDS_Mesh::FindElementVtk(), SMDS_NodeFactory::FindNode(), Free(), and SMDS_Mesh::GetElementType().

◆ Free()

◆ FromVtkToSmds()

smIdType SMDS_ElementFactory::FromVtkToSmds ( vtkIdType  vtkID)

Return an SMDS ID by a Vtk one.

Parameters
[in]vtkID- Vtk ID
Returns
smIdType - SMDS ID

References mySmdsIDs.

Referenced by SMDS_Mesh::FromVtkToSmds().

◆ GetFreeID()

◆ GetIterator()

template<class ElemIterator >
boost::shared_ptr< ElemIterator > SMDS_ElementFactory::GetIterator ( SMDS_MeshElement::Filter filter,
size_t  nbElemsToReturn = -1 
)

◆ GetMaxID()

smIdType SMDS_ElementFactory::GetMaxID ( )

◆ GetMinID()

smIdType SMDS_ElementFactory::GetMinID ( )

Return minimal ID of an used element.

Returns
smIdType - element ID

References myChunks.

Referenced by SMDS_Mesh::MinElementID(), and SMDS_Mesh::MinNodeID().

◆ GetShapeIterator()

template<class ElemIterator >
boost::shared_ptr< ElemIterator > SMDS_ElementFactory::GetShapeIterator ( int  shapeID,
size_t  nbElemsToReturn,
const SMDS_MeshElement sm1stElem 
)

Return an iterator on all element assigned to a given shape.

References ChunkSize(), SMDS_MeshElement::GetID(), SMDS_ElementChunk::GetSubIDRangesMinMax(), and myChunks.

Referenced by SMDS_Mesh::shapeElementsIterator(), and SMDS_Mesh::shapeNodesIterator().

◆ NbUsedElements()

smIdType SMDS_ElementFactory::NbUsedElements ( ) const

◆ NewCell()

◆ NewElement()

SMDS_MeshElement * SMDS_ElementFactory::NewElement ( const smIdType  id)

Return an element by ID. NULL if the element with the given ID is already used.

Return an element by ID.

NULL if the element with the given ID is already used

Parameters
[in]id- element ID
Returns
SMDS_MeshElement* - element pointer

References SMDS_MeshElement::IsNull(), myChunks, SMDS_MeshElement::myHolder, myMesh, myNbUsedElements, SMDS_Mesh::setMyModified(), and SMDS_ElementChunk.

Referenced by SMDS_Mesh::AddBallWithID(), Compact(), SMDS_NodeFactory::Compact(), NewCell(), and SMDS_NodeFactory::NewNode().

◆ SetAllNotMarked()

void SMDS_ElementFactory::SetAllNotMarked ( )

Clear marked flag of all elements.

References myChunks.

Referenced by SMDS_Mesh::SetAllCellsNotMarked(), and SMDS_Mesh::SetAllNodesNotMarked().

Friends And Related Function Documentation

◆ SMDS_ElementChunk

friend class SMDS_ElementChunk
friend

Referenced by GetFreeID(), and NewElement().

Field Documentation

◆ myChunks

◆ myChunksWithUnused

◆ myIsNodal

bool SMDS_ElementFactory::myIsNodal
protected

◆ myMesh

SMDS_Mesh* SMDS_ElementFactory::myMesh
protected

◆ myNbUsedElements

smIdType SMDS_ElementFactory::myNbUsedElements
protected

◆ mySmdsIDs

std::vector< smIdType > SMDS_ElementFactory::mySmdsIDs
protected

◆ myVtkIDs

std::vector< vtkIdType > SMDS_ElementFactory::myVtkIDs
protected