diff options
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/geom-curves.h | 18 | ||||
| -rw-r--r-- | src/helper/geom.cpp | 22 |
2 files changed, 21 insertions, 19 deletions
diff --git a/src/helper/geom-curves.h b/src/helper/geom-curves.h index f927634d8..5b921e572 100644 --- a/src/helper/geom-curves.h +++ b/src/helper/geom-curves.h @@ -26,17 +26,15 @@ inline bool is_straight_curve(Geom::Curve const & c) { } // the curve can be a quad/cubic bezier, but could still be a perfect straight line // if the control points are exactly on the line connecting the initial and final points. - else if ( Geom::QuadraticBezier const *quad = dynamic_cast<Geom::QuadraticBezier const*>(&c) ) { - Geom::Line line( quad->initialPoint(), quad->finalPoint() ); - if ( are_near((*quad)[1], line) ) { - return true; - } - } - else if ( Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&c) ) { - Geom::Line line( cubic->initialPoint(), cubic->finalPoint() ); - if ( are_near((*cubic)[1], line) && are_near((*cubic)[2], line) ) { - return true; + Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&c); + if (curve) { + Geom::Line line(curve->initialPoint(), curve->finalPoint()); + std::vector<Geom::Point> pts = curve->points(); + for (unsigned i = 1; i < pts.size() - 1; ++i) { + if (!are_near(pts[i], line)) + return false; } + return true; } return false; diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 4bf56f6c1..2420b43b4 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -476,15 +476,19 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) output.back().close( pit->closed() ); for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { - if( dynamic_cast<Geom::CubicBezier const*>(&*cit) || - is_straight_curve(*cit) ) - { - output.back().append(*cit); - } - else { - // convert all other curve types to cubicbeziers - Geom::Path cubicbezier_path = Geom::cubicbezierpath_from_sbasis(cit->toSBasis(), 0.1); - output.back().append(cubicbezier_path); + if (is_straight_curve(*cit)) { + Geom::LineSegment l(cit->initialPoint(), cit->finalPoint()); + output.back().append(l); + } else { + Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&*cit); + if (curve && curve->order() == 3) { + Geom::CubicBezier b((*curve)[0], (*curve)[1], (*curve)[2], (*curve)[3]); + output.back().append(b); + } else { + // convert all other curve types to cubicbeziers + Geom::Path cubicbezier_path = Geom::cubicbezierpath_from_sbasis(cit->toSBasis(), 0.1); + output.back().append(cubicbezier_path); + } } } } |
