]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Updating of groups for exporting of calculation case.
authoradv <adv@opencascade.com>
Fri, 10 Jan 2014 09:29:25 +0000 (09:29 +0000)
committeradv <adv@opencascade.com>
Fri, 10 Jan 2014 09:29:25 +0000 (09:29 +0000)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_ShapesGroup.cxx
src/HYDROData/HYDROData_ShapesGroup.h

index 198222ab62a76428d734c9c6163ba39374c9eb0f..bcbd1964dd8109d60c05a5f91b5243c72f804a48 100644 (file)
@@ -632,55 +632,74 @@ Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedG
   return aNewGroup;
 }
 
-bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy )
+bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
+                                        SALOMEDS::Study_ptr theStudy ) const
 {
+  HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
+
+  // Get groups definitions
+  HYDROData_SequenceOfObjects aSplittedGroups = GetSplittedGroups();
+
+  HYDROData_SequenceOfObjects::Iterator anIter( aSplittedGroups );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    // Get shapes group
+    Handle(HYDROData_ShapesGroup) aGroup =
+      Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
+    if ( aGroup.IsNull() )
+      continue;
+
+    HYDROData_ShapesGroup::GroupDefinition aGroupDef;
+
+    aGroupDef.Name = aGroup->GetName().toLatin1().constData();
+    aGroup->GetShapes( aGroupDef.Shapes );
+
+    aSeqOfGroupsDefs.Append( aGroupDef );
+  }
+  
   // Get faces
   TopTools_ListOfShape aFaces;
   HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
   HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
-  for ( ; aRegionIter.More(); aRegionIter.Next() ) {
+  for ( ; aRegionIter.More(); aRegionIter.Next() )
+  {
     Handle(HYDROData_Region) aRegion =
       Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
-    if( aRegion.IsNull() ) {
+    if( aRegion.IsNull() )
       continue;
-    }
 
-    TopoDS_Shape aRegionShape = aRegion->GetShape();
+    TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
     aFaces.Append( aRegionShape );
   }
 
-  // Get groups
-  HYDROData_SequenceOfObjects aSplittedGroups = GetSplittedGroups();
-
-  return Export( theGeomEngine, theStudy, aFaces, aSplittedGroups );
+  return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs );
 }
 
-bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy,
-                                        const TopTools_ListOfShape& theFaces,
-                                        const HYDROData_SequenceOfObjects& theSplittedGroups )
+bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var                            theGeomEngine,
+                                        SALOMEDS::Study_ptr                           theStudy,
+                                        const TopTools_ListOfShape&                   theFaces,
+                                        const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const
 {
   // Sew faces
-  BRepBuilderAPI_Sewing aSewing( Precision::Confusion()*10.0 );
+  BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
   aSewing.SetNonManifoldMode( Standard_True );
 
   TopTools_ListIteratorOfListOfShape aFaceIter( theFaces );
-  for ( ; aFaceIter.More(); aFaceIter.Next() ) {
+  for ( ; aFaceIter.More(); aFaceIter.Next() )
+  {
     TopoDS_Shape aShape = aFaceIter.Value();
-    if ( !aShape.IsNull() && (aShape.ShapeType() == TopAbs_FACE) ) {
-      TopoDS_Face aFace = TopoDS::Face( aShape );
-      if ( !aFace.IsNull() ) {
-        aSewing.Add( aFace );
-      }
-    } else {
+    if ( aShape.IsNull() )
+      continue;
+
+    if ( aShape.ShapeType() == TopAbs_FACE )
+    {
+      aSewing.Add( aShape );
+    }
+    else
+    {
       TopExp_Explorer anExp( aShape, TopAbs_FACE );
-      for ( ; anExp.More(); anExp.Next() ) {
-        TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
-        if ( !aFace.IsNull() ) {
-          aSewing.Add( aFace );
-        }
-      }
+      for ( ; anExp.More(); anExp.Next() )
+        aSewing.Add( anExp.Current() );
     }
   } // faces iterator
   
@@ -688,76 +707,73 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
   TopoDS_Shape aSewedShape = aSewing.SewedShape();
 
   // If the sewed shape is empty - return false
-  if ( aSewedShape.IsNull() || !TopoDS_Iterator(aSewedShape).More() ) {
+  if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() )
     return false;
-  }
 
   // Publish the sewed shape
   QString aName = EXPORT_NAME;
   GEOM::GEOM_Object_ptr aMainShape = 
     publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName );
 
-  if ( aMainShape->_is_nil() ) {
+  if ( aMainShape->_is_nil() )
     return false;
-  }
+
+  if ( theGroupsDefs.IsEmpty() )
+    return true;
 
   // Create groups
   TopTools_IndexedMapOfShape aMapOfSubShapes;
   TopExp::MapShapes( aSewedShape, aMapOfSubShapes );
 
-  QHash<QString, QSet<int> > aGroupsData;
+  NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> > aGroupsData;
 
-  HYDROData_SequenceOfObjects::Iterator anIter( theSplittedGroups );
-  for ( ; anIter.More(); anIter.Next() ) {
-    // Get shapes group
-    Handle(HYDROData_ShapesGroup) aGroup =
-      Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
-    if ( aGroup.IsNull() ) {
-      continue;
-    }
+  for ( int aGrId = 1, nbGroups = theGroupsDefs.Length(); aGrId <= nbGroups; ++aGrId )
+  {
+    const HYDROData_ShapesGroup::GroupDefinition& aGroupDef = theGroupsDefs.Value( aGrId );
 
-    QSet<int> anIndexes;
-
-    // Get shapes of the group
-    TopTools_SequenceOfShape aShapes;
-    aGroup->GetShapes( aShapes );
-    for( int i = 1, aNbShapes = aShapes.Length(); i <= aNbShapes; i++ ) {
-      const TopoDS_Shape& aShape = aShapes.Value( i );
-      const TopoDS_Shape ModifiedShape = aSewing.Modified( aShape );
-      if ( !ModifiedShape.IsNull() ) {
-        int anIndex = aMapOfSubShapes.FindIndex( ModifiedShape );
-        if ( anIndex > 0 ) {
-          anIndexes << anIndex;
-        }
-      }
-    }
-    
-    if ( anIndexes.count() > 0 ) {
-      aGroupsData.insert( aGroup->GetName(), anIndexes );
+    NCollection_Sequence<int> aGroupIndexes;
+    for( int i = 1, n = aGroupDef.Shapes.Length(); i <= n; i++ )
+    {
+      const TopoDS_Shape& aShape = aGroupDef.Shapes.Value( i );
+
+      const TopoDS_Shape& ModifiedShape = aSewing.Modified( aShape );
+      if ( ModifiedShape.IsNull() )
+        continue;
+
+      int anIndex = aMapOfSubShapes.FindIndex( ModifiedShape );
+      if ( anIndex > 0 ) aGroupIndexes.Append( anIndex );
     }
+
+    if ( !aGroupIndexes.IsEmpty() )
+      aGroupsData.Bind( aGroupDef.Name, aGroupIndexes );
   }
   
-  if ( !aGroupsData.isEmpty() ) {
+  if ( !aGroupsData.IsEmpty() )
+  {
     GEOM::GEOM_IGroupOperations_var aGroupOp = 
       theGeomEngine->GetIGroupOperations( theStudy->StudyId() );  
 
-    foreach ( const QString& aGroupName, aGroupsData.keys() ) {
-      QSet<int> aGroupIndexes = aGroupsData.value( aGroupName );
+    NCollection_DataMap< TCollection_AsciiString, NCollection_Sequence<int> >::Iterator aMapIt( aGroupsData );
+    for ( ; aMapIt.More(); aMapIt.Next() )
+    {
+      const TCollection_AsciiString& aGroupName = aMapIt.Key(); 
+      const NCollection_Sequence<int>& aGroupIndexes = aMapIt.Value();
 
-      GEOM::GEOM_Object_var aGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
-      if ( !CORBA::is_nil(aGroup) && aGroupOp->IsDone() ) {
-        GEOM::ListOfLong_var anIndexes = new GEOM::ListOfLong;
-        anIndexes->length( aGroupIndexes.count() );
-        int aListIndex = 0;
-        foreach ( const int anIndex, aGroupIndexes ) {
-          anIndexes[aListIndex++] = anIndex;
-        }
+      GEOM::GEOM_Object_var aGeomGroup = aGroupOp->CreateGroup( aMainShape, TopAbs_EDGE );
+      if ( CORBA::is_nil( aGeomGroup ) || !aGroupOp->IsDone() )
+        continue;
 
-        aGroupOp->UnionIDs( aGroup, anIndexes );
-        if ( aGroupOp->IsDone() ) {
-          SALOMEDS::SObject_var aGroupSO = 
-            theGeomEngine->AddInStudy( theStudy, aGroup, qPrintable( aGroupName ), aMainShape );
-        }
+      GEOM::ListOfLong_var aGeomIndexes = new GEOM::ListOfLong;
+      aGeomIndexes->length( aGroupIndexes.Length() );
+
+      for( int i = 1, n = aGroupIndexes.Length(); i <= n; i++ )
+        aGeomIndexes[ i - 1 ] = aGroupIndexes.Value( i );
+
+      aGroupOp->UnionIDs( aGeomGroup, aGeomIndexes );
+      if ( aGroupOp->IsDone() )
+      {
+        SALOMEDS::SObject_var aGroupSO = 
+          theGeomEngine->AddInStudy( theStudy, aGeomGroup, aGroupName.ToCString(), aMainShape );
       }
     }
   }
@@ -767,7 +783,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine,
 
 GEOM::GEOM_Object_ptr HYDROData_CalculationCase::publishShapeInGEOM( 
   GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy,
-  const TopoDS_Shape& theShape, const QString& theName )
+  const TopoDS_Shape& theShape, const QString& theName ) const
 {
   GEOM::GEOM_Object_var aGeomObj;
 
index f8c3ef554f750dd7e7cd41350242387629326aa3..0f2d6579c4c63824ca34f654a9796e441b3e71fd 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef HYDROData_CalculationCase_HeaderFile
 #define HYDROData_CalculationCase_HeaderFile
 
-#include <HYDROData_Entity.h>
+#include <HYDROData_ShapesGroup.h>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -201,8 +201,8 @@ public:
    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
    * \return true in case of success
    */
-  HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy );
+  HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
+                                        SALOMEDS::Study_ptr theStudy ) const;
 
 public:      
   // Public methods to work with Calculation services
@@ -252,10 +252,10 @@ private:
    * \param theSplittedGroups the list of groups
    * \return true in case of success
    */
-  HYDRODATA_EXPORT bool Export( GEOM::GEOM_Gen_var theGeomEngine,
-                                SALOMEDS::Study_ptr theStudy,
-                                const TopTools_ListOfShape& theFaces,
-                                const HYDROData_SequenceOfObjects& theSplittedGroups );
+  HYDRODATA_EXPORT bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
+                                SALOMEDS::Study_ptr                           theStudy,
+                                const TopTools_ListOfShape&                   theFaces,
+                                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const;
 
   /**
    * Publish the given shape in GEOM as a GEOM object.
@@ -265,10 +265,10 @@ private:
    * \param theName the name of the published object
    * \return the published GEOM object
    */
-  GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
+  GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
                                             SALOMEDS::Study_ptr theStudy,
                                             const TopoDS_Shape& theShape, 
-                                            const QString& theName );
+                                            const QString&      theName ) const;
 
 protected:
 
index 12103c787be22250d261167419a95149ea3ec36f..81916d5a2b3855b980f6f710afdf4a2d31d42b1e 100644 (file)
@@ -4,18 +4,23 @@
 #include "HYDROData_CalculationCase.h"
 #include "HYDROData_Document.h"
 #include "HYDROData_Iterator.h"
+#include "HYDROData_ShapesTool.h"
 #include "HYDROData_Zone.h"
 
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Shell.hxx>
 #include <TopoDS_Face.hxx>
+
+#include <TopExp.hxx>
+
 #include <TopTools_ListOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopExp.hxx>
+
 #include <BRep_Builder.hxx>
 #include <BRepAlgoAPI_Fuse.hxx>
+
 #include <ShapeUpgrade_UnifySameDomain.hxx>
 
 #include <QStringList>
@@ -166,8 +171,12 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone()
   return aNewZone;
 }
 
-TopoDS_Shape HYDROData_Region::GetShape() const
+TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups ) const
 {
+  HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroups;
+  if ( theSeqOfGroups )
+    aSeqOfGroups = *theSeqOfGroups;
+
   TopoDS_Shape aResShape;
 
   // Unite the region zones (each zone is a face) into one face (united face)
@@ -178,74 +187,95 @@ TopoDS_Shape HYDROData_Region::GetShape() const
 
   HYDROData_SequenceOfObjects aZones = GetZones();
   HYDROData_SequenceOfObjects::Iterator aZoneIter( aZones );
-  for ( ; aZoneIter.More(); aZoneIter.Next() ) {
+  for ( ; aZoneIter.More(); aZoneIter.Next() )
+  {
     Handle(HYDROData_Zone) aZone =
       Handle(HYDROData_Zone)::DownCast( aZoneIter.Value() );
-  
-    if ( aZone.IsNull() ) {
+    if ( aZone.IsNull() )
       continue;
-    }
 
-    TopoDS_Face aFace = TopoDS::Face( aZone->GetShape() );
-    if ( !aFace.IsNull() ) {
-      aRegionFacesList.Append( aFace );
-    }
+    TopoDS_Shape aZoneShape = aZone->GetShape();
+    if ( aZoneShape.IsNull() || aZoneShape.ShapeType() != TopAbs_FACE )
+      continue;
+
+    TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
+    aRegionFacesList.Append( aZoneFace );
   } // zones iterator
   
-  // Check number of faces
-  int aNbFaces = aRegionFacesList.Extent();
-  if ( aNbFaces > 0 ) {
-    // The unite region face
-    TopoDS_Face aRegionFace;
-  
-    if ( aNbFaces == 1 ) {
-      aRegionFace = TopoDS::Face( aRegionFacesList.First() );
-    } else {
-      // Fuse faces into one
-      TopoDS_Shape aFuseShape;
-      TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
-      for ( ; aFaceIter.More(); aFaceIter.Next() ) {
-        if ( aFuseShape.IsNull() ) {
-          aFuseShape = aFaceIter.Value();
-        } else {
-          BRepAlgoAPI_Fuse aFuse(aFuseShape, aFaceIter.Value());
-          if ( !aFuse.IsDone() ) {
-            aFuseShape.Nullify();
-            break;
-          }
-          aFuseShape = aFuse.Shape();
-        }
-      } // faces iterator
-
-      // Check the result of fuse operation
-      if ( !aFuseShape.IsNull() ) {
-        ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
-        anUnifier.Build();
-        TopoDS_Shape anUnitedShape = anUnifier.Shape();
-
-        TopTools_IndexedMapOfShape aMapOfFaces;
-        TopExp::MapShapes( anUnitedShape, TopAbs_FACE, aMapOfFaces );
-        if ( aMapOfFaces.Extent() == 1 ) {
-          aRegionFace = TopoDS::Face( aMapOfFaces(1) );
-        }
-      }
-    }
+  if ( aRegionFacesList.IsEmpty() )
+    return aResShape;
 
-    if ( !aRegionFace.IsNull() ) { // result shape is a face
-      aResShape = aRegionFace;
-    } else { // result shape is a shell
-      TopoDS_Shell aShell;
-      BRep_Builder aBuilder;
-      aBuilder.MakeShell( aShell );
+  // The unite region face
+  TopoDS_Face aRegionFace;
 
-      TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
-      for ( ; aFaceIter.More(); aFaceIter.Next() ) {
-        aBuilder.Add( aShell, aFaceIter.Value() );
+  if ( aRegionFacesList.Extent() == 1 )
+  {
+    aRegionFace = TopoDS::Face( aRegionFacesList.First() );
+  }
+  else
+  {
+    // Try to fuse all region faces into one common face
+    TopoDS_Shape aFuseShape;
+    TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
+    for ( ; aFaceIter.More(); aFaceIter.Next() )
+    {
+      if ( aFuseShape.IsNull() )
+      {
+        aFuseShape = aFaceIter.Value();
+        continue;
       }
 
-      aResShape = aShell;
+      BRepAlgoAPI_Fuse aFuse( aFuseShape, aFaceIter.Value() );
+      if ( !aFuse.IsDone() )
+      {
+        aFuseShape.Nullify();
+        break;
+      }
+
+      aFuseShape = aFuse.Shape();
+      HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfGroups, &aFuse );
+    } // faces iterator
+
+    // Check the result of fuse operation
+    if ( !aFuseShape.IsNull() )
+    {
+      ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
+      anUnifier.Build();
+
+      const TopoDS_Shape& anUnitedShape = anUnifier.Shape();
+
+      TopTools_SequenceOfShape aShapeFaces;
+      HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces );
+      if ( aShapeFaces.Length() == 1 )
+      {
+        aRegionFace = TopoDS::Face( aShapeFaces.Value( 1 ) );
+        HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfGroups, &anUnifier );
+
+        // temporary commented because of needs of testing
+        //if ( theSeqOfGroups )
+          //*theSeqOfGroups = aSeqOfGroups;
+      }
     }
   }
+
+  if ( !aRegionFace.IsNull() )
+  {
+    // result shape is a face
+    aResShape = aRegionFace;
+  }
+  else
+  {
+    // result shape is a shell
+    TopoDS_Shell aShell;
+    BRep_Builder aBuilder;
+    aBuilder.MakeShell( aShell );
+
+    TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
+    for ( ; aFaceIter.More(); aFaceIter.Next() )
+      aBuilder.Add( aShell, aFaceIter.Value() );
+
+    aResShape = aShell;
+  }
   
   return aResShape;
 }
index 7139837bc89959d04bf38453ffeef4722ded3a6e..d5de50456238467dd46daba15411aeb2299a54b3 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef HYDROData_Region_HeaderFile
 #define HYDROData_Region_HeaderFile
 
-#include "HYDROData_Entity.h"
+#include "HYDROData_ShapesGroup.h"
 
 
 DEFINE_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
@@ -94,7 +94,7 @@ public:
    * - a shell if the zones faces can't be united into one face
    * \return shape as TopoDS_Shape
    */
-  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0 ) const;
 
 protected:
 
index 237059c0a60afecd7bd458a0926e1773e4dbfedf..a540e527f0599b13fa3e22939c9fd5a274556c34 100644 (file)
@@ -1,6 +1,8 @@
 
 #include "HYDROData_ShapesGroup.h"
 
+#include "HYDROData_ShapesTool.h"
+
 #include <TDF_ChildIDIterator.hxx>
 
 #include <TopoDS.hxx>
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 
+#include <BRepBuilderAPI_MakeShape.hxx>
+
+#include <ShapeUpgrade_UnifySameDomain.hxx>
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_ShapesGroup,HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ShapesGroup,HYDROData_Entity)
 
+void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*          theGroupsDefs,
+                                                     BRepBuilderAPI_MakeShape* 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 );
+      /*
+      if ( theAlgo->IsDeleted( aShape ) )
+      {
+        aGroupDef.Shapes.Remove( i );
+        --i;
+      }
+      else 
+      {*/
+        const TopTools_ListOfShape& aModifiedByAlgo = theAlgo->Modified( aShape );
+        if ( !aModifiedByAlgo.IsEmpty() )
+        {
+          HYDROData_ShapesTool::AddShapes( aShapesToAdd, aModifiedByAlgo );
+          aGroupDef.Shapes.Remove( i );
+          --i;
+        }
+        else
+        {
+          const TopTools_ListOfShape& aGeneratedByAlgo = theAlgo->Generated( aShape );
+          if ( !aGeneratedByAlgo.IsEmpty() )
+          {
+            HYDROData_ShapesTool::AddShapes( aShapesToAdd, aGeneratedByAlgo );
+            aGroupDef.Shapes.Remove( i );
+            --i;
+          }
+        }
+      //}
+    }
+
+    HYDROData_ShapesTool::AddShapes( aGroupDef.Shapes, aShapesToAdd );
+  }
+}
+
+void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs*              theGroupsDefs,
+                                                     ShapeUpgrade_UnifySameDomain* 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->Generated( aShape );
+      if ( aGeneratedByAlgo.IsNull() || aShape.IsEqual( aGeneratedByAlgo ) )
+        continue;
+
+      aShapesToAdd.Append( aGeneratedByAlgo );
+      aGroupDef.Shapes.Remove( i );
+      --i;
+    }
+
+    HYDROData_ShapesTool::AddShapes( aGroupDef.Shapes, aShapesToAdd );
+  }
+}
+
 HYDROData_ShapesGroup::HYDROData_ShapesGroup()
 : HYDROData_Entity()
 {
index 8d6a1948ba44ab1c63c8994c495eb97c6fa5801e..56bed37c3cd04fa652007831c6f8705624c17f75 100644 (file)
@@ -6,8 +6,12 @@
 
 #include <TopTools_SequenceOfShape.hxx>
 
+#include <QString>
+
 class TopoDS_Shape;
 class TopTools_ListOfShape;
+class BRepBuilderAPI_MakeShape;
+class ShapeUpgrade_UnifySameDomain;
 
 DEFINE_STANDARD_HANDLE(HYDROData_ShapesGroup, HYDROData_Entity)
 
@@ -16,6 +20,23 @@ DEFINE_STANDARD_HANDLE(HYDROData_ShapesGroup, HYDROData_Entity)
  */
 class HYDROData_ShapesGroup : public HYDROData_Entity
 {
+public:
+
+  struct GroupDefinition
+  {
+    GroupDefinition() {}
+
+    static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
+                        BRepBuilderAPI_MakeShape*              theAlgo );
+
+    static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
+                        ShapeUpgrade_UnifySameDomain*          theAlgo );
+
+    TCollection_AsciiString            Name;
+    TopTools_SequenceOfShape           Shapes;
+  };
+  typedef NCollection_Sequence<GroupDefinition> SeqOfGroupsDefs;
+
 protected:
   /**
    * Enumeration of tags corresponding to the persistent object parameters.