From c45a54c35539998a21d8dbf650df45d583d6fc56 Mon Sep 17 00:00:00 2001 From: nbv Date: Wed, 10 May 2017 17:22:18 +0300 Subject: [PATCH] 0028724: Extrema between circle and plane cannot be found The main reason of the regression is that the Extrema algorithm finds the truth extrema point but cannot adjust it to the range of given circle. It is connected with the fact that Geom(2d)Adaptor_Curve::IsPeriodic() method returns false for given circle because adaptor contains a piece of the circle which is not closed. New algorithm of IsPeriodic() method will return the information about periodicity of the curve itself (independently of first and last parameter of adaptor). The documentation about Geom(2d)_TrimmedCurve and Geom_RectangularTrimmedSurface has been updated in frame of the information about IsPeriodic-methods. (cherry picked from commit b3cba642626bf141475c6e614fdc1df5e93cfcf7) --- src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx | 5 +---- src/GeomAdaptor/GeomAdaptor_Curve.cxx | 2 +- src/GeomFill/GeomFill_NSections.cxx | 11 ++++++++--- tests/bugs/modalg_6/bug28724 | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 tests/bugs/modalg_6/bug28724 diff --git a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx index e9e2013a53..1bae7542c6 100644 --- a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx +++ b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx @@ -500,10 +500,7 @@ Standard_Boolean Geom2dAdaptor_Curve::IsClosed() const Standard_Boolean Geom2dAdaptor_Curve::IsPeriodic() const { - if (myCurve->IsPeriodic()) - return IsClosed(); - else - return Standard_False; + return myCurve->IsPeriodic(); } //======================================================================= diff --git a/src/GeomAdaptor/GeomAdaptor_Curve.cxx b/src/GeomAdaptor/GeomAdaptor_Curve.cxx index b6cb7bd4ed..6d68a9dcaf 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.cxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.cxx @@ -495,7 +495,7 @@ Standard_Boolean GeomAdaptor_Curve::IsClosed() const Standard_Boolean GeomAdaptor_Curve::IsPeriodic() const { - return (myCurve->IsPeriodic()? IsClosed() : Standard_False); + return myCurve->IsPeriodic(); } //======================================================================= diff --git a/src/GeomFill/GeomFill_NSections.cxx b/src/GeomFill/GeomFill_NSections.cxx index 1b02a345be..2940bfae30 100644 --- a/src/GeomFill/GeomFill_NSections.cxx +++ b/src/GeomFill/GeomFill_NSections.cxx @@ -968,9 +968,14 @@ void GeomFill_NSections::GetMinimalWeight(TColStd_Array1OfReal& Weights) const C1.SetRadius(radius); Handle(Geom_Curve) C = new (Geom_Circle) (C1); - if (! AC1.IsPeriodic()) { - Handle(Geom_Curve) Cbis = new (Geom_TrimmedCurve) - (C, AC1.FirstParameter(), AC1.LastParameter()); + + const Standard_Real aParF = AC1.FirstParameter(); + const Standard_Real aParL = AC1.LastParameter(); + const Standard_Real aPeriod = AC1.IsPeriodic() ? AC1.Period() : 0.0; + + if ((aPeriod == 0.0) || (Abs(aParL - aParF - aPeriod) > Precision::PConfusion())) + { + Handle(Geom_Curve) Cbis = new Geom_TrimmedCurve(C, aParF, aParL); C = Cbis; } return C; diff --git a/tests/bugs/modalg_6/bug28724 b/tests/bugs/modalg_6/bug28724 new file mode 100644 index 0000000000..3626c082ab --- /dev/null +++ b/tests/bugs/modalg_6/bug28724 @@ -0,0 +1,16 @@ +puts "========" +puts "OCC28724" +puts "========" +puts "" +############################################## +# Extrema between circle and plane cannot be found +############################################## + +restore [locate_data_file bug28724_cmpd.brep] co +explode co + +distmini d co_1 co_2 + +if {[dval d_val] > 1.0e-7} { + puts "Error: Extrema cannot find minimal distance" +} \ No newline at end of file -- 2.39.5