From 2b5ced28c338a41a7eddbfa35d72a16db18d1236 Mon Sep 17 00:00:00 2001 From: ifv Date: Tue, 16 Apr 2019 10:49:26 +0300 Subject: [PATCH] 0030647: Geom2dGcc_Circ2d2TanRad not giving all the solutions Correct choice od number of sampling points is added for Adaptor2d_OffsetCurve --- src/Adaptor2d/Adaptor2d_OffsetCurve.cxx | 29 ++++++++++++++++++++++++- src/Adaptor2d/Adaptor2d_OffsetCurve.hxx | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx b/src/Adaptor2d/Adaptor2d_OffsetCurve.cxx index 4c4fa9b832..8805b4bccd 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,30 @@ 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; + +} + +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..1d5b2caf4e 100644 --- a/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx +++ b/src/Adaptor2d/Adaptor2d_OffsetCurve.hxx @@ -174,6 +174,8 @@ public: Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE; + Standard_EXPORT Standard_Integer NbSamples() const Standard_OVERRIDE;; + -- 2.39.5