+///////////////////////////////////////////////////////////////////////////////
+/// Add a triangle defined by its nodes
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ int ID)
+{
+ //MESSAGE("AddFaceWithID " << ID)
+ SMDS_MeshFace * face=createTriangle(n1, n2, n3, ID);
+
+// if (face && !registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its nodes. An ID is automatically affected to the
+/// created face
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4)
+{
+ return SMDS_Mesh::AddFaceWithID(n1,n2,n3, n4, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its nodes IDs
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int idnode1,
+ int idnode2,
+ int idnode3,
+ int idnode4,
+ int ID)
+{
+ SMDS_MeshNode *node1, *node2, *node3, *node4;
+ node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+ node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+ node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+ node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+ if(!node1 || !node2 || !node3 || !node4) return NULL;
+ return SMDS_Mesh::AddFaceWithID(node1, node2, node3, node4, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its nodes
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ int ID)
+{
+ //MESSAGE("AddFaceWithID " << ID);
+ SMDS_MeshFace * face=createQuadrangle(n1, n2, n3, n4, ID);
+
+// if (face && !registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a triangle defined by its edges. An ID is automatically assigned to the
+/// Created face
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1,
+ const SMDS_MeshEdge * e2,
+ const SMDS_MeshEdge * e3)
+{
+ if (!hasConstructionEdges())
+ return NULL;
+ //MESSAGE("AddFaceWithID");
+ return AddFaceWithID(e1,e2,e3, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a triangle defined by its edges
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
+ const SMDS_MeshEdge * e2,
+ const SMDS_MeshEdge * e3,
+ int ID)
+{
+ if (!hasConstructionEdges())
+ return NULL;
+ if ( !e1 || !e2 || !e3 ) return 0;
+
+ if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ MESSAGE("AddFaceWithID" << ID);
+
+ SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = face;
+ myInfo.myNbTriangles++;
+
+ if (!registerElement(ID, face)) {
+ registerElement(myElementIDFactory->GetFreeID(), face);
+ //RemoveElement(face, false);
+ //face = NULL;
+ }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its edges. An ID is automatically assigned to the
+/// Created face
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1,
+ const SMDS_MeshEdge * e2,
+ const SMDS_MeshEdge * e3,
+ const SMDS_MeshEdge * e4)
+{
+ if (!hasConstructionEdges())
+ return NULL;
+ //MESSAGE("AddFaceWithID" );
+ return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Add a quadrangle defined by its edges
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
+ const SMDS_MeshEdge * e2,
+ const SMDS_MeshEdge * e3,
+ const SMDS_MeshEdge * e4,
+ int ID)
+{
+ if (!hasConstructionEdges())
+ return NULL;
+ MESSAGE("AddFaceWithID" << ID);
+ if ( !e1 || !e2 || !e3 || !e4 ) return 0;
+ if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = face;
+ myInfo.myNbQuadrangles++;
+
+ if (!registerElement(ID, face))
+ {
+ registerElement(myElementIDFactory->GetFreeID(), face);
+ //RemoveElement(face, false);
+ //face = NULL;
+ }
+ return face;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron and add it to the mesh.
+///@return The created tetrahedron
+///////////////////////////////////////////////////////////////////////////////
+
+SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
+ if(v==NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron and add it to the mesh.
+///@param ID The ID of the new volume
+///@return The created tetrahedron 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 ID)
+{
+ //MESSAGE("AddVolumeWithID" << ID);
+ SMDS_MeshNode *node1, *node2, *node3, *node4;
+ node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+ node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+ node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+ node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+ if(!node1 || !node2 || !node3 || !node4) return NULL;
+ return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new tetrahedron 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_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume* volume = 0;
+ if ( !n1 || !n2 || !n3 || !n4) return volume;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if(hasConstructionFaces()) {
+ SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
+ SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4);
+ SMDS_MeshFace * f3=FindFaceOrCreate(n1,n3,n4);
+ SMDS_MeshFace * f4=FindFaceOrCreate(n2,n3,n4);
+ volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbTetras++;
+ }
+ else if(hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else {
+ // --- retrieve nodes ID
+ myNodeIds.resize(4);
+ myNodeIds[0] = n1->getVtkId();
+ myNodeIds[1] = n3->getVtkId(); // order SMDS-->VTK
+ myNodeIds[2] = n2->getVtkId();
+ myNodeIds[3] = n4->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.myNbTetras++;
+ }
+
+ // if (!registerElement(ID, volume)) {
+ // RemoveElement(volume, false);
+ // volume = NULL;
+ // }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid and add it to the mesh.
+///Nodes 1,2,3 and 4 define the base of the pyramid
+///@return The created pyramid
+///////////////////////////////////////////////////////////////////////////////
+
+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)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
+ if(v==NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid and add it to the mesh.
+///Nodes 1,2,3 and 4 define the base of the pyramid
+///@param ID The ID of the new volume
+///@return The created pyramid 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 ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshNode *node1, *node2, *node3, *node4, *node5;
+ 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);
+ if(!node1 || !node2 || !node3 || !node4 || !node5) return NULL;
+ return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new pyramid and add it to the mesh.
+///Nodes 1,2,3 and 4 define the base of the pyramid
+///@param ID The ID of the new volume
+///@return The created pyramid
+///////////////////////////////////////////////////////////////////////////////
+
+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,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume* volume = 0;
+ if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if(hasConstructionFaces()) {
+ SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
+ SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5);
+ SMDS_MeshFace * f3=FindFaceOrCreate(n2,n3,n5);
+ SMDS_MeshFace * f4=FindFaceOrCreate(n3,n4,n5);
+ volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbPyramids++;
+ }
+ else if(hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else {
+ // --- retrieve nodes ID
+ myNodeIds.resize(5);
+ myNodeIds[0] = n1->getVtkId();
+ myNodeIds[1] = n4->getVtkId();
+ myNodeIds[2] = n3->getVtkId();
+ myNodeIds[3] = n2->getVtkId();
+ myNodeIds[4] = n5->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.myNbPyramids++;
+ }
+
+ // if (!registerElement(ID, volume)) {
+ // RemoveElement(volume, false);
+ // volume = NULL;
+ // }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism and add it to the mesh.
+///Nodes 1,2,3 is a triangle and 1,2,5,4 a quadrangle.
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+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)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
+ if(v==NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism and add it to the mesh.
+///Nodes 1,2,3 is a triangle and 1,2,5,4 a quadrangle.
+///@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(int idnode1,
+ int idnode2,
+ int idnode3,
+ int idnode4,
+ int idnode5,
+ int idnode6,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6;
+ 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);
+ if(!node1 || !node2 || !node3 || !node4 || !node5 || !node6) return NULL;
+ return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6, ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new prism and add it to the mesh.
+///Nodes 1,2,3 is a triangle and 1,2,5,4 a quadrangle.
+///@param ID The ID of the new volume
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+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,
+ int ID)
+{
+ //MESSAGE("AddVolumeWithID " << ID);
+ SMDS_MeshVolume* volume = 0;
+ if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if(hasConstructionFaces()) {
+ SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
+ SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6);
+ SMDS_MeshFace * f3=FindFaceOrCreate(n1,n4,n5,n2);
+ SMDS_MeshFace * f4=FindFaceOrCreate(n2,n5,n6,n3);
+ SMDS_MeshFace * f5=FindFaceOrCreate(n3,n6,n4,n1);
+ volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
+ adjustmyCellsCapacity(ID);
+ myCells[ID] = volume;
+ myInfo.myNbPrisms++;
+ }
+ else if(hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else {
+ // --- retrieve nodes ID
+ myNodeIds.resize(6);
+ myNodeIds[0] = n1->getVtkId();
+ myNodeIds[1] = n2->getVtkId();
+ myNodeIds[2] = n3->getVtkId();
+ myNodeIds[3] = n4->getVtkId();
+ myNodeIds[4] = n5->getVtkId();
+ myNodeIds[5] = 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.myNbPrisms++;
+ }
+
+ // if (!registerElement(ID, volume)) {
+ // RemoveElement(volume, false);
+ // volume = NULL;
+ // }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexagonal prism and add it to the mesh.
+///@return The created prism
+///////////////////////////////////////////////////////////////////////////////
+
+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,
+ const SMDS_MeshNode * n9,
+ const SMDS_MeshNode * n10,
+ const SMDS_MeshNode * n11,
+ const SMDS_MeshNode * n12)
+{
+ int ID = myElementIDFactory->GetFreeID();
+ SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6,
+ n7, n8, n9, n10, n11, n12,
+ ID);
+ if(v==NULL) myElementIDFactory->ReleaseID(ID);
+ return v;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexagonal prism and add it to the mesh.
+///@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(int idnode1,
+ int idnode2,
+ int idnode3,
+ int idnode4,
+ int idnode5,
+ int idnode6,
+ int idnode7,
+ int idnode8,
+ int idnode9,
+ int idnode10,
+ int idnode11,
+ int idnode12,
+ int ID)
+{
+ SMDS_MeshNode *node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
+ SMDS_MeshNode *node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
+ SMDS_MeshNode *node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode3);
+ SMDS_MeshNode *node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode4);
+ SMDS_MeshNode *node5 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode5);
+ SMDS_MeshNode *node6 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode6);
+ SMDS_MeshNode *node7 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode7);
+ SMDS_MeshNode *node8 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode8);
+ SMDS_MeshNode *node9 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode9);
+ SMDS_MeshNode *node10 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode10);
+ SMDS_MeshNode *node11 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode11);
+ SMDS_MeshNode *node12 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode12);
+ return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6,
+ node7, node8, node9, node10, node11, node12,
+ ID);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///Create a new hexagonal prism 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_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,
+ const SMDS_MeshNode * n9,
+ const SMDS_MeshNode * n10,
+ const SMDS_MeshNode * n11,
+ const SMDS_MeshNode * n12,
+ int ID)
+{
+ SMDS_MeshVolume* volume = 0;
+ if(!n1 || !n2 || !n3 || !n4 || !n5 || !n6 ||
+ !n7 || !n8 || !n9 || !n10 || !n11 || !n12 )
+ return volume;
+ if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ if(hasConstructionFaces()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else if(hasConstructionEdges()) {
+ MESSAGE("Error : Not implemented");
+ return NULL;
+ }
+ else {
+ // --- retrieve nodes ID
+ myNodeIds.resize(12);
+ myNodeIds[0] = n1->getVtkId();
+ myNodeIds[1] = n6->getVtkId();
+ myNodeIds[2] = n5->getVtkId();
+ myNodeIds[3] = n4->getVtkId();
+ myNodeIds[4] = n3->getVtkId();
+ myNodeIds[5] = n2->getVtkId();
+
+ myNodeIds[6] = n7->getVtkId();
+ myNodeIds[7] = n12->getVtkId();
+ myNodeIds[8] = n11->getVtkId();
+ myNodeIds[9] = n10->getVtkId();
+ myNodeIds[10] = n9->getVtkId();
+ myNodeIds[11] = n8->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.myNbHexPrism++;
+ }
+
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///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
+///////////////////////////////////////////////////////////////////////////////