]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PR: debug split into tetras
authorprascle <prascle>
Sun, 5 Dec 2010 22:57:20 +0000 (22:57 +0000)
committerprascle <prascle>
Sun, 5 Dec 2010 22:57:20 +0000 (22:57 +0000)
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHDS/SMESHDS_SubMesh.cxx

index 5579ca090397014aa5c8ebe76471ea91bf1fa51e..4a970ffa2718255aa0bc23ae24a8558b4f8b111a 100644 (file)
@@ -1717,10 +1717,10 @@ void SMESH_MeshEditor::SplitVolumesIntoTetra (const TIDSortedElemSet & theElems,
         }
         for ( int i = 0; i < triangles.size(); ++i )
         {
-          if ( !triangles.back() ) continue;
+          if ( !triangles[i] ) continue;
           if ( fSubMesh )
-            fSubMesh->AddElement( triangles.back());
-          newElems.Append( triangles.back() );
+            fSubMesh->AddElement( triangles[i]);
+          newElems.Append( triangles[i] );
         }
         ReplaceElemInGroups( face, triangles, GetMeshDS() );
         GetMeshDS()->RemoveFreeElement( face, fSubMesh, /*fromGroups=*/false );
index 58f29ea4e422efd0cbe95ee64ed346b90aaa4c54..ada454b9c051bce9b780e5ec9baf4674e8484655 100644 (file)
@@ -55,13 +55,34 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
   if (!IsComplexSubmesh())
     {
       //MESSAGE("in " << myIndex << " AddElement "<< ME->GetID());
-      int idInSubShape = ME->getIdInShape();
-      if (idInSubShape != -1)
+      int oldShapeId = ME->getshapeId();
+      if ( oldShapeId > 0 )
         {
-          MESSAGE("add element in subshape already belonging to a subshape "
-              << ME->GetID() << "  " << ME->getIdInShape() << " " << ME->getshapeId());
-          throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
+          if (oldShapeId != myIndex)
+            {
+              MESSAGE("add element in subshape already belonging to another subshape "
+                << ME->GetID() << " " << oldShapeId << " " << myIndex);
+              throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
+            }
+          else
+            {
+              int idInSubShape = ME->getIdInShape();
+              MESSAGE("add element in subshape already belonging to that subshape "
+                << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
+              // check if ok: do nothing if ok
+              if ((idInSubShape == -1) || (idInSubShape >= myElements.size()))
+                {
+                  MESSAGE("out of bounds");
+                  throw SALOME_Exception(LOCALIZED("out of bounds"));
+                }
+              if (ME != myElements[idInSubShape])
+                {
+                  MESSAGE("not the same element");
+                  throw SALOME_Exception(LOCALIZED("not the same element"));
+                }
+            }
         }
+
       SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
       elem->setShapeId(myIndex);
       elem->setIdInShape(myElements.size());