diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-03-23 19:59:42 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-03-23 19:59:42 +0000 |
| commit | f83ca21ebe8f3ed5400ede7093eda0394b8c05b4 (patch) | |
| tree | 30930aa5f7cfe304285cc4e1eacb96cadbdc29e2 | |
| parent | return const reference when getting path data from lpe-PathParam! (diff) | |
| download | inkscape-f83ca21ebe8f3ed5400ede7093eda0394b8c05b4.tar.gz inkscape-f83ca21ebe8f3ed5400ede7093eda0394b8c05b4.zip | |
update to latest 2geom (r1195)
(bzr r5178)
| -rw-r--r-- | src/2geom/piecewise.h | 14 | ||||
| -rw-r--r-- | src/2geom/sbasis.h | 13 |
2 files changed, 26 insertions, 1 deletions
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<output_type> valueAndDerivatives(double t, unsigned cnt) const { + unsigned n = segN(t); + std::vector<output_type> 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<T> operator()(SBasis f); Piecewise<T> operator()(Piecewise<SBasis>f); 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<double> valueAndDerivatives(double /*t*/, unsigned /*n*/) const { + std::vector<double> valueAndDerivatives(double t, unsigned n) const { + std::vector<double> 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(); } |
