]> OCCT Git - occt-copy.git/commitdiff
0028683: Wrong result of CUT operation
authoremv <emv@opencascade.com>
Thu, 27 Apr 2017 13:50:31 +0000 (16:50 +0300)
committeremv <emv@opencascade.com>
Fri, 28 Apr 2017 09:12:46 +0000 (12:12 +0300)
1. Partial porting of the patches for the issues #0026738 and #0028017:
   Careful treatment of the SD vertices created on the Face/Face intersection stage.

2. Avoid creation of the small section edges.

3. Test case for the issue.

4. Adjusting test cases for current behavior.

src/BOPAlgo/BOPAlgo_PaveFiller.cdl
src/BOPAlgo/BOPAlgo_PaveFiller.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx
src/BOPDS/BOPDS_DS.cdl
src/BOPDS/BOPDS_DS.cxx
tests/bugs/modalg_2/bug472_3
tests/bugs/modalg_6/bug28683 [new file with mode: 0644]

index e61e3d591c458bc44d4f7dc5d65ac8e0c8ac1a3d..1c454afd83de6ef1fe5916d261a914cd2dcaa737 100644 (file)
@@ -124,6 +124,11 @@ is
     TreatVerticesEE(me:out) 
       is protected; 
 
+    MakeSDVerticesFF(me:out;
+      theDMVLV: DataMapOfIntegerListOfInteger from BOPCol;
+      theDMNewSD: out DataMapOfIntegerInteger from BOPCol)
+    is protected;
+
     MakeSplitEdges(me:out) 
       is protected;   
         
@@ -132,7 +137,13 @@ is
         
     MakePCurves(me:out) 
       is protected; 
-        
+
+    MakeSDVertices(me:out;
+      theVertIndices : ListOfInteger from BOPCol;
+      theAddInterfs  : Boolean from Standard = Standard_True)
+    returns Integer from Standard
+    is protected;
+
     ProcessDE(me:out) 
       is protected;  
        
@@ -180,7 +191,8 @@ is
         nF2       : Integer from Standard; 
         theMI     : MapOfInteger from BOPCol; 
         theMVEF   : MapOfInteger from BOPCol; 
-        theMVTol  : out DataMapOfIntegerReal from BOPCol) 
+        theMVTol  : out DataMapOfIntegerReal from BOPCol;
+        aDMVLV    : out DataMapOfIntegerListOfInteger from BOPCol) 
       is protected;   
     ---Purpose: 
     -- Checks and puts paves from <theMVOn> on the curve <theNC>.
@@ -271,7 +283,8 @@ is
         theNC      : out Curve from BOPDS; 
         theMI      : MapOfInteger from BOPCol;
         theMVEF    : MapOfInteger from BOPCol;
-        theMVTol   : out DataMapOfIntegerReal from BOPCol)
+        theMVTol   : out DataMapOfIntegerReal from BOPCol;
+        aDMVLV     : out DataMapOfIntegerListOfInteger from BOPCol)
       is protected; 
     ---Purpose: 
     -- Checks and puts paves created in EF intersections on the curve <theNC>.
@@ -282,7 +295,8 @@ is
         theMI      : MapOfInteger from BOPCol;
         theNC      : out Curve from BOPDS; 
         theMVStick : MapOfInteger from BOPCol; 
-        theMVTol   : out DataMapOfIntegerReal from BOPCol)
+        theMVTol   : out DataMapOfIntegerReal from BOPCol;
+        aDMVLV     : out DataMapOfIntegerListOfInteger from BOPCol)
       is protected;  
     ---Purpose: 
     -- Puts stick paves on the curve <theNC>
@@ -323,6 +337,7 @@ is
         theNC     : out Curve from BOPDS; 
         theMI     : MapOfInteger from BOPCol;
         theMVTol  : out DataMapOfIntegerReal from BOPCol;
+        aDMVLV    : out DataMapOfIntegerListOfInteger from BOPCol;
         aType     : Integer from Standard = 0)
       is protected; 
     ---Purpose: 
@@ -378,12 +393,6 @@ is
       is protected; 
     ---Purpose: 
     -- Keeps data for post treatment 
-     
-    RefineFaceInfoOn(me:out) 
-      is protected; 
-    ---Purpose: 
-    -- Refines the state On for the all faces having 
-    -- state information 
 
     UpdateFaceInfo(me:out;
         theDME:out DataMapOfPaveBlockListOfPaveBlock from BOPDS) 
index f868df9323c9ab6691a25d87ebf205e4770e78fd..f2fe49634305345bb3f048c9c933391b0ba3e62d 100644 (file)
@@ -254,7 +254,8 @@ void BOPAlgo_PaveFiller::Perform()
     return; 
   }
   //
-  RefineFaceInfoOn();
+  myDS->ReleasePaveBlocks();
+  myDS->RefineFaceInfoOn();
   //
   MakePCurves();
   if (myErrorStatus) {
index 06cf48518081dcfa8382e956b048bdf3cbb01c58..ae8f2b31272a7b2dd9dff4ce8652e301e4d6e870 100644 (file)
 
 #include <Bnd_Box.hxx>
 
+#include <BRep_TVertex.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopoDS.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <BRepBndLib.hxx>
 
 // function: PerformVV
 // purpose: 
 //=======================================================================
-void BOPAlgo_PaveFiller::PerformVV() 
+  void BOPAlgo_PaveFiller::PerformVV() 
 {
   Standard_Boolean bWithSubShape;
-  Standard_Integer n1, n2, iFlag, nX, n, aSize, i, j, iX, k, aNbBlocks;
+  Standard_Integer n1, n2, iFlag, aSize, k, aNbBlocks;
   Handle(NCollection_IncAllocator) aAllocator;
-  //BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
-  BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
-  TopoDS_Vertex aVn;
-  BOPDS_ShapeInfo aSIn;
   //
   myErrorStatus=0;
   //
@@ -61,8 +61,6 @@ void BOPAlgo_PaveFiller::PerformVV()
     return; 
   }
   //
-  aSIn.SetShapeType(TopAbs_VERTEX);
-  
   BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
   aVVs.SetStartSize(aSize);
   aVVs.SetIncrement(aSize);
@@ -72,7 +70,6 @@ void BOPAlgo_PaveFiller::PerformVV()
   aAllocator=new NCollection_IncAllocator();
   BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
   BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
-  BOPCol_ListOfShape aLV(aAllocator);
   //
   // 1. Map V/LV
   for (; myIterator->More(); myIterator->Next()) {
@@ -95,43 +92,7 @@ void BOPAlgo_PaveFiller::PerformVV()
   for (k=0; k<aNbBlocks; ++k) {
     const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
     //
-    aLV.Clear();
-    aItLI.Initialize(aLI);
-    for (; aItLI.More(); aItLI.Next()) {
-      nX=aItLI.Value();
-      const TopoDS_Shape& aV=myDS->Shape(nX);
-      aLV.Append(aV);
-    }
-    //
-    BOPTools_AlgoTools::MakeVertex(aLV, aVn);
-    //
-    // Append new vertex to the DS
-    aSIn.SetShape(aVn);
-    n=myDS->Append(aSIn);
-    //
-    BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
-    Bnd_Box& aBox=aSIDS.ChangeBox();
-    BRepBndLib::Add(aVn, aBox);
-    //
-    // Fill ShapesSD
-    aItLI.Initialize(aLI);
-    for (i=0; aItLI.More(); aItLI.Next(), ++i) {
-      n1=aItLI.Value();
-      myDS->AddShapeSD(n1, n);
-      //
-      aItLI2.Initialize(aLI);
-      for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
-        if (j>i) {
-          n2=aItLI2.Value();
-          //
-          myDS->AddInterf(n1, n2);
-          iX=aVVs.Append()-1;
-          BOPDS_InterfVV& aVV=aVVs(iX);
-          aVV.SetIndices(n1, n2);
-          aVV.SetIndexNew(n);
-        }
-      }
-    }
+    MakeSDVertices(aLI);
   }
   //
   BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
@@ -144,8 +105,84 @@ void BOPAlgo_PaveFiller::PerformVV()
   }
   //
   //-----------------------------------------------------scope t
-  aLV.Clear();
   aMBlocks.Clear();
   aMILI.Clear();
   aAllocator.Nullify();
+}
+  //=======================================================================
+// function: MakeSDVertices
+// purpose: 
+//=======================================================================
+Standard_Integer BOPAlgo_PaveFiller::MakeSDVertices
+   (const BOPCol_ListOfInteger& theVertIndices,
+    const Standard_Boolean theAddInterfs)
+{
+  TopoDS_Vertex aVSD, aVn;
+  Standard_Integer nSD = -1;
+  BOPCol_ListIteratorOfListOfInteger aItLI(theVertIndices);
+  BOPCol_ListOfShape aLV;
+  for (; aItLI.More(); aItLI.Next()) {
+    Standard_Integer nX = aItLI.Value(), nSD1;
+    if (myDS->HasShapeSD(nX, nSD1)) {
+      const TopoDS_Shape& aVSD1 = myDS->Shape(nSD1);
+      if (nSD == -1) {
+        aVSD = TopoDS::Vertex(aVSD1);
+        nSD = nSD1;
+      }
+      else {
+        aLV.Append(aVSD1);
+      }
+    }
+    const TopoDS_Shape& aV = myDS->Shape(nX);
+    aLV.Append(aV);
+  }
+  BOPTools_AlgoTools::MakeVertex(aLV, aVn);
+  Standard_Integer nV;
+  if (nSD != -1) {
+    // update old SD vertex with new value
+    Handle(BRep_TVertex)& aTVertex =
+      reinterpret_cast<Handle(BRep_TVertex)&>(const_cast<Handle(TopoDS_TShape)&>(aVSD.TShape()));
+    aTVertex->Pnt(BRep_Tool::Pnt(aVn));
+    aTVertex->Tolerance(BRep_Tool::Tolerance(aVn));
+    aVn = aVSD;
+    nV = nSD;
+  }
+  else {
+    // Append new vertex to the DS
+    BOPDS_ShapeInfo aSIn;
+    aSIn.SetShapeType(TopAbs_VERTEX);
+    aSIn.SetShape(aVn);
+    nV = myDS->Append(aSIn);
+  }
+  BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV);
+  Bnd_Box& aBox = aSIDS.ChangeBox();
+  BRepBndLib::Add(aVn, aBox);
+  aBox.SetGap(aBox.GetGap());
+  //
+  // Fill ShapesSD
+  BOPDS_VectorOfInterfVV& aVVs = myDS->InterfVV();
+  if (theAddInterfs)
+    aVVs.SetIncrement(theVertIndices.Extent());
+  //
+  aItLI.Initialize(theVertIndices);
+  for (; aItLI.More(); aItLI.Next()) {
+    Standard_Integer n1 = aItLI.Value();
+    myDS->AddShapeSD(n1, nV);
+    //
+    if (theAddInterfs) {
+      BOPCol_ListIteratorOfListOfInteger aItLI2 = aItLI;
+      aItLI2.Next();
+      for (; aItLI2.More(); aItLI2.Next()) {
+        Standard_Integer n2 = aItLI2.Value();
+        //
+        myDS->AddInterf(n1, n2);
+        //
+        Standard_Integer iX = aVVs.Append() - 1;
+        BOPDS_InterfVV& aVV = aVVs(iX);
+        aVV.SetIndices(n1, n2);
+        aVV.SetIndexNew(nV);
+      }
+    }
+  }
+  return nV;
 }
index 65e3005863bde6d79bb0e07ecacdc3dfda08c4ad..a3540450bb5bf25e07bfe9b44fbf7edb09f3971f 100644 (file)
@@ -312,8 +312,6 @@ void BOPAlgo_PaveFiller::PerformEF()
     nF=aItMI.Value();
     myDS->UpdateFaceInfoIn(nF);
   }
-  // Refine FaceInfoOn to remove all formal pave blocks 
-  // made during EF processing 
   //-----------------------------------------------------scope t
   aMIEFC.Clear();
   aMVCPB.Clear();
index 0551a6298760582df21b5c2a5fb1056478e0ef00..2df3348203b59bfbb9f5d75676d20c1412e9244b 100644 (file)
@@ -62,6 +62,7 @@
 #include <BOPCol_ListOfInteger.hxx>
 #include <BOPCol_IndexedMapOfInteger.hxx>
 #include <BOPCol_DataMapOfIntegerReal.hxx>
+#include <BOPCol_MapOfShape.hxx>
 
 #include <BOPInt_Context.hxx>
 #include <BOPInt_Tools.hxx>
@@ -292,7 +293,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
   BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
   BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
   BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
-  BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
+  BOPCol_DataMapOfIntegerInteger aDMNewSD(100, aAllocator);
+  BOPCol_DataMapOfIntegerListOfInteger aDMVLV;
   //
   for (i=0; i<aNbFF; ++i) {
     BOPDS_InterfFF& aFF=aFFs(i);
@@ -360,12 +362,12 @@ void BOPAlgo_PaveFiller::MakeBlocks()
       // DEBt
       aNC.InitPaveBlock1();
       //
-      PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol);
+      PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol, aDMVLV);
       //
-      PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol);
+      PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol, aDMVLV);
       //904/F7
       if (aNbC == 1) {
-        PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol);
+        PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol, aDMVLV);
       }
       //
       if (aIC.HasBounds()) {
@@ -472,25 +474,32 @@ void BOPAlgo_PaveFiller::MakeBlocks()
       aLPBC.RemoveFirst();
     }//for (j=0; j<aNbC; ++j) {
     //back to previous tolerance values for unused vertices
-    { 
-      BRep_Builder aBB;
+    aItMV.Initialize(aMVTol);
+    for (; aItMV.More(); aItMV.Next()) {
+      nV1 = aItMV.Key();
+      aTol = aItMV.Value();
       //
-      aItMV.Initialize(aMVTol);
-      for (; aItMV.More(); aItMV.Next()) {
-        nV1 = aItMV.Key();
-        aTol = aItMV.Value();
-        //
-        const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
-        //
-        aBB.UpdateVertex(aV, aTol);
-      }
+      const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
+      const Handle(BRep_TVertex)& TV =
+        *((Handle(BRep_TVertex)*)&aV.TShape());
+      TV->Tolerance(aTol);
+      // reset bnd box
+      BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV1);
+      Bnd_Box& aBoxDS = aSIDS.ChangeBox();
+      aBoxDS = Bnd_Box();
+      BRepBndLib::Add(aV, aBoxDS);
+      aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
+      //
+      if (aDMVLV.IsBound(nV1))
+        aDMVLV.UnBind(nV1);
     }
     //
     ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd);
   }//for (i=0; i<aNbFF; ++i) {
   // 
   // post treatment
-  myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator);
+  MakeSDVerticesFF(aDMVLV, aDMNewSD);
+  myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMNewSD, aAllocator);
   if (myErrorStatus) {
     return;
   }
@@ -498,7 +507,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
   // update face info
   UpdateFaceInfo(aDMExEdges);
   //Update all pave blocks
-  UpdatePaveBlocks(aDMI);
+  UpdatePaveBlocks(aDMNewSD);
   //-----------------------------------------------------scope t
   aMF.Clear();
   aMVStick.Clear();
@@ -506,10 +515,34 @@ void BOPAlgo_PaveFiller::MakeBlocks()
   aMVOnIn.Clear();
   aDMExEdges.Clear();
   aMI.Clear();
-  aDMI.Clear();
+  aDMNewSD.Clear();
   aAllocator.Nullify();
 }
 
+//=======================================================================
+//function : MakeSDVerticesFF
+//purpose  : 
+//=======================================================================
+void BOPAlgo_PaveFiller::MakeSDVerticesFF
+  (const BOPCol_DataMapOfIntegerListOfInteger& theDMVLV,
+   BOPCol_DataMapOfIntegerInteger& theDMNewSD)
+{
+  // Create a new SD vertex for each group of coinciding vertices
+  // and put new substitutions to theDMNewSD.
+  BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItG(theDMVLV);
+  for (; aItG.More(); aItG.Next()) {
+    const BOPCol_ListOfInteger& aList = aItG.Value();
+    // make SD vertices w/o creation of interfs
+    Standard_Integer nSD = MakeSDVertices(aList, Standard_False);
+    // update theDMNewSD
+    BOPCol_ListIteratorOfListOfInteger aItL(aList);
+    for (; aItL.More(); aItL.Next()) {
+      Standard_Integer nV = aItL.Value();
+      theDMNewSD.Bind(nV, nSD);
+    }
+  }
+}
+
 //=======================================================================
 //function : PostTreatFF
 //purpose  : 
@@ -518,7 +551,7 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
     (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
      BOPCol_DataMapOfShapeInteger& aMVI,
      BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
-     BOPCol_DataMapOfIntegerInteger& aDMI,
+     BOPCol_DataMapOfIntegerInteger& aDMNewSD,
      Handle(NCollection_BaseAllocator)& theAllocator)
 {
   Standard_Integer iRet, aNbS;
@@ -589,9 +622,25 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
   }
   //
   // 1 prepare arguments
+  BOPCol_MapOfShape anAddedSD;
   for (k=1; k<=aNbS; ++k) {
     const TopoDS_Shape& aS=theMSCPB.FindKey(k);
     aLS.Append(aS);
+    // add vertices-candidates for SD from the map aDMNewSD,
+    // so that they took part in fuse operation.
+    TopoDS_Iterator itV(aS);
+    for (; itV.More(); itV.Next()) {
+      const TopoDS_Shape& aVer = itV.Value();
+      Standard_Integer iVer = aMVI.Find(aVer);
+      if (aDMNewSD.IsBound(iVer)) {
+        Standard_Integer iSD = aDMNewSD.Find(iVer);
+        const TopoDS_Shape& aVSD = myDS->Shape(iSD);
+        if (anAddedSD.Add(aVSD)) {
+          aLS.Append(aVSD);
+          aMVI.Bind(aVSD, iSD);
+        }
+      }
+    }
   }
   //
   // 2 Fuse shapes
@@ -613,6 +662,8 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
     aType=aSIx.ShapeType();
     //
     if (aType==TopAbs_VERTEX) {
+      Standard_Boolean bIntersectionPoint = theMSCPB.Contains(aSx);
+      //
       if (aPDS->HasShapeSD(nSx, nVSD)) {
         aV=aPDS->Shape(nVSD);
       }
@@ -630,14 +681,23 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
       else {
         iV=aMVI.Find(aV);
       }
-      // update FF interference
-      const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
-      iX=aCPB.IndexInterf();
-      iP=aCPB.Index();
-      BOPDS_InterfFF& aFF=aFFs(iX);
-      BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
-      BOPDS_Point& aNP=aVNP(iP);
-      aNP.SetIndex(iV);
+      //
+      if (!bIntersectionPoint) {
+        // save SD connection
+        nSx = aMVI.Find(aSx);
+        aDMNewSD.Bind(nSx, iV);
+        myDS->AddShapeSD(nSx, iV);
+      }
+      else {
+        // update FF interference
+        const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
+        iX=aCPB.IndexInterf();
+        iP=aCPB.Index();
+        BOPDS_InterfFF& aFF=aFFs(iX);
+        BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
+        BOPDS_Point& aNP=aVNP(iP);
+        aNP.SetIndex(iV);
+      }
     }//if (aType==TopAbs_VERTEX) {
     //
     else if (aType==TopAbs_EDGE) {
@@ -689,24 +749,7 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
           } 
         }
         //
-        if (!aNbLPBx) {
-          aE=aSx;
-          //
-          if (!aMVI.IsBound(aE)) {
-            aSI.SetShapeType(aType);
-            aSI.SetShape(aE);
-            iE=myDS->Append(aSI);
-            aMVI.Bind(aE, iE);
-          }
-          else {
-            iE=aMVI.Find(aE);
-          }
-          // append new PaveBlock to aLPBC
-          aPB1->SetEdge(iE);
-          aLPBC.Append(aPB1);
-        } // if (!aNbLPBx) {
-        //
-        else {
+        if (aNbLPBx) {
           aItLPB.Initialize(aLPBx);
           if (bOld) {
             aPave1[0] = aPB1->Pave1();
@@ -749,7 +792,7 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
               }
               const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
               if (aP1.Parameter() == aPave[j].Parameter() && aP1.Index() != iV) {
-                aDMI.Bind(aP1.Index(), iV);
+                aDMNewSD.Bind(aP1.Index(), iV);
               }
               //
               aPave[j].SetIndex(iV);
@@ -785,6 +828,17 @@ Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
       }
     }//else if (aType==TopAbs_EDGE)
   }//for (; aItLS.More(); aItLS.Next()) {
+  //
+  // Update SD for vertices that did not participate in operation
+  BOPCol_DataMapOfIntegerInteger::Iterator itDM(aDMNewSD);
+  for (; itDM.More(); itDM.Next())
+  {
+    if (aDMNewSD.IsBound(itDM.Value())) {
+      Standard_Integer iSD = aDMNewSD.Find(itDM.Value());
+      itDM.ChangeValue() = iSD;
+      myDS->AddShapeSD(itDM.Key(), iSD);
+    }
+  }
   return iRet;
 }
 
@@ -1153,7 +1207,8 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
    const Standard_Integer nF2,
    const BOPCol_MapOfInteger& aMI,
    const BOPCol_MapOfInteger& aMVEF,
-   BOPCol_DataMapOfIntegerReal& aMVTol)
+   BOPCol_DataMapOfIntegerReal& aMVTol,
+   BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
 {
   Standard_Boolean bInBothFaces;
   Standard_Integer nV;
@@ -1165,7 +1220,7 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
   aIt.Initialize(aMVEF);
   for (; aIt.More(); aIt.Next()) {
     nV=aIt.Value();
-    PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2);
+    PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 2);
   }
   //Put all other vertices
   aIt.Initialize(aMVOnIn);
@@ -1194,7 +1249,7 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
       }
     }
     //
-    PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1);
+    PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 1);
   }
 }
 
@@ -1342,7 +1397,8 @@ void BOPAlgo_PaveFiller::PutEFPavesOnCurve
   (BOPDS_Curve& aNC,
    const BOPCol_MapOfInteger& aMI,
    const BOPCol_MapOfInteger& aMVEF,
-   BOPCol_DataMapOfIntegerReal& aMVTol)
+   BOPCol_DataMapOfIntegerReal& aMVTol,
+   BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
 {
   if (!aMVEF.Extent()) {
     return;
@@ -1380,7 +1436,7 @@ void BOPAlgo_PaveFiller::PutEFPavesOnCurve
     Standard_Integer aNbPoints = aProjPT.NbPoints();
     if (aNbPoints) {
       aDist = aProjPT.LowerDistance();
-      PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol);
+      PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol, aDMVLV);
     }
   }
 }
@@ -1395,7 +1451,8 @@ void BOPAlgo_PaveFiller::PutStickPavesOnCurve
    const BOPCol_MapOfInteger& aMI,
    BOPDS_Curve& aNC,
    const BOPCol_MapOfInteger& aMVStick,
-   BOPCol_DataMapOfIntegerReal& aMVTol)
+   BOPCol_DataMapOfIntegerReal& aMVTol,
+   BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
 {
   BOPCol_MapOfInteger aMV;
   aMV.Assign(aMVStick);
@@ -1468,7 +1525,7 @@ void BOPAlgo_PaveFiller::PutStickPavesOnCurve
             // The intersection curve aIC is vanishing curve (the crease)
             aD=sqrt(aD2);
             //
-            PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
+            PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol, aDMVLV);
           }
         }//for (jVU=1; jVU=aNbVU; ++jVU) {
       }
@@ -1584,6 +1641,7 @@ void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV,
                                         BOPDS_Curve& aNC,
                                         const BOPCol_MapOfInteger& aMI,
                                         BOPCol_DataMapOfIntegerReal& aMVTol,
+                                        BOPCol_DataMapOfIntegerListOfInteger& aDMVLV,
                                         const Standard_Integer iCheckExtend)
 {
   Standard_Boolean bIsVertexOnLine;
@@ -1604,23 +1662,45 @@ void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV,
   if (bIsVertexOnLine) {
     // check if aPB contains the parameter aT
     Standard_Boolean bExist;
-    Standard_Integer nVToUpdate;
-    Standard_Real aPTol, aDist, aTolVNew, aTolV2, aDTol;
-    TopoDS_Vertex aVToUpdate;
-    gp_Pnt aP1, aP2;
+    Standard_Integer nVUsed;
+    Standard_Real aPTol, aDTol;
     //
-    aTolV2 = 0.;
     aDTol = 1.e-12;
     //
     GeomAdaptor_Curve aGAC(aIC.Curve());
     aPTol = aGAC.Resolution(aTolR3D);
     //
-    bExist = aPB->ContainsParameter(aT, aPTol, nVToUpdate);
+    bExist = aPB->ContainsParameter(aT, aPTol, nVUsed);
     if (bExist) {
       // use existing pave
-      aP1 = BRep_Tool::Pnt(aV);
-      aTolV2 = BRep_Tool::Tolerance(aV);
-      aVToUpdate = (*(TopoDS_Vertex *)(&myDS->Shape(nVToUpdate)));
+      if (!aDMVLV.IsBound(nVUsed)) {
+        BOPCol_ListOfInteger aList;
+        aList.Append(nVUsed);
+        aDMVLV.Bind(nVUsed, aList);
+        //
+        if (!aMVTol.IsBound(nVUsed)) {
+          const TopoDS_Vertex& aVUsed = (*(TopoDS_Vertex *)(&myDS->Shape(nVUsed)));
+          aTolV = BRep_Tool::Tolerance(aVUsed);
+          aMVTol.Bind(nVUsed, aTolV);
+        }
+      }
+      //
+      BOPCol_ListOfInteger& aList = aDMVLV.ChangeFind(nVUsed);
+      // avoid repeated elements in the list
+      BOPCol_ListIteratorOfListOfInteger aItLI(aList);
+      for (; aItLI.More(); aItLI.Next()) {
+        if (aItLI.Value() == nV) {
+          break;
+        }
+      }
+      if (!aItLI.More()) {
+        aList.Append(nV);
+      }
+      // save initial tolerance for the vertex
+      if (!aMVTol.IsBound(nV)) {
+        aTolV = BRep_Tool::Tolerance(aV);
+        aMVTol.Bind(nV, aTolV);
+      }
     }
     else {
       // add new pave
@@ -1629,27 +1709,22 @@ void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV,
       aPave.SetParameter(aT);
       aPB->AppendExtPave(aPave);
       //
-      aP1 = aGAC.Value(aT);
-      nVToUpdate = nV;
-      aVToUpdate = aV;
-    }
-    //
-    aTolV = BRep_Tool::Tolerance(aVToUpdate);
-    aP2 = BRep_Tool::Pnt(aVToUpdate);
-    aDist = aP1.Distance(aP2);
-    aTolVNew = aDist - aTolV2;
-    //
-    if (aTolVNew > aTolV) {
-      BRep_Builder aBB;
-      aBB.UpdateVertex(aVToUpdate, aTolVNew+aDTol);
-      //
-      if (!aMVTol.IsBound(nVToUpdate)) {
-        aMVTol.Bind(nVToUpdate, aTolV);
+      gp_Pnt aP1 = aGAC.Value(aT);
+      aTolV = BRep_Tool::Tolerance(aV);
+      gp_Pnt aP2 = BRep_Tool::Pnt(aV);
+      Standard_Real aDist = aP1.Distance(aP2);
+      if (aDist > aTolV) {
+        BRep_Builder().UpdateVertex(aV, aDist + aDTol);
+        //
+        if (!aMVTol.IsBound(nV)) {
+          aMVTol.Bind(nV, aTolV);
+        }
+        //
+        BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
+        Bnd_Box& aBoxDS=aSIDS.ChangeBox();
+        BRepBndLib::Add(aV, aBoxDS);
+        aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
       }
-      // 
-      BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVToUpdate);
-      Bnd_Box& aBoxDS=aSIDS.ChangeBox();
-      BRepBndLib::Add(aVToUpdate, aBoxDS);
     }
   }
 }
@@ -1997,9 +2072,9 @@ Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes
 //purpose  : 
 //=======================================================================
 void BOPAlgo_PaveFiller::UpdatePaveBlocks
-  (const BOPCol_DataMapOfIntegerInteger& aDMI)
+  (const BOPCol_DataMapOfIntegerInteger& aDMNewSD)
 {
-  if (aDMI.IsEmpty()) {
+  if (aDMNewSD.IsEmpty()) {
     return;
   }
   //
@@ -2029,10 +2104,10 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks
         aPB->Range(aT[0], aT[1]);
         //
         for (j = 0; j < 2; ++j) {
-          if (aDMI.IsBound(nV[j])) {
+          if (aDMNewSD.IsBound(nV[j])) {
             BOPDS_Pave aPave;
             //
-            nV[j] = aDMI.Find(nV[j]);
+            nV[j] = aDMNewSD.Find(nV[j]);
             aPave.SetIndex(nV[j]);
             aPave.SetParameter(aT[j]);
             //
index a9a130cd32f293035b15214ac13f725cab80f9ef..fbc1bd0fbad2a6c5da5c402a4c1fdf26f52faa09 100644 (file)
@@ -318,48 +318,6 @@ void BOPAlgo_PaveFiller::MakePCurves()
   }
 }
 
-//=======================================================================
-// function: RefineFaceInfoOn
-// purpose: 
-//=======================================================================
-void BOPAlgo_PaveFiller::RefineFaceInfoOn() 
-{
-  Standard_Integer aNbPBP;
-  //
-  myErrorStatus=0;
-  //
-  BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
-  aNbPBP=aPBP.Extent();
-  if(!aNbPBP) {
-    return;
-  }
-  //
-  Standard_Boolean bV1, bV2;
-  Standard_Integer i, nV1, nV2, aNbPB;
-  Handle(BOPDS_PaveBlock) aPB;
-  //
-  for (i=0; i<aNbPBP; ++i) {
-    BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
-    //
-    aNbPB=aLPB.Extent();
-    if (aNbPB==1) {
-      aPB=aLPB.First();
-      aPB->Indices(nV1, nV2);
-      bV1=myDS->IsNewShape(nV1);
-      bV2=myDS->IsNewShape(nV2);
-      //
-      if (!(bV1 || bV2)) {
-        if (!myDS->IsCommonBlock(aPB)) {
-          // the PB seems to be untouced
-          aLPB.Clear();
-          continue;
-        }
-      }//if (!(bV1 || bV2)) {
-    }//if (aNbPB==1) {
-  }//for (i=0; i<aNbPBP; ++i) {
-  myDS->RefineFaceInfoOn();
-}
-
 //=======================================================================
 //function : UpdateVertices
 //purpose  : update tolerances of vertices comparing extremities of
index 7bad8897ec18822303f636997bc5d033d25eac5b..b34a8479adebe86351cdb6fa5050043adad5a1c9 100644 (file)
@@ -99,6 +99,8 @@ static
           //
           // 2.
           BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE);
+          if (aLPBD.IsEmpty())
+            continue;
           aPBD=aLPBD.First();
           //
           FillPaves(nV, nE, nF, aLPBOut, aPBD);
@@ -226,7 +228,7 @@ static
       aPB->SetEdge(nSp);
     }
     else {
-      //aPB->SetEdge(nDE);
+      myDS->ChangeShapeInfo(nDE).SetReference(-1);
       aLPB.Clear();
       break;
     }
index 4c0ddd945d84e6da8e897671260d59272c3a6ff1..84af643d4c2e76bb82f448242ffa46655c4f51c1 100644 (file)
@@ -591,7 +591,11 @@ is
              
     InitPaveBlocksForVertex(me:out; 
             theNV:Integer from Standard);        
-     
+
+    ReleasePaveBlocks(me:out);
+    ---Purpose:
+    -- Clears information about PaveBlocks for the untouched edges.
+
 fields  
     myAllocator        : BaseAllocator from BOPCol is protected;
     myArguments        : ListOfShape from BOPCol is protected;   
index 44810a106070cd9b349d8d6030ef701002fc87fc..b81f8ef8d8eaf3493d1a456af6a827e98b58372a 100644 (file)
@@ -1946,3 +1946,47 @@ void BOPDS_DS::InitPaveBlocksForVertex(const Standard_Integer theNV)
     }
   }
 }
+
+//=======================================================================
+//function : ReleasePaveBlocks
+//purpose  :
+//=======================================================================
+void BOPDS_DS::ReleasePaveBlocks()
+{
+  // It is necessary to remove the reference to PaveBlocks for the untouched
+  // edges to avoid creation of the same images for them.
+  // Pave blocks for this reference should be cleared.
+  // This will allow to differ the small edges, for which it is
+  // impossible to build pave block from the normal edges for which the
+  // pave block have been created, but stayed untouched.
+  // The small edge, for which no pave blocks have been created,
+  // should be avoided in the result, thus the reference to empty list
+  // of pave blocks will stay to mark the edge as Deleted.
+
+  BOPDS_VectorOfListOfPaveBlock& aPBP = ChangePaveBlocksPool();
+  Standard_Integer aNbPBP = aPBP.Extent();
+  if (!aNbPBP) {
+    return;
+  }
+  //
+  for (Standard_Integer i = 0; i < aNbPBP; ++i) {
+    BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
+    if (aLPB.Extent() == 1) {
+      const Handle(BOPDS_PaveBlock)& aPB = aLPB.First();
+      if (!IsCommonBlock(aPB)) {
+        Standard_Integer nV1, nV2;
+        aPB->Indices(nV1, nV2);
+        if (!IsNewShape(nV1) && !IsNewShape(nV2)) {
+          // Both vertices are original, thus the PB is untouched.
+          // Remove reference for the original edge
+          Standard_Integer nE = aPB->OriginalEdge();
+          if (nE >= 0) {
+            ChangeShapeInfo(nE).SetReference(-1);
+          }
+          // Clear contents of the list
+          aLPB.Clear();
+        }
+      }
+    }
+  }
+}
index 1e67122a8751a68d0d16ecfc905e6d75ada750d9..5d66658a20cb161b6af59023b57dc886f6972ff5 100755 (executable)
@@ -1,6 +1,6 @@
-#puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_"
-#puts "TODO OCC12345 ALL: Error : The square of result shape is"
-puts "TODO OCC12345 ALL: Error : The command is not valid"
+puts "TODO OCC12345 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC12345 ALL: Error : The square of result shape is"
+#puts "TODO OCC12345 ALL: Error : The command is not valid"
 puts "TODO OCC12345 ALL: Error : Result shape is WRONG because it must contains"
 
 puts "========================"
diff --git a/tests/bugs/modalg_6/bug28683 b/tests/bugs/modalg_6/bug28683
new file mode 100644 (file)
index 0000000..8d6edac
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========"
+puts "OCC28683"
+puts "========"
+puts ""
+####################################################################################
+## Wrong result of CUT operation
+####################################################################################
+
+restore [locate_data_file bug28683_shapes.brep] b
+explode b
+bcut result b_1 b_2
+donly result
+checkshape result
+
+set square 1.82492
+set nb_v_good 6
+set nb_e_good 6
+set nb_w_good 1
+set nb_f_good 1