diff options
Diffstat (limited to 'src/2geom/bezier-curve.h')
| -rw-r--r-- | src/2geom/bezier-curve.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index 9b08466f8..636a263a7 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -69,6 +69,7 @@ public: /** @brief Get the control points. * @return Vector with order() + 1 control points. */ std::vector<Point> controlPoints() const { return bezier_points(inner); } + D2<Bezier> const &fragment() const { return inner; } /** @brief Modify a control point. * @param ix The zero-based index of the point to modify. Note that the caller is responsible for checking that this value is <= order(). @@ -104,6 +105,7 @@ public: virtual Point initialPoint() const { return inner.at0(); } virtual Point finalPoint() const { return inner.at1(); } virtual bool isDegenerate() const { return inner.isConstant(0); } + virtual bool isLineSegment() const { return size() == 2; } virtual void setInitial(Point const &v) { setPoint(0, v); } virtual void setFinal(Point const &v) { setPoint(order(), v); } virtual Rect boundsFast() const { return *bounds_fast(inner); } @@ -145,7 +147,7 @@ public: virtual Coord nearestTime(Point const &p, Coord from = 0, Coord to = 1) const; virtual Coord length(Coord tolerance) const; virtual std::vector<CurveIntersection> intersect(Curve const &other, Coord eps = EPSILON) const; - virtual Point pointAt(Coord t) const { return inner.valueAt(t); } + virtual Point pointAt(Coord t) const { return inner.pointAt(t); } virtual std::vector<Point> pointAndDerivatives(Coord t, unsigned n) const { return inner.valueAndDerivatives(t, n); } @@ -229,6 +231,10 @@ public: BezierCurveN(sx.second, sy.second)); } + virtual bool isLineSegment() const { + return size() == 2; + } + virtual Curve *duplicate() const { return new BezierCurveN(*this); } @@ -251,6 +257,10 @@ public: virtual Coord nearestTime(Point const &p, Coord from = 0, Coord to = 1) const { return BezierCurve::nearestTime(p, from, to); } + virtual std::vector<CurveIntersection> intersect(Curve const &other, Coord eps = EPSILON) const { + // call super. this is implemented only to allow specializations + return BezierCurve::intersect(other, eps); + } virtual void feed(PathSink &sink, bool moveto_initial) const { // call super. this is implemented only to allow specializations BezierCurve::feed(sink, moveto_initial); @@ -281,8 +291,10 @@ Curve *BezierCurveN<degree>::derivative() const { } // optimized specializations +template <> inline bool BezierCurveN<1>::isLineSegment() const { return true; } template <> Curve *BezierCurveN<1>::derivative() const; template <> Coord BezierCurveN<1>::nearestTime(Point const &, Coord, Coord) const; +template <> std::vector<CurveIntersection> BezierCurveN<1>::intersect(Curve const &, Coord) const; template <> void BezierCurveN<1>::feed(PathSink &sink, bool moveto_initial) const; template <> void BezierCurveN<2>::feed(PathSink &sink, bool moveto_initial) const; template <> void BezierCurveN<3>::feed(PathSink &sink, bool moveto_initial) const; |
