From: ifv Date: Thu, 10 Apr 2014 13:52:25 +0000 (+0400) Subject: 0024766: Wrong result for distmini between a TopoDS_Shell and a TopoDS_Edge on versio... X-Git-Tag: V6_8_0_beta~420 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=0e4e12407f9f6534345833ba42712b36f9fa048c 0024766: Wrong result for distmini between a TopoDS_Shell and a TopoDS_Edge on version 6.6.0. Test case for issue CR24766 Modified test case bugs/modalg_5/bug24766 --- diff --git a/src/BRepExtrema/BRepExtrema_ExtCC.cxx b/src/BRepExtrema/BRepExtrema_ExtCC.cxx index 047821d0e7..9ca3b84ade 100644 --- a/src/BRepExtrema/BRepExtrema_ExtCC.cxx +++ b/src/BRepExtrema/BRepExtrema_ExtCC.cxx @@ -43,8 +43,11 @@ void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2) Standard_Real V1,V2; BRepAdaptor_Curve Curv(E2); myHC = new BRepAdaptor_HCurve(Curv); + Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion()); + Tol = Max(Curv.Resolution(Tol), Precision::PConfusion()); BRep_Tool::Range(E2,V1,V2); myExtCC.SetCurve(2,myHC->Curve(),V1,V2); + myExtCC.SetTolerance(2, Tol); } //======================================================================= @@ -57,8 +60,11 @@ void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1) Standard_Real U1, U2; BRepAdaptor_Curve Curv(E1); Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv); + Standard_Real Tol = Min(BRep_Tool::Tolerance(E1), Precision::Confusion()); + Tol = Max(Curv.Resolution(Tol), Precision::PConfusion()); BRep_Tool::Range(E1,U1,U2); myExtCC.SetCurve (1, HC->Curve(), U1, U2); + myExtCC.SetTolerance(1, Tol); myExtCC.Perform(); } diff --git a/src/BRepExtrema/BRepExtrema_ExtCF.cxx b/src/BRepExtrema/BRepExtrema_ExtCF.cxx index b818a57f43..897f2018c1 100644 --- a/src/BRepExtrema/BRepExtrema_ExtCF.cxx +++ b/src/BRepExtrema/BRepExtrema_ExtCF.cxx @@ -33,7 +33,7 @@ BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F) { - Initialize(F); + Initialize(E, F); Perform(E, F); } @@ -42,14 +42,24 @@ BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F) //purpose : //======================================================================= -void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2) +void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F) { - BRepAdaptor_Surface Surf(F2); + BRepAdaptor_Surface Surf(F); + BRepAdaptor_Curve aC(E); myHS = new BRepAdaptor_HSurface(Surf); - const Standard_Real Tol = BRep_Tool::Tolerance(F2); + Standard_Real aTolC, aTolS; + // + aTolS = Min(BRep_Tool::Tolerance(F), Precision::Confusion()); + aTolS = Min(Surf.UResolution(aTolS), Surf.VResolution(aTolS)); + aTolS = Max(aTolS, Precision::PConfusion()); + // + aTolC = Min(BRep_Tool::Tolerance(E), Precision::Confusion()); + aTolC = aC.Resolution(aTolC); + aTolC = Max(aTolC, Precision::PConfusion()); + // Standard_Real U1, U2, V1, V2; - BRepTools::UVBounds(F2, U1, U2, V1, V2); - myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol); + BRepTools::UVBounds(F, U1, U2, V1, V2); + myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, aTolC, aTolS); } //======================================================================= diff --git a/src/BRepExtrema/BRepExtrema_ExtCF.hxx b/src/BRepExtrema/BRepExtrema_ExtCF.hxx index cff941a587..b820c788f1 100644 --- a/src/BRepExtrema/BRepExtrema_ExtCF.hxx +++ b/src/BRepExtrema/BRepExtrema_ExtCF.hxx @@ -39,12 +39,12 @@ class BRepExtrema_ExtCF { } //! It calculates all the distances.
- Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& V,const TopoDS_Face& E); + Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& E,const TopoDS_Face& F); - Standard_EXPORT void Initialize(const TopoDS_Face& E); + Standard_EXPORT void Initialize(const TopoDS_Edge& E, const TopoDS_Face& F); //! An exception is raised if the fields have not been initialized.
//! Be careful: this method uses the Face only for classify not for the fields.
- Standard_EXPORT void Perform(const TopoDS_Edge& V,const TopoDS_Face& F); + Standard_EXPORT void Perform(const TopoDS_Edge& E,const TopoDS_Face& F); //! True if the distances are found.
Standard_EXPORT Standard_Boolean IsDone() const { diff --git a/src/BRepExtrema/BRepExtrema_ExtFF.cxx b/src/BRepExtrema/BRepExtrema_ExtFF.cxx index 5498a6bd6b..0881dcc4cb 100644 --- a/src/BRepExtrema/BRepExtrema_ExtFF.cxx +++ b/src/BRepExtrema/BRepExtrema_ExtFF.cxx @@ -47,7 +47,9 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2) { BRepAdaptor_Surface Surf(F2); myHS = new BRepAdaptor_HSurface(Surf); - const Standard_Real Tol = BRep_Tool::Tolerance(F2); + Standard_Real Tol = Min(BRep_Tool::Tolerance(F2), Precision::Confusion()); + Tol = Min(Surf.UResolution(Tol), Surf.VResolution(Tol)); + Tol = Max(Tol, Precision::PConfusion()); Standard_Real U1, U2, V1, V2; BRepTools::UVBounds(F2, U1, U2, V1, V2); myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol); @@ -66,7 +68,9 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2) BRepAdaptor_Surface Surf1(F1); Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1); - const Standard_Real Tol1 = BRep_Tool::Tolerance(F1); + Standard_Real Tol1 = Min(BRep_Tool::Tolerance(F1), Precision::Confusion()); + Tol1 = Min(Surf1.UResolution(Tol1), Surf1.VResolution(Tol1)); + Tol1 = Max(Tol1, Precision::PConfusion()); Standard_Real U1, U2, V1, V2; BRepTools::UVBounds(F1, U1, U2, V1, V2); myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1); diff --git a/src/BRepExtrema/BRepExtrema_ExtPC.cxx b/src/BRepExtrema/BRepExtrema_ExtPC.cxx index ef6642fab6..4c491c8863 100644 --- a/src/BRepExtrema/BRepExtrema_ExtPC.cxx +++ b/src/BRepExtrema/BRepExtrema_ExtPC.cxx @@ -44,8 +44,10 @@ void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E) Standard_Real U1,U2; BRepAdaptor_Curve Curv(E); myHC = new BRepAdaptor_HCurve(Curv); + Standard_Real Tol = Min(BRep_Tool::Tolerance(E), Precision::Confusion()); + Tol = Max(Curv.Resolution(Tol), Precision::PConfusion()); BRep_Tool::Range(E,U1,U2); - myExtPC.Initialize(myHC->Curve(),U1,U2); + myExtPC.Initialize(myHC->Curve(),U1,U2,Tol); } //======================================================================= diff --git a/src/BRepExtrema/BRepExtrema_ExtPF.cxx b/src/BRepExtrema/BRepExtrema_ExtPF.cxx index 0450ac63e1..5b2d4be300 100644 --- a/src/BRepExtrema/BRepExtrema_ExtPF.cxx +++ b/src/BRepExtrema/BRepExtrema_ExtPF.cxx @@ -24,6 +24,7 @@ #include #include #include +#include //======================================================================= //function : BRepExtrema_ExtPF @@ -48,12 +49,15 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace, // cette surface doit etre en champ. Extrema ne fait // pas de copie et prend seulement un pointeur dessus. mySurf.Initialize(TheFace, Standard_False); - const Standard_Real Tol = BRep_Tool::Tolerance(TheFace); + Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion()); + Standard_Real aTolU, aTolV; + aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion()); + aTolV = Max(mySurf.VResolution(Tol), Precision::PConfusion()); Standard_Real U1, U2, V1, V2; BRepTools::UVBounds(TheFace, U1, U2, V1, V2); myExtPS.SetFlag(TheFlag); myExtPS.SetAlgo(TheAlgo); - myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol); + myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV); } //======================================================================= diff --git a/tests/bugs/modalg_5/bug24766 b/tests/bugs/modalg_5/bug24766 new file mode 100644 index 0000000000..29fa453413 --- /dev/null +++ b/tests/bugs/modalg_5/bug24766 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC24766" +puts "============" +puts "" +################################################# +# Wrong result for distmini between a TopoDS_Shell and a TopoDS_Edge on version 6.6.0. +################################################# + +restore [locate_data_file bug24766_shell_for_points.brep] s1 +restore [locate_data_file bug24766_edge_to_line.brep] e1 + +set dist_list [distmini d s1 e1] + +regexp {([-0-9.+eE]+)} [dump d_val] full dist + +set expected_dist 2.09628394812595e-15 +set tol_abs_dist 1.0e-12 +set tol_rel_dist 0.001 + +checkreal "Minimal distantion" ${dist} ${expected_dist} ${tol_abs_dist} ${tol_rel_dist}