summaryrefslogtreecommitdiffstats
path: root/src/2geom/d2-sbasis.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-04-13 19:27:01 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-04-13 19:27:01 +0000
commit4261da6fc2c9ba0b26452adf7fddc83fba6ed7ea (patch)
treed79bf3653449f7bbac3a45e729bf66c6a428fd13 /src/2geom/d2-sbasis.cpp
parentMake fallback to iq auth in the odd situation of server saying it has streams... (diff)
downloadinkscape-4261da6fc2c9ba0b26452adf7fddc83fba6ed7ea.tar.gz
inkscape-4261da6fc2c9ba0b26452adf7fddc83fba6ed7ea.zip
sync with current 2geom, split_at_discontinuities method and SVGEllipticalArc
(bzr r5418)
Diffstat (limited to 'src/2geom/d2-sbasis.cpp')
-rw-r--r--src/2geom/d2-sbasis.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/2geom/d2-sbasis.cpp b/src/2geom/d2-sbasis.cpp
index a646e2cf4..dbf4da10e 100644
--- a/src/2geom/d2-sbasis.cpp
+++ b/src/2geom/d2-sbasis.cpp
@@ -97,9 +97,8 @@ Piecewise<D2<SBasis> > operator*(Piecewise<D2<SBasis> > const &a, Matrix const &
}
//if tol>0, only force continuity where the jump is smaller than tol.
-Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f,
- double tol,
- bool closed){
+Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f, double tol, bool closed)
+{
if (f.size()==0) return f;
Piecewise<D2<SBasis> > result=f;
unsigned cur = (closed)? 0:1;
@@ -129,4 +128,26 @@ Piecewise<D2<SBasis> > force_continuity(Piecewise<D2<SBasis> > const &f,
}
return result;
}
+
+std::vector<Geom::Piecewise<Geom::D2<Geom::SBasis> > >
+split_at_discontinuities (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwsbin, double tol)
+{
+ using namespace Geom;
+ std::vector<Piecewise<D2<SBasis> > > ret;
+ unsigned piece_start = 0;
+ for (unsigned i=0; i<pwsbin.segs.size(); i++){
+ if (i==(pwsbin.segs.size()-1) || L2(pwsbin.segs[i].at1()- pwsbin.segs[i+1].at0()) > tol){
+ Piecewise<D2<SBasis> > piece;
+ piece.cuts.push_back(pwsbin.cuts[piece_start]);
+ for (unsigned j = piece_start; j<i+1; j++){
+ piece.segs.push_back(pwsbin.segs[j]);
+ piece.cuts.push_back(pwsbin.cuts[j+1]);
+ }
+ ret.push_back(piece);
+ piece_start = i+1;
+ }
+ }
+ return ret;
}
+
+} // namespace Geom