Version: 9.16.0
SMDS_UnstructuredGrid Class Reference

This class extends vtkUnstructuredGrid to deal with downward connectivity. More...

#include <SMDS_UnstructuredGrid.hxx>

Inheritance diagram for SMDS_UnstructuredGrid:

Public Member Functions

void setSMDS_mesh (SMDS_Mesh *mesh)
 
void compactGrid (std::vector< smIdType > &idNodesOldToNew, smIdType newNodeSize, std::vector< smIdType > &idCellsOldToNew, smIdType newCellSize)
 
virtual vtkMTimeType GetMTime ()
 
virtual vtkPoints * GetPoints ()
 
vtkIdType InsertNextLinkedCell (int type, int npts, vtkIdType *pts)
 
int CellIdToDownId (vtkIdType vtkCellId)
 
void setCellIdToDownId (vtkIdType vtkCellId, int downId)
 
void CleanDownwardConnectivity ()
 
void BuildDownwardConnectivity (bool withEdges)
 Build downward connectivity: to do only when needed because heavy memory load. More...
 
int GetNeighbors (int *neighborsVtkIds, int *downIds, unsigned char *downTypes, int vtkId, bool getSkin=false)
 Get the neighbors of a cell. More...
 
int GetParentVolumes (int *volVtkIds, int vtkId)
 get the volumes containing a face or an edge of the grid The edge or face belongs to the vtkUnstructuredGrid More...
 
int GetParentVolumes (int *volVtkIds, int downId, unsigned char downType)
 get the volumes containing a face or an edge of the downward structure The edge or face does not necessary belong to the vtkUnstructuredGrid More...
 
void GetNodeIds (std::set< int > &nodeSet, int downId, unsigned char downType)
 get the node id's of a cell. More...
 
void ModifyCellNodes (int vtkVolId, std::map< int, int > localClonedNodeIds)
 change some nodes in cell without modifying type or internal connectivity. More...
 
int getOrderedNodesOfFace (int vtkVolId, int &dim, std::vector< vtkIdType > &orderedNodes)
 reorder the nodes of a face More...
 
SMDS_MeshCellextrudeVolumeFromFace (int vtkVolId, int domain1, int domain2, std::set< int > &originalNodes, std::map< int, std::map< int, int > > &nodeDomains, std::map< int, std::map< long, int > > &nodeQuadDomains)
 Create a volume (prism or hexahedron) by duplication of a face. More...
 
void BuildLinks ()
 
void DeleteLinks ()
 
SMDS_CellLinksGetLinks ()
 
bool HasLinks () const
 
SMDS_DownwardgetDownArray (unsigned char vtkType)
 
void AllocateDiameters (vtkIdType maxVtkID)
 Allocates data array for ball diameters. More...
 
void SetBallDiameter (vtkIdType vtkID, double diameter)
 Sets diameter of a ball element. More...
 
double GetBallDiameter (vtkIdType vtkID) const
 Returns diameter of a ball element. More...
 

Static Public Member Functions

static SMDS_UnstructuredGridNew ()
 

Data Fields

SMDS_Mesh_mesh
 

Protected Member Functions

 SMDS_UnstructuredGrid ()
 
 ~SMDS_UnstructuredGrid ()
 
void copyNodes (vtkPoints *newPoints, std::vector< smIdType > &idNodesOldToNew, vtkIdType &alreadyCopied, vtkIdType start, vtkIdType end)
 
void copyBloc (vtkUnsignedCharArray *newTypes, const std::vector< smIdType > &idCellsOldToNew, const std::vector< smIdType > &idNodesOldToNew, vtkCellArray *newConnectivity, vtkIdTypeArray *newLocations, std::vector< vtkIdType > &pointsCell)
 

Protected Attributes

std::vector< int > _cellIdToDownId
 convert vtk Id to downward[vtkType] id, initialized with -1 More...
 
std::vector< unsigned char > _downTypes
 
std::vector< SMDS_Downward * > _downArray
 

Detailed Description

This class extends vtkUnstructuredGrid to deal with downward connectivity.

Use method BuildDownwardConnectivity to build downward connectivity and CleanDownwardConnectivity() to clean it. The downward connectivity takes up a lot of memory, so, build it only when necessary and clean after usage.

Downward connectivity is no more valid if vtkUnstructuredGrid is modified.

Built downward connectivity is kept in std::vector<SMDS_Downward*> _downArray; Vector item #i stores connectivity of all elements of VTK type i.

As vtkUnstructuredGrid has elements and nodes numbering different from the SMDS one, here are the methods to convert IDs between VTK and SMDS:

  1. vtkId -> smId (nodes and elements) smIdType SMDS_Mesh::FromVtkToSmds(vtkIdType)
  2. smId -> vtkId (elements) SMDS_MeshElement* SMDS_Mesh::FindElement(smIdType) vtkIdType SMDS_MeshElement::GetVtkID()
  3. smId -> vtkId (nodes) SMDS_MeshNode* SMDS_Mesh::FindNode(smIdType) vtkId = SMDS_MeshElement::GetVtkID()

And here are the way to convert between VTK IDs and downward connectivity indices:

  1. vtkId -> downId + vtkType int SMDS_UnstructuredGrid::CellIdToDownId(vtkIdType) int vtkUnstructuredGrid::GetCellType(vtkIdType)
  2. (downId + vtkType) -> vtkId SMDS_Downward* SMDS_UnstructuredGrid::getDownArray(unsigned char vtkType) int SMDS_Downward::getVtkCellId(int downId) Not all elements of downward connectivity can have corresponding VTK cells. -1 will be returned if there is no VTK cell.

Constructor & Destructor Documentation

◆ SMDS_UnstructuredGrid()

SMDS_UnstructuredGrid::SMDS_UnstructuredGrid ( )
protected

References _cellIdToDownId, _downArray, _downTypes, and _mesh.

Referenced by New().

◆ ~SMDS_UnstructuredGrid()

SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid ( )
protected

Member Function Documentation

◆ AllocateDiameters()

void SMDS_UnstructuredGrid::AllocateDiameters ( vtkIdType  MaxVtkID)

Allocates data array for ball diameters.

Parameters
MaxVtkID- max ID of a ball element

References SetBallDiameter().

Referenced by DriverMED_R_SMESHDS_Mesh::Perform().

◆ BuildDownwardConnectivity()

◆ BuildLinks()

void SMDS_UnstructuredGrid::BuildLinks ( )

◆ CellIdToDownId()

int SMDS_UnstructuredGrid::CellIdToDownId ( vtkIdType  vtkCellId)

◆ CleanDownwardConnectivity()

void SMDS_UnstructuredGrid::CleanDownwardConnectivity ( )

◆ compactGrid()

void SMDS_UnstructuredGrid::compactGrid ( std::vector< smIdType > &  idNodesOldToNew,
smIdType  newNodeSize,
std::vector< smIdType > &  idCellsOldToNew,
smIdType  newCellSize 
)

updateCells

References copyBloc(), copyNodes(), and DeleteLinks().

Referenced by SMDS_Mesh::CompactMesh().

◆ copyBloc()

void SMDS_UnstructuredGrid::copyBloc ( vtkUnsignedCharArray *  newTypes,
const std::vector< smIdType > &  idCellsOldToNew,
const std::vector< smIdType > &  idNodesOldToNew,
vtkCellArray *  newConnectivity,
vtkIdTypeArray *  newLocations,
std::vector< vtkIdType > &  pointsCell 
)
protected

Referenced by compactGrid().

◆ copyNodes()

void SMDS_UnstructuredGrid::copyNodes ( vtkPoints *  newPoints,
std::vector< smIdType > &  idNodesOldToNew,
vtkIdType &  alreadyCopied,
vtkIdType  start,
vtkIdType  end 
)
protected

References end().

Referenced by compactGrid().

◆ DeleteLinks()

void SMDS_UnstructuredGrid::DeleteLinks ( )

◆ extrudeVolumeFromFace()

SMDS_MeshCell * SMDS_UnstructuredGrid::extrudeVolumeFromFace ( int  vtkVolId,
int  domain1,
int  domain2,
std::set< int > &  originalNodes,
std::map< int, std::map< int, int > > &  nodeDomains,
std::map< int, std::map< long, int > > &  nodeQuadDomains 
)

Create a volume (prism or hexahedron) by duplication of a face.

Designed for use in creation of flat elements separating volume domains. A face separating two domains is shared by two volume cells. All the nodes are already created (for the two faces). Each original Node is associated to corresponding nodes in the domains. Some nodes may be duplicated for more than two domains, when domain separations intersect. In that case, even some of the nodes to use for the original face may be changed.

Parameters
vtkVolIdvtk id of a volume containing the face, to get an orientation for the face.
domain1domain of the original face
domain2domain of the duplicated face
originalNodesthe vtk node ids of the original face
nodeDomainsmap(original id --> map(domain --> duplicated node id))
Returns
ok if success.

References _mesh, SMDS_Mesh::AddFaceFromVtkIds(), SMDS_Mesh::AddNode(), SMDS_Mesh::AddVolumeFromVtkIds(), SMDS_MeshCell::applyInterlace(), SMDS_Mesh::FindElementVtk(), SMDS_Mesh::FindNodeVtk(), SMDS_MeshElement::GetNodeIndex(), getOrderedNodesOfFace(), SMDS_MeshElement::GetVtkID(), SMDS_MeshCell::reverseSmdsOrder(), SMDSEntity_Quad_Quadrangle, and SMDSEntity_Quadrangle.

Referenced by SMESH_MeshEditor::DoubleNodesOnGroupBoundaries().

◆ GetBallDiameter()

double SMDS_UnstructuredGrid::GetBallDiameter ( vtkIdType  vtkID) const

Returns diameter of a ball element.

Parameters
vtkID- vtk id of the ball element

Referenced by SMDS_BallElement::GetDiameter().

◆ getDownArray()

◆ GetLinks()

◆ GetMTime()

vtkMTimeType SMDS_UnstructuredGrid::GetMTime ( )
virtual

◆ GetNeighbors()

int SMDS_UnstructuredGrid::GetNeighbors ( int *  neighborsVtkIds,
int *  downIds,
unsigned char *  downTypes,
int  vtkId,
bool  getSkin = false 
)

Get the neighbors of a cell.

Only the neighbors having the dimension of the cell are taken into account (neighbors of a volume are the volumes sharing a face with this volume, neighbors of a face are the faces sharing an edge with this face...).

Parameters
neighborsVtkIdsvector of neighbors vtk id's to fill (reserve enough space).
downIdsdownward id's of cells of dimension n-1, to fill (reserve enough space).
downTypesvtk types of cells of dimension n-1, to fill (reserve enough space).
vtkIdthe vtk id of the cell
Returns
number of neighbors

References _cellIdToDownId, _downArray, SMDS_Downward::getCellDimension(), and NBMAXNEIGHBORS.

Referenced by SMESH_MeshEditor::CreateHoleSkin(), and SMESH_MeshEditor::DoubleNodesOnGroupBoundaries().

◆ GetNodeIds()

void SMDS_UnstructuredGrid::GetNodeIds ( std::set< int > &  nodeSet,
int  downId,
unsigned char  downType 
)

get the node id's of a cell.

The cell is defined by it's downward connectivity id and type.

Parameters
nodeSetset of of vtk node id's to fill.
downIddownward connectivity id of the cell.
downTypetype of cell.

References _downArray.

Referenced by SMESH_MeshEditor::DoubleNodesOnGroupBoundaries().

◆ getOrderedNodesOfFace()

int SMDS_UnstructuredGrid::getOrderedNodesOfFace ( int  vtkVolId,
int &  dim,
std::vector< vtkIdType > &  orderedNodes 
)

reorder the nodes of a face

Parameters
vtkVolIdvtk id of a volume containing the face, to get an orientation for the face.
orderedNodeslist of nodes to reorder (in out)
Returns
size of the list

References _cellIdToDownId, _downArray, SMDS_Downward::getCellDimension(), and SMDS_Downward::getOrderedNodesOfFace().

Referenced by extrudeVolumeFromFace().

◆ GetParentVolumes() [1/2]

int SMDS_UnstructuredGrid::GetParentVolumes ( int *  volVtkIds,
int  downId,
unsigned char  downType 
)

get the volumes containing a face or an edge of the downward structure The edge or face does not necessary belong to the vtkUnstructuredGrid

Parameters
volVtkIdsvector of parent volume ids to fill (reserve enough space!)
downIdid in the downward structure
downTypetype of cell

References _downArray, and SMDS_Downward::getCellDimension().

◆ GetParentVolumes() [2/2]

int SMDS_UnstructuredGrid::GetParentVolumes ( int *  volVtkIds,
int  vtkId 
)

get the volumes containing a face or an edge of the grid The edge or face belongs to the vtkUnstructuredGrid

Parameters
volVtkIdsvector of parent volume ids to fill (reserve enough space!)
vtkIdvtk id of the face or edge

References _downArray, CellIdToDownId(), SMDS_Downward::getCellDimension(), and MESSAGE.

Referenced by SMESH_MeshEditor::DoubleNodesOnGroupBoundaries().

◆ GetPoints()

vtkPoints * SMDS_UnstructuredGrid::GetPoints ( )
virtual

◆ HasLinks()

bool SMDS_UnstructuredGrid::HasLinks ( ) const

◆ InsertNextLinkedCell()

vtkIdType SMDS_UnstructuredGrid::InsertNextLinkedCell ( int  type,
int  npts,
vtkIdType *  pts 
)

◆ ModifyCellNodes()

void SMDS_UnstructuredGrid::ModifyCellNodes ( int  vtkVolId,
std::map< int, int >  localClonedNodeIds 
)

change some nodes in cell without modifying type or internal connectivity.

Nodes inverse connectivity is maintained up to date.

Parameters
vtkVolIdvtk id of the cell
localClonedNodeIdsmap old node id to new node id.

Referenced by SMESHDS_Mesh::ModifyCellNodes().

◆ New()

SMDS_UnstructuredGrid * SMDS_UnstructuredGrid::New ( )
static

◆ SetBallDiameter()

void SMDS_UnstructuredGrid::SetBallDiameter ( vtkIdType  vtkID,
double  diameter 
)

Sets diameter of a ball element.

Parameters
vtkID- vtk id of the ball element
diameter- diameter of the ball element

Referenced by AllocateDiameters(), SMDS_BallElement::init(), and SMDS_BallElement::SetDiameter().

◆ setCellIdToDownId()

void SMDS_UnstructuredGrid::setCellIdToDownId ( vtkIdType  vtkCellId,
int  downId 
)

References _cellIdToDownId.

Referenced by SMDS_Downward::addCell().

◆ setSMDS_mesh()

void SMDS_UnstructuredGrid::setSMDS_mesh ( SMDS_Mesh mesh)

References _mesh.

Referenced by SMDS_Mesh::SMDS_Mesh().

Field Documentation

◆ _cellIdToDownId

std::vector<int> SMDS_UnstructuredGrid::_cellIdToDownId
protected

◆ _downArray

◆ _downTypes

std::vector<unsigned char> SMDS_UnstructuredGrid::_downTypes
protected

Referenced by SMDS_UnstructuredGrid().

◆ _mesh