Version: 6.3.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends

SMDS_DownTetra Class Reference

#include <SMDS_Downward.hxx>

Inheritance diagram for SMDS_DownTetra:
Inheritance graph
[legend]

Public Member Functions

virtual void getOrderedNodesOfFace (int cellId, std::vector< vtkIdType > &orderedNodes)
virtual int getNumberOfUpCells (int cellId)
virtual const intgetUpCells (int cellId)
virtual const unsigned char * getUpTypes (int cellId)
virtual void getNodeIds (int cellId, std::set< int > &nodeSet)
virtual int getNumberOfDownCells (int cellId)
 Get the number of downward entities associated to a cell (always the same for a given vtk type of cell)
virtual const intgetDownCells (int cellId)
 get a pointer on the downward entities id's associated to a cell.
virtual const unsigned char * getDownTypes (int cellId)
 get a list of vtk cell types associated to downward entities of a given cell, in the same order than the downward entities id's list (
virtual int getNodes (int cellId, int *nodevec)
int getVtkCellId (int cellId)
int getMaxId ()

Static Public Member Functions

static int getCellDimension (unsigned char cellType)
 get the dimension of a cell (1,2,3 for 1D, 2D 3D) given the vtk cell type

Protected Member Functions

 SMDS_DownTetra (SMDS_UnstructuredGrid *grid)
 ~SMDS_DownTetra ()
virtual void addDownCell (int cellId, int lowCellId, unsigned char aType)
 Id's are downward connectivity id's.
virtual void computeFacesWithNodes (int cellId, ListElemByNodesType &facesWithNodes)
 Create a list of faces described by a vtk Type and an ordered set of Node Id's The linear tetrahedron is defined by four points.
virtual void allocate (int nbElems)
virtual void compactStorage ()
int FindFaceByNodes (int cellId, ElemByNodesType &faceByNodes)
int addCell (int vtkId=-1)
 Give or create an entry for downward connectivity structure relative to a cell.
virtual void initCell (int cellId)
 generic method do nothing.
virtual void addUpCell (int cellId, int upCellId, unsigned char aType)
 Id's are downward connectivity id's.
virtual int getNodeSet (int cellId, int *nodeSet)

Protected Attributes

SMDS_UnstructuredGrid_grid
int _maxId
int _nbDownCells
 the same number for all cells of a derived class
std::vector< int_cellIds
 growing size: all the down cell id's, size = _maxId * _nbDownCells
std::vector< int_vtkCellIds
 growing size: size = _maxId, either vtkId or -1
std::vector< unsigned char > _cellTypes
 fixed size: the same vector for all cells of a derived class

Static Protected Attributes

static std::vector< int_cellDimension
 conversion table: type --> dimension

Friends

class SMDS_UnstructuredGrid

Detailed Description

Definition at line 269 of file SMDS_Downward.hxx.


Constructor & Destructor Documentation

SMDS_DownTetra::SMDS_DownTetra ( SMDS_UnstructuredGrid grid) [protected]

Definition at line 1119 of file SMDS_Downward.cxx.

References SMDS_Downward._cellTypes.

                                                          :
  SMDS_Down3D(grid, 4)
{
  _cellTypes.push_back(VTK_TRIANGLE);
  _cellTypes.push_back(VTK_TRIANGLE);
  _cellTypes.push_back(VTK_TRIANGLE);
  _cellTypes.push_back(VTK_TRIANGLE);
}
SMDS_DownTetra::~SMDS_DownTetra ( ) [protected]

Definition at line 1128 of file SMDS_Downward.cxx.

{
}

Member Function Documentation

int SMDS_Downward::addCell ( int  vtkId = -1) [protected, inherited]

Give or create an entry for downward connectivity structure relative to a cell.

If the entry already exists, just return its id, otherwise, create it. The internal storage memory is allocated if needed. The SMDS_UnstructuredGrid._cellIdToDownId vector is completed for vtkUnstructuredGrid cells.

Parameters:
vtkIdfor a vtkUnstructuredGrid cell or -1 (default) for a created downward cell.
Returns:
the rank in downward[vtkType] structure.

Definition at line 112 of file SMDS_Downward.cxx.

References SMDS_Downward._grid, SMDS_Downward._maxId, SMDS_Downward._vtkCellIds, SMDS_Downward.allocate(), SMDS_UnstructuredGrid.CellIdToDownId(), SMDS_Downward.initCell(), and SMDS_UnstructuredGrid.setCellIdToDownId().

{
  int localId = -1;
  if (vtkId >= 0)
    localId = _grid->CellIdToDownId(vtkId);
  if (localId >= 0)
    return localId;

  localId = this->_maxId;
  this->_maxId++;
  this->allocate(_maxId);
  if (vtkId >= 0)
    {
      this->_vtkCellIds[localId] = vtkId;
      _grid->setCellIdToDownId(vtkId, localId);
    }
  this->initCell(localId);
  return localId;
}
void SMDS_DownTetra::addDownCell ( int  cellId,
int  lowCellId,
unsigned char  aType 
) [protected, virtual]

Id's are downward connectivity id's.

add a downward entity of dimension n-1 (cell or node) to a given cell.

Actual implementation is done in derived methods.

Parameters:
cellIdindex of the parent cell (dimension n) in the downward structure relative to a vtk cell type.
lowCellIdindex of the children cell to add (dimension n-1)
aTypevtk cell type of the cell to add (needed to find the SMDS_Downward structure containing the cell to add).

Reimplemented from SMDS_Downward.

Definition at line 1164 of file SMDS_Downward.cxx.

References SMDS_Downward._cellIds, SMDS_Downward._nbDownCells, and ex21_lamp.faces.

{
  //ASSERT((cellId >=0)&& (cellId < _maxId));
  //ASSERT(aType == VTK_TRIANGLE);
  int *faces = &_cellIds[_nbDownCells * cellId];
  for (int i = 0; i < _nbDownCells; i++)
    {
      if (faces[i] < 0)
        {
          faces[i] = lowCellId;
          return;
        }
      if (faces[i] == lowCellId)
        return;
    }
  ASSERT(0);
}
void SMDS_Downward::addUpCell ( int  cellId,
int  upCellId,
unsigned char  aType 
) [protected, virtual, inherited]

Id's are downward connectivity id's.

add a downward entity of dimension n+1 to a given cell.

Actual implementation is done in derived methods.

Parameters:
cellIdindex of the children cell (dimension n) in the downward structure relative to a vtk cell type.
upCellIdindex of the parent cell to add (dimension n+1)
aTypevtk cell type of the cell to add (needed to find the SMDS_Downward structure containing the cell to add).

Reimplemented in SMDS_Down1D, and SMDS_Down2D.

Definition at line 190 of file SMDS_Downward.cxx.

{
  ASSERT(0); // must be re-implemented in derived class
}
void SMDS_Down3D::allocate ( int  nbElems) [protected, virtual, inherited]

Implements SMDS_Downward.

Definition at line 777 of file SMDS_Downward.cxx.

References SMDS_Downward._cellIds, SMDS_Downward._nbDownCells, SMDS_Downward._vtkCellIds, and SMDS_Mesh.chunkSize.

{
  if (nbElems >= _vtkCellIds.size())
    {
      _cellIds.resize(_nbDownCells * (nbElems + SMDS_Mesh::chunkSize), -1);
      _vtkCellIds.resize(nbElems + SMDS_Mesh::chunkSize, -1);
    }
}
void SMDS_Down3D::compactStorage ( ) [protected, virtual, inherited]

Implements SMDS_Downward.

Definition at line 786 of file SMDS_Downward.cxx.

{
  // nothing to do, size was known before
}
void SMDS_DownTetra::computeFacesWithNodes ( int  cellId,
ListElemByNodesType facesWithNodes 
) [protected, virtual]

Create a list of faces described by a vtk Type and an ordered set of Node Id's The linear tetrahedron is defined by four points.

See also:
vtkTetra.h in Filtering.
Parameters:
cellIdvolumeId in vtkUnstructuredGrid
facesWithNodesvector of face descriptors to be filled

Implements SMDS_Down3D.

Definition at line 1188 of file SMDS_Downward.cxx.

References SMDS_Downward._grid, ListElemByNodesType.elems, ListElemByNodesType.nbElems, ElemByNodesType.nbNodes, ElemByNodesType.nodeIds, SMESH_AdvancedEditor.nodes, and ElemByNodesType.vtkType.

{
  // --- find point id's of the volume

  vtkIdType npts = 0;
  vtkIdType *nodes; // will refer to the point id's of the volume
  _grid->GetCellPoints(cellId, npts, nodes);

  // --- create all the ordered list of node id's for each face

  facesWithNodes.nbElems = 4;

  facesWithNodes.elems[0].nodeIds[0] = nodes[0];
  facesWithNodes.elems[0].nodeIds[1] = nodes[1];
  facesWithNodes.elems[0].nodeIds[2] = nodes[2];
  facesWithNodes.elems[0].nbNodes = 3;
  facesWithNodes.elems[0].vtkType = VTK_TRIANGLE;

  facesWithNodes.elems[1].nodeIds[0] = nodes[0];
  facesWithNodes.elems[1].nodeIds[1] = nodes[1];
  facesWithNodes.elems[1].nodeIds[2] = nodes[3];
  facesWithNodes.elems[1].nbNodes = 3;
  facesWithNodes.elems[1].vtkType = VTK_TRIANGLE;

  facesWithNodes.elems[2].nodeIds[0] = nodes[0];
  facesWithNodes.elems[2].nodeIds[1] = nodes[2];
  facesWithNodes.elems[2].nodeIds[2] = nodes[3];
  facesWithNodes.elems[2].nbNodes = 3;
  facesWithNodes.elems[2].vtkType = VTK_TRIANGLE;

  facesWithNodes.elems[3].nodeIds[0] = nodes[1];
  facesWithNodes.elems[3].nodeIds[1] = nodes[2];
  facesWithNodes.elems[3].nodeIds[2] = nodes[3];
  facesWithNodes.elems[3].nbNodes = 3;
  facesWithNodes.elems[3].vtkType = VTK_TRIANGLE;
}
int SMDS_Down3D::FindFaceByNodes ( int  cellId,
ElemByNodesType faceByNodes 
) [protected, inherited]

Definition at line 816 of file SMDS_Downward.cxx.

References SMDS_Downward._cellIds, SMDS_Downward._cellTypes, SMDS_Downward._grid, SMDS_Downward._nbDownCells, ex21_lamp.faces, SMDS_UnstructuredGrid.getDownArray(), SMDS_Downward.getNodeSet(), ElemByNodesType.nbNodes, ElemByNodesType.nodeIds, SMESH_mechanic_editor.point, and ElemByNodesType.vtkType.

Referenced by SMDS_UnstructuredGrid.BuildDownwardConnectivity().

{
  int *faces = &_cellIds[_nbDownCells * cellId];
  int npoints = 0;

  for (int i = 0; i < _nbDownCells; i++)
    {
      if ((faces[i] >= 0) && (faceByNodes.vtkType == _cellTypes[i]))
        {
          if (npoints == 0)
            npoints = faceByNodes.nbNodes;

          int nodeSet[10];
          int npts = this->_grid->getDownArray(faceByNodes.vtkType)->getNodeSet(faces[i], nodeSet);
          if (npts != npoints)
            continue; // skip this face
          bool found = false;
          for (int j = 0; j < npts; j++)
            {
              int point = faceByNodes.nodeIds[j];
              found = false;
              for (int k = 0; k < npts; k++)
                {
                  if (nodeSet[k] == point)
                    {
                      found = true;
                      break; // point j is in the 2 faces, skip remaining k values
                    }
                }
              if (!found)
                break; // point j is not in the 2 faces, skip the remaining tests
            }
          if (found)
            return faces[i];
        }
    }
  return -1;
}
int SMDS_Downward::getCellDimension ( unsigned char  cellType) [static, inherited]

get the dimension of a cell (1,2,3 for 1D, 2D 3D) given the vtk cell type

Parameters:
cellTypevtk cell type
See also:
vtkCellType.h
Returns:
1,2 or 3

Definition at line 44 of file SMDS_Downward.cxx.

References VTK_MAXTYPE.

Referenced by SMDS_UnstructuredGrid.BuildDownwardConnectivity(), SMDS_Down1D.computeFaces(), SMDS_Down2D.computeVolumeIdsFromNodesFace(), SMDS_Down1D.computeVtkCells(), SMDS_UnstructuredGrid.GetNeighbors(), SMDS_UnstructuredGrid.getOrderedNodesOfFace(), and SMDS_UnstructuredGrid.GetParentVolumes().

{
  if (_cellDimension.empty())
    {
      _cellDimension.resize(VTK_MAXTYPE + 1, 0);
      _cellDimension[VTK_LINE] = 1;
      _cellDimension[VTK_QUADRATIC_EDGE] = 1;
      _cellDimension[VTK_TRIANGLE] = 2;
      _cellDimension[VTK_QUADRATIC_TRIANGLE] = 2;
      _cellDimension[VTK_QUAD] = 2;
      _cellDimension[VTK_QUADRATIC_QUAD] = 2;
      _cellDimension[VTK_TETRA] = 3;
      _cellDimension[VTK_QUADRATIC_TETRA] = 3;
      _cellDimension[VTK_HEXAHEDRON] = 3;
      _cellDimension[VTK_QUADRATIC_HEXAHEDRON] = 3;
      _cellDimension[VTK_WEDGE] = 3;
      _cellDimension[VTK_QUADRATIC_WEDGE] = 3;
      _cellDimension[VTK_PYRAMID] = 3;
      _cellDimension[VTK_QUADRATIC_PYRAMID] = 3;
    }
  return _cellDimension[cellType];
}
const int * SMDS_Downward::getDownCells ( int  cellId) [virtual, inherited]

get a pointer on the downward entities id's associated to a cell.

See also:
SMDS_Downward.getNumberOfDownCells for the number of downward entities.
SMDS_Downward.getDownTypes for the vtk cell types associated to the downward entities.
Parameters:
cellIdindex of the cell in the downward structure relative to a given vtk cell type.
Returns:
table of downward entities id's.

Definition at line 156 of file SMDS_Downward.cxx.

References SMDS_Downward._cellIds, and SMDS_Downward._nbDownCells.

Referenced by SMDS_Down1D.computeFaces(), and SMESH_MeshEditor.DoubleNodesOnGroupBoundaries().

{
  //ASSERT((cellId >=0) && (cellId < _maxId));
  return &_cellIds[_nbDownCells * cellId];
}
const unsigned char * SMDS_Downward::getDownTypes ( int  cellId) [virtual, inherited]

get a list of vtk cell types associated to downward entities of a given cell, in the same order than the downward entities id's list (

See also:
SMDS_Downward.getDownCells).
Parameters:
cellIdindex of the cell in the downward structure relative to a vtk cell type.
Returns:
table of downward entities types.

Definition at line 168 of file SMDS_Downward.cxx.

References SMDS_Downward._cellTypes.

Referenced by SMDS_Down1D.computeFaces(), and SMESH_MeshEditor.DoubleNodesOnGroupBoundaries().

{
  return &_cellTypes[0];
}
int SMDS_Downward.getMaxId ( ) [inherited]

Definition at line 85 of file SMDS_Downward.hxx.

References SMDS_Downward._maxId.

Referenced by SMDS_UnstructuredGrid.BuildDownwardConnectivity().

  {
    return _maxId;
  }
void SMDS_Down3D::getNodeIds ( int  cellId,
std::set< int > &  nodeSet 
) [virtual, inherited]

Implements SMDS_Downward.

Definition at line 806 of file SMDS_Downward.cxx.

References SMDS_Downward._grid, SMDS_Downward._vtkCellIds, and SMESH_AdvancedEditor.nodes.

{
  int vtkId = this->_vtkCellIds[cellId];
  vtkIdType npts = 0;
  vtkIdType *nodes; // will refer to the point id's of the volume
  _grid->GetCellPoints(vtkId, npts, nodes);
  for (int i = 0; i < npts; i++)
    nodeSet.insert(nodes[i]);
}
virtual int SMDS_Downward.getNodes ( int  cellId,
int nodevec 
) [virtual, inherited]

Reimplemented in SMDS_Down1D.

Definition at line 80 of file SMDS_Downward.hxx.

Referenced by SMESH_MeshEditor.DoubleNodesOnGroupBoundaries().

{return 0; }
int SMDS_Downward::getNodeSet ( int  cellId,
int nodeSet 
) [protected, virtual, inherited]

Reimplemented in SMDS_Down1D, and SMDS_Down2D.

Definition at line 195 of file SMDS_Downward.cxx.

Referenced by SMDS_Down2D.FindEdgeByNodes(), and SMDS_Down3D.FindFaceByNodes().

{
  return 0;
}
int SMDS_Downward::getNumberOfDownCells ( int  cellId) [virtual, inherited]

Get the number of downward entities associated to a cell (always the same for a given vtk type of cell)

Parameters:
cellIdnot used here.
Returns:

Definition at line 145 of file SMDS_Downward.cxx.

References SMDS_Downward._nbDownCells.

Referenced by SMDS_Down1D.computeFaces(), and SMESH_MeshEditor.DoubleNodesOnGroupBoundaries().

{
  return _nbDownCells;
}
int SMDS_Down3D::getNumberOfUpCells ( int  cellId) [virtual, inherited]

Implements SMDS_Downward.

Definition at line 791 of file SMDS_Downward.cxx.

{
  return 0;
}
void SMDS_DownTetra::getOrderedNodesOfFace ( int  cellId,
std::vector< vtkIdType > &  orderedNodes 
) [virtual]

Implements SMDS_Down3D.

Definition at line 1132 of file SMDS_Downward.cxx.

References SMDS_Downward._grid, SMDS_UnstructuredGrid._mesh, SMDS_Downward._vtkCellIds, SMDS_Mesh.fromVtkToSmds(), SMESH_test.ids, MESSAGE, and SMESH_AdvancedEditor.nodes.

{
  set<int> setNodes;
  setNodes.clear();
  for (int i = 0; i < orderedNodes.size(); i++)
    setNodes.insert(orderedNodes[i]);
  //MESSAGE("cellId = " << cellId);

  vtkIdType npts = 0;
  vtkIdType *nodes; // will refer to the point id's of the volume
  _grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

  set<int> tofind;
  int ids[12] = { 0, 1, 2,  0, 3, 1,  2, 3, 0,   1, 3, 2 };
//int ids[12] = { 2, 1, 0,  1, 3, 0,  0, 3, 2,   2, 3, 1 };
  for (int k = 0; k < 4; k++)
    {
      tofind.clear();
      for (int i = 0; i < 3; i++)
        tofind.insert(nodes[ids[3 * k + i]]);
      if (setNodes == tofind)
        {
          for (int i = 0; i < 3; i++)
            orderedNodes[i] = nodes[ids[3 * k + i]];
          return;
        }
    }
  MESSAGE("=== Problem volume " << _vtkCellIds[cellId] << " " << _grid->_mesh->fromVtkToSmds(_vtkCellIds[cellId]));
  MESSAGE(orderedNodes[0] << " " << orderedNodes[1] << " " << orderedNodes[2]);
  MESSAGE(nodes[0] << " " << nodes[1] << " " << nodes[2] << " " << nodes[3]);
}
const int * SMDS_Down3D::getUpCells ( int  cellId) [virtual, inherited]

Implements SMDS_Downward.

Definition at line 796 of file SMDS_Downward.cxx.

{
  return 0;
}
const unsigned char * SMDS_Down3D::getUpTypes ( int  cellId) [virtual, inherited]

Implements SMDS_Downward.

Definition at line 801 of file SMDS_Downward.cxx.

{
  return 0;
}
int SMDS_Downward.getVtkCellId ( int  cellId) [inherited]

Definition at line 81 of file SMDS_Downward.hxx.

References SMDS_Downward._vtkCellIds.

  {
    return _vtkCellIds[cellId];
  }
void SMDS_Downward::initCell ( int  cellId) [protected, virtual, inherited]

generic method do nothing.

see derived methods

Parameters:
cellId

Reimplemented in SMDS_Down1D.

Definition at line 136 of file SMDS_Downward.cxx.

Referenced by SMDS_Downward.addCell().

{
}

Friends And Related Function Documentation

friend class SMDS_UnstructuredGrid [friend]

Reimplemented from SMDS_Down3D.

Definition at line 271 of file SMDS_Downward.hxx.


Field Documentation

vector< int > SMDS_Downward::_cellDimension [static, protected, inherited]

conversion table: type --> dimension

Definition at line 108 of file SMDS_Downward.hxx.

Referenced by SMDS_Downward.SMDS_Downward().

std::vector<int> SMDS_Downward._cellIds [protected, inherited]
std::vector<unsigned char> SMDS_Downward._cellTypes [protected, inherited]
SMDS_UnstructuredGrid* SMDS_Downward._grid [protected, inherited]
int SMDS_Downward._maxId [protected, inherited]
int SMDS_Downward._nbDownCells [protected, inherited]
std::vector<int> SMDS_Downward._vtkCellIds [protected, inherited]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS