Salome HOME
Splitting data for calculation case edges (Feature #242).
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.cxx
index 2e29c18eef76aca72dcf33a0cdbfb00f9743dc42..a3fe087a0a4285d7f3b2790db9e4e579734ec4f5 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "HYDROData_SplitToZonesTool.h"
 
-#include "HYDROData_Polyline.h"
+#include "HYDROData_PolylineXY.h"
 
 #include <BRepAlgoAPI_Common.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
@@ -35,8 +35,9 @@ TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
 }
 
 HYDROData_SplitToZonesTool::SplitDataList
-HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& theObjectList,
-                                          const Handle(HYDROData_Polyline)&  thePolyline )
+  HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects&  theObjectList,
+                                     const HYDROData_SequenceOfObjects&  theGroupsList,
+                                     const Handle(HYDROData_PolylineXY)& thePolyline )
 {
   SplitDataList anOutputSplitDataList;
 
@@ -46,9 +47,25 @@ HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& the
   {
     Handle(HYDROData_Object) aGeomObj = 
       Handle(HYDROData_Object)::DownCast( theObjectList.Value( anIndex ) );
-    if( !aGeomObj.IsNull() )
-    {
-      SplitData aSplitData( aGeomObj->GetTopShape(), aGeomObj->GetName() );
+    if( aGeomObj.IsNull() )
+      continue;
+
+    TopoDS_Shape aShape = aGeomObj->GetTopShape();
+    if ( aShape.IsNull() )
+      continue;
+        
+    if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
+      // Create split data for each face contained in the compound
+      TopExp_Explorer anExp( aShape, TopAbs_FACE );
+      for ( ; anExp.More(); anExp.Next() ) {
+        TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
+        if ( !aFace.IsNull() ) {
+          SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() );
+          anInputSplitDataList.append( aSplitData );
+        }
+      }
+    } else {
+      SplitData aSplitData( SplitData::Data_Zone, aShape, aGeomObj->GetName() );
       anInputSplitDataList.append( aSplitData );
     }
   }
@@ -93,14 +110,14 @@ HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& the
   // Step 2. Take into account the boundary polyline.
   if( !thePolyline.IsNull() )
   {
-    TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetTopShape() );
+    TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetShape() );
     if( !aWire.IsNull() )
     {
       BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
       aMakeFace.Build();
       if( aMakeFace.IsDone() )
       {
-        SplitData aBoundarySplitData( aMakeFace.Face(), "" );
+        SplitData aBoundarySplitData( SplitData::Data_Zone, aMakeFace.Face(), "" );
 
         SplitDataList aCutSplitDataList;
         SplitDataListIterator anOutputIter( anOutputSplitDataList );
@@ -157,9 +174,9 @@ bool HYDROData_SplitToZonesTool::SplitTwoData( const SplitData& theData1,
   BRepAlgoAPI_Cut aCut2( aShape2, aShape1 );
   TopoDS_Shape aCut2Shape = aCut2.Shape();
 
-  theData1Subtracted = SplitData( aCut1Shape, anObjectNames1 );
-  theData2Subtracted = SplitData( aCut2Shape, anObjectNames2 );
-  theDataIntersected = SplitData( aCommonShape, anObjectNames1 + anObjectNames2 );
+  theData1Subtracted = SplitData( SplitData::Data_Zone, aCut1Shape, anObjectNames1 );
+  theData2Subtracted = SplitData( SplitData::Data_Zone, aCut2Shape, anObjectNames2 );
+  theDataIntersected = SplitData( SplitData::Data_Zone, aCommonShape, anObjectNames1 + anObjectNames2 );
 
   return true;
 }
@@ -177,7 +194,7 @@ HYDROData_SplitToZonesTool::ExtractSeparateData( const SplitData& theData )
       TopoDS_Face aFace = TopoDS::Face( aShape );
       if( !aFace.IsNull() )
       {
-        SplitData aSplitData( aFace, theData.ObjectNames );
+        SplitData aSplitData( SplitData::Data_Zone, aFace, theData.ObjectNames );
         aSplitDataList.append( aSplitData );
       }
     }