]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
export of calc case -- groups def.
authorisn <isn@opencascade.com>
Fri, 21 Oct 2016 15:27:57 +0000 (18:27 +0300)
committerisn <isn@opencascade.com>
Tue, 25 Oct 2016 12:13:11 +0000 (15:13 +0300)
13 files changed:
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_GeomTool.cxx
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_ShapesGroup.cxx
src/HYDROData/HYDROData_ShapesGroup.h
src/HYDROData/HYDROData_SplitShapesGroup.cxx
src/HYDROData/HYDROData_SplitShapesGroup.h
src/HYDROData/HYDROData_SplitToZonesTool.cxx
src/HYDROData/HYDROData_SplitToZonesTool.h
src/HYDRO_tests/test_HYDROData_CalcCase.cxx

index 9323fe6ce90221ede273a5a1a7ded33126c9cbfb..610e96a12bdb70606d38955d917eb5c08119afce 100644 (file)
@@ -303,7 +303,8 @@ void HYDROData_CalculationCase::Update()
         const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
         if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
           aZonesList.append( aSplitData );
-        else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
+        else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge ||
+                  aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_IntEdge)
           anEdgesList.append( aSplitData );
       }
     }
@@ -460,6 +461,12 @@ void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Docu
       continue;
 
     aSplitGroup->AddShape( aSplitData.Shape );
+
+    TopTools_SequenceOfShape theShapes;
+    aSplitGroup->GetShapes(theShapes);
+
+    if (aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_IntEdge)
+      aSplitGroup->SetInternal(true); 
   }
 }
 
@@ -1055,6 +1062,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
   // Get groups definitions
   HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups();
 
+  TopTools_SequenceOfShape IntSh; //internal edges
   HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups );
   for ( ; anIter.More(); anIter.Next() )
   {
@@ -1070,6 +1078,16 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
     aGroup->GetShapes( aGroupDef.Shapes );
 
     aSeqOfGroupsDefs.Append( aGroupDef );
+
+    Handle(HYDROData_SplitShapesGroup) aSSGroup = Handle(HYDROData_SplitShapesGroup)::DownCast( anIter.Value() );
+    TopTools_SequenceOfShape dummy;
+    if (!aSSGroup.IsNull())
+      if (aSSGroup->GetInternal())
+      {
+        aSSGroup->GetShapes(dummy);
+        IntSh.Append(dummy);
+      }
+
   }
   
   // Get faces
@@ -1087,7 +1105,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
     if ( isAllNotSubmersible )
       isAllNotSubmersible = false;
 
-    TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
+    TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs, &IntSh );
     aShToNames.Add( aRegionShape, aRegion->GetName() );
   }
 
@@ -1122,33 +1140,32 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
   TCollection_AsciiString aNam("Sh_");
   int i=1;
 #endif
+  TopTools_DataMapOfShapeListOfShape SH2M;
   for ( int i = 1; i <= aShToName.Extent(); i++ )
   {
     const TopoDS_Shape& aShape = aShToName.FindKey(i);
     if ( aShape.IsNull() )
       continue;
-
-    if ( aShape.ShapeType() == TopAbs_FACE )
+    
+    SH2M.Bind(aShape, TopTools_ListOfShape());
+    TopTools_ListOfShape& LM = SH2M.ChangeFind(aShape);
+    if ( aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL )
     {
       aSewing.Add( aShape );
-#ifdef DEB_CALCULATION
-      TCollection_AsciiString aName = aNam + ++i + ".brep";
-      BRepTools::Write(aShape ,aName.ToCString());
-#endif
+      LM.Append(aShape);
     }
-    else
+    else if (aShape.ShapeType() == TopAbs_COMPOUND)
     {
-#ifdef DEB_CALCULATION
-      int j = 1;
-#endif
-      TopExp_Explorer anExp( aShape, TopAbs_FACE );
-      for (; anExp.More(); anExp.Next() ) {
+      TopExp_Explorer anExp( aShape, TopAbs_SHELL );
+      for (; anExp.More(); anExp.Next() )
+      {
         aSewing.Add( anExp.Current() );
-#ifdef DEB_CALCULATION
-
-        TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
-        BRepTools::Write(anExp.Current() ,aName.ToCString());
-#endif
+        LM.Append(anExp.Current());
+      }
+      anExp.Init( aShape, TopAbs_FACE, TopAbs_SHELL );
+      {
+        aSewing.Add( anExp.Current() );
+        LM.Append(anExp.Current());
       }
     }
   } // faces iterator
@@ -1162,13 +1179,14 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
   {
     const TopoDS_Shape& CurShape = aShToName.FindKey(i);
     const QString& Qstr = aShToName.FindFromIndex(i);
-    for (TopExp_Explorer Exp(CurShape, TopAbs_FACE); Exp.More(); Exp.Next())
+    const TopTools_ListOfShape& LM = SH2M(CurShape);
+    for (TopTools_ListIteratorOfListOfShape it(LM); it.More(); it.Next())
     {
-      const TopoDS_Face& cf = TopoDS::Face(Exp.Current());
-      if (aSewing.IsModified(cf))
-        aFacesToNameModif.Add(aSewing.Modified(cf), Qstr);
+      const TopoDS_Shape& csh = it.Value();
+      if (aSewing.IsModified(csh))
+        aFacesToNameModif.Add(aSewing.Modified(csh), Qstr);
       else
-        aFacesToNameModif.Add(cf, Qstr);
+        aFacesToNameModif.Add(csh, Qstr);
     }
   }
 
index 8d4c2afb413b600cb7e6f9ea336a029ba5b6e8ce..5a055f78e16909bbbd011e2e5e8a0a9c8f8ebb6c 100644 (file)
@@ -822,3 +822,22 @@ double HYDROData_Entity::GetDouble( int theTag, double theDefValue ) const
 
   return anAttr->Get();
 }
+
+void HYDROData_Entity::SetInteger( int theTag, int theValue )
+{
+  Handle(TDataStd_Integer) anAttr;
+  TDF_Label aLabel = myLab.FindChild( theTag );
+  if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+    aLabel.AddAttribute( anAttr = new TDataStd_Integer() );
+  anAttr->Set( theValue );
+}
+
+int HYDROData_Entity::GetInteger( int theTag, int theDefValue ) const
+{
+  Handle(TDataStd_Integer) anAttr;
+  TDF_Label aLabel = myLab.FindChild( theTag );
+  if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+    return 0;
+
+  return anAttr->Get();
+}
index a38e771dd47ba9a8499061bc6a34835b23e38882..37bdcc664111c8204c90200ed210224aae9b9858 100644 (file)
@@ -453,6 +453,10 @@ protected:
   void SetDouble( int theTag, double theValue );
   double GetDouble( int theTag, double theDefValue = 0.0 ) const;
 
+  void SetInteger( int theTag, int theValue );
+  int GetInteger( int theTag, int theDefValue = 0 ) const;
+
+
   int GetGeomChangeFlag() const;
 
 protected:
index 45add50105550ee9dcc15ee24188078af6d6f599..3d54e13f34e87e59f3cb4d8b03723619ca9f2f92 100644 (file)
@@ -175,6 +175,14 @@ GEOM::GEOM_Object_ptr HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( GEOM::GE
 
   TopTools_MapOfShape mapShape;
 
+  NCollection_IndexedDataMap<TopoDS_Shape, QString, TopTools_ShapeMapHasher> aFF2N;
+  for (int i = 1; i <= aFacesToNameModif.Extent(); i++)
+  {
+    TopExp_Explorer exp (aFacesToNameModif.FindKey(i), TopAbs_FACE);
+    for (;exp.More(); exp.Next())
+      aFF2N.Add(exp.Current(), aFacesToNameModif.FindFromIndex(i));
+  }
+
   TopExp_Explorer exp (theShape, TopAbs_FACE);
   QVector<QString> Names;
   for (; exp.More(); exp.Next())
@@ -183,7 +191,7 @@ GEOM::GEOM_Object_ptr HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( GEOM::GE
     if (mapShape.Add(csh))
     {
       //listShape.Append(csh);
-      QString Qstr = aFacesToNameModif.FindFromKey(csh);
+      QString Qstr = aFF2N.FindFromKey(csh);
       Names.push_back(Qstr);
     }
   }
index 698cfc944925502b5744e9ae3adc281bc39b5523..226e0e46c550d8f5bdc9927b47d84aebdc7e01ab 100644 (file)
@@ -38,6 +38,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 
+
 #include <BRep_Builder.hxx>
 #include <BRepAlgoAPI_Fuse.hxx>
 
 #include <QStringList>
 #include <QColor>
 
+#include "Handle_Geom_Plane.hxx"
+#include "Geom_Plane.hxx"
+#include "gp_Pln.hxx"
+#include "BRepTools_ReShape.hxx"
+
 //#define DEB_GET_REGION_SHAPE
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
@@ -239,7 +245,9 @@ void getUsedGroups( const TopoDS_Shape&                     theShape,
   }
 }
 
-TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups ) const
+
+
+TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups, const TopTools_SequenceOfShape* IntSh ) const
 {
   HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroups;
   HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfUsedGroups;
@@ -260,6 +268,9 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs*
 
   HYDROData_SequenceOfObjects aZones = GetZones();
   HYDROData_SequenceOfObjects::Iterator aZoneIter( aZones );
+  TopTools_IndexedMapOfShape AllE;
+  TopTools_IndexedMapOfShape IE; //int edges
+
   for ( ; aZoneIter.More(); aZoneIter.Next() )
   {
     Handle(HYDROData_Zone) aZone =
@@ -273,19 +284,25 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs*
 
     TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
     aRegionFacesList.Append( aZoneFace );
-
+    TopExp::MapShapes(aZoneFace, TopAbs_EDGE, AllE); // collect all edges
     getUsedGroups( aZoneFace, aSeqOfGroups, aSeqOfUsedGroups );
   } // zones iterator
+
+  for (int i = 1; i <= IntSh->Length(); i++)
+  {
+    const TopoDS_Shape& CS = (*IntSh)(i);
+    if (AllE.Contains(CS))
+      IE.Add(CS);
+  }
   
   if ( aRegionFacesList.IsEmpty() )
     return aResShape;
 
-  // The unite region face
   TopoDS_Face aRegionFace;
 
   if ( aRegionFacesList.Extent() == 1 )
   {
-    aRegionFace = TopoDS::Face( aRegionFacesList.First() );
+    aResShape = TopoDS::Face( aRegionFacesList.First() );
   }
   else
   {
@@ -312,6 +329,35 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs*
       }
 
       aFuseShape = aFuse.Shape();
+
+      //update history of internal edges
+      TopTools_IndexedMapOfShape DIE;
+      TopTools_ListOfShape newSh1, newSh2;
+      for (int i = 1; i <= IE.Extent(); i++)
+      {
+        const TopoDS_Shape& CSH = IE(i);
+        newSh1.Clear();
+        newSh2.Clear();
+        newSh1 = aFuse.Modified(CSH);
+        if (newSh1.IsEmpty())
+        {
+          newSh2 = aFuse.Generated(CSH);
+          if (newSh2.IsEmpty())
+            DIE.Add(CSH);
+          else
+            for (TopTools_ListIteratorOfListOfShape lt(newSh2); lt.More(); lt.Next())
+              if (!lt.Value().IsNull())
+                 DIE.Add(lt.Value());
+        }
+        else
+        {
+          for (TopTools_ListIteratorOfListOfShape lt(newSh1); lt.More(); lt.Next())
+            if (!lt.Value().IsNull())
+              DIE.Add(lt.Value());
+        }
+      }
+      IE = DIE;
+      //update groups
       HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &aFuse );
     } // faces iterator
 
@@ -319,73 +365,86 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs*
     HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Fused face edges:", aFuseShape, TopAbs_EDGE );
 #endif
 
-    // Check the result of fuse operation
-    if ( !aFuseShape.IsNull() )
+    BRep_Builder BB;
+    TopoDS_Face DF;
+    if (!IE.IsEmpty())
     {
-      ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
-      anUnifier.Build();
+      //add dummy face to existing shell
+      //this face contains all internal edges
+      //USD algo will skip such edges and will not perform unifying through them 
+      //(more than 2 faces are connected to one edge + non same domain surfaces)
+      TopoDS_Wire DW;
+      Handle_Geom_Plane DPl = new Geom_Plane(gp_Pln (gp_Pnt(0,0,0), gp_Dir(0,1,0))); //non same domain with the main surf
+      BB.MakeFace(DF, DPl, Precision::Confusion());
+      BB.MakeWire(DW);
+      for (int i = 1; i <= IE.Extent(); i++)
+        BB.Add(DW, IE(i));
+      BB.Add(DF, DW);
+      BB.Add(aFuseShape, DF);
+    }
 
-      const TopoDS_Shape& anUnitedShape = anUnifier.Shape();
+    ShapeUpgrade_UnifySameDomain unif( aFuseShape );
+    unif.Build();
+    TopoDS_Shape anUnitedShape;
+    const TopoDS_Shape& out = unif.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( &aSeqOfUsedGroups, &unif );
 
-#ifdef DEB_GET_REGION_SHAPE
-        HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Result face edges:", aRegionFace, TopAbs_EDGE );
-#endif
+    if (!IE.IsEmpty())
+    {
+      //remove dummy face from shell; shell becomes valid
+      const TopoDS_Shape& NDF = unif.Generated(DF);
+      BRepTools_ReShape ReShaper;
+      ReShaper.Remove(NDF);
+      anUnitedShape = ReShaper.Apply(out);
+      HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &ReShaper );
+    }
+    else
+      anUnitedShape = out;
 
-        HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &anUnifier );
+    TopTools_SequenceOfShape aShapeFaces;
+    HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces );
+    if ( aShapeFaces.Length() == 1 ) //it should be either face or compound of faces (?)
+    {
+      const TopoDS_Face& CF = TopoDS::Face( aShapeFaces.Value( 1 ));
+      aResShape = CF;
+    }
+    else
+    {
+      TopTools_SequenceOfShape aShapeShells;
+      HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_SHELL, aShapeShells );
+      if (aShapeShells.Length() == 1)
+        aResShape = TopoDS::Shell(aShapeShells(1));
+      else
+        aResShape = anUnitedShape;
+    }
 
-        // Update the sequence of groups
-        if ( theSeqOfGroups )
+    // Update the sequence of groups
+    if ( theSeqOfGroups )
+    {
+      HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator aUsedIter( aSeqOfUsedGroups );
+      for ( ; aUsedIter.More(); aUsedIter.Next() )
+      {
+        const HYDROData_ShapesGroup::GroupDefinition& aUsedGroupDef = aUsedIter.Value();
+        if ( aUsedGroupDef.Shapes.IsEmpty() )
+          continue;
+
+        HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator anOriIter( aSeqOfGroups );
+        for ( ; anOriIter.More(); anOriIter.Next() )
         {
-          HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator aUsedIter( aSeqOfUsedGroups );
-          for ( ; aUsedIter.More(); aUsedIter.Next() )
-          {
-            const HYDROData_ShapesGroup::GroupDefinition& aUsedGroupDef = aUsedIter.Value();
-            if ( aUsedGroupDef.Shapes.IsEmpty() )
-              continue;
-
-            HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator anOriIter( aSeqOfGroups );
-            for ( ; anOriIter.More(); anOriIter.Next() )
-            {
-              HYDROData_ShapesGroup::GroupDefinition& anOriGroupDef = anOriIter.ChangeValue();
-              if ( anOriGroupDef.Name != aUsedGroupDef.Name )
-                continue;
-
-              HYDROData_ShapesTool::AddShapes( anOriGroupDef.Shapes, aUsedGroupDef.Shapes );
-              break;
-            }
-          }
-
-          *theSeqOfGroups = aSeqOfGroups;
+          HYDROData_ShapesGroup::GroupDefinition& anOriGroupDef = anOriIter.ChangeValue();
+          if ( anOriGroupDef.Name != aUsedGroupDef.Name )
+            continue;
+
+          HYDROData_ShapesTool::AddShapes( anOriGroupDef.Shapes, aUsedGroupDef.Shapes );
+          break;
         }
       }
-    }
-  }
 
-  if ( !aRegionFace.IsNull() )
-  {
-    // result shape is a face
-    aResShape = aRegionFace;
+      *theSeqOfGroups = aSeqOfGroups;
+    }
   }
-  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 08af0ab65ef6c53ce724bcedf726a64baab2077c..bc9a7c6af1019458340f4e8fdafc68cdc5acd492 100644 (file)
@@ -114,7 +114,8 @@ 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( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0 ) const;
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0, 
+                                                  const TopTools_SequenceOfShape* IntSh = NULL ) const;
 
   HYDRODATA_EXPORT bool IsSubmersible() const;
 
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";
index db2a29ea4d4af497f395be5be985b2c6724380eb..394bf16e3d059f2bc367655103e9dcd4f3554475 100644 (file)
@@ -29,6 +29,7 @@ class TopoDS_Shape;
 class TopTools_ListOfShape;
 class BRepBuilderAPI_MakeShape;
 class ShapeUpgrade_UnifySameDomain;
+class BRepTools_ReShape;
 
 DEFINE_STANDARD_HANDLE(HYDROData_ShapesGroup, HYDROData_Entity)
 
@@ -49,6 +50,10 @@ public:
     static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
                         ShapeUpgrade_UnifySameDomain*          theAlgo );
 
+    static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
+                        BRepTools_ReShape*                     theAlgo );
+    
+
     void        Dump( std::ostream& theStream ) const;
 
     static void Dump( std::ostream&                                theStream,
index dd50bc4e01f7907eb4e7a0e143037cf32e32ecd3..a73b11cb8966efefafb4cd6213f8be2ed3e7d0e3 100644 (file)
@@ -30,4 +30,13 @@ HYDROData_SplitShapesGroup::~HYDROData_SplitShapesGroup()
 {
 }
 
+void HYDROData_SplitShapesGroup::SetInternal(bool flag)
+{
+  SetInteger(DataTag_InternalEdge, (int)flag);
+}
+
+bool HYDROData_SplitShapesGroup::GetInternal() const
+{
+  return (bool)GetInteger(DataTag_InternalEdge);
+}
 
index 81e04ded6134136a4091efebc201257cc23dc4f9..b6812301e38c2d3c80d1fd0999568b1f518944a9 100644 (file)
@@ -35,7 +35,8 @@ protected:
    */
   enum DataTag
   {
-    DataTag_First = HYDROData_ShapesGroup::DataTag_First + 100 ///< first tag, to reserve
+    DataTag_First = HYDROData_ShapesGroup::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_InternalEdge
   };
 
 public:
@@ -46,6 +47,9 @@ public:
    */
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_SPLIT_GROUP; }
 
+  void SetInternal(bool flag);
+  bool GetInternal() const;
+
 protected:
 
   friend class HYDROData_Iterator;
index e5a1d8428aa7d3b87393a9bd3eb1f5e7eb896f5c..ddcc40706f0870ebfe84d50ab6e51a9bab8f7903 100644 (file)
@@ -34,6 +34,7 @@
 #include <BRepCheck_Analyzer.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 #include <gp_Pln.hxx>
 #include <BRepGProp.hxx>
 #include <GProp_GProps.hxx>
@@ -42,6 +43,7 @@
 
 #include <BOPAlgo_BOP.hxx>
 #include <BOPAlgo_Builder.hxx>
+#include <TopExp.hxx>
 
 //#define DEB_SPLIT_TO_ZONES 1
 //#define DEB_SPLIT_TO_ZONES_CHECK_PARTITION 1
@@ -138,7 +140,9 @@ HYDROData_SplitToZonesTool::SplitDataList
 {
   DEBTRACE("Split");
   SplitDataList anOutputSplitDataList;
-  if(theObjectList.IsEmpty()) return anOutputSplitDataList;
+  NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> OutNE;
+  if(theObjectList.IsEmpty())
+    return anOutputSplitDataList;
   // Preparation. 
   // Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
   SplitDataList anInputSplitDataList;
@@ -214,14 +218,37 @@ HYDROData_SplitToZonesTool::SplitDataList
   // If only one shape is given we don't split it 
   // algorithm just returns the unpacked input data
   bool limplus1Object(false);
-  if(theObjectList.Size() == 1 )  {
-    if(thePolyline.IsNull()) {
-      anOutputSplitDataList.append(anInputSplitDataList); 
+  if(theObjectList.Size() == 1 ) 
+  {
+    if(thePolyline.IsNull()) 
+    {
+      //anOutputSplitDataList.append(anInputSplitDataList); 
+      SplitData SD = anInputSplitDataList.at(0);
+      TopTools_ListOfShape newshs;
+      CutFaceByEdges(SD.Face(), newshs, InterPolys, &OutNE);
+      for (TopTools_ListIteratorOfListOfShape it(newshs); it.More(); it.Next())
+      {
+        SplitData NSD = SD;
+        NSD.Shape = it.Value();
+        anOutputSplitDataList.append(NSD);
+      }
+
+      NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>::Iterator spit(OutNE);
+      for (;spit.More();spit.Next())
+      {
+        const TopoDS_Edge& E = TopoDS::Edge(spit.Key());
+        if (E.IsNull())
+          continue;
+        SplitData SDI(SplitData::Data_IntEdge, E, spit.Value()->GetName());   
+        anOutputSplitDataList.append(SDI);
+      }
+
       if(!theGroupsList.IsEmpty() ) 
         anOutputSplitDataList.append(anInputGroupList);
       return anOutputSplitDataList;
-    } else
-        limplus1Object = true;// size =1 && hasLimits
+    }
+    else
+      limplus1Object = true;// size =1 && hasLimits
   }
   HYDROData_DataMapOfShapeListOfString aDM3;
   if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
@@ -552,7 +579,16 @@ HYDROData_SplitToZonesTool::SplitDataList
     }
   }
 
-  AddInternalEdges(aDM2, InterPolys);
+  AddInternalEdges(aDM2, InterPolys, &OutNE);
+  NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>::Iterator spit(OutNE);
+  for (;spit.More();spit.Next())
+  {
+    const TopoDS_Edge& E = TopoDS::Edge(spit.Key());
+    if (E.IsNull())
+      continue;
+    SplitData SDI(SplitData::Data_IntEdge, E, spit.Value()->GetName());   
+    anOutputSplitDataList.append(SDI);
+  }
 
   // Step 4. Fill output structure.
 #ifdef DEB_SPLIT_TO_ZONES
@@ -622,22 +658,23 @@ HYDROData_SplitToZonesTool::SplitDataList
 }
 
 void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
-   const HYDROData_SequenceOfObjects& thePolylines)
+   const HYDROData_SequenceOfObjects& thePolylines,
+   NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE)
 {
 
   HYDROData_SequenceOfObjects::Iterator it(thePolylines);
   TopTools_ListOfShape Wires;
+  NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> W2P;
   for (;it.More();it.Next())
   {
     Handle(HYDROData_PolylineXY) P = Handle(HYDROData_PolylineXY)::DownCast(it.Value());
-    Wires.Append(P->GetShape());
-    //Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
-    //if (P->GetNbConnectedWires(aConnectedWires) > 0)
-    //  Wires.Append(aConnectedWires->Value(1));
+    const TopoDS_Shape& CW = P->GetShape();
+    Wires.Append(CW);
+    W2P.Bind(CW, P);
   }
 
   HYDROData_DataMapOfShapeListOfShape newDM;
-
+  TopTools_IndexedDataMapOfShapeShape OutNE1;
   for (int i = 1; i <= DM.Extent();i++)
   {
     const TopoDS_Shape& K = DM.FindKey(i);
@@ -645,7 +682,7 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf
     TopTools_ListOfShape out;
     if (K.ShapeType() == TopAbs_FACE)
     {
-      CutByEdges(K, Wires, out);
+      CutByEdges(K, Wires, out, &OutNE1);
       TopTools_ListIteratorOfListOfShape it(out);
       for (;it.More(); it.Next())
       {
@@ -658,17 +695,44 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf
       newDM.Add(K, V); // ignore edges, wires...
   }
 
+  for (int i = 1; i <= OutNE1.Extent(); i++)
+    OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i)));
+
   DM = newDM;
 }
 
+void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in, 
+                                                TopTools_ListOfShape& out, 
+                                                const HYDROData_SequenceOfObjects& thePolylines,
+                                                NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE)
+{
 
-int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
-  TopTools_ListOfShape& outShs)
+  HYDROData_SequenceOfObjects::Iterator it(thePolylines);
+  TopTools_ListOfShape Wires;
+  NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> W2P;
+  for (;it.More();it.Next())
+  {
+    Handle(HYDROData_PolylineXY) P = Handle(HYDROData_PolylineXY)::DownCast(it.Value());
+    const TopoDS_Shape& CW = P->GetShape();
+    Wires.Append(CW);
+    W2P.Bind(CW, P);
+  }
+
+  TopTools_IndexedDataMapOfShapeShape OutNE1;
+  CutByEdges(in, Wires, out, &OutNE1);
+
+  for (int i = 1; i <= OutNE1.Extent(); i++)
+    OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i)));
+
+}
+
+int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
+  TopTools_ListOfShape& outShs, TopTools_IndexedDataMapOfShapeShape* OutNE)
 {
   int anError;
   if (InSh.IsNull())
     return -1;
-  if (InEdges.IsEmpty())
+  if (InW.IsEmpty())
   {
     outShs.Clear();
     outShs.Append(InSh);
@@ -677,7 +741,8 @@ int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTo
   TopTools_ListIteratorOfListOfShape anIt;
   BOPAlgo_Builder anAlgo;
   anAlgo.AddArgument(InSh);
-  anIt.Initialize( InEdges );
+
+  anIt.Initialize( InW );
   for( ; anIt.More(); anIt.Next() )
     anAlgo.AddArgument( anIt.Value() );
 
@@ -689,5 +754,39 @@ int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTo
   outShs = anAlgo.Modified( InSh );
   if (outShs.IsEmpty())
     outShs.Append(InSh);
+
+  if (OutNE)
+  {
+    TopTools_IndexedDataMapOfShapeShape NonFOutNE;
+    anIt.Initialize( InW );
+    for( ; anIt.More(); anIt.Next() )
+    {
+      const TopoDS_Shape& OSH = anIt.Value(); 
+      TopExp_Explorer exp(OSH, TopAbs_EDGE);
+      for (;exp.More();exp.Next())
+      {
+        const TopoDS_Edge& OE = TopoDS::Edge(exp.Current());
+        const TopTools_ListOfShape& ls = anAlgo.Modified(OE);
+        TopTools_ListIteratorOfListOfShape itls(ls);
+        for (;itls.More();itls.Next())
+          NonFOutNE.Add(itls.Value(), OSH);
+      }
+    }
+
+    //filter edges; if face contain an edge => keep it
+    TopTools_IndexedMapOfShape AllEdges; //edges from output shape
+    for (anIt.Initialize(outShs); anIt.More();anIt.Next())
+      TopExp::MapShapes(anIt.Value(), TopAbs_EDGE, AllEdges);
+
+    for (int i = 1; i <= NonFOutNE.Extent(); i++)
+    {
+      const TopoDS_Shape& CE = NonFOutNE.FindKey(i);
+      const TopoDS_Shape& V = NonFOutNE.FindFromIndex(i);
+      if (AllEdges.Contains(CE))
+        OutNE->Add(CE, V);
+    }
+
+  }
+
   return 0;
 }
index 530e7f2aba241f1606e998177afb99c67fe4df50..63a3065e6c7cf5727c5ae84c588b7429f48dc400 100644 (file)
 #include <TopoDS_Face.hxx>
 #include <TopTools_ShapeMapHasher.hxx>
 #include <NCollection_IndexedMap.hxx>
-#include <NCollection_IndexedDataMap.hxx>
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <QStringList>
+#include <NCollection_DataMap.hxx>
 
 class Handle(HYDROData_PolylineXY);
 
@@ -50,7 +51,8 @@ public:
     {
       Data_None,
       Data_Zone,
-      Data_Edge
+      Data_Edge,
+      Data_IntEdge
     };
 
     TopoDS_Shape    Shape;
@@ -93,10 +95,17 @@ public:
   static SplitDataList       Split( const HYDROData_SequenceOfObjects&  theObjectList );
 
   static void AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
-                               const HYDROData_SequenceOfObjects& thePolylines);
+                               const HYDROData_SequenceOfObjects& thePolylines,
+                               NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
 
-  static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
-                        TopTools_ListOfShape& outShs);
+  static void CutFaceByEdges(const TopoDS_Face& in, 
+                             TopTools_ListOfShape& out, 
+                             const HYDROData_SequenceOfObjects& thePolylines,
+                             NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
+
+  static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
+                        TopTools_ListOfShape& outShs,
+                        TopTools_IndexedDataMapOfShapeShape* OutNE2OE);
 
   static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
 
index fdec7023eea0c18c2751bc5067c5a125fcf87834..f1cf71b8f434df1a775dea7cc5a9048e4ede7eca 100644 (file)
@@ -52,7 +52,9 @@ void test_HYDROData_CalcCase::test_add_int_wires()
     Wires.Append(InP);
 
     TopTools_ListOfShape OutSh;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+    TopTools_IndexedDataMapOfShapeShape ls;
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
+
     CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
     TopoDS_Compound cmp;
     B.MakeCompound(cmp);
@@ -74,7 +76,8 @@ void test_HYDROData_CalcCase::test_add_int_wires()
     Wires.Append(InP);
 
     TopTools_ListOfShape OutSh;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+    TopTools_IndexedDataMapOfShapeShape ls;
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
     //CPPUNIT_ASSERT_IMAGES
@@ -92,7 +95,8 @@ void test_HYDROData_CalcCase::test_add_int_wires()
     Wires.Append(InP);
 
     TopTools_ListOfShape OutSh;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+    TopTools_IndexedDataMapOfShapeShape ls;
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" );
     CPPUNIT_ASSERT_IMAGES