]> OCCT Git - occt-copy.git/commitdiff
0031913: Modeling Algorithms - Invalid result of cut operation [OCCT 7.2.0 backport]
authoremv <emv@opencascade.com>
Tue, 24 Nov 2020 14:29:29 +0000 (17:29 +0300)
committeremv <emv@opencascade.com>
Thu, 26 Nov 2020 14:11:26 +0000 (17:11 +0300)
Porting parts of #0029711 - reduce tolerance of increased vertices to the actual value of the distance to the section curve on which it will be kept.

src/BOPAlgo/BOPAlgo_PaveFiller.hxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
tests/bugs/modalg_5/bug24655
tests/bugs/modalg_7/bug31913 [new file with mode: 0644]

index c34565a816460b691ee7901b2838bce0a15a1c04..dac52629d17180bebec4c9e8e333d9030ee63794 100644 (file)
@@ -262,7 +262,7 @@ protected:
                                 BOPCol_DataMapOfIntegerReal& theMVTol,
                                 BOPCol_DataMapOfIntegerListOfInteger& aDMVLV);
 
-  Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC);
+  Standard_EXPORT void FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,BOPCol_DataMapOfIntegerReal& theMVTol);
 
   //! Depending on the parameter aType it checks whether
   //! the vertex nV was created in EE or EF intersections.
index bbc1b35c91637db6c2330a319094e55a7e95d821..e1cbe33fe04cad4c060fbc3a5e55fc5d051f9433 100644 (file)
@@ -442,7 +442,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
     // if some E-F vertex was put on a curve due to large E-F intersection range,
     // and it also was put on another curve correctly then remove this vertex from
     // the first curve. Detect such case if the distance to curve exceeds aTolR3D.
-    FilterPavesOnCurves(aVC);
+    FilterPavesOnCurves(aVC, aMVTol);
 
     for (j = 0; j<aNbC; ++j) {
       BOPDS_Curve& aNC=aVC.ChangeValue(j);
@@ -1565,13 +1565,14 @@ void BOPAlgo_PaveFiller::PutPavesOnCurve
 namespace {
   struct PaveBlockDist {
     Handle(BOPDS_PaveBlock) PB;
-    Standard_Real Dist; // square distance from vertex to the paveblock
+    Standard_Real SquareDist; // square distance from vertex to the paveblock
     Standard_Real SinAngle; // sinus of angle between projection vector 
     // and tangent at projection point
     Standard_Real Tolerance; // tolerance of the section curve
   };
 }
-void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
+void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC,
+                                             BOPCol_DataMapOfIntegerReal& theMVTol)
 {
   // For each vertex found in ExtPaves of pave blocks of section curves
   // collect list of pave blocks with distance to the curve
@@ -1625,9 +1626,9 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
     for (; itL.More(); itL.Next())
     {
       const PaveBlockDist& aPBD = itL.Value();
-      if (aPBD.Dist < aMinDist)
+      if (aPBD.SquareDist < aMinDist)
       {
-        aMinDist = aPBD.Dist;
+        aMinDist = aPBD.SquareDist;
         aPBMinDist = aPBD.PB;
       }
     }
@@ -1635,13 +1636,32 @@ void BOPAlgo_PaveFiller::FilterPavesOnCurves(const BOPDS_VectorOfCurve& theVNC)
     // and there are other pave blocks for which the distance is less than the current.
     // Do not remove a vertex if it is projected on the curve with quite large angle
     // (see test bugs modalg_6 bug27761).
+
+    // Reduce tolerance for the vertex to the value of maximal distance to
+    // to section curve on which it will be kept.
+    Standard_Real aMaxDistKept = -1;
+    Standard_Boolean isRemoved = Standard_False;
     for (itL.Init(aList); itL.More(); itL.Next())
     {
       const PaveBlockDist& aPBD = itL.Value();
       Standard_Real aCheckDist = 100. * Max(aPBD.Tolerance*aPBD.Tolerance, aMinDist);
-      if (aPBD.Dist > aCheckDist && aPBD.SinAngle < aSinAngleMin)
+      if (aPBD.SquareDist > aCheckDist && aPBD.SinAngle < aSinAngleMin)
       {
         aPBD.PB->RemoveExtPave(nV);
+        isRemoved = Standard_True;
+      }
+      else if (aPBD.SquareDist > aMaxDistKept)
+        aMaxDistKept = aPBD.SquareDist;
+    }
+
+    if (isRemoved && aMaxDistKept > 0)
+    {
+      const Standard_Real* pTol = theMVTol.Seek(nV);
+      if (pTol)
+      {
+        const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
+        const Standard_Real aRealTol = Max(*pTol, sqrt(aMaxDistKept) + Precision::Confusion());
+        (*(Handle(BRep_TVertex)*)&aV.TShape())->Tolerance(aRealTol);
       }
     }
   }
index 1c6a0cf0071bbbca251eb03276ed457d9f28b68f..b5d7b5e8aac4b6124d20dc3d200cb28b0e9f918e 100644 (file)
@@ -16,5 +16,5 @@ checkprops result -s 11.9246
 checkshape result
 
 # Analysis of "nbshapes result"
-checknbshapes result -vertex 23 -edge 34 -wire 13 -face 13 -shell 1 -solid 1 -compsolid 0 -compound 1 -shape 86
+checknbshapes result -wire 13 -face 13 -shell 1 -solid 1
 checkview -display result -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_7/bug31913 b/tests/bugs/modalg_7/bug31913
new file mode 100644 (file)
index 0000000..97e873d
--- /dev/null
@@ -0,0 +1,25 @@
+puts "============================================================================================="
+puts "0031913: Modeling Algorithms - Invalid result of cut operation"
+puts "============================================================================================="
+puts ""
+
+restore [locate_data_file bug31913_shell_to_cut.brep] s1
+restore [locate_data_file bug31913_cutting_solid.brep] s2
+
+bclearobjects
+bcleartools
+baddobjects s1
+baddtools s2
+bfillds
+bbop rcommon 0
+bbop rcut 2
+
+checkshape rcommon
+checknbshapes rcommon -face 17 -wire 17
+checkprops rcommon -s 0.0317669
+
+checkshape rcut
+checknbshapes rcut -face 73 -wire 73
+checkprops rcut -s 39.1577
+
+checkview -display rcommon -2d -path ${imagedir}/${test_image}.png