From 521e1c61912e7b034652be4a6ba85daaf82999af Mon Sep 17 00:00:00 2001 From: emv Date: Thu, 1 Oct 2015 13:57:53 +0300 Subject: [PATCH] 0026718: Big tolerance value of the edge in the result of General Fuse operation 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 | 40 ++++++++++++++++------ tests/boolean/gdml_private/ZD3 | 3 +- tests/boolean/gdml_private/ZD6 | 2 +- tests/bugs/modalg_6/bug26718 | 45 +++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 14 deletions(-) create mode 100755 tests/bugs/modalg_6/bug26718 diff --git a/src/BOPTools/BOPTools_AlgoTools2D_1.cxx b/src/BOPTools/BOPTools_AlgoTools2D_1.cxx index 0e713e5475..c098f90854 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D_1.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D_1.cxx @@ -37,6 +37,7 @@ #include #include +#include #include @@ -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; } - diff --git a/tests/boolean/gdml_private/ZD3 b/tests/boolean/gdml_private/ZD3 index 362116bf4d..2f8beda78c 100644 --- a/tests/boolean/gdml_private/ZD3 +++ b/tests/boolean/gdml_private/ZD3 @@ -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] - diff --git a/tests/boolean/gdml_private/ZD6 b/tests/boolean/gdml_private/ZD6 index ef2a429bd3..718103630a 100644 --- a/tests/boolean/gdml_private/ZD6 +++ b/tests/boolean/gdml_private/ZD6 @@ -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 index 0000000000..eb8e62dde5 --- /dev/null +++ b/tests/bugs/modalg_6/bug26718 @@ -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