From: johanengelen Date: Sun, 23 Mar 2008 19:59:42 +0000 (+0000) Subject: update to latest 2geom (r1195) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=254b75c9676df2c13fa5a886263fad0ed27198c6;p=inkscape.git update to latest 2geom (r1195) --- diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index 171599768..1d0fd93ba 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -73,12 +73,26 @@ class Piecewise { unsigned n = segN(t); return segs[n](segT(t, n)); } + std::vector valueAndDerivatives(double t, unsigned cnt) const { + unsigned n = segN(t); + std::vector ret, val = segs[n].valueAndDerivatives(segT(t, n), cnt); + double mult = 1; + for(unsigned i = 0; i < val.size(); i++) { + ret.push_back(val[i] * mult); + mult /= cuts[n+1] - cuts[n]; + } + return ret; + } //TODO: maybe it is not a good idea to have this? Piecewise operator()(SBasis f); Piecewise operator()(Piecewisef); inline unsigned size() const { return segs.size(); } inline bool empty() const { return segs.empty(); } + inline void clear() { + segs.clear(); + cuts.clear(); + } /**Convenience/implementation hiding function to add segment/cut pairs. * Asserts that basic size and order invariants are correct diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h index c7489e27d..82ff989e7 100644 --- a/src/2geom/sbasis.h +++ b/src/2geom/sbasis.h @@ -113,7 +113,18 @@ public: return valueAt(t); } - std::vector valueAndDerivatives(double /*t*/, unsigned /*n*/) const { + std::vector valueAndDerivatives(double t, unsigned n) const { + std::vector ret; + if(n==1) { + ret.push_back(valueAt(t)); + return ret; + } + if(n==2) { + double der; + ret.push_back(valueAndDerivative(t, der)); + ret.push_back(der); + return ret; + } //TODO throwNotImplemented(); }