From 833034f301099cfd77abe4d57cba1bfd5659183a Mon Sep 17 00:00:00 2001 From: ifv Date: Mon, 15 Apr 2019 12:47:08 +0300 Subject: [PATCH] 0030647: Geom2dGcc_Circ2d2TanRad not giving all the solutions Method for calculation of correct number of sampling points is added for Adaptor2d_OffsetCurve. Now number of sampling points correspond with similar method for Geom2dAdaptor_Curve for curve type GeomAbs_OffsetCurve Test case added --- src/Adaptor2d/Adaptor2d_OffsetCurve.cxx | 33 ++++++++++++++++++++++++- src/Adaptor2d/Adaptor2d_OffsetCurve.hxx | 1 + tests/bugs/modalg_7/bug30647 | 30 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/modalg_7/bug30647 diff --git a/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx b/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx index 4c4fa9b832..16e5dc412f 100644 --- a/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx +++ b/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx @@ -458,7 +458,7 @@ GeomAbs_CurveType Adaptor2d_OffsetCurve::GetType() const { return GeomAbs_Circle; default: - return GeomAbs_OtherCurve; + return GeomAbs_OffsetCurve; } } @@ -650,3 +650,34 @@ Handle(Geom2d_BSplineCurve) Adaptor2d_OffsetCurve::BSpline() const "Adaptor2d_OffsetCurve::BSpline() - wrong curve type"); return myCurve->BSpline(); } + +static Standard_Integer nbPoints(const Handle(Adaptor2d_HCurve2d)& theCurve) +{ + + Standard_Integer nbs = 20; + + if (theCurve->GetType() == GeomAbs_Line) + nbs = 2; + else if (theCurve->GetType() == GeomAbs_BezierCurve) + { + nbs = 3 + theCurve->NbPoles(); + } + else if (theCurve->GetType() == GeomAbs_BSplineCurve) { + nbs = theCurve->NbKnots(); + nbs *= theCurve->Degree(); + } + + if (nbs > 200) + nbs = 200; + return nbs; + +} +//======================================================================= +//function : NbSamples +//purpose : +//======================================================================= + +Standard_Integer Adaptor2d_OffsetCurve::NbSamples() const +{ + return nbPoints(myCurve); +} diff --git a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx index b1b1c356f3..fc379a0269 100644 --- a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx +++ b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx @@ -174,6 +174,7 @@ public: Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE; + Standard_EXPORT Standard_Integer NbSamples() const Standard_OVERRIDE; diff --git a/tests/bugs/modalg_7/bug30647 b/tests/bugs/modalg_7/bug30647 new file mode 100644 index 0000000000..51f88b464f --- /dev/null +++ b/tests/bugs/modalg_7/bug30647 @@ -0,0 +1,30 @@ +puts "========" +puts "0030647: Geom2dGcc_Circ2d2TanRad not giving all the solutions" +puts "========" +puts "" + +restore [locate_data_file bug30647_curve1_720.brep] c1 +restore [locate_data_file bug30647_curve2_720.brep] c2 + +explode c1 e +mk2dcurve q1 c1_1 +explode c2 e +mk2dcurve q2 c2_1 + +cirtang r -c q1 -c q2 -r 0.4 + +smallview -2D- + +2dclear q1 +2dfit +display q1 + +xwd ${imagedir}/${test_image}.png + +set NbCurv [llength [directory r_*]] + +if { $NbCurv == 8 } { + puts "OK: Number of circles is good" +} else { + puts "Error: Not all solutions" +} -- 2.39.5