diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2010-10-28 20:48:21 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2010-10-28 20:48:21 +0000 |
| commit | 6c551a6197ae163bd492042dba7219e1c7ef5aa9 (patch) | |
| tree | e585f2002bb5d74d61f3c89ff6d224f8ad1e7bdd /src | |
| parent | German translation update (diff) | |
| download | inkscape-6c551a6197ae163bd492042dba7219e1c7ef5aa9.tar.gz inkscape-6c551a6197ae163bd492042dba7219e1c7ef5aa9.zip | |
LPE Knot: only consider closing line segment if its length is non-zero
Fixed bugs:
- https://launchpad.net/bugs/606859
(bzr r9862)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index dcc2aee75..4c74df02e 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -47,6 +47,17 @@ public: }; +Geom::Path::size_type size_nondegenerate(Geom::Path const &path) { + Geom::Path::size_type retval = path.size_open(); + + // if path is closed and closing segment is not degenerate + if (path.closed() && !path.back_closed().isDegenerate()) { + retval = path.size_closed(); + } + + return retval; +} + //--------------------------------------------------------------------------- //LPEKnot specific Interval manipulation. //--------------------------------------------------------------------------- @@ -90,7 +101,7 @@ findShadowedTime(Geom::Path const &patha, std::vector<Geom::Point> const &pt_and std::vector<double> times; //TODO: explore the path fwd/backward from ta (worth?) - for (unsigned i=0; i<patha.size_default(); i++){ + for (unsigned i = 0; i < size_nondegenerate(patha); i++){ D2<SBasis> f = p[i].toSBasis(); std::vector<double> times_i, temptimes; temptimes = roots(f[Y]-width); @@ -110,8 +121,8 @@ findShadowedTime(Geom::Path const &patha, std::vector<Geom::Point> const &pt_and std::vector<double>::iterator new_end = std::unique( times.begin(), times.end() ); times.resize( new_end - times.begin() ); - double tmin = 0, tmax = patha.size_default(); - double period = patha.size_default(); + double tmin = 0, tmax = size_nondegenerate(patha); + double period = size_nondegenerate(patha); if (times.size()>0){ unsigned rk = upper_bound( times.begin(), times.end(), ta ) - times.begin(); if ( rk < times.size() ) @@ -141,9 +152,9 @@ namespace LPEKnotNS {//just in case... CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vector<CrossingPoint>(){ // std::cout<<"\nCrossingPoints creation from path vector\n"; for( unsigned i=0; i<paths.size(); i++){ - for( unsigned ii=0; ii<paths[i].size_default(); ii++){ + for( unsigned ii=0; ii < size_nondegenerate(paths[i]); ii++){ for( unsigned j=i; j<paths.size(); j++){ - for( unsigned jj=(i==j?ii:0); jj<paths[j].size_default(); jj++){ + for( unsigned jj=(i==j?ii:0); jj < size_nondegenerate(paths[j]); jj++){ std::vector<std::pair<double,double> > times; if ( i==j && ii==jj){ @@ -169,7 +180,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect if ( i==j && fabs(times[k].first+ii - times[k].second-jj)<=zero ){//this is just end=start of successive curves in a path. continue; } - if ( i==j && ii == 0 && jj==paths[i].size_default()-1 && + if ( i==j && ii == 0 && jj == size_nondegenerate(paths[i])-1 && paths[i].closed() && fabs(times[k].first) <= zero && fabs(times[k].second - 1) <= zero ){//this is just end=start of a closed path. @@ -393,7 +404,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) if (i0 == gpaths.size() ) {THROW_EXCEPTION("lpe-knot error: group member not recognized");}// this should not happen... std::vector<Interval> dom; - dom.push_back(Interval(0.,gpaths[i0].size_default())); + dom.push_back(Interval(0., size_nondegenerate(gpaths[i0]))); for (unsigned p = 0; p < crossing_points.size(); p++){ if (crossing_points[p].i == i0 || crossing_points[p].j == i0){ unsigned i = crossing_points[p].i; @@ -404,13 +415,13 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) double curveidx, t; t = modf(ti, &curveidx); - if(curveidx == gpaths[i].size_default() ) { curveidx--; t = 1.;} - assert(curveidx >= 0 && curveidx < gpaths[i].size_default()); + if(curveidx == size_nondegenerate(gpaths[i]) ) { curveidx--; t = 1.;} + assert(curveidx >= 0 && curveidx < size_nondegenerate(gpaths[i])); std::vector<Point> flag_i = gpaths[i][curveidx].pointAndDerivatives(t,1); t = modf(tj, &curveidx); - if(curveidx == gpaths[j].size_default() ) { curveidx--; t = 1.;} - assert(curveidx >= 0 && curveidx < gpaths[j].size_default()); + if(curveidx == size_nondegenerate(gpaths[j]) ) { curveidx--; t = 1.;} + assert(curveidx >= 0 && curveidx < size_nondegenerate(gpaths[j])); std::vector<Point> flag_j = gpaths[j][curveidx].pointAndDerivatives(t,1); @@ -439,7 +450,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) width += gstroke_widths[j]; } Interval hidden = findShadowedTime(gpaths[i0], flag_j, ti, width/2); - double period = gpaths[i0].size_default(); + double period = size_nondegenerate(gpaths[i0]); if (hidden.max() > period ) hidden -= period; if (hidden.min()<0){ dom = complementOf( Interval(0,hidden.max()) ,dom); @@ -458,7 +469,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) //If the current path is closed and the last/first point is still there, glue first and last piece. unsigned beg_comp = 0, end_comp = dom.size(); - if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == gpaths[i0].size_default() ){ + if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == size_nondegenerate(gpaths[i0]) ){ if ( dom.size() == 1){ path_out.push_back(gpaths[i0]); continue; @@ -473,7 +484,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) } } for (unsigned comp = beg_comp; comp < end_comp; comp++){ - assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= gpaths.at(i0).size_default()); + assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0))); path_out.push_back(gpaths[i0].portion(dom.at(comp))); } } @@ -660,3 +671,4 @@ KnotHolderEntityCrossingSwitcher::knot_click(guint state) End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : + |
