]> OCCT Git - occt.git/commitdiff
0026718: Big tolerance value of the edge in the result of General Fuse operation
authoremv <emv@opencascade.com>
Thu, 1 Oct 2015 10:57:53 +0000 (13:57 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 1 Oct 2015 10:58:59 +0000 (13:58 +0300)
class BOPTools_AlgoTools2D
method
  Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
  (const TopoDS_Edge& aE2, // old
   const TopoDS_Edge& aE1, // new
   const TopoDS_Face& aF,
   const Handle(IntTools_Context)& aCtx)

To prevent huge tolerance increasing check the distances between 2d and 3d
curves (through surface) before attaching 2d curve to the edge.

Test case for issue CR26718

Correction of test cases for issue CR26718

src/BOPTools/BOPTools_AlgoTools2D_1.cxx
tests/boolean/gdml_private/ZD3
tests/boolean/gdml_private/ZD6
tests/bugs/modalg_6/bug26718 [new file with mode: 0755]

index 0e713e5475a3cf5981732874b68a1b2a73b026cd..c098f90854a87cacd6421f145c4d973ad344123c 100644 (file)
@@ -37,6 +37,7 @@
 #include <TopExp_Explorer.hxx>
 
 #include <IntTools_Context.hxx>
+#include <IntTools_Tools.hxx>
 
 #include <BOPTools_AlgoTools2D.hxx>
 
@@ -55,7 +56,6 @@ static
   Standard_Boolean IsClosed(const TopoDS_Edge& ,
                             const TopoDS_Face& );
 
-
 //=======================================================================
 //function : AttachExistingPCurve
 //purpose  : 
@@ -66,9 +66,10 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
    const TopoDS_Face& aF, 
    const Handle(IntTools_Context)& aCtx)
 {
-  Standard_Boolean bIsToReverse, bIsClosed;
+  Standard_Boolean bIsToReverse, bIsClosed, bComp;
   Standard_Integer iRet;
   Standard_Real aTol, aT11, aT12, aT21, aT22, aTolPPC;
+  Standard_Real aTolSP, aTMax;
   Handle(Geom2d_Curve) aC2Dold, aC2DoldC;
   Handle(Geom2d_Curve) aC2DT;
   BRep_Builder aBB;
@@ -97,13 +98,10 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
   //
   aC2DT=new Geom2d_TrimmedCurve(aC2DoldC, aT21, aT22);
   //
-  aTol=BRep_Tool::Tolerance(aE1);
-  BRep_Tool::Range (aE1, aT11, aT12);
-  aBB.SameRange(aE1, Standard_False);
-  aBB.SameParameter(aE1, Standard_False);
-  
   aTolPPC=Precision::PConfusion();
   //
+  Handle(Geom_Curve) aCE1 = BRep_Tool::Curve(aE1, aT11, aT12);
+  //
   GeomLib::SameRange(aTolPPC, aC2DT, aT21, aT22, aT11, aT12, aC2DT);
   //
   if (aC2DT.IsNull()){
@@ -111,15 +109,36 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
     return iRet;
   }
   //
+  // check the curves on same parameter to prevent 
+  // big tolerance increasing
+  Handle(Geom_Surface) aSF = BRep_Tool::Surface(aF);
+  //
+  bComp = IntTools_Tools::ComputeTolerance
+    (aCE1, aC2DT, aSF, aT11, aT12, aTolSP, aTMax);
+  if (!bComp) {
+    iRet = 3;
+    return iRet;
+  }
+  //
+  aTol = BRep_Tool::Tolerance(aE1);
+  //
+  if ((aTolSP > 10.*aTol) && aTolSP > 0.1) {
+    iRet = 4;
+    return iRet;
+  }
+  //
+  aBB.SameRange(aE1, Standard_False);
+  aBB.SameParameter(aE1, Standard_False);
+  //
   aBB.UpdateEdge(aE1, aC2DT, aF, aTol);
   BRepLib::SameParameter(aE1);
   BRepLib::SameRange(aE1);
   //
-  bIsClosed=IsClosed(aE2, aF);
+  bIsClosed = IsClosed(aE2, aF);
   if (bIsClosed) {
-    iRet=UpdateClosedPCurve(aE2, aE1, aF, aCtx);
+    iRet = UpdateClosedPCurve(aE2, aE1, aF, aCtx);
     if(iRet) {
-      iRet=3;
+      iRet = 5;
     }
   }
   //
@@ -309,4 +328,3 @@ Standard_Boolean IsClosed(const TopoDS_Edge& aE,
   }
   return bRet;
 }
-
index 362116bf4da169a788108665701f61c0af24b7e5..2f8beda78c1829232713fc39a0d5a93b04ab2d26 100644 (file)
@@ -1,3 +1,2 @@
-puts "TODO OCC26018 Windows: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
 source [locate_data_file 200a0-1_sopac-dn500.asm.1.gdml.tcl]
-
index ef2a429bd3d23524d3a1d50babc3c240fcbb7613..718103630aa7f3345bc8dce3ef03758377375ab2 100644 (file)
@@ -1,2 +1,2 @@
+puts "TODO OCC26018 ALL: Faulty shapes in variables faulty_1 to faulty_"
 source [locate_data_file 200a0-1_sopac-dn500_piquage.prt.1.gdml.tcl]
-
diff --git a/tests/bugs/modalg_6/bug26718 b/tests/bugs/modalg_6/bug26718
new file mode 100755 (executable)
index 0000000..eb8e62d
--- /dev/null
@@ -0,0 +1,45 @@
+puts "============"
+puts "OCC26718"
+puts "============"
+puts ""
+#############################################################################################
+## Big tolerance value of the edge in the result of Genral Fuse operation
+#############################################################################################
+
+restore [locate_data_file bug26718_w6_b1.brep] b1
+restore [locate_data_file bug26718_w6_b2.brep] b2
+
+bclearobjects
+bcleartools
+baddobjects b1
+baddtools b2
+
+bfillds
+bbuild result
+
+set square 2.3834e+06
+
+set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 7
+ EDGE      : 11
+ WIRE      : 8
+ FACE      : 5
+ SHELL     : 2
+ SOLID     : 2
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 36
+"
+
+checknbshapes result -ref ${nbshapes_expected} -t -m "Result obtained by General Fuse operation"
+
+regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance
+puts "MaxTolerance=$MaxTolerance"
+
+set expected_MaxTolerance 0.317915740714732
+set tol_abs_MaxTolerance 0.01
+set tol_rel_MaxTolerance 0.01
+checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance}
+
+set 3dviewer 1