Salome HOME
lots 3,8
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.cxx
index bef3e9a222b8dc9889fcad84385a75f56ea3cefb..94d57ea7b5647713be2d65eae0fb0b370f2707fe 100644 (file)
 #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>
 #include <Geom_Plane.hxx>
 #include <BRepBuilderAPI_FindPlane.hxx>
 
+#include <BOPAlgo_BOP.hxx>
+#include <BOPAlgo_Builder.hxx>
+#include <TopExp.hxx>
+#include <assert.h>
+
 //#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))
@@ -47,6 +53,9 @@
 static TCollection_AsciiString fileNameBefore("BeforeTranslation");
 #endif
 
+//#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
 {
   TopoDS_Face aResFace;
@@ -110,7 +119,7 @@ void HYDROData_SplitToZonesTool::SetFileNames(const QString& theNameBefore, cons
 #endif
 }
 //======================================================================================
-Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp, 
+bool HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp, 
                                                         HYDROData_Transform& theTool)
 {
   theTool.Clear();
@@ -119,18 +128,23 @@ Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& t
   const Standard_Boolean bToTransform = theTool.ToTransform();  
   theTool.SetToTransform(bToTransform);  
   theTool.Perform();
-  Standard_Integer anErr = theTool.ErrorStatus();
-  return anErr;
+  return theTool.HasErrors();
 }
 
 //======================================================================================
 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)
 {
+#ifndef NDEBUG
+  DEBTRACE("Split");
+#endif
   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;
@@ -150,7 +164,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     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 ) {
@@ -198,7 +212,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
       }
     }
@@ -206,14 +220,96 @@ 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;
+      TopTools_IndexedDataMapOfShapeListOfShape OutOrSh2M;
+      CutFaceByEdges(SD.Face(), newshs, InterPolys, &OutNE, &OutOrSh2M);
+      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);
+      }
+
+#ifndef NDEBUG
+      //check CutFaceByEdges method: ensure that SD.Face() edges fully covered by
+      //history map (OutOrSh2M)
+      if (!OutOrSh2M.IsEmpty())
+      {
+        TopTools_IndexedMapOfShape EE;
+        TopExp::MapShapes(SD.Face(), TopAbs_EDGE, EE);
+        int noncontNb = 0;      
+        for (int i = 1; i <= EE.Extent(); i++)
+        {
+          const TopoDS_Shape& E = EE(i);
+          noncontNb += !OutOrSh2M.Contains(E);
+        }
+        //noncontNb > 0 => some problem with edge history
+        assert(noncontNb == 0);
+      }
+#endif
+
       if(!theGroupsList.IsEmpty() ) 
-        anOutputSplitDataList.append(anInputGroupList);
+      {
+        SplitDataList ModifInpGroupList;
+        SplitDataListIterator it(anInputGroupList);
+        while( it.hasNext() )
+        {
+          const SplitData& SData = it.next();
+          if (SData.Type != SplitData::Data_Edge)
+            ModifInpGroupList.append(SData); //add as is
+          const TopoDS_Shape& SData_sh = SData.Shape;
+          TopTools_ListOfShape modif_ls;
+          if (!InterPolys.IsEmpty())
+            if (OutOrSh2M.Contains(SData_sh))
+              modif_ls = OutOrSh2M.FindFromKey(SData_sh);
+            //else TODO -  show message that one of the object should be updated
+
+#ifndef NDEBUG
+          if (!InterPolys.IsEmpty() && OutOrSh2M.IsEmpty())
+            assert (true);
+#endif
+          if (modif_ls.IsEmpty())
+            ModifInpGroupList.append(SData); //non modified
+          else
+          {
+            TopTools_ListIteratorOfListOfShape itl_modif(modif_ls);
+            for (;itl_modif.More();itl_modif.Next())
+            {
+              const TopoDS_Shape& CSH = itl_modif.Value();
+              if (CSH.ShapeType() == TopAbs_EDGE)
+              {
+                SplitData NewSData;
+                NewSData.ObjectNames = SData.ObjectNames;
+                NewSData.Type = SData.Type;
+                NewSData.Shape = CSH;
+                ModifInpGroupList.append(NewSData);
+              }
+            }
+          }
+
+        }
+        anOutputSplitDataList.append(ModifInpGroupList);
+      }
       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
@@ -226,7 +322,7 @@ HYDROData_SplitToZonesTool::SplitDataList
 
   // Step 1. Prepare Partition structures. 
   TopoDS_Shape aResult;
-  BOPCol_ListOfShape aLS;  
+  TopTools_ListOfShape aLS;  
   QStringList aListOfNames;
   TopoDS_Compound aCmp;
   BRep_Builder aBB;
@@ -237,19 +333,19 @@ HYDROData_SplitToZonesTool::SplitDataList
     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
 
   HYDROData_DataMapOfShapeListOfShape aDM1;
   if(anInputSplitDataList.size() > 1) {
     HYDROData_Transform splitTool; 
-    const Standard_Integer anErr = SplitFaces(aCmp, splitTool);    
+    bool anErr = SplitFaces(aCmp, splitTool);    
     if(anErr)
       return anOutputSplitDataList;
     aResult = splitTool.Shape();
@@ -258,7 +354,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;
@@ -269,7 +365,7 @@ HYDROData_SplitToZonesTool::SplitDataList
     
     // Step 3. Collect history  
     //HYDROData_DataMapOfShapeListOfShape aDM1;
-    BOPCol_ListIteratorOfListOfShape anIt(aLS); 
+    TopTools_ListIteratorOfListOfShape anIt(aLS); 
   #ifdef DEB_SPLIT_TO_ZONES
     TCollection_AsciiString aNamM ("EdgM_");
     TCollection_AsciiString aNamG ("EdgG_");
@@ -305,15 +401,17 @@ HYDROData_SplitToZonesTool::SplitDataList
         for (int j =1;exp.More();exp.Next(),j++) {
           aList.Clear();
           Standard_Boolean foundE(Standard_False);
-          const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current());    
-          //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
+          const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current()); 
+#ifndef NDEBUG
+          DEBTRACE("NB_EDGE_M = " << aListM.Extent());
+#endif
           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
           }
           /* *********************************************************************
@@ -327,9 +425,9 @@ HYDROData_SplitToZonesTool::SplitDataList
           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.Add(exp.Current(), aList);
@@ -384,12 +482,14 @@ HYDROData_SplitToZonesTool::SplitDataList
               const TopoDS_Shape& aFace = exp.Current();
               if(!aFace.IsNull()) {
                 const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace);
-                //cout << "Modified: " << aListOfNew.Extent() <<endl;                                    
+#ifndef NDEBUG
+                DEBTRACE("Modified: " << aListOfNew.Extent());
+#endif
                 if(!aListOfNew.IsEmpty()) {
                   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 {
@@ -398,8 +498,8 @@ HYDROData_SplitToZonesTool::SplitDataList
                       if(!aListOfGen.IsEmpty()) {
                         /* 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 {
@@ -447,9 +547,9 @@ 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())
@@ -543,6 +643,18 @@ HYDROData_SplitToZonesTool::SplitDataList
       }
     }
   }
+
+  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
   TCollection_AsciiString aNam4 ("SC_");
@@ -557,7 +669,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    
     }
@@ -571,19 +683,19 @@ HYDROData_SplitToZonesTool::SplitDataList
         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
           }
       }
@@ -593,7 +705,7 @@ 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
   }
 
@@ -605,6 +717,155 @@ HYDROData_SplitToZonesTool::SplitDataList
 {
   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,
+   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());
+    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);
+    const TopTools_ListOfShape& V = DM.FindFromIndex(i);
+    TopTools_ListOfShape out;
+    if (K.ShapeType() == TopAbs_FACE)
+    {
+      CutByEdges(K, Wires, out, &OutNE1, NULL);
+      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...
+  }
+
+  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,                                                
+                                                TopTools_IndexedDataMapOfShapeListOfShape* OutOrSh2M)
+{
+
+  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, OutOrSh2M);
+
+  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, 
+                                           TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH)
+{
+  int anError;
+  if (InSh.IsNull())
+    return -1;
+  if (InW.IsEmpty())
+  {
+    outShs.Clear();
+    outShs.Append(InSh);
+    return 0;
+  }
+  TopTools_ListIteratorOfListOfShape anIt;
+  BOPAlgo_Builder anAlgo;
+  anAlgo.AddArgument(InSh);
+
+  anIt.Initialize( InW );
+  for( ; anIt.More(); anIt.Next() )
+    anAlgo.AddArgument( anIt.Value() );
+
+  anAlgo.Perform(); 
+  if (anAlgo.HasErrors())
+    return -1;
+
+  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);
+    }
+  }
+
+  //map all sub-shapes from the original InSh to modified shapes  
+  if (OInSH2MSH)
+  {
+    TopTools_IndexedMapOfShape allSh;
+    TopExp::MapShapes(InSh, allSh);
+    for(int i = 1; i <= allSh.Extent(); i++ )
+    {
+      const TopoDS_Shape& or_sh = allSh(i); 
+      const TopTools_ListOfShape& ls = anAlgo.Modified(or_sh);
+      OInSH2MSH->Add(or_sh, ls);
+    }
+  }
 
-  return Split( theObjectList, aGeomGroups, aPolyline );
+  return 0;
 }