Salome HOME
EDF 2281 : missing translations, doc and pictures
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_5.cxx
index fae995ed9f983eb58ccbd3906b6a0fe23ef12e43..a00a435d6f9b57a365c57cbf318c87a8f77d92fb 100644 (file)
@@ -1,29 +1,31 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
+//
 // 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 
+// License as published by the Free Software Foundation; either
 // version 2.1 of the License.
-// 
-// 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 
+//
+// 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 
+// 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/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// File:       NMTTools_PaveFiller_5.cxx
-// Created:    Mon Dec 15 11:28:33 2003
-// Author:     Peter KURNEV
-//             <pkv@irinox>
-
 
-#include <NMTTools_PaveFiller.ixx>
+// File:        NMTTools_PaveFiller_5.cxx
+// Created:     Mon Dec 15 11:28:33 2003
+// Author:      Peter KURNEV
+//              <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
 
 #include <TColStd_IndexedMapOfInteger.hxx>
 
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Compound.hxx>
 
+#include <TopExp.hxx>
+
 #include <TopTools_IndexedMapOfShape.hxx>
 
 #include <IntTools_ShrunkRange.hxx>
 #include <IntTools_Range.hxx>
 #include <IntTools_EdgeFace.hxx>
-#include <IntTools_PContext.hxx>
 #include <IntTools_SequenceOfCommonPrts.hxx>
 #include <IntTools_CommonPrt.hxx>
 #include <IntTools_Tools.hxx>
+#include <IntTools_Context.hxx>
 
 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
@@ -63,7 +67,7 @@
 #include <BOPTools_ListOfPaveBlock.hxx>
 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
 #include <BOPTools_ESInterference.hxx>
-#include <BOPTools_InterferencePool.hxx>
+
 #include <BOPTools_CArray1OfVVInterference.hxx>
 #include <BOPTools_CArray1OfESInterference.hxx>
 #include <BOPTools_VVInterference.hxx>
@@ -72,6 +76,8 @@
 #include <BOPTools_IMapOfPaveBlock.hxx>
 
 #include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_InterfPool.hxx>
 
 #include <NMTTools_ListOfCommonBlock.hxx>
 #include <NMTTools_CommonBlockAPI.hxx>
 #include <NMTTools_CommonBlockAPI.hxx>
 #include <NMTTools_ListOfCommonBlock.hxx>
 
+
 static
   void VertexParameter(const IntTools_CommonPrt& aCPart,
-                      Standard_Real& aT);
+                       Standard_Real& aT);
 static
   Standard_Boolean IsOnPave(const Standard_Real& aTR,
-                           const IntTools_Range& aCPRange,
-                           const Standard_Real& aTolerance);
-
+                            const IntTools_Range& aCPRange,
+                            const Standard_Real& aTolerance);
+//
 //=======================================================================
 // function: PerformEF
-// purpose: 
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::PerformEF() 
+  void NMTTools_PaveFiller::PerformEF()
 {
-  myIsDone=Standard_False;
-  
-  Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength;
   Standard_Boolean bJustAdd;
-  Standard_Real aTolE, aTolF, aDeflection=0.01;
-  Standard_Integer aDiscretize=35;
+  Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength;
+  Standard_Integer aDiscretize;
+  Standard_Real aTolE, aTolF, aDeflection;
   BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
   BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB;
   BOPTools_IMapOfPaveBlock aIMPBx;
-  
   //
-  BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
+  myIsDone=Standard_False;
+  aDeflection=0.01;
+  aDiscretize=35;
   //
-  myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE);
+  BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
+  //
+  myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE);
   //
   // BlockLength correction
-  aNbEFs=ExpectedPoolLength();
+  aNbEFs=myDSIt->BlockLength();
   aBlockLength=aEFs.BlockLength();
   if (aNbEFs > aBlockLength) {
     aEFs.SetBlockLength(aNbEFs);
   }
   //
-  for (; myDSIt.More(); myDSIt.Next()) {
-    myDSIt.Current(n1, n2, bJustAdd);
-    anIndexIn = 0;
+  for (; myDSIt->More(); myDSIt->Next()) {
+    myDSIt->Current(n1, n2, bJustAdd);
     //
-    if (myIntrPool->IsComputed(n1, n2)) {
+    if(bJustAdd) {
       continue;
     }
     //
-    nE=n1; 
-    nF=n2; 
-    SortTypes(nE, nF);
+    anIndexIn = 0;
+    //
+    nE=n1;
+    nF=n2;
+    if (myDS->GetShapeType(n2)==TopAbs_EDGE) {
+      nE=n2;
+      nF=n1;
+    }
     //
     // all Common Blocks for face nF
-    //XXX
     NMTTools_ListOfCommonBlock aLCBF;
     CommonBlocksFace(nF, aLCBF);
     NMTTools_CommonBlockAPI aCBAPIF(aLCBF);
-    //XXX
-    if(bJustAdd) {
-      myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
-      continue;
-    }
+    //
     // Edge
-    const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE));
+    const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));
     if (BRep_Tool::Degenerated(aE)){
       continue;
     }
-    aTolE=BRep_Tool::Tolerance(aE);
+    //
     // Face
-    const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF));
+    const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF));
+    //
+    TopTools_IndexedMapOfShape aME;
+    TopExp::MapShapes(aF, TopAbs_EDGE, aME);
+    if (aME.Contains(aE)) {
+      continue;
+    }
+    //
     aTolF=BRep_Tool::Tolerance(aF);
-    const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); 
+    aTolE=BRep_Tool::Tolerance(aE);
+
+    const Bnd_Box& aBBF=myDS->GetBoundingBox(nF);
     //
     // Process each PaveBlock on edge nE
     BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
@@ -154,19 +170,18 @@ static
     BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
     for (; anIt.More(); anIt.Next()) {
       BOPTools_PaveBlock& aPB=anIt.Value();
-      //XXX
       if (aCBAPIF.IsCommonBlock(aPB)) {
-       continue;
+        continue;
       }
-      //XXX
+      //
       const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
       const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
-      const Bnd_Box&        aBBE=aShrunkRange.BndBox();
+      const Bnd_Box& aBBE=aShrunkRange.BndBox();
       //
       if (aBBF.IsOut (aBBE)) {
-       continue;
+        continue;
       }
-      // 
+      //
       // EF
       IntTools_EdgeFace aEF;
       aEF.SetEdge (aE);
@@ -175,102 +190,113 @@ static
       aEF.SetTolF (aTolF);
       aEF.SetDiscretize (aDiscretize);
       aEF.SetDeflection (aDeflection);
-      // 
-      aEF.SetContext((IntTools_PContext)&myContext);
-      // 
+      //
+      aEF.SetContext(myContext);
+      //
       IntTools_Range anewSR = aSR;
-      // 
-      // Correction of the Shrunk Range 
+      //
+      // Correction of the Shrunk Range
       BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
       aEF.SetRange (anewSR);
       //
       aEF.Perform();
       //
       if (aEF.IsDone()) {
-       const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
-       Standard_Integer i, aNbCPrts;
-       aNbCPrts=aCPrts.Length();
-       for (i=1; i<=aNbCPrts; i++) {
-         //
-         anIndexIn=0;
-         //
-         const IntTools_CommonPrt& aCPart=aCPrts(i);
-         TopAbs_ShapeEnum aType=aCPart.Type();
-         switch (aType) {
-
-           case TopAbs_VERTEX:  {
-             Standard_Boolean bIsOnPave1, bIsOnPave2;
-             Standard_Integer nVF;
-             Standard_Real aT, aTolToDecide; 
-             TopoDS_Vertex aNewVertex;
-             //
-             const IntTools_Range& aR=aCPart.Range1();
-             //
-             // New Vertex
-             VertexParameter(aCPart, aT);
-             BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex);
-             //
-             //decide to add pave or not
-             aTolToDecide=5.e-8;
-             //
-             bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide); 
-             bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide); 
-             //
-             if (!bIsOnPave1 && !bIsOnPave2) {
-               nVF=CheckFacePaves(aNewVertex, nF);
-               if (!nVF) {
-                 // really new vertex
-                 // Add Interference to the Pool
-                 BOPTools_ESInterference anInterf (nE, nF, aCPart);
-                 anIndexIn=aEFs.Append(anInterf);
-                 anInterf.SetNewShape(0);
-                 //
-                 aMapVI.Add(aNewVertex, anIndexIn);
-                 aIMPBx.Add(aPB);
-                 //
-               }// if (!nVF)
-             }// if (!bIsOnPave1 && !bIsOnPave2) 
-             myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
-           }// case TopAbs_VERTEX:
-             break;
-           //
-           case TopAbs_EDGE: {
-             Standard_Boolean aCoinsideFlag;
-             //
-             aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
-             if (!aCoinsideFlag) {
-               myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
-               break;
-             }
-             //
-             // Fill aMapCB
-             if (aMapCB.Contains(aPB)) {
-               TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB);
-               aMapF.Add(nF);
-             }
-             else {
-               TColStd_IndexedMapOfInteger aMapF;
-               aMapF.Add(nF);
-               aMapCB.Add(aPB, aMapF);
-             }
-             //modified by NIZNHY-PKV Fri Jan 23 14:13:08 2004 f
-             aIMPBx.Add(aPB);
-             //modified by NIZNHY-PKV Fri Jan 23 14:13:10 2004 t
-           }// case TopAbs_EDGE:
-             break;
+        Standard_Boolean bCoinsideFlag;
+        Standard_Integer i, aNbCPrts;
+        TopAbs_ShapeEnum aType;
+        //
+        const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
+        //
+        aNbCPrts=aCPrts.Length();
+        for (i=1; i<=aNbCPrts; ++i) {
+          anIndexIn=0;
+          //
+          const IntTools_CommonPrt& aCPart=aCPrts(i);
+          aType=aCPart.Type();
+          //
+          switch (aType) {
+            //
+            case TopAbs_VERTEX:  {
+              Standard_Boolean bIsOnPave1, bIsOnPave2;
+              Standard_Integer nVF;
+              Standard_Real aT, aTolToDecide;
+              TopoDS_Vertex aNewVertex;
+              //
+              const IntTools_Range& aR=aCPart.Range1();
+              //
+              // New Vertex
+              VertexParameter(aCPart, aT);
+              BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex);
+              //
+              //decide to add pave or not
+              aTolToDecide=5.e-8;
+              bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide);
+              bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide);
+              //
+              if (!bIsOnPave1 && !bIsOnPave2) {
+                nVF=CheckFacePaves(aNewVertex, nF);
+                if (!nVF) {
+                  // really new vertex
+                  // Add Interference to the Pool
+                  BOPTools_ESInterference anInterf (nE, nF, aCPart);
+                  anIndexIn=aEFs.Append(anInterf);
+                  anInterf.SetNewShape(0);
+                  //
+                  aMapVI.Add(aNewVertex, anIndexIn);
+                  aIMPBx.Add(aPB);
+                  //
+                  myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
+                  //
+                }// if (!nVF)
+              }// if (!bIsOnPave1 && !bIsOnPave2)
+              //
+              //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f
+              else {
+                const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2();
+                nVF=aPave.Index();
+                const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
+                BOPTools_Tools::UpdateVertex (aVF, aNewVertex);
+              }
+              //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t
+              //
+            }// case TopAbs_VERTEX:
+              break;
+            //
+            case TopAbs_EDGE: {
+              bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
+              if (!bCoinsideFlag) {
+                break;
+              }
+              //
+              // Fill aMapCB
+              if (aMapCB.Contains(aPB)) {
+                TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB);
+                aMapF.Add(nF);
+              }
+              else {
+                TColStd_IndexedMapOfInteger aMapF;
+                aMapF.Add(nF);
+                aMapCB.Add(aPB, aMapF);
+              }
+              //
+              aIMPBx.Add(aPB);
+              myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
+            }// case TopAbs_EDGE:
+              break;
 
-           default:
-             break;
-         } // switch (aType) 
-       } // for (i=1; i<=aNbCPrts; i++) 
+            default:
+              break;
+          } // switch (aType)
+        } // for (i=1; i<=aNbCPrts; i++)
       } //if (aEF.IsDone())
-    } // for (; anIt.More(); anIt.Next()) 
-  }// for (; myDSIt.More(); myDSIt.Next()) 
+    } // for (; anIt.More(); anIt.Next())
+  }// for (; myDSIt.More(); myDSIt.Next())
   //
   // Treat New vertices
   EFNewVertices(aMapVI);
   //
-  // Add draft Common Blocks of EF type 
+  // Add draft Common Blocks of EF type
   EFCommonBlocks(aMapCB);
   //
   // Collect all CB we suspected to split by new vertices
@@ -285,15 +311,15 @@ static
       nEx=aPBx.OriginalEdge();
       NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx));
       if (aLCB.Extent()) {
-       NMTTools_CommonBlockAPI aCBAPIx(aLCB);
-       if (aCBAPIx.IsCommonBlock(aPBx)) {
-         NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx);
-         const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1();
-         if (!aMx.Contains(aPB1)){
-           aMx.Add(aPB1);
-           aLCBx.Append(aCBx);
-         }
-       }
+        NMTTools_CommonBlockAPI aCBAPIx(aLCB);
+        if (aCBAPIx.IsCommonBlock(aPBx)) {
+          NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx);
+          const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1();
+          if (!aMx.Contains(aPB1)){
+            aMx.Add(aPB1);
+            aLCBx.Append(aCBx);
+          }
+        }
       }
     }
   }
@@ -307,14 +333,14 @@ static
 }
 //=======================================================================
 // function:EFCommonBlocks
-// purpose: 
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::EFCommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB)
+  void NMTTools_PaveFiller::EFCommonBlocks
+    (const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB)
 {
   Standard_Integer i, aNbPB, nE, j, aNbF, nF;
   //
   aNbPB=aMapCB.Extent();
-  //
   for (i=1; i<=aNbPB; ++i) {
     const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i);
     const TColStd_IndexedMapOfInteger& aMapF=aMapCB.FindFromIndex(i);
@@ -328,8 +354,8 @@ static
     if (aCBAPI.IsCommonBlock(aPB)) {
       NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
       for (j=1; j<=aNbF; ++j) {
-       nF=aMapF(j);
-       aCB.AddFace(nF);
+        nF=aMapF(j);
+        aCB.AddFace(nF);
       }
     }
     else {
@@ -337,8 +363,8 @@ static
       //
       aCB.AddPaveBlock(aPB);
       for (j=1; j<=aNbF; ++j) {
-       nF=aMapF(j);
-       aCB.AddFace(nF);
+        nF=aMapF(j);
+        aCB.AddFace(nF);
       }
       aLCB.Append(aCB);
     }
@@ -346,12 +372,13 @@ static
 }
 //=======================================================================
 // function:EFNewVertices
-// purpose: 
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::EFNewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
+  void NMTTools_PaveFiller::EFNewVertices
+    (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
 {
   Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple;
-  Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges;
+  Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges, iTmp;
   Standard_Real aT;
   TopoDS_Compound aCompound;
   TopoDS_Vertex aNewVertex;
@@ -361,14 +388,13 @@ static
   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
   TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple;
   //
-  BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
-  //
   aNb=aMapVI.Extent();
-  //
-  if (!aNb) { // no new vertices, no new problems 
+  if (!aNb) { // no new vertices, no new problems
     return;
   }
   //
+  BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
+  //
   // 0.
   if (aNb==1) {
     aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1));
@@ -383,22 +409,18 @@ static
     aBB.Add(aCompound, aV);
   }
   //
-  // 2. VV intersection between these vertices 
+  // 2. VV intersection between these vertices
   //       using the auxiliary Filler
-  NMTDS_ShapesDataStructure tDS;
+  NMTTools_PaveFiller tPF;
   //
-  tDS.SetCompositeShape(aCompound);
-  tDS.Init();
+  tPF.SetCompositeShape(aCompound);
   //
-  BOPTools_InterferencePool tInterfPool(tDS);
-  NMTTools_PaveFiller tPaveFiller(tInterfPool);
+  tPF.Init();
+  tPF.PerformVV();
   //
-  tPaveFiller.Init();
-  //
-  tPaveFiller.PerformVV();
-  tPaveFiller.PerformNewVertices();
-  //
-  const BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterfs();
+  NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
+  NMTDS_InterfPool& tInterfPool=*(tPF.IP());
+  BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterferences();
   //
   // 3. Separate Comlex and Simple new vertices
   aNbVV=aVVInterfs.Extent();
@@ -425,7 +447,7 @@ static
     EFNewVertices(aV, aMapVI);
   }
   //
-  // 3. Fill Maps : NewVertex-edges (aMNVE) 
+  // 3. Fill Maps : NewVertex-edges (aMNVE)
   //                NewVertex-interferences (aMNVIEE)
   aNb=aVVInterfs.Extent();
   for (i=1; i<=aNb; ++i) {
@@ -453,7 +475,12 @@ static
     iX=aMapVI.FindFromKey(aV1);
     const BOPTools_ESInterference& aEF1=aEFs(iX);
     aEF1.Indices(nE, nF);
-    SortTypes(nE, nF);
+    //
+    if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
+      iTmp=nE;
+      nE=nF;
+      nF=iTmp;
+    }
     aME.Add(nE);
     aMIEF.Add(iX);
     //aWith
@@ -461,10 +488,16 @@ static
     iX=aMapVI.FindFromKey(aV2);
     const BOPTools_ESInterference& aEF2=aEFs(iX);
     aEF2.Indices(nE, nF);
-    SortTypes(nE, nF);
+    //
+    if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
+      iTmp=nE;
+      nE=nF;
+      nF=iTmp;
+    }
     aME.Add(nE);
     aMIEF.Add(iX);
-  }
+  }// for (i=1; i<=aNb; ++i) {
+  //
   // 4. Process new vertices
   aNb=aMNVE.Extent();
   for (i=1; i<=aNb; ++i) { // xx
@@ -486,53 +519,57 @@ static
       BOPTools_ESInterference& aEF=aEFs(iX);
       aEF.SetNewShape(aNewShape);
     }
-    // 
-    // Update Paves on all edges 
+    //
+    // Update Paves on all edges
     const TColStd_IndexedMapOfInteger& aME=aMNVE(i);
     aNbEdges=aME.Extent();
     for (j=1; j<=aNbEdges; ++j) {
       nE=aME(j);
-      const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE));
+      const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
       //
-      aFlag=myContext.ComputeVE (aNewVertex, aE, aT);
+      aFlag=myContext->ComputeVE (aNewVertex, aE, aT);
       //
       if (!aFlag) {
-       aPave.SetInterference(-1);
-       aPave.SetType (BooleanOperations_EdgeSurface);
-       aPave.SetIndex(aNewShape);
-       aPave.SetParam(aT);
-       //
-       BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
-       aPaveSet.Append(aPave);
+        aPave.SetInterference(-1);
+        aPave.SetType (BooleanOperations_EdgeSurface);
+        aPave.SetIndex(aNewShape);
+        aPave.SetParam(aT);
+        //
+        BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
+        aPaveSet.Append(aPave);
       }
     }
   }
 }
 //=======================================================================
 // function:EFNewVertices
-// purpose: 
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::EFNewVertices (const TopoDS_Vertex& aNewVertex,
-                                          const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) 
+  void NMTTools_PaveFiller::EFNewVertices
+    (const TopoDS_Vertex& aNewVertex,
+     const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
 {
   Standard_Integer i, aNewShape, nE, nF;
   Standard_Real aT;
   BOPTools_Pave aPave;
   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
   //
-  BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
+  BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
   //
   // Insert New Vertex in DS;
   myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
   aNewShape=myDS->NumberOfInsertedShapes();
   myDS->SetState (aNewShape, BooleanOperations_ON);
+  //
   // Insert New Vertex in EFInterference
   i=aMapVI.FindFromKey(aNewVertex);
   BOPTools_ESInterference& aEFInterf= aEFs(i);
   aEFInterf.SetNewShape(aNewShape);
   // Extract interference info
   aEFInterf.Indices(nE, nF);
-  SortTypes(nE, nF);
+  if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
+    nE=nF;
+  }
   const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt();
   VertexParameter(aCPart, aT);
   //
@@ -548,17 +585,19 @@ static
 }
 //=======================================================================
 // function: CheckFacePaves
-// purpose: 
+// purpose:
 //=======================================================================
-  Standard_Integer NMTTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex,
-                                                       const Standard_Integer nF)
+  Standard_Integer NMTTools_PaveFiller::CheckFacePaves
+    (const TopoDS_Vertex& aNewVertex,
+     const Standard_Integer nF)
 {
-  Standard_Integer nEF, nVF, iFlag, i, aNbV;
+  Standard_Integer nEF, nVF, iFlag, i, aNbV, iRet;
   BOPTools_ListIteratorOfListOfPave anIt;
   TColStd_IndexedMapOfInteger aMVF;
-  // 
-  BooleanOperations_OnceExplorer aExp(*myDS);
   //
+  iRet=0;
+  //
+  BooleanOperations_OnceExplorer aExp(*myDS);
   aExp.Init(nF, TopAbs_EDGE);
   for (; aExp.More(); aExp.Next()) {
     nEF=aExp.Current();
@@ -575,26 +614,24 @@ static
   aNbV=aMVF.Extent();
   for (i=1; i<=aNbV; ++i) {
     nVF=aMVF(i);
-    const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
+    const TopoDS_Vertex aVF=TopoDS::Vertex(myDS->Shape(nVF));
     iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
     if (!iFlag) {
       return nVF;
     }
   }
-  return 0;
+  return iRet;
 }
-
 //
 //=======================================================================
 // function: VertexParameter
-// purpose: 
+// purpose:
 //=======================================================================
 void VertexParameter(const IntTools_CommonPrt& aCPart,
-                    Standard_Real& aT)
+                     Standard_Real& aT)
 {
   const IntTools_Range& aR=aCPart.Range1();
   aT=0.5*(aR.First()+aR.Last());
-  //
   if((aCPart.VertexParameter1() >= aR.First()) &&
      (aCPart.VertexParameter1() <= aR.Last())) {
     aT = aCPart.VertexParameter1();
@@ -602,11 +639,11 @@ void VertexParameter(const IntTools_CommonPrt& aCPart,
 }
 //=======================================================================
 // function: IsOnPave
-// purpose: 
+// purpose:
 //=======================================================================
 Standard_Boolean IsOnPave(const Standard_Real& aTR,
-                         const IntTools_Range& aCPRange,
-                         const Standard_Real& aTolerance)
+                          const IntTools_Range& aCPRange,
+                          const Standard_Real& aTolerance)
 {
   Standard_Boolean bIsOnPave;
   Standard_Real aT1, aT2, dT1, dT2;
@@ -617,7 +654,8 @@ Standard_Boolean IsOnPave(const Standard_Real& aTR,
   if (bIsOnPave) {
     return bIsOnPave;
   }
-  dT1=Abs(aTR-aT1);  
+  //
+  dT1=Abs(aTR-aT1);
   dT2=Abs(aTR-aT2);
   bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance);
   return bIsOnPave;