Salome HOME
Convert the altitude for bathymetry to negative number during it reading from the...
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.cxx
index 2e29c18eef76aca72dcf33a0cdbfb00f9743dc42..0990ef4c1ddfee9d748ebd502834ff7e3c843b93 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>
@@ -36,7 +36,7 @@ TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
 
 HYDROData_SplitToZonesTool::SplitDataList
 HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& theObjectList,
-                                          const Handle(HYDROData_Polyline)&  thePolyline )
+                                          const Handle(HYDROData_PolylineXY)&  thePolyline )
 {
   SplitDataList anOutputSplitDataList;
 
@@ -48,8 +48,21 @@ HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& the
       Handle(HYDROData_Object)::DownCast( theObjectList.Value( anIndex ) );
     if( !aGeomObj.IsNull() )
     {
-      SplitData aSplitData( aGeomObj->GetTopShape(), aGeomObj->GetName() );
-      anInputSplitDataList.append( aSplitData );
+      TopoDS_Shape aShape = aGeomObj->GetTopShape();
+      if ( !aShape.IsNull() && 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( aFace, aGeomObj->GetName() );
+            anInputSplitDataList.append( aSplitData );
+          }
+        }
+      } else {
+        SplitData aSplitData( aShape, aGeomObj->GetName() );
+        anInputSplitDataList.append( aSplitData );
+      }
     }
   }
 
@@ -93,7 +106,7 @@ 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 );