Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESHDS / SMESHDS_Mesh.cxx
index c1d3cc45c57837ba80a211819b53d54db8c78341..6fab4c837e60032d7db8d8c99a02c9d9bc66be2a 100644 (file)
@@ -46,10 +46,12 @@ using namespace std;
 //purpose  : 
 //=======================================================================
 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
 //purpose  : 
 //=======================================================================
 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
+  myMeshID(theMeshID),
   myIsEmbeddedMode(theIsEmbeddedMode),
   myIsEmbeddedMode(theIsEmbeddedMode),
-  myMeshID(theMeshID)
+  myCurSubID(-1)
 {
   myScript = new SMESHDS_Script(theIsEmbeddedMode);
 {
   myScript = new SMESHDS_Script(theIsEmbeddedMode);
+  myCurSubMesh = 0;
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -711,7 +713,8 @@ void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * sub
 
   // Rm from sub-mesh
   // Node should belong to only one sub-mesh
 
   // Rm from sub-mesh
   // Node should belong to only one sub-mesh
-  subMesh->RemoveNode(n);
+  if( subMesh )
+    subMesh->RemoveNode(n);
 
   SMDS_Mesh::RemoveFreeElement(n);
 }
 
   SMDS_Mesh::RemoveFreeElement(n);
 }
@@ -768,7 +771,8 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMe
 
   // Rm from sub-mesh
   // Element should belong to only one sub-mesh
 
   // Rm from sub-mesh
   // Element should belong to only one sub-mesh
-  subMesh->RemoveElement(elt);
+  if( subMesh )
+    subMesh->RemoveElement(elt);
 
   SMDS_Mesh::RemoveFreeElement(elt);
 }
 
   SMDS_Mesh::RemoveFreeElement(elt);
 }
@@ -846,7 +850,8 @@ bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode *      aNode,
                                    const TopoDS_Shell & S)
 {
 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode *      aNode,
                                    const TopoDS_Shell & S)
 {
-  add( aNode, getSubmesh(S) );
+  if ( add( aNode, getSubmesh(S) ))
+    const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
 }
 //=======================================================================
 //function : SetNodeOnVolume
 }
 //=======================================================================
 //function : SetNodeOnVolume
@@ -855,7 +860,8 @@ void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode *      aNode,
 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode *      aNode,
                                    const TopoDS_Solid & S)
 {
 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode *      aNode,
                                    const TopoDS_Solid & S)
 {
-  add( aNode, getSubmesh(S) );
+  if ( add( aNode, getSubmesh(S) ))
+    const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -1140,7 +1146,8 @@ int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
 //=======================================================================
 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
 {
 //=======================================================================
 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
 {
-  add( aNode, getSubmesh( Index ));
+  if ( add( aNode, getSubmesh( Index )))
+    const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( Index );
 }
 
 //=======================================================================
 }
 
 //=======================================================================