Salome HOME
#18835 Automatically create groups on Geometry in SMESH when the SHAPER result is...
authoreap <eap@opencascade.com>
Wed, 11 Mar 2020 16:57:24 +0000 (19:57 +0300)
committereap <eap@opencascade.com>
Wed, 11 Mar 2020 16:57:24 +0000 (19:57 +0300)
src/SMESH_I/SMESH_Mesh_i.cxx

index aa25d7d07ad1551bb8ccc519d24a3cd2f06dae0f..0f4dd5407fb284706aeb2d1b18a7616786f38c44 100644 (file)
@@ -2422,7 +2422,8 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
     if ( ii2i != ii2iMap.end() )
       oldID = ii2i->second;
 
-    TopoDS_Shape newShape = newGroupShape( *data, isBreakLink ? IS_BREAK_LINK : MAIN_TRANSFORMED );
+    int how = ( isBreakLink || !sameTopology ) ? IS_BREAK_LINK : MAIN_TRANSFORMED;
+    TopoDS_Shape newShape = newGroupShape( *data, how );
     if ( !newShape.IsNull() )
     {
       if ( meshDS->ShapeToIndex( newShape ) > 0 ) // a group reduced to one sub-shape
@@ -2441,12 +2442,12 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
   // re-assign hypotheses
   for ( size_t i = 0; i < ids2Hyps.size(); ++i )
   {
-    if ( !sameTopology && ids2Hyps[i].first != 1 )
-      continue; // assign only global hypos
     int sID = ids2Hyps[i].first;
     std::map< int, int >::iterator o2n = old2newIDs.find( sID );
     if ( o2n != old2newIDs.end() )
       sID = o2n->second;
+    else if ( sID != 1 )
+      continue;
     const TopoDS_Shape& s = meshDS->IndexToShape( sID );
     const THypList&  hyps = ids2Hyps[i].second;
     THypList::const_iterator h = hyps.begin();
@@ -2454,12 +2455,6 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
       _impl->AddHypothesis( s, (*h)->GetID() );
   }
 
-  if ( !sameTopology )
-  {
-    // remove invalid study sub-objects
-    CheckGeomGroupModif();
-  }
-  else
   {
     // restore groups on geometry
     for ( size_t i = 0; i < groupsData.size(); ++i )
@@ -2506,6 +2501,12 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
       i_sm->second = _impl->GetSubMesh( meshDS->IndexToShape( i_sm->first ));
   }
 
+  if ( !sameTopology )
+  {
+    // remove invalid study sub-objects
+    CheckGeomGroupModif();
+  }
+
   _gen_i->UpdateIcons( me );
 
   if ( !isBreakLink && isShaper )