]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
non-regression test SMESH_TEST/Grids/smesh/mesh_rotation/A8
authoreap <eap@opencascade.com>
Mon, 8 Apr 2013 13:09:24 +0000 (13:09 +0000)
committereap <eap@opencascade.com>
Mon, 8 Apr 2013 13:09:24 +0000 (13:09 +0000)
Fix generateGroups() to correctly generate "top" groups for initial
groups of nodes

src/SMESH/SMESH_MeshEditor.cxx

index 6d3e74d4e62167dc7d24cf358ebb756b1a6bfe30..c7f5746db77b3fe449433601dee02b1067e451a2 100644 (file)
@@ -6065,7 +6065,26 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
           if ( resElem != sourceElem )
             resultElems.push_back( resElem );
 
-      // add resultElems to groups made by ones the sourceElem belongs to
+      // there must be a top element
+      const SMDS_MeshElement* topElem = 0;
+      if ( isNodes )
+      {
+        topElem = resultElems.back();
+        resultElems.pop_back();
+      }
+      else
+      {
+        list< const SMDS_MeshElement* >::reverse_iterator resElemIt = resultElems.rbegin();
+        for ( ; resElemIt != resultElems.rend() ; ++resElemIt )
+          if ( (*resElemIt)->GetType() == sourceElem->GetType() )
+          {
+            topElem = *resElemIt;
+            resultElems.erase( --(resElemIt.base()) ); // erase *resElemIt
+            break;
+          }
+      }
+
+      // add resultElems to groups originted from ones the sourceElem belongs to
       list< TOldNewGroup >::iterator gOldNew, gLast = groupsOldNew.end();
       for ( gOldNew = groupsOldNew.begin(); gOldNew != gLast; ++gOldNew )
       {
@@ -6074,19 +6093,15 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
         {
           // fill in a new group
           SMDS_MeshGroup & newGroup = gOldNew->get<1>()->SMDSGroup();
-          list< const SMDS_MeshElement* > rejectedElems; // elements of other type
           list< const SMDS_MeshElement* >::iterator resLast = resultElems.end(), resElemIt;
           for ( resElemIt = resultElems.begin(); resElemIt != resLast; ++resElemIt )
-            if ( !newGroup.Add( *resElemIt ))
-              rejectedElems.push_back( *resElemIt );
+            newGroup.Add( *resElemIt );
 
-          // fill "top" group
-          if ( !rejectedElems.empty() )
+          // fill "top" group
+          if ( topElem )
           {
             SMDS_MeshGroup & newTopGroup = gOldNew->get<2>()->SMDSGroup();
-            resLast = rejectedElems.end();
-            for ( resElemIt = rejectedElems.begin(); resElemIt != resLast; ++resElemIt )
-              !newTopGroup.Add( *resElemIt );
+            newTopGroup.Add( topElem );
           }
         }
       }
@@ -6116,7 +6131,9 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
 
         // make a name
         const bool isTop = ( nbNewGroups == 2 &&
-                             newGroupDS->GetType() == oldGroupDS->GetType() );
+                             newGroupDS->GetType() == oldGroupDS->GetType() &&
+                             is2nd );
+
         string name = oldGroupDS->GetStoreName();
         if ( !targetMesh ) {
           string suffix = ( isTop ? "top": postfix.c_str() );