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>
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_MeshElement * | NewElement (const smIdType id) |
Return an element by ID. NULL if the element with the given ID is already used. More... | |
SMDS_MeshCell * | NewCell (const smIdType id) |
Return a SMDS_MeshCell by ID. NULL if the cell with the given ID is already used. More... | |
const SMDS_MeshElement * | FindElement (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_Mesh * | myMesh |
TChunkVector | myChunks |
TChunkPtrSet | myChunksWithUnused |
std::vector< vtkIdType > | myVtkIDs |
std::vector< smIdType > | mySmdsIDs |
smIdType | myNbUsedElements |
Friends | |
class | SMDS_ElementChunk |
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
SMDS_ElementFactory::SMDS_ElementFactory | ( | SMDS_Mesh * | mesh, |
const bool | isNodal = false |
||
) |
Create a factory of cells or nodes in a given mesh.
|
virtual |
Destructor.
References myChunks, and myChunksWithUnused.
|
static |
Return a number of elements in a chunk.
Referenced by GetShapeIterator(), and _RangeSet< RANGE >::Size().
|
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().
|
virtual |
Remove unused elements located not at the end of the last chunk.
Minimize allocated memory
[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().
|
virtual |
Return true if Compact() will change IDs of elements.
Reimplemented in SMDS_NodeFactory.
References GetMaxID(), and NbUsedElements().
Referenced by SMDS_Mesh::edgesIterator(), SMDS_Mesh::elementEntityIterator(), SMDS_Mesh::elementGeomIterator(), SMDS_Mesh::elementsIterator(), SMDS_Mesh::facesIterator(), SMDS_Mesh::HasNumerationHoles(), and SMDS_Mesh::volumesIterator().
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
[in] | id | - element ID |
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().
void SMDS_ElementFactory::Free | ( | const SMDS_MeshElement * | e | ) |
Mark the element as non-used.
[in] | e | - element |
References FindElement(), SMDS_ElementChunk::Free(), SMDS_MeshElement::GetID(), SMDS_MeshElement::GetVtkID(), SMDS_MeshElement::myHolder, myMesh, myNbUsedElements, mySmdsIDs, myVtkIDs, and SMDS_Mesh::setMyModified().
Referenced by Compact(), SMDS_NodeFactory::Compact(), SMDS_Mesh::RemoveElement(), and SMDS_Mesh::RemoveFreeElement().
smIdType SMDS_ElementFactory::FromVtkToSmds | ( | vtkIdType | vtkID | ) |
Return an SMDS ID by a Vtk one.
[in] | vtkID | - Vtk ID |
References mySmdsIDs.
Referenced by SMDS_Mesh::FromVtkToSmds().
smIdType SMDS_ElementFactory::GetFreeID | ( | ) |
Return minimal ID of a non-used element.
References SMDS_ElementChunk::GetUnusedID(), myChunks, myChunksWithUnused, and SMDS_ElementChunk.
Referenced by SMDS_Mesh::Add0DElement(), SMDS_Mesh::AddBall(), SMDS_Mesh::AddEdge(), SMDS_Mesh::AddFace(), SMDS_Mesh::AddFaceFromVtkIds(), SMDS_Mesh::AddNode(), SMDS_Mesh::AddPolygonalFace(), SMDS_Mesh::AddPolyhedralVolume(), SMDS_Mesh::AddQuadPolygonalFace(), SMDS_Mesh::AddVolume(), and SMDS_Mesh::AddVolumeFromVtkIds().
boost::shared_ptr< ElemIterator > SMDS_ElementFactory::GetIterator | ( | SMDS_MeshElement::Filter * | filter, |
size_t | nbElemsToReturn = -1 |
||
) |
Return an iterator on all element filtered using a given filter.
References SMDS_ElementChunk::GetUsedRangesMinMax(), and myChunks.
Referenced by SMDS_Mesh::edgesIterator(), SMDS_Mesh::elementEntityIterator(), SMDS_Mesh::elementGeomIterator(), SMDS_Mesh::elementsIterator(), SMDS_Mesh::facesIterator(), SMDS_Mesh::nodesIterator(), and SMDS_Mesh::volumesIterator().
smIdType SMDS_ElementFactory::GetMaxID | ( | ) |
Return maximal ID of an used element.
References myChunks.
Referenced by Compact(), SMDS_NodeFactory::Compact(), CompactChangePointers(), SMDS_NodeFactory::CompactChangePointers(), SMDS_Mesh::CompactMesh(), SMDS_Mesh::MaxElementID(), and SMDS_Mesh::MaxNodeID().
smIdType SMDS_ElementFactory::GetMinID | ( | ) |
Return minimal ID of an used element.
References myChunks.
Referenced by SMDS_Mesh::MinElementID(), and SMDS_Mesh::MinNodeID().
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().
smIdType SMDS_ElementFactory::NbUsedElements | ( | ) | const |
Return a number of used elements.
References myNbUsedElements.
Referenced by Compact(), SMDS_NodeFactory::Compact(), CompactChangePointers(), SMDS_NodeFactory::CompactChangePointers(), and SMDS_Mesh::CompactMesh().
SMDS_MeshCell* SMDS_ElementFactory::NewCell | ( | const smIdType | id | ) |
Return a SMDS_MeshCell by ID. NULL if the cell with the given ID is already used.
References NewElement().
Referenced by SMDS_Mesh::Add0DElementWithID(), SMDS_Mesh::AddEdgeWithID(), SMDS_Mesh::AddFaceFromVtkIds(), SMDS_Mesh::AddFaceWithID(), SMDS_Mesh::AddPolygonalFaceWithID(), SMDS_Mesh::AddPolyhedralVolumeWithID(), SMDS_Mesh::AddQuadPolygonalFaceWithID(), SMDS_Mesh::AddVolumeFromVtkIds(), and SMDS_Mesh::AddVolumeWithID().
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
[in] | id | - element ID |
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().
void SMDS_ElementFactory::SetAllNotMarked | ( | ) |
Clear marked flag of all elements.
References myChunks.
Referenced by SMDS_Mesh::SetAllCellsNotMarked(), and SMDS_Mesh::SetAllNodesNotMarked().
|
friend |
Referenced by GetFreeID(), and NewElement().
|
protected |
|
protected |
|
protected |
Referenced by SMDS_ElementChunk::SMDS_ElementChunk().
|
protected |
Referenced by SMDS_NodeFactory::Compact(), Free(), SMDS_ElementChunk::GetMesh(), and NewElement().
|
protected |
Referenced by Clear(), Free(), NbUsedElements(), and NewElement().
|
protected |
Referenced by Clear(), Compact(), Free(), FromVtkToSmds(), and SMDS_ElementChunk::SetVTKID().
|
protected |
Referenced by Clear(), Compact(), Free(), SMDS_ElementChunk::GetVtkID(), and SMDS_ElementChunk::SetVTKID().