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

SMDS_MeshElementIDFactory Class Reference

#include <SMDS_MeshElementIDFactory.hxx>

Inheritance diagram for SMDS_MeshElementIDFactory:
Inheritance graph
[legend]

Public Member Functions

 SMDS_MeshElementIDFactory ()
bool BindID (int ID, SMDS_MeshElement *elem)
int SetInVtkGrid (SMDS_MeshElement *elem)
SMDS_MeshElementMeshElement (int ID)
virtual int GetFreeID ()
virtual void ReleaseID (int ID, int vtkId=-1)
SMDS_ElemIteratorPtr elementsIterator () const
virtual void Clear ()
int GetVtkCellType (int SMDSType)
int GetMaxID () const
int GetMinID () const
virtual void emptyPool (int maxId)
void SetMesh (SMDS_Mesh *mesh)
SMDS_MeshGetMesh ()
bool isPoolIdEmpty ()
void adjustMaxId (int ID)

Protected Member Functions

void updateMinMax () const
void updateMinMax (int id) const

Protected Attributes

std::vector< intmyVtkCellTypes
int myMin
int myMax
int myMaxID
std::set< intmyPoolOfID
SMDS_MeshmyMesh

Friends

class SMDS_Mesh

Detailed Description

Definition at line 39 of file SMDS_MeshElementIDFactory.hxx.


Constructor & Destructor Documentation

SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory ( )

Definition at line 49 of file SMDS_MeshElementIDFactory.cxx.

References myVtkCellTypes, SMDSEntity_0D, SMDSEntity_Edge, SMDSEntity_Hexa, SMDSEntity_Last, SMDSEntity_Node, SMDSEntity_Penta, SMDSEntity_Polygon, SMDSEntity_Polyhedra, SMDSEntity_Pyramid, SMDSEntity_Quad_Edge, SMDSEntity_Quad_Hexa, SMDSEntity_Quad_Penta, SMDSEntity_Quad_Polygon, SMDSEntity_Quad_Polyhedra, SMDSEntity_Quad_Pyramid, SMDSEntity_Quad_Quadrangle, SMDSEntity_Quad_Tetra, SMDSEntity_Quad_Triangle, SMDSEntity_Quadrangle, SMDSEntity_Tetra, and SMDSEntity_Triangle.

                                                    :
  SMDS_MeshNodeIDFactory()
{
//    myIDElements.clear();
//    myVtkIndex.clear();
    myVtkCellTypes.clear();
    myVtkCellTypes.reserve(SMDSEntity_Last);
    myVtkCellTypes[SMDSEntity_Node]            = VTK_VERTEX;
    myVtkCellTypes[SMDSEntity_0D]              = VTK_VERTEX;
    myVtkCellTypes[SMDSEntity_Edge]            = VTK_LINE;
    myVtkCellTypes[SMDSEntity_Quad_Edge]       = VTK_QUADRATIC_EDGE;
    myVtkCellTypes[SMDSEntity_Triangle]        = VTK_TRIANGLE;
    myVtkCellTypes[SMDSEntity_Quad_Triangle]   = VTK_QUADRATIC_TRIANGLE;
    myVtkCellTypes[SMDSEntity_Quadrangle]      = VTK_QUAD;
    myVtkCellTypes[SMDSEntity_Quad_Quadrangle] = VTK_QUADRATIC_TRIANGLE;
    myVtkCellTypes[SMDSEntity_Polygon]         = VTK_POLYGON;
    myVtkCellTypes[SMDSEntity_Quad_Polygon]    = VTK_POLYGON; // -PR- verifer
    myVtkCellTypes[SMDSEntity_Tetra]           = VTK_TETRA;
    myVtkCellTypes[SMDSEntity_Quad_Tetra]      = VTK_QUADRATIC_TETRA;
    myVtkCellTypes[SMDSEntity_Pyramid]         = VTK_PYRAMID;
    myVtkCellTypes[SMDSEntity_Quad_Pyramid]    = VTK_CONVEX_POINT_SET;
    myVtkCellTypes[SMDSEntity_Hexa]            = VTK_HEXAHEDRON;
    myVtkCellTypes[SMDSEntity_Quad_Hexa]       = VTK_QUADRATIC_HEXAHEDRON;
    myVtkCellTypes[SMDSEntity_Penta]           = VTK_WEDGE;
    myVtkCellTypes[SMDSEntity_Quad_Penta]      = VTK_QUADRATIC_WEDGE;
//#ifdef VTK_HAVE_POLYHEDRON
    myVtkCellTypes[SMDSEntity_Polyhedra]       = VTK_POLYHEDRON;
//#else
//    myVtkCellTypes[SMDSEntity_Polyhedra]       = VTK_CONVEX_POINT_SET;
//#endif
    myVtkCellTypes[SMDSEntity_Quad_Polyhedra]  = VTK_CONVEX_POINT_SET;
}

Member Function Documentation

void SMDS_MeshIDFactory.adjustMaxId ( int  ID) [inherited]

Definition at line 48 of file SMDS_MeshIDFactory.hxx.

Referenced by SMDS_Mesh.AddNodeWithID().

{ if (ID > myMaxID) myMaxID = ID;};
bool SMDS_MeshElementIDFactory::BindID ( int  ID,
SMDS_MeshElement elem 
)

Reimplemented from SMDS_MeshNodeIDFactory.

Definition at line 113 of file SMDS_MeshElementIDFactory.cxx.

References MESSAGE, SMDS_MeshIDFactory.myMesh, SMDS_Mesh.registerElement(), and SetInVtkGrid().

Referenced by SMDS_Mesh.Add0DElementWithID().

{
  MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID);
  SetInVtkGrid(elem);
  return myMesh->registerElement(ID, elem);
}
void SMDS_MeshElementIDFactory::Clear ( ) [virtual]
SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator ( ) const
void SMDS_MeshNodeIDFactory::emptyPool ( int  maxId) [virtual, inherited]

Reimplemented from SMDS_MeshIDFactory.

Definition at line 145 of file SMDS_MeshNodeIDFactory.cxx.

References SMDS_MeshNodeIDFactory.myMax.

Referenced by SMESHDS_Mesh.compactMesh().

{
  SMDS_MeshIDFactory::emptyPool(maxId);
  myMax = maxId;
}
int SMDS_MeshElementIDFactory::GetFreeID ( ) [virtual]
int SMDS_MeshNodeIDFactory::GetMaxID ( ) const [inherited]
SMDS_Mesh * SMDS_MeshIDFactory::GetMesh ( ) [inherited]

Definition at line 103 of file SMDS_MeshIDFactory.cxx.

References SMDS_MeshIDFactory.myMesh.

Referenced by SMDS_MeshNodeIDFactory.MeshElement(), and MeshElement().

{
        return myMesh;
}
int SMDS_MeshNodeIDFactory::GetMinID ( ) const [inherited]
int SMDS_MeshElementIDFactory::GetVtkCellType ( int  SMDSType)

Definition at line 213 of file SMDS_MeshElementIDFactory.cxx.

References myVtkCellTypes, and SMDSEntity_Last.

{
    assert((SMDSType >=0) && (SMDSType< SMDSEntity_Last));
    return myVtkCellTypes[SMDSType];
}
bool SMDS_MeshIDFactory.isPoolIdEmpty ( ) [inherited]

Definition at line 46 of file SMDS_MeshIDFactory.hxx.

{ return myPoolOfID.empty(); };
SMDS_MeshElement * SMDS_MeshElementIDFactory::MeshElement ( int  ID)

Reimplemented from SMDS_MeshNodeIDFactory.

Definition at line 124 of file SMDS_MeshElementIDFactory.cxx.

References SMDS_Mesh.FindElement(), SMDS_MeshIDFactory.GetMesh(), SMDS_Mesh.myCells, and SMDS_MeshIDFactory.myMesh.

Referenced by SMDS_Mesh.GetElementType(), and GetFreeID().

{
  if ((ID<1) || (ID>=myMesh->myCells.size()))
    return NULL;
  const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
  return (SMDS_MeshElement*)(elem);
}
void SMDS_MeshElementIDFactory::ReleaseID ( int  ID,
int  vtkId = -1 
) [virtual]

Reimplemented from SMDS_MeshNodeIDFactory.

Definition at line 150 of file SMDS_MeshElementIDFactory.cxx.

References MESSAGE, SMDS_Mesh.myCellIdVtkToSmds, SMDS_MeshNodeIDFactory.myMax, SMDS_MeshIDFactory.myMesh, SMDS_MeshNodeIDFactory.myMin, and SMDS_Mesh.setMyModified().

Referenced by SMDS_Mesh.AddVolume(), SMDS_Mesh.AddVolumeFromVtkIds(), SMDS_Mesh.Clear(), SMDS_Mesh.RemoveElement(), SMDS_Mesh.RemoveFreeElement(), and SMDS_Mesh.~SMDS_Mesh().

{
  if (ID < 1) // TODO check case ID == O
    {
      MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
      return;
    }
  //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
  if (vtkId >= 0)
    {
      assert(vtkId < myMesh->myCellIdVtkToSmds.size());
      myMesh->myCellIdVtkToSmds[vtkId] = -1;
      myMesh->setMyModified();
    }
  SMDS_MeshIDFactory::ReleaseID(ID);
  if (ID == myMax)
    myMax = 0;
  if (ID == myMin)
    myMax = 0;
}
int SMDS_MeshElementIDFactory::SetInVtkGrid ( SMDS_MeshElement elem)

Definition at line 82 of file SMDS_MeshElementIDFactory.cxx.

References SMDS_Mesh.getGrid(), SMDS_MeshElement.getVtkId(), ex11_grid3partition.grid, MESSAGE, SMDS_MeshIDFactory.myMesh, SMDS_MeshElement.nodesIterator(), and SMDS_MeshElement.setVtkId().

Referenced by BindID(), and SMDS_Mesh.registerElement().

{
   // --- retrieve nodes ID

  SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
  assert(cell);
  vector<vtkIdType> nodeIds;
  SMDS_ElemIteratorPtr it = elem->nodesIterator();
  while(it->more())
  {
      int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId();
      MESSAGE("   node in cell " << cell->getVtkId() << " : " << nodeId)
      nodeIds.push_back(nodeId);
  }

  // --- insert cell in vtkUnstructuredGrid

  vtkUnstructuredGrid * grid = myMesh->getGrid();
  //int locType = elem->GetType();
  int typ = VTK_VERTEX;//GetVtkCellType(locType);
  int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
  cell->setVtkId(cellId); 
  //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
  return cellId;
}
void SMDS_MeshIDFactory::SetMesh ( SMDS_Mesh mesh) [inherited]

Definition at line 98 of file SMDS_MeshIDFactory.cxx.

References PAL_MESH_041_mesh.mesh, and SMDS_MeshIDFactory.myMesh.

Referenced by SMDS_Mesh.SMDS_Mesh().

{
        myMesh = mesh;
}
void SMDS_MeshElementIDFactory.updateMinMax ( int  id) const [protected]

Reimplemented from SMDS_MeshNodeIDFactory.

Definition at line 56 of file SMDS_MeshElementIDFactory.hxx.

  {
    if (id > myMax) myMax = id;
    if (id < myMin) myMin = id;
  }
void SMDS_MeshElementIDFactory::updateMinMax ( ) const [protected]

Reimplemented from SMDS_MeshNodeIDFactory.

Definition at line 176 of file SMDS_MeshElementIDFactory.cxx.

References SMDS_Mesh.myCells, SMDS_MeshNodeIDFactory.myMax, SMDS_MeshIDFactory.myMesh, and SMDS_MeshNodeIDFactory.myMin.

Referenced by SMDS_Mesh.registerElement().

{
  myMin = INT_MAX;
  myMax = 0;
  for (int i = 0; i < myMesh->myCells.size(); i++)
    {
      if (myMesh->myCells[i])
        {
          int id = myMesh->myCells[i]->GetID();
          if (id > myMax)
            myMax = id;
          if (id < myMin)
            myMin = id;
        }
    }
  if (myMin == INT_MAX)
    myMin = 0;
}

Friends And Related Function Documentation

friend class SMDS_Mesh [friend]

Definition at line 42 of file SMDS_MeshElementIDFactory.hxx.


Field Documentation

int SMDS_MeshNodeIDFactory.myMax [mutable, protected, inherited]
int SMDS_MeshIDFactory.myMaxID [protected, inherited]
SMDS_Mesh* SMDS_MeshIDFactory.myMesh [protected, inherited]
int SMDS_MeshNodeIDFactory.myMin [mutable, protected, inherited]
std::set<int> SMDS_MeshIDFactory.myPoolOfID [protected, inherited]

Definition at line 62 of file SMDS_MeshElementIDFactory.hxx.

Referenced by GetVtkCellType(), and SMDS_MeshElementIDFactory().

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