]> OCCT Git - occt-copy.git/commitdiff
0026444: Boolean operation "bcut" gives invalid result between solid and halfspace...
authoremv <emv@opencascade.com>
Wed, 29 Jul 2015 12:24:03 +0000 (15:24 +0300)
committerabv <abv@opencascade.com>
Wed, 2 Sep 2015 11:38:36 +0000 (14:38 +0300)
class BOPAlgo_PaveFiller
method void BOPAlgo_PaveFiller::PutPaveOnCurve
  (const Standard_Integer nV,
   const Standard_Real aTolR3D,
   BOPDS_Curve& aNC,
   const BOPCol_MapOfInteger& aMI,
   BOPCol_DataMapOfIntegerReal& aMVTol,
   const Standard_Integer iCheckExtend)

Do not put the pave on the curve in case if there is already one with the same parameter.
Update tolerance of the existing vertex to reach the new one.

Added test case bugs/modalg_6/bug26444.
Test boolean/volumemaker/G1 is stable now (deleted TODOs), test offset/faces_type_i/C9 is bad (offset is done with wrong result).

src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx
src/BOPDS/BOPDS_PaveBlock.cdl
src/BOPDS/BOPDS_PaveBlock.cxx
tests/boolean/volumemaker/G1
tests/bugs/modalg_6/bug26444 [new file with mode: 0644]
tests/offset/faces_type_i/C9

index 850f5828b2a8541afd97a8d8a507edd47938ea7e..b51988c1ed65b6e82eb2612c11914ea855164002 100644 (file)
@@ -1740,41 +1740,70 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
    const Standard_Integer iCheckExtend)
 {
   Standard_Boolean bIsVertexOnLine;
-  Standard_Real aT, aTol, aTolNew;
-  BOPDS_Pave aPave;
+  Standard_Real aT, aTolV;
   //
-  const TopoDS_Vertex aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
+  const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
   Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
   const IntTools_Curve& aIC = aNC.Curve();
   //
   bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
   if (!bIsVertexOnLine && iCheckExtend) {
-    aTol = BRep_Tool::Tolerance(aV);
+    aTolV = BRep_Tool::Tolerance(aV);
     //
-    ExtendedTolerance(nV, aMI, aTol, iCheckExtend);
-    bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTol, aIC, aTolR3D, aT);
+    ExtendedTolerance(nV, aMI, aTolV, iCheckExtend);
+    bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolV, aIC, aTolR3D, aT);
   }
   //
   if (bIsVertexOnLine) {
-    aPave.SetIndex(nV);
-    aPave.SetParameter(aT);
+    // 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;
     //
-    aPB->AppendExtPave(aPave);
+    aTolV2 = 0.;
+    aDTol = 1.e-12;
     //
-    aTol = BRep_Tool::Tolerance(aV);
+    GeomAdaptor_Curve aGAC(aIC.Curve());
+    aPTol = aGAC.Resolution(aTolR3D);
     //
-    BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV);
+    bExist = aPB->ContainsParameter(aT, aPTol, nVToUpdate);
+    if (bExist) {
+      // use existing pave
+      aP1 = BRep_Tool::Pnt(aV);
+      aTolV2 = BRep_Tool::Tolerance(aV);
+      aVToUpdate = (*(TopoDS_Vertex *)(&myDS->Shape(nVToUpdate)));
+    }
+    else {
+      // add new pave
+      BOPDS_Pave aPave;
+      aPave.SetIndex(nV);
+      aPave.SetParameter(aT);
+      aPB->AppendExtPave(aPave);
+      //
+      aP1 = aGAC.Value(aT);
+      nVToUpdate = nV;
+      aVToUpdate = aV;
+    }
     //
-    if (!aMVTol.IsBound(nV)) {
-      aTolNew = BRep_Tool::Tolerance(aV);
-      if (aTolNew > aTol) {
-        aMVTol.Bind(nV, aTol);
+    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);
       }
+      // 
+      BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVToUpdate);
+      Bnd_Box& aBoxDS=aSIDS.ChangeBox();
+      BRepBndLib::Add(aVToUpdate, aBoxDS);
     }
-    // 
-    BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
-    Bnd_Box& aBoxDS=aSIDS.ChangeBox();
-    BRepBndLib::Add(aV, aBoxDS);
   }
 }
 
@@ -2194,7 +2223,7 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks
         }
         //
         if (bRebuild) {
-          nSp = SplitEdge(aPB->Edge(), nV[0], aT[0], nV[1], aT[1]);
+          nSp = SplitEdge(aPB->OriginalEdge(), nV[0], aT[0], nV[1], aT[1]);
           if (bCB) {
             aCB->SetEdge(nSp);
           }
index 8d784a6e4f6b2181fbd8d3b4230e6ff0d4c9ddb9..82b8e33f8fec3447f9f3a58eee9cfde9f8a9454e 100644 (file)
@@ -244,7 +244,7 @@ static
                                      const Handle(BOPDS_PaveBlock)& aPBD)
 {
   Standard_Boolean bXDir, bIsDone;
-  Standard_Integer nE, aNbPoints, j;
+  Standard_Integer nE, aNbPoints, j, anInd;
   Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT;
   Standard_Real aTolCmp;
   gp_Pnt2d aP2d1, aP2d2, aP2D;
@@ -329,7 +329,7 @@ static
         continue; 
       }
       //
-      if (aPBD->ContainsParameter(aX, aDT)) {
+      if (aPBD->ContainsParameter(aX, aDT, anInd)) {
         continue;
       }
       aPave.SetParameter(aX);
index b018bc5724733eec03c494865ad13834bf354139..a54e2c686b579abbdfbc07b48021963d59063dbe 100644 (file)
@@ -186,13 +186,15 @@ is
         
     ContainsParameter(me; 
         thePrm:Real from Standard; 
-        theTol:Real from Standard) 
+        theTol:Real from Standard;
+        theInd: in out Integer from Standard) 
     returns Boolean from Standard; 
     ---Purpose: 
     --- Query 
     --- Returns true if the extra paves contain the pave 
     --- with given value of the parameter <thePrm> 
     ---  <theTol>  - the value of the tolerance to compare 
+    ---  <theInd>  - index of the found pave
  
     -- 
     -- shrunk data   
index 14ff6a27c4cff8cc0f685e7e3cbcffc6d5c88c0d..0d756b8e74288e3d111938abb8f9f001e3b273cf 100755 (executable)
 //purpose  : 
 //=======================================================================
   Standard_Boolean BOPDS_PaveBlock::ContainsParameter(const Standard_Real theT,
-                                                      const Standard_Real theTol)const
+                                                      const Standard_Real theTol,
+                                                      Standard_Integer& theInd) const
 {
   Standard_Boolean bRet;
-  Standard_Real dT;
   BOPDS_ListIteratorOfListOfPave aIt;
   //
-  bRet=Standard_False;
+  bRet = Standard_False;
   aIt.Initialize(myExtPaves);
   for (; aIt.More(); aIt.Next()) {
-    dT=aIt.Value().Parameter()-theT;
-    if (dT<0.) {
-      dT=-dT;
-    }
-    if (dT<theTol) {
-      bRet=!bRet;
+    const BOPDS_Pave& aPave = aIt.Value();
+    bRet = (Abs(aPave.Parameter() - theT) < theTol);
+    if (bRet) {
+      theInd = aPave.Index();
       break;
     }
   }
index 8c59ae6013afc041e35256ec651fa59122bc97c9..d7be6d1778a70c0f188c8624d1f1dab9a69b29c9 100644 (file)
@@ -2,9 +2,6 @@
 # cone cylinder plane
 # Error status: 102
 
-puts "TODO OCC26020 ALL: Error status"
-puts "TODO OCC26020 ALL: TEST INCOMPLETE"
-
 # conical face 
 cone con_f1 -59.814698440000001 384.36473473000001 127 0.41716766026590824 -0.90882954575006414 -5.4874902763032048e-016 89.995898744693349 0
 erase con_f1
diff --git a/tests/bugs/modalg_6/bug26444 b/tests/bugs/modalg_6/bug26444
new file mode 100644 (file)
index 0000000..c873f15
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========"
+puts "OCC26444"
+puts "========"
+puts ""
+####################################################################################
+# Boolean operation "bcut" gives invalid result between solid and halfspace solid.
+####################################################################################
+
+restore [locate_data_file bug26444_cutting_shape.brep] a
+restore [locate_data_file bug26444_shape_to_cut.brep] b
+restore [locate_data_file bug26444_ref_out.brep] p2
+dump p2
+halfspace s1 a -0.541421905726473 0.200000002980232 0.00899999961256981
+bcut result b s1
+
+set square 0.106547
+set 2dviewer 1
index 180f24236b788856b603cefb08fd580b0fe55f6b..30efb80b0608ed8029d229888559e43921f01be2 100644 (file)
@@ -1,5 +1,5 @@
-puts "TODO OCC23748 ALL: ERROR. offsetperform operation not done."
-puts "TODO OCC23547 ALL: TEST INCOMPLETE"
+puts "TODO OCC23748 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC23547 ALL: Error : The volume of the resulting shape is"
 psphere s 15 270
 
 OFFSETSHAPE 1 {s_2} $calcul $type