Salome HOME
Merge branch 'BR_MULTI_BATHS' into HEAD
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.cxx
index ae9518b34665fe76c66e5e773a8b910b9bdd2a46..e5a1d8428aa7d3b87393a9bd3eb1f5e7eb896f5c 100644 (file)
@@ -1,3 +1,20 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "HYDROData_SplitToZonesTool.h"
 
@@ -23,6 +40,9 @@
 #include <Geom_Plane.hxx>
 #include <BRepBuilderAPI_FindPlane.hxx>
 
+#include <BOPAlgo_BOP.hxx>
+#include <BOPAlgo_Builder.hxx>
+
 //#define DEB_SPLIT_TO_ZONES 1
 //#define DEB_SPLIT_TO_ZONES_CHECK_PARTITION 1
 #if (defined (DEB_SPLIT_TO_ZONES) || defined(DEB_SPLIT_TO_ZONES_CHECK_PARTITION))
@@ -30,6 +50,9 @@
 static TCollection_AsciiString fileNameBefore("BeforeTranslation");
 #endif
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
 {
   TopoDS_Face aResFace;
@@ -110,8 +133,10 @@ Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& t
 HYDROData_SplitToZonesTool::SplitDataList
   HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects&  theObjectList,
                                      const HYDROData_SequenceOfObjects&  theGroupsList,
-                                     const Handle(HYDROData_PolylineXY)& thePolyline )
+                                     const Handle(HYDROData_PolylineXY)& thePolyline,
+                                     const HYDROData_SequenceOfObjects& InterPolys)
 {
+  DEBTRACE("Split");
   SplitDataList anOutputSplitDataList;
   if(theObjectList.IsEmpty()) return anOutputSplitDataList;
   // Preparation. 
@@ -122,16 +147,18 @@ HYDROData_SplitToZonesTool::SplitDataList
 #endif
   for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ )
   {
-    Handle(HYDROData_Object) aGeomObj = 
-      Handle(HYDROData_Object)::DownCast( theObjectList.Value( anIndex ) );
-    if( aGeomObj.IsNull() )
-      continue;
+    Handle(HYDROData_Entity) anObj = theObjectList.Value( anIndex );
+    TopoDS_Shape aShape;
+
+    Handle(HYDROData_Object) aGeomObj = Handle(HYDROData_Object)::DownCast( anObj );
+    if( !aGeomObj.IsNull() ) {
+      aShape = aGeomObj->GetTopShape();
+    }
 
-    TopoDS_Shape aShape = aGeomObj->GetTopShape();
     if ( aShape.IsNull() )
       continue;  
 #ifdef DEB_SPLIT_TO_ZONES
-   TCollection_AsciiString aName = aNam + anIndex + ".brep";
+   TCollection_AsciiString aName = aNam + anIndex + "_a.brep";
    BRepTools::Write(aShape, aName.ToCString());
 #endif
     if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
@@ -140,12 +167,12 @@ HYDROData_SplitToZonesTool::SplitDataList
       for ( ; anExp.More(); anExp.Next() ) {
         const TopoDS_Face& aFace = TopoDS::Face( anExp.Current() );
         if ( !aFace.IsNull() ) {
-          SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() );
+          SplitData aSplitData( SplitData::Data_Zone, aFace, anObj->GetName() );
           anInputSplitDataList.append( aSplitData );
         }
       }
     } else {
-      SplitData aSplitData( SplitData::Data_Zone, aShape, aGeomObj->GetName() );
+      SplitData aSplitData( SplitData::Data_Zone, aShape, anObj->GetName() );
       anInputSplitDataList.append( aSplitData );
     }
   }
@@ -179,7 +206,7 @@ HYDROData_SplitToZonesTool::SplitDataList
         anInputGroupList.append( aSplitData );
 #ifdef DEB_SPLIT_TO_ZONES
         QString aStr = aSplitData.ObjectNames.join(" "); 
-        cout << "Group# = " <<anIndex <<" Nmb in grp = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size() <<endl;   
+        DEBTRACE("Group# = " <<anIndex <<" Nmb in grp = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size());
 #endif
       }
     }
@@ -201,7 +228,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     QStringList aListOfNames;
     for (int i=0;i < anInputGroupList.size() ;i++) {
       const TopoDS_Shape& aSh = anInputGroupList.at(i).Shape;
-      aDM3.Bind(aSh, anInputGroupList.at(i).ObjectNames);
+      aDM3.Add(aSh, anInputGroupList.at(i).ObjectNames);
     }
   }
 
@@ -214,16 +241,16 @@ HYDROData_SplitToZonesTool::SplitDataList
   aBB.MakeCompound(aCmp);
   for (int i=0;i < anInputSplitDataList.size() ;i++) {
     const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape;
-    aDM3.Bind(aSh, anInputSplitDataList.at(i).ObjectNames);
+    aDM3.Add(aSh, anInputSplitDataList.at(i).ObjectNames);
     aLS.Append(aSh);
     aBB.Add(aCmp,aSh);
 #ifdef DEB_SPLIT_TO_ZONES
-    //TCollection_AsciiString aName = aNam + i + ".brep";
-    //BRepTools::Write(aSh, aName.ToCString());
+    TCollection_AsciiString aName = aNam + i + "_b.brep";
+    BRepTools::Write(aSh, aName.ToCString());
 #endif
   }
 #ifdef DEB_SPLIT_TO_ZONES_CHECK_PARTITION
-  TCollection_AsciiString aNameBefore = fileNameBefore + ".brep";
+  TCollection_AsciiString aNameBefore = fileNameBefore + "_c.brep";
   BRepTools::Write(aCmp, aNameBefore.ToCString());
 #endif
 
@@ -239,7 +266,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     BRepCheck_Analyzer aCheck (aResult);
     if(!aCheck.IsValid()) {
   #ifdef DEB_SPLIT_TO_ZONES
-      cout << "result is not valid" <<endl;
+      DEBTRACE("result is not valid");
       BRepTools::Write(aResult, "SplitFacesNV.brep");  
   #endif
       return anOutputSplitDataList;
@@ -260,13 +287,24 @@ HYDROData_SplitToZonesTool::SplitDataList
       const TopTools_ListOfShape& aListOfNew = splitTool.Modified(anIt.Value());
       if(!aListOfNew.IsEmpty())
         foundF = Standard_True;
+
       TopTools_ListOfShape aList;
+
       TopTools_ListIteratorOfListOfShape it(aListOfNew);
       for(;it.More();it.Next())       
-        aList.Append(it.Value());    
+        aList.Append(it.Value());
+         /* *********************************************************************
+      // Bug in History: partition should give only modified entities! => temporary solution is used
+      //const TopTools_ListOfShape& aListOfGen = splitTool.Generated(anIt.Value());
+      //if(!aListOfGen.IsEmpty())
+        //foundF = Standard_True;
+      //it.Initialize(aListOfGen);    
+      //for(;it.More();it.Next())     
+       // aList.Append(it.Value());  
+          ********************************************************************* */
       if(!foundF) // face is not modified
         aList.Append (anIt.Value());
-      aDM1.Bind(anIt.Value(), aList);
+      aDM1.Add(anIt.Value(), aList);
   #ifdef DEB_SPLIT_TO_ZONES
       TCollection_AsciiString aName;
   #endif
@@ -276,26 +314,33 @@ HYDROData_SplitToZonesTool::SplitDataList
           aList.Clear();
           Standard_Boolean foundE(Standard_False);
           const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current());    
-          //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
+          DEBTRACE("NB_EDGE_M = " << aListM.Extent());
           if(aListM.Extent()) foundE = Standard_True;
           it.Initialize(aListM);    
           for(int k=1;it.More();it.Next(),k++) {    
             aList.Append(it.Value());
   #ifdef DEB_SPLIT_TO_ZONES
-            //aName = aNamM + i + j +k +".brep";
-            //BRepTools::Write(it.Value(),aName.ToCString());
+            aName = aNamM + i + j +k +"_d.brep";
+            BRepTools::Write(it.Value(),aName.ToCString());
   #endif
           }
+          /* *********************************************************************
+                 //const TopTools_ListOfShape& aListG = splitTool.Generated(exp.Current());
+          //if(aListG.Extent()) foundE = Standard_True;
+          //it.Initialize(aListG);    
+          //for(int k=1;it.More();it.Next(),k++)
+            //aList.Append(it.Value());
           //cout << "NB_EDGE = " << aList.Extent() <<endl;
+                 ************************************************************************** */
           if(!foundE) {
             aList.Append (exp.Current());
   #ifdef DEB_SPLIT_TO_ZONES
-            aName = aNamG + i + j +".brep";
+            aName = aNamG + i + j +"_e.brep";
             BRepTools::Write(exp.Current(),aName.ToCString());
-            cout << aName.ToCString()<< " = " << exp.Current().TShape() <<endl;
+            DEBTRACE(aName.ToCString()<< " = " << exp.Current().TShape());
   #endif
           }
-          aDM1.Bind(exp.Current(), aList);
+          aDM1.Add(exp.Current(), aList);
         }
       }
     }
@@ -310,8 +355,10 @@ HYDROData_SplitToZonesTool::SplitDataList
   Standard_Boolean hasLimits(Standard_False);
   QString aBndName;
   HYDROData_MapOfShape aBndView;
-  if (! thePolyline.IsNull()) {    
-    const TopoDS_Wire aBndWire = TopoDS::Wire(thePolyline->GetShape());
+  if (! thePolyline.IsNull()) {
+    Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
+    int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires);
+    const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
     if(!aBndWire.IsNull()) {
       TopoDS_Face limFace;       
       if(buildLimFace(aBndWire, limFace)) {
@@ -334,10 +381,10 @@ HYDROData_SplitToZonesTool::SplitDataList
               aBndView.Add(anEdge);
               QStringList aListOfNames;
               aListOfNames.append(aBndName);
-              aDM3.Bind(anEdge, aListOfNames);
+              aDM3.Add(anEdge, aListOfNames);
               TopTools_ListOfShape aList;
               aList.Append(anEdge);
-              aDM1.Bind(anEdge,aList);
+              aDM1.Add(anEdge,aList);
             }
             HYDROData_MapOfShape aView;
             exp.Init (aResult, TopAbs_FACE);
@@ -345,28 +392,28 @@ HYDROData_SplitToZonesTool::SplitDataList
               const TopoDS_Shape& aFace = exp.Current();
               if(!aFace.IsNull()) {
                 const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace);
-                //cout << "Modified: " << aListOfNew.Extent() <<endl;                                    
+                DEBTRACE("Modified: " << aListOfNew.Extent());
                 if(!aListOfNew.IsEmpty()) {
-                  aDM4.Bind(aFace, aListOfNew);
+                  aDM4.Add(aFace, aListOfNew);
 #ifdef DEB_SPLIT_TO_ZONES
-                  //TCollection_AsciiString aName = aNam + i + ".brep";
-                  //BRepTools::Write(aListOfNew.Last(), aName.ToCString());                
+                  TCollection_AsciiString aName = aNam + i + "_f.brep";
+                  BRepTools::Write(aListOfNew.Last(), aName.ToCString());
 #endif
                 }
                 else {
                     if(!mkCom.IsDeleted(aFace)) {
                       const TopTools_ListOfShape& aListOfGen = mkCom.Generated(aFace);    
                       if(!aListOfGen.IsEmpty()) {
-                        aDM4.Bind(aFace, aListOfGen);    
+                        /* aDM4.Bind(aFace, aListOfGen); ???   */
 #ifdef DEB_SPLIT_TO_ZONES
-                        //TCollection_AsciiString aName = aNam + i + "g.brep";
-                        //BRepTools::Write(aListOfGen.Last(), aName.ToCString());
+                        TCollection_AsciiString aName = aNam + i + "_g.brep";
+                        BRepTools::Write(aListOfGen.Last(), aName.ToCString());
 #endif
                       }
                        else {
                         TopTools_ListOfShape aList; 
                         aList.Append(aFace);
-                        aDM4.Bind(aFace, aList); //the same face - not modified
+                        aDM4.Add(aFace, aList); //the same face - not modified
                        }
                     }
              }
@@ -378,16 +425,16 @@ HYDROData_SplitToZonesTool::SplitDataList
                  aView.Add(anEdge);
                  const TopTools_ListOfShape& aListOfNewEd = mkCom.Modified(anEdge);                 
                  if(!aListOfNewEd.IsEmpty())
-                   aDM4.Bind(anEdge, aListOfNewEd);
+                   aDM4.Add(anEdge, aListOfNewEd);
                  else {
                    if(!mkCom.IsDeleted(anEdge)) {
                      const TopTools_ListOfShape& aListOfGenEd = mkCom.Generated(anEdge);
                      if(!aListOfGenEd.IsEmpty()) {
-                       aDM4.Bind(anEdge, aListOfGenEd);
+                       /* aDM4.Bind(anEdge, aListOfGenEd); ???*/
                      } else {
                        TopTools_ListOfShape aList; 
                        aList.Append(anEdge);
-                       aDM4.Bind(anEdge, aList);//the same edge - not modified
+                       aDM4.Add(anEdge, aList);//the same edge - not modified
                      }
                    }
                  }
@@ -408,22 +455,22 @@ HYDROData_SplitToZonesTool::SplitDataList
 #ifdef DEB_SPLIT_TO_ZONES
              TopTools_ListIteratorOfListOfShape itl(aListOfNewEd);
              for(int j=1;itl.More();itl.Next(),j++) {
-               TCollection_AsciiString aName = aNam + i + "_" + j + ".brep";
+               TCollection_AsciiString aName = aNam + i + "_" + j + "_j.brep";
                BRepTools::Write(itl.Value(), aName.ToCString());
-               cout <<aName.ToCString()<<" = "<< itl.Value().TShape() <<endl;
+               DEBTRACE(aName.ToCString()<<" = "<< itl.Value().TShape());
              }
 #endif
              if(!aListOfNewEd.IsEmpty())
-               aDM4.Bind(anEdge, aListOfNewEd);
+               aDM4.Add(anEdge, aListOfNewEd);
              else {
                if(!mkCom.IsDeleted(anEdge)) {
                  const TopTools_ListOfShape& aListOfGenEd = mkCom.Generated(anEdge);
                  if(!aListOfGenEd.IsEmpty()) {
-                   aDM4.Bind(anEdge, aListOfGenEd);
+                   /* aDM4.Bind(anEdge, aListOfGenEd); ??? */
                  } else {
                    TopTools_ListOfShape aList; 
                    aList.Append(anEdge);
-                   aDM4.Bind(anEdge, aList);//the same edge - not modified
+                   aDM4.Add(anEdge, aList);//the same edge - not modified
                  }
                }
              }
@@ -438,13 +485,13 @@ HYDROData_SplitToZonesTool::SplitDataList
              TopTools_ListOfShape aList;
              aList.Append(aKey);
              const TopTools_ListOfShape& aListOfNew = mIt.Value();
-             aDM1.Bind(aKey, aListOfNew);
+             aDM1.Add(aKey, aListOfNew);
              TopTools_ListIteratorOfListOfShape it(aListOfNew);
              for(;it.More();it.Next()) {
-               if(!aDM2.IsBound(it.Value()))
-                 aDM2.Bind(it.Value(), aList);
+               if(!aDM2.Contains(it.Value()))
+                 aDM2.Add(it.Value(), aList);
                else {
-                 TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value());
+                 TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it.Value());
                  aList.Prepend(aKey);
                }
              }
@@ -459,16 +506,16 @@ HYDROData_SplitToZonesTool::SplitDataList
              const TopTools_ListOfShape& aListOfNew = aMIt.Value();
              TopTools_ListIteratorOfListOfShape it(aListOfNew);
              for(;it.More();it.Next()) {// iterate new: b1, b2, b3...
-               if(!aDM4.IsBound(it.Value())) // bi - is deleted
+               if(!aDM4.Contains(it.Value())) // bi - is deleted
                  continue; // go to the next bi
                else {
-                  const TopTools_ListOfShape& aListOfNew4 = aDM4.Find(it.Value());
+                 const TopTools_ListOfShape& aListOfNew4 = aDM4.FindFromKey(it.Value());
                   TopTools_ListIteratorOfListOfShape it4(aListOfNew4); // {c1, c2, c3,...}
                   for(;it4.More();it4.Next()) {
-                    if(!aDM2.IsBound(it4.Value()))
-                      aDM2.Bind(it4.Value(), aList);
+                    if(!aDM2.Contains(it4.Value()))
+                      aDM2.Add(it4.Value(), aList);
                     else {
-                      TopTools_ListOfShape& aList = aDM2.ChangeFind(it4.Value());
+                      TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it4.Value());
                       aList.Prepend(aKey);
                     }
                   }
@@ -495,15 +542,18 @@ HYDROData_SplitToZonesTool::SplitDataList
       const TopTools_ListOfShape& aListOfNew = aMIt.Value();
       TopTools_ListIteratorOfListOfShape it(aListOfNew);
       for(;it.More();it.Next()) {
-        if(!aDM2.IsBound(it.Value()))
-          aDM2.Bind(it.Value(), aList);
+        if(!aDM2.Contains(it.Value()))
+          aDM2.Add(it.Value(), aList);
         else {
-          TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value());
+          TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it.Value());
           aList.Prepend(aKey);
         }
       }
     }
   }
+
+  AddInternalEdges(aDM2, InterPolys);
+
   // Step 4. Fill output structure.
 #ifdef DEB_SPLIT_TO_ZONES
   TCollection_AsciiString aNam4 ("SC_");
@@ -518,7 +568,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     else {
       aDestSplitData.Type = SplitData::Data_Edge;
 #ifdef DEB_SPLIT_TO_ZONES
-      TCollection_AsciiString aName = aNam4 + i + ".brep";
+      TCollection_AsciiString aName = aNam4 + i + "_k.brep";
       BRepTools::Write(aKey,aName.ToCString());
 #endif    
     }
@@ -528,23 +578,23 @@ HYDROData_SplitToZonesTool::SplitDataList
     TopTools_ListIteratorOfListOfShape it(aListOfOld);
     for(int j =1;it.More();it.Next(),j++) {    
       const TopoDS_Shape& aSh = it.Value(); //old
-      if(aDM3.IsBound(aSh)) {
-        const QStringList& ObjectNames = aDM3.Find(aSh);    
+      if(aDM3.Contains(aSh)) {
+        const QStringList& ObjectNames = aDM3.FindFromKey(aSh);    
         aListOfNames.append(ObjectNames);
 #ifdef DEB_SPLIT_TO_ZONES
-        TCollection_AsciiString aName = aNam4 + i +"_" + j + ".brep";
+        TCollection_AsciiString aName = aNam4 + i +"_" + j + "_l.brep";
         BRepTools::Write(aSh ,aName.ToCString());        
 #endif    
       }    else {
 #ifdef DEB_SPLIT_TO_ZONES
-        TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + ".brep";
+        TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + "_m.brep";
         BRepTools::Write(aSh ,aName.ToCString());        
-        cout <<aName.ToCString()<<" = "<< aSh.TShape() <<endl;
+        DEBTRACE(aName.ToCString()<<" = "<< aSh.TShape());
 #endif
           if(aBndView.Contains(aSh) && hasLimits) {            
             aListOfNames.append(aBndName);
 #ifdef DEB_SPLIT_TO_ZONES
-            cout << " BndName = "<<aBndName.toStdString() <<endl; 
+            DEBTRACE(" BndName = "<<aBndName.toStdString());
 #endif
           }
       }
@@ -554,10 +604,90 @@ HYDROData_SplitToZonesTool::SplitDataList
     anOutputSplitDataList.append(aDestSplitData);    
 #ifdef DEB_SPLIT_TO_ZONES
     QString aStr = aDestSplitData.ObjectNames.join(" "); 
-    cout << "New# = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aDestSplitData.ObjectNames.size() <<endl; 
+    DEBTRACE("New# = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aDestSplitData.ObjectNames.size());
 #endif
   }
 
   return anOutputSplitDataList;
 }
 
+HYDROData_SplitToZonesTool::SplitDataList
+  HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects& theObjectList )
+{
+  HYDROData_SequenceOfObjects aGeomGroups;
+  Handle(HYDROData_PolylineXY) aPolyline;
+  HYDROData_SequenceOfObjects InterPolys;
+
+  return Split( theObjectList, aGeomGroups, aPolyline, InterPolys );
+}
+
+void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
+   const HYDROData_SequenceOfObjects& thePolylines)
+{
+
+  HYDROData_SequenceOfObjects::Iterator it(thePolylines);
+  TopTools_ListOfShape Wires;
+  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));
+  }
+
+  HYDROData_DataMapOfShapeListOfShape newDM;
+
+  for (int i = 1; i <= DM.Extent();i++)
+  {
+    const TopoDS_Shape& K = DM.FindKey(i);
+    const TopTools_ListOfShape& V = DM.FindFromIndex(i);
+    TopTools_ListOfShape out;
+    if (K.ShapeType() == TopAbs_FACE)
+    {
+      CutByEdges(K, Wires, out);
+      TopTools_ListIteratorOfListOfShape it(out);
+      for (;it.More(); it.Next())
+      {
+        const TopoDS_Shape& NF = it.Value();
+        if (!NF.IsNull())
+          newDM.Add(NF, V);
+      }
+    }
+    else
+      newDM.Add(K, V); // ignore edges, wires...
+  }
+
+  DM = newDM;
+}
+
+
+int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
+  TopTools_ListOfShape& outShs)
+{
+  int anError;
+  if (InSh.IsNull())
+    return -1;
+  if (InEdges.IsEmpty())
+  {
+    outShs.Clear();
+    outShs.Append(InSh);
+    return 0;
+  }
+  TopTools_ListIteratorOfListOfShape anIt;
+  BOPAlgo_Builder anAlgo;
+  anAlgo.AddArgument(InSh);
+  anIt.Initialize( InEdges );
+  for( ; anIt.More(); anIt.Next() )
+    anAlgo.AddArgument( anIt.Value() );
+
+  anAlgo.Perform(); 
+  anError = anAlgo.ErrorStatus();
+  if (anError)
+    return anError;
+
+  outShs = anAlgo.Modified( InSh );
+  if (outShs.IsEmpty())
+    outShs.Append(InSh);
+  return 0;
+}