Salome HOME
Merge branch 'BR_HYDRO_IMPS_2016' into pre/IMPS_2016
[modules/hydro.git] / src / HYDROData / HYDROData_ShapesGroup.cxx
index 6c0d5ae00a91fa2b54fd081020f6ebc63e767855..92fd7e17d88987d26050ff51a39f6cae9d2d1eba 100644 (file)
@@ -30,6 +30,7 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <BRepTools_ReShape.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_ShapesGroup,HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ShapesGroup,HYDROData_Entity)
@@ -113,6 +114,44 @@ void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*
   }
 }
 
+void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*              theGroupsDefs,
+                                                     BRepTools_ReShape*            theAlgo )
+{
+  if ( !theGroupsDefs || !theAlgo )
+    return;
+
+  SeqOfGroupsDefs::Iterator anIter( *theGroupsDefs );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    GroupDefinition& aGroupDef = anIter.ChangeValue();
+    if ( aGroupDef.Shapes.IsEmpty() )
+      continue;
+
+    TopTools_ListOfShape aShapesToAdd;
+    for ( int i = 1; i <= aGroupDef.Shapes.Length(); ++i )
+    {
+      TopoDS_Shape aShape = aGroupDef.Shapes.Value( i );
+
+      TopoDS_Shape aGeneratedByAlgo = theAlgo->Value( aShape );
+      if ( aGeneratedByAlgo.IsNull() )
+      {
+        // Edge has been removed
+        aGroupDef.Shapes.Remove( i );
+        --i;
+      }
+      else if ( !aShape.IsEqual( aGeneratedByAlgo ) )
+      {
+        // Edge has been modified
+        aShapesToAdd.Append( aGeneratedByAlgo );
+        aGroupDef.Shapes.Remove( i );
+        --i;
+      }      
+    }
+
+    HYDROData_ShapesTool::AddShapes( aGroupDef.Shapes, aShapesToAdd );
+  }
+}
+
 void HYDROData_ShapesGroup::GroupDefinition::Dump( std::ostream& theStream ) const
 {
   theStream << "Name: " << Name.ToCString() << "\n";