+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexahedron and add it to the mesh.
+///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges.
+///@return The created hexahedron
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6,
+ const SMDS_MeshNode * n7,
+ const SMDS_MeshNode * n8)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
+ if(v==NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexahedron and add it to the mesh.
+///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges.
+///@param ID The ID of the new volume
+///@return The created hexahedron or NULL if an element with this ID already
+///exists or if input nodes are not found.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1,
+ int idnode2,
+ int idnode3,
+ int idnode4,
+ int idnode5,
+ int idnode6,
+ int idnode7,
+ int idnode8,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6, *node7, *node8;
+ node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+ node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+ node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+ node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+ node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
+ node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
+ node7 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode7);
+ node8 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode8);
+ if(!node1 || !node2 || !node3 || !node4 || !node5 || !node6 || !node7 || !node8)
+ return NULL;
+ return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6,
+ node7, node8, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexahedron and add it to the mesh.
+///Nodes 1,2,3,4 and 5,6,7,8 are quadrangle and 5,1 and 7,3 are an edges.
+///@param ID The ID of the new volume
+///@return The created prism or NULL if an element with this ID already exists
+///or if input nodes are not found.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6,
+ const SMDS_MeshNode * n7,
+ const SMDS_MeshNode * n8,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume* volume = 0;
+ if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if(hasConstructionFaces()) {
+ SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
+ SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8);
+ SMDS_MeshFace * f3=FindFaceOrCreate(n1,n4,n8,n5);
+ SMDS_MeshFace * f4=FindFaceOrCreate(n1,n2,n6,n5);
+ SMDS_MeshFace * f5=FindFaceOrCreate(n2,n3,n7,n6);
+ SMDS_MeshFace * f6=FindFaceOrCreate(n3,n4,n8,n7);
+ volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbHexas++;
+ }
+ else if(hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else {
+ // --- retrieve nodes ID
+ myNodeIds.resize(8);
+ myNodeIds[0] = n1->getVtkId();
+ myNodeIds[1] = n4->getVtkId();
+ myNodeIds[2] = n3->getVtkId();
+ myNodeIds[3] = n2->getVtkId();
+ myNodeIds[4] = n5->getVtkId();
+ myNodeIds[5] = n8->getVtkId();
+ myNodeIds[6] = n7->getVtkId();
+ myNodeIds[7] = n6->getVtkId();
+
+ SMDS_VtkVolume *volvtk = myVolumePool->getNew();
+ volvtk->init(myNodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
+ volume = volvtk;
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbHexas++;
+ }
+
+ // if (!registerElement(ID, volume)) {
+ // RemoveElement(volume, false);
+ // volume = NULL;
+ // }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron defined by its faces and add it to the mesh.
+///@return The created tetrahedron
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4)
+{
+ //MESSAGE("AddVolumeWithID");
+ if (!hasConstructionFaces())
+ return NULL;
+ return AddVolumeWithID(f1,f2,f3,f4, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created tetrahedron
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ int ID)
+{
+ MESSAGE("AddVolumeWithID" << ID);
+ if (!hasConstructionFaces())
+ return NULL;
+ if ( !f1 || !f2 || !f3 || !f4) return 0;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbTetras++;
+
+ if (!registerElement(ID, volume)) {
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
+ }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid defined by its faces and add it to the mesh.
+///@return The created pyramid
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ const SMDS_MeshFace * f5)
+{
+ //MESSAGE("AddVolumeWithID");
+ if (!hasConstructionFaces())
+ return NULL;
+ return AddVolumeWithID(f1,f2,f3,f4,f5, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created pyramid
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ const SMDS_MeshFace * f5,
+ int ID)
+{
+ MESSAGE("AddVolumeWithID" << ID);
+ if (!hasConstructionFaces())
+ return NULL;
+ if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbPyramids++;
+
+ if (!registerElement(ID, volume)) {
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
+ }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism defined by its faces and add it to the mesh.
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ const SMDS_MeshFace * f5,
+ const SMDS_MeshFace * f6)
+{
+ //MESSAGE("AddVolumeWithID" );
+ if (!hasConstructionFaces())
+ return NULL;
+ return AddVolumeWithID(f1,f2,f3,f4,f5,f6, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism defined by its faces and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ const SMDS_MeshFace * f5,
+ const SMDS_MeshFace * f6,
+ int ID)
+{
+ MESSAGE("AddVolumeWithID" << ID);
+ if (!hasConstructionFaces())
+ return NULL;
+ if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbPrisms++;
+
+ if (!registerElement(ID, volume)) {
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
+ }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes IDs
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (const vector<int> & nodes_ids,
+ const int ID)
+{
+ int nbNodes = nodes_ids.size();
+ vector<const SMDS_MeshNode*> nodes (nbNodes);
+ for (int i = 0; i < nbNodes; i++) {
+ nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
+ if (!nodes[i]) return NULL;
+ }
+ return SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace*
+SMDS_Mesh::AddPolygonalFaceWithID (const vector<const SMDS_MeshNode*> & nodes,
+ const int ID)
+{
+ SMDS_MeshFace * face;
+
+ if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if (hasConstructionEdges())
+ {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else
+ {
+ myNodeIds.resize( nodes.size() );
+ for ( size_t i = 0; i < nodes.size(); ++i )
+ myNodeIds[i] = nodes[i]->getVtkId();
+
+ SMDS_VtkFace *facevtk = myFacePool->getNew();
+ facevtk->initPoly(myNodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
+ face = facevtk;
+
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = face;
+ myInfo.myNbPolygons++;
+ }
+
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a polygon defined by its nodes.
+/// An ID is automatically affected to the created face.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddPolygonalFace (const vector<const SMDS_MeshNode*> & nodes)
+{
+ return SMDS_Mesh::AddPolygonalFaceWithID(nodes, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadratic polygon defined by its nodes IDs
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddQuadPolygonalFaceWithID (const vector<int> & nodes_ids,
+ const int ID)
+{
+ vector<const SMDS_MeshNode*> nodes( nodes_ids.size() );
+ for ( size_t i = 0; i < nodes.size(); i++) {
+ nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
+ if (!nodes[i]) return NULL;
+ }
+ return SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadratic polygon defined by its nodes
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace*
+SMDS_Mesh::AddQuadPolygonalFaceWithID (const vector<const SMDS_MeshNode*> & nodes,
+ const int ID)
+{
+ SMDS_MeshFace * face;
+
+ if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if (hasConstructionEdges())
+ {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else
+ {
+ myNodeIds.resize( nodes.size() );
+ for ( size_t i = 0; i < nodes.size(); ++i )
+ myNodeIds[i] = nodes[i]->getVtkId();
+
+ SMDS_VtkFace *facevtk = myFacePool->getNew();
+ facevtk->initQuadPoly(myNodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
+ face = facevtk;
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = face;
+ myInfo.myNbQuadPolygons++;
+ }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadratic polygon defined by its nodes.
+/// An ID is automatically affected to the created face.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddQuadPolygonalFace (const vector<const SMDS_MeshNode*> & nodes)
+{
+ return SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @param ID The ID of the new volume
+/// @return The created volume or NULL if an element with this ID already exists
+/// or if input nodes are not found.
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID
+ (const vector<int> & nodes_ids,
+ const vector<int> & quantities,
+ const int ID)
+{
+ int nbNodes = nodes_ids.size();
+ vector<const SMDS_MeshNode*> nodes (nbNodes);
+ for (int i = 0; i < nbNodes; i++) {
+ nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
+ if (!nodes[i]) return NULL;
+ }
+ return SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @param ID The ID of the new volume
+/// @return The created volume
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume*
+SMDS_Mesh::AddPolyhedralVolumeWithID (const vector<const SMDS_MeshNode*>& nodes,
+ const vector<int> & quantities,
+ const int ID)
+{
+ SMDS_MeshVolume* volume = 0;
+ if ( nodes.empty() || quantities.empty() )
+ return NULL;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if (hasConstructionFaces())
+ {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else if (hasConstructionEdges())
+ {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else
+ {
+ //#ifdef VTK_HAVE_POLYHEDRON
+ //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID);
+ myNodeIds.resize( nodes.size() );
+ for ( size_t i = 0; i < nodes.size(); ++i )
+ myNodeIds[i] = nodes[i]->getVtkId();
+
+ SMDS_VtkVolume *volvtk = myVolumePool->getNew();
+ volvtk->initPoly(myNodeIds, quantities, this);
+ if (!this->registerElement(ID, volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
+ volume = volvtk;
+ //#else
+ // MESSAGE("AddPolyhedralVolumeWithID smds " << ID);
+ // for ( int i = 0; i < nodes.size(); ++i )
+ // if ( !nodes[ i ] ) return 0;
+ // volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
+ //#endif
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbPolyhedrons++;
+ }
+
+ //#ifndef VTK_HAVE_POLYHEDRON
+ // if (!registerElement(ID, volume))
+ // {
+ // registerElement(myElementIDFactory->GetFreeID(), volume);
+ // //RemoveElement(volume, false);
+ // //volume = NULL;
+ // }
+ //#endif
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Create a new polyhedral volume and add it to the mesh.
+/// @return The created volume
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume
+ (const vector<const SMDS_MeshNode*> & nodes,
+ const vector<int> & quantities)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshVolume * v = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+ if (v == NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeFromVtkIdsWithID(vtkNodeIds, ID);
+ if (v == NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds, const int ID)
+{
+ SMDS_VtkVolume *volvtk = myVolumePool->getNew();
+ volvtk->init(vtkNodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volvtk;
+ vtkIdType aVtkType = volvtk->GetVtkType();
+ switch (aVtkType)
+ {
+ case VTK_TETRA:
+ myInfo.myNbTetras++;
+ break;
+ case VTK_PYRAMID:
+ myInfo.myNbPyramids++;
+ break;
+ case VTK_WEDGE:
+ myInfo.myNbPrisms++;
+ break;
+ case VTK_HEXAHEDRON:
+ myInfo.myNbHexas++;
+ break;
+ case VTK_QUADRATIC_TETRA:
+ myInfo.myNbQuadTetras++;
+ break;
+ case VTK_QUADRATIC_PYRAMID:
+ myInfo.myNbQuadPyramids++;
+ break;
+ case VTK_QUADRATIC_WEDGE:
+ myInfo.myNbQuadPrisms++;
+ break;
+ case VTK_QUADRATIC_HEXAHEDRON:
+ myInfo.myNbQuadHexas++;
+ break;
+//#ifdef VTK_HAVE_POLYHEDRON
+ case VTK_POLYHEDRON:
+ myInfo.myNbPolyhedrons++;
+ break;
+//#endif
+ default:
+ myInfo.myNbPolyhedrons++;
+ break;
+ }
+ return volvtk;
+}
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshFace * f = SMDS_Mesh::AddFaceFromVtkIdsWithID(vtkNodeIds, ID);
+ if (f == NULL) myElementIDFactory->ReleaseID(ID);
+ return f;
+}
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds, const int ID)
+{
+ SMDS_VtkFace *facevtk = myFacePool->getNew();
+ facevtk->init(vtkNodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = facevtk;
+ vtkIdType aVtkType = facevtk->GetVtkType();
+ switch (aVtkType)
+ {
+ case VTK_TRIANGLE:
+ myInfo.myNbTriangles++;
+ break;
+ case VTK_QUAD:
+ myInfo.myNbQuadrangles++;
+ break;
+ case VTK_QUADRATIC_TRIANGLE:
+ myInfo.myNbQuadTriangles++;
+ break;
+ case VTK_QUADRATIC_QUAD:
+ myInfo.myNbQuadQuadrangles++;
+ break;
+ case VTK_BIQUADRATIC_QUAD:
+ myInfo.myNbBiQuadQuadrangles++;
+ break;
+ case VTK_BIQUADRATIC_TRIANGLE:
+ myInfo.myNbBiQuadTriangles++;
+ break;
+ case VTK_POLYGON:
+ myInfo.myNbPolygons++;
+ break;
+ default:
+ myInfo.myNbPolygons++;
+ }
+ return facevtk;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Registers element with the given ID, maintains inverse connections
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
+{
+ //MESSAGE("registerElement " << ID);
+ if ((ID >=0) && (ID < myCells.size()) && myCells[ID]) // --- already bound
+ {
+ MESSAGE(" ------------------ already bound "<< ID << " " << myCells[ID]->getVtkId());
+ return false;
+ }
+
+ element->myID = ID;
+ element->myMeshId = myMeshId;
+
+ SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(element);
+ MYASSERT(cell);
+ int vtkId = cell->getVtkId();
+ if (vtkId == -1)
+ vtkId = myElementIDFactory->SetInVtkGrid(element);
+
+ if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector
+ {
+// MESSAGE(" --------------------- resize myCellIdVtkToSmds " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize);
+ myCellIdVtkToSmds.resize(vtkId + SMDS_Mesh::chunkSize, -1);
+ }
+ myCellIdVtkToSmds[vtkId] = ID;
+
+ myElementIDFactory->updateMinMax(ID);
+ return true;
+}