+SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
+ const SMDS_MeshFace * f2,
+ const SMDS_MeshFace * f3,
+ const SMDS_MeshFace * f4,
+ int ID)
+{
+ if (!hasConstructionFaces())
+ return NULL;
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
+ myVolumes.Add(volume);
+
+ if (!registerElement(ID, 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)
+{
+ 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)
+{
+ if (!hasConstructionFaces())
+ return NULL;
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
+ myVolumes.Add(volume);
+
+ if (!registerElement(ID, 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)
+{
+ 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)
+{
+ if (!hasConstructionFaces())
+ return NULL;
+ SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
+ myVolumes.Add(volume);
+
+ if (!registerElement(ID, volume)) {
+ RemoveElement(volume, false);
+ volume = NULL;
+ }
+ return volume;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Registers element with the given ID, maintains inverse connections
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element)
+{
+ if (myElementIDFactory->BindID(ID, element)) {
+ SMDS_ElemIteratorPtr it = element->nodesIterator();
+ while (it->more()) {
+ SMDS_MeshNode *node = static_cast<SMDS_MeshNode*>
+ (const_cast<SMDS_MeshElement*>(it->next()));
+ node->AddInverseElement(element);
+ }
+ return true;
+ }
+ return false;