Salome HOME
export of 3D poly to SHP (lot 5)
[modules/hydro.git] / src / HYDROData / HYDROData_ShapesGroup.cxx
index 12807de7f35040acbb6d59202f279c777d3368da..c0d0c7614ea2cccfdac2106f692a0a3c142cb265 100644 (file)
 //
 
 #include "HYDROData_ShapesGroup.h"
-
 #include "HYDROData_ShapesTool.h"
 
+#include <BRepBuilderAPI_MakeShape.hxx>
 #include <TDF_ChildIDIterator.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-
-#include <BRepBuilderAPI_MakeShape.hxx>
-
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <BRepTools_ReShape.hxx>
+
+//#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_ShapesGroup,HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ShapesGroup,HYDROData_Entity)
 
 void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*          theGroupsDefs,
@@ -85,6 +84,53 @@ void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*
   if ( !theGroupsDefs || !theAlgo )
     return;
 
+  SeqOfGroupsDefs::Iterator anIter( *theGroupsDefs );
+  if (theAlgo->History().IsNull())
+    return;
+
+  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 aModifSh;
+      if ( !aShape.IsNull())
+      {
+        const TopTools_ListOfShape& listModified = theAlgo->History()->Modified(aShape);
+        if (listModified.Extent() > 0)
+        {
+          aModifSh = listModified.First(); 
+          // Edge has been modified
+          aShapesToAdd.Append( aModifSh );
+          aGroupDef.Shapes.Remove( i );
+          --i;      
+        }
+        else if ( theAlgo->History()->IsRemoved(aShape) )
+        {    
+          // Edge has been removed
+          aGroupDef.Shapes.Remove( i );
+          --i;
+        }
+  
+      }      
+   }
+
+    HYDROData_ShapesTool::AddShapes( aGroupDef.Shapes, aShapesToAdd );
+  }
+}
+
+void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*              theGroupsDefs,
+                                                     BRepTools_ReShape*            theAlgo )
+{
+  if ( !theGroupsDefs || !theAlgo )
+    return;
+
   SeqOfGroupsDefs::Iterator anIter( *theGroupsDefs );
   for ( ; anIter.More(); anIter.Next() )
   {
@@ -97,7 +143,7 @@ void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*
     {
       TopoDS_Shape aShape = aGroupDef.Shapes.Value( i );
 
-      TopoDS_Shape aGeneratedByAlgo = theAlgo->Generated( aShape );
+      TopoDS_Shape aGeneratedByAlgo = theAlgo->Value( aShape );
       if ( aGeneratedByAlgo.IsNull() )
       {
         // Edge has been removed