[Part] Avoid nullptr when using createArc
We could make `GeomCurve::createArc(...) = 0`, but then it needs to be implemented in many subclasses which cannot be incomplete. It is implemented for some of them, but others may need additional work (e.g. offsets), and would need some exception throwing similar to what is now used.
This commit is contained in:
@@ -795,7 +795,7 @@ GeomBSplineCurve* GeomCurve::toNurbs(double first, double last) const
|
||||
|
||||
GeomCurve* GeomCurve::createArc([[maybe_unused]] double first, [[maybe_unused]] double last) const
|
||||
{
|
||||
return nullptr;
|
||||
THROWM(Base::NotImplementedError, "createArc: not implemented for this type of curve");
|
||||
}
|
||||
|
||||
bool GeomCurve::tangent(double u, gp_Dir& dir) const
|
||||
@@ -3606,13 +3606,21 @@ void GeomHyperbola::setHandle(const Handle(Geom_Hyperbola)& c)
|
||||
myCurve = Handle(Geom_Hyperbola)::DownCast(c->Copy());
|
||||
}
|
||||
|
||||
Geometry *GeomHyperbola::copy() const
|
||||
Geometry* GeomHyperbola::copy() const
|
||||
{
|
||||
GeomHyperbola *newHyp = new GeomHyperbola(myCurve);
|
||||
newHyp->copyNonTag(this);
|
||||
return newHyp;
|
||||
}
|
||||
|
||||
GeomCurve* GeomHyperbola::createArc(double first, double last) const
|
||||
{
|
||||
auto newArc = new GeomArcOfHyperbola(Handle(Geom_Hyperbola)::DownCast(this->handle()->Copy()));
|
||||
newArc->setRange(first, last, false);
|
||||
|
||||
return newArc;
|
||||
}
|
||||
|
||||
GeomBSplineCurve* GeomHyperbola::toNurbs(double first, double last) const
|
||||
{
|
||||
return GeomConic::toNurbs(first, last);
|
||||
@@ -4058,6 +4066,14 @@ Geometry *GeomParabola::copy() const
|
||||
return newPar;
|
||||
}
|
||||
|
||||
GeomCurve* GeomParabola::createArc(double first, double last) const
|
||||
{
|
||||
auto newArc = new GeomArcOfParabola(Handle(Geom_Parabola)::DownCast(this->handle()->Copy()));
|
||||
newArc->setRange(first, last, false);
|
||||
|
||||
return newArc;
|
||||
}
|
||||
|
||||
GeomBSplineCurve* GeomParabola::toNurbs(double first, double last) const
|
||||
{
|
||||
// the default implementation suffices because a non-rational B-spline with
|
||||
|
||||
Reference in New Issue
Block a user