From 4563cf3e6c54ffd699af037f0d8f8c224710b6e0 Mon Sep 17 00:00:00 2001 From: ifv Date: Mon, 2 Apr 2018 17:05:51 +0300 Subject: [PATCH] 0029655: [Regression to 6.9.1] Distance between cylinder and straight line Trimming line by corner points of surface bounding box is added to reduce rang of line Test case added --- src/Extrema/Extrema_ExtCS.cxx | 66 ++++++++++++----------------------- tests/bugs/modalg_7/bug29655 | 19 ++++++++++ 2 files changed, 41 insertions(+), 44 deletions(-) create mode 100644 tests/bugs/modalg_7/bug29655 diff --git a/src/Extrema/Extrema_ExtCS.cxx b/src/Extrema/Extrema_ExtCS.cxx index 797e001c5f..25cc8cd62d 100644 --- a/src/Extrema/Extrema_ExtCS.cxx +++ b/src/Extrema/Extrema_ExtCS.cxx @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include #include #include @@ -147,53 +145,34 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, Standard_Real ufirst = myS->FirstUParameter(), ulast = myS->LastUParameter(), vfirst = myS->FirstVParameter(), vlast = myS->LastVParameter(); - if(Precision::IsInfinite(Abs(cfirst)) || Precision::IsInfinite(Abs(clast))) { - + if (!(Precision::IsInfinite(ufirst) || Precision::IsInfinite(ulast) || + Precision::IsInfinite(vfirst) || Precision::IsInfinite(vlast))) + { + Standard_Real tmin = Precision::Infinite(), tmax = -tmin; + Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; Bnd_Box aSurfBox; BndLib_AddSurface::Add(*myS, ufirst, ulast, vfirst, vlast, Precision::Confusion(), aSurfBox); - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; aSurfBox.Get(xmin, ymin, zmin, xmax, ymax, zmax); - Standard_Real tmin = Precision::Infinite(), tmax = -tmin; gp_Lin aLin = C.Line(); - - - if(!( Precision::IsInfinite(Abs(xmin)) || Precision::IsInfinite(Abs(xmax)) || - Precision::IsInfinite(Abs(ymin)) || Precision::IsInfinite(Abs(ymax)) || - Precision::IsInfinite(Abs(zmin)) || Precision::IsInfinite(Abs(zmax))) ) { - - Extrema_ExtPElC anExt; - Extrema_POnCurv aPntOnLin; - Standard_Real aParOnLin; - Standard_Real lim = Precision::Infinite(); - gp_Pnt aLimPntArray[8]; - - aLimPntArray[0].SetCoord(xmin, ymin, zmin); - aLimPntArray[1].SetCoord(xmax, ymin, zmin); - aLimPntArray[2].SetCoord(xmin, ymax, zmin); - aLimPntArray[3].SetCoord(xmax, ymax, zmin); - aLimPntArray[4].SetCoord(xmin, ymin, zmax); - aLimPntArray[5].SetCoord(xmax, ymin, zmax); - aLimPntArray[6].SetCoord(xmin, ymax, zmax); - aLimPntArray[7].SetCoord(xmax, ymax, zmax); - - for(i = 0; i <= 7; i++) { - anExt.Perform(aLimPntArray[i], aLin, Precision::Confusion(), -lim, lim); - aPntOnLin = anExt.Point(1); - aParOnLin = aPntOnLin.Parameter(); - tmin = Min(aParOnLin, tmin); - tmax = Max(aParOnLin, tmax); - } - + Standard_Real aParOnLin; + gp_Pnt aLimPntArray[8]; + + aLimPntArray[0].SetCoord(xmin, ymin, zmin); + aLimPntArray[1].SetCoord(xmax, ymin, zmin); + aLimPntArray[2].SetCoord(xmin, ymax, zmin); + aLimPntArray[3].SetCoord(xmax, ymax, zmin); + aLimPntArray[4].SetCoord(xmin, ymin, zmax); + aLimPntArray[5].SetCoord(xmax, ymin, zmax); + aLimPntArray[6].SetCoord(xmin, ymax, zmax); + aLimPntArray[7].SetCoord(xmax, ymax, zmax); + + for (i = 0; i <= 7; i++) { + aParOnLin = ElCLib::Parameter(aLin, aLimPntArray[i]); + tmin = Min(aParOnLin, tmin); + tmax = Max(aParOnLin, tmax); } - else { - tmin = -1.e+50; - tmax = 1.e+50; - } - - cfirst = Max(cfirst, tmin); - clast = Min(clast, tmax); - + clast = Min(clast, tmax); } if (myS->IsUPeriodic()) @@ -219,7 +198,6 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C, } } return; - } } break; diff --git a/tests/bugs/modalg_7/bug29655 b/tests/bugs/modalg_7/bug29655 new file mode 100644 index 0000000000..d710c1c653 --- /dev/null +++ b/tests/bugs/modalg_7/bug29655 @@ -0,0 +1,19 @@ +puts "========" +puts "OCC29655" +puts "========" +puts "" +################################################# +# 0029655: [Regression to 6.9.1] Distance between cylinder and straight line +################################################# + +restore [locate_data_file bug29655.brep] s +explode s +distmini res s_1 s_2 + + +if { [isdraw res] } { + checknbshapes res -vertex 1 -edge 0 +} else { puts "Error : result of distmini is wrong" } + + + -- 2.39.5