From 0af424c23c0389d0efca612ab74f6c53046b9629 Mon Sep 17 00:00:00 2001 From: imn Date: Fri, 14 Apr 2017 15:15:18 +0300 Subject: [PATCH] 0028601: ShapeFix_Shape increases tolerance of sub-shapes of a valid shape - Avoid increase of edge/vertex tolerance if the distance between 3D curve and p-curve is within old tolerance. --- src/ShapeFix/ShapeFix.cxx | 27 +++++++++++++++++---------- tests/bugs/heal/bug329 | 2 -- tests/bugs/modalg_6/bug28601 | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 tests/bugs/modalg_6/bug28601 diff --git a/src/ShapeFix/ShapeFix.cxx b/src/ShapeFix/ShapeFix.cxx index 11bb03d555..75679bd9da 100644 --- a/src/ShapeFix/ShapeFix.cxx +++ b/src/ShapeFix/ShapeFix.cxx @@ -210,6 +210,7 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape, Standard_Real tol0 = BRep_Tool::Tolerance(edge); tol = tol0; Standard_Real tol2 = tol*tol; + Standard_Boolean isChanged = Standard_False; const Standard_Integer NCONTROL = 23; for ( Standard_Integer i = 0; i < NCONTROL; i++ ) { @@ -217,17 +218,23 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape, gp_Pnt pnt = crv->Value ( par ); gp_Pnt prj = ACS.Value( par ); Standard_Real dist = pnt.SquareDistance(prj); - if ( tol2 < dist ) - tol2 = dist; - } - tol = 1.00005 * sqrt(tol2); // coeff: see trj3_pm1-ct-203.stp #19681, edge 10 - if ( tol >= tol0 ) - { - B.UpdateEdge ( edge, tol ); - for ( TopoDS_Iterator itV(edge); itV.More(); itV.Next() ) + if ( tol2 < dist ) { - TopoDS_Shape S = itV.Value(); - B.UpdateVertex ( TopoDS::Vertex ( S ), tol ); + tol2 = dist; + isChanged = Standard_True; + } + } + if ( isChanged ) + { + tol = 1.00005 * sqrt(tol2); // coeff: see trj3_pm1-ct-203.stp #19681, edge 10 + if ( tol >= tol0 ) + { + B.UpdateEdge ( edge, tol ); + for ( TopoDS_Iterator itV(edge); itV.More(); itV.Next() ) + { + TopoDS_Shape S = itV.Value(); + B.UpdateVertex ( TopoDS::Vertex ( S ), tol ); + } } } } diff --git a/tests/bugs/heal/bug329 b/tests/bugs/heal/bug329 index 382840334a..3d6b51a1fd 100755 --- a/tests/bugs/heal/bug329 +++ b/tests/bugs/heal/bug329 @@ -1,5 +1,3 @@ -puts "TODO OCC12345 ALL: Error : Tolerance invalid. Function FixShape works WRONGLY" - puts "========================" puts " OCC329 " puts "========================" diff --git a/tests/bugs/modalg_6/bug28601 b/tests/bugs/modalg_6/bug28601 new file mode 100644 index 0000000000..f95c43b720 --- /dev/null +++ b/tests/bugs/modalg_6/bug28601 @@ -0,0 +1,21 @@ +puts "========" +puts "OCC28601" +puts "========" +puts "" +################################################################### +# ShapeFix_Shape increases tolerance of sub-shapes of a valid shape +################################################################### + +box b 10 10 10 +set tol_before [checkmaxtol b] +fixshape b1 b +set tol_after [checkmaxtol b1] + +puts "MAX tolerance shape before fixshape : $tol_before" +puts "MAX tolerance shape after fixshape : $tol_after" + +if { ${tol_after} > ${tol_before} } { + puts "Error: Export /Import cause increasing tolerances of shape" +} else { + puts "Export /Import does not cause increasing tolerances of shape" +} \ No newline at end of file