+SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
+ SMDS_MeshNodeIDFactory()
+{
+}
+
+int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
+{
+ // --- 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;
+}
+
+//=======================================================================
+//function : BindID
+//purpose :
+//=======================================================================
+
+bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+{
+ MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID);
+ SetInVtkGrid(elem);
+ return myMesh->registerElement(ID, elem);
+}
+
+//=======================================================================
+//function : MeshElement
+//purpose :
+//=======================================================================
+SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
+{
+ if ((ID<1) || (ID>=myMesh->myCells.size()))
+ return NULL;
+ const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
+ return (SMDS_MeshElement*)(elem);
+}
+
+//=======================================================================
+//function : GetFreeID
+//purpose :
+//=======================================================================
+
+int SMDS_MeshElementIDFactory::GetFreeID()
+{
+ int ID;
+ do {
+ ID = SMDS_MeshIDFactory::GetFreeID();
+ } while ( MeshElement( ID ));
+ return ID;
+}
+
+//=======================================================================
+//function : ReleaseID
+//purpose :
+//=======================================================================
+void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
+{
+ 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;
+}
+
+//=======================================================================
+//function : updateMinMax
+//purpose :
+//=======================================================================