From 5257499771b40a8e4e2baa3d15194da2ccb10f7f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 12 Mar 2015 21:51:30 +0100 Subject: Fix a bug in lattice2 with SegmentLines and add a Expander widget to contract all point parameters (bzr r13998) --- src/helper/geom.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/helper/geom.cpp') diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 6eba6e949..307412b57 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -556,6 +556,52 @@ pathv_to_linear( Geom::PathVector const &pathv, double /*maxdisp*/) return output; } +/* + * Converts all segments in all paths to Geom Cubic bezier. + */ +Geom::PathVector +pathv_to_cubicbezier( Geom::PathVector const &pathv) +{ + Geom::PathVector output; + double cubicGap = 0.01; + for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + output.push_back( Geom::Path() ); + output.back().start( pit->initialPoint() ); + output.back().close( pit->closed() ); + bool end_open = false; + if (pit->closed()) { + const Geom::Curve &closingline = pit->back_closed(); + if (!are_near(closingline.initialPoint(), closingline.finalPoint())) { + end_open = true; + } + } + Geom::Path pitCubic = (Geom::Path)(*pit); + if(end_open && pit->closed()){ + pitCubic.close(false); + pitCubic.appendNew( pitCubic.initialPoint() ); + pitCubic.close(true); + } + for (Geom::Path::const_iterator cit = pitCubic.begin(); cit != pitCubic.end_open(); ++cit) { + if (is_straight_curve(*cit)) { + Geom::CubicBezier b(cit->initialPoint(), cit->pointAt(0.3334) + Geom::Point(cubicGap,cubicGap), cit->finalPoint(), cit->finalPoint()); + output.back().append(b); + } else { + Geom::BezierCurve const *curve = dynamic_cast(&*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); + } + } + } + } + + return output; +} + // The next routine is modified from curv4_div::recursive_bezier from file agg_curves.cpp //---------------------------------------------------------------------------- // Anti-Grain Geometry (AGG) - Version 2.5 -- cgit v1.2.3 From 9dde2a95bdbe44c1acdfa4bb279ca554771bb0c8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 14 Mar 2015 11:22:32 +0100 Subject: Lattice 2 now handle in miror mode revase of axis, also fix a bug moving extem axis knots (bzr r14001) --- src/helper/geom.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/helper/geom.cpp') diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 307412b57..91689375f 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -558,6 +558,9 @@ pathv_to_linear( Geom::PathVector const &pathv, double /*maxdisp*/) /* * Converts all segments in all paths to Geom Cubic bezier. + * This is used in lattice2 LPE, maybe is better move the function to the effect + * But maybe could be usable by others, so i put here. + * The straight curve part is needed as it for the effect to work apropiately */ Geom::PathVector pathv_to_cubicbezier( Geom::PathVector const &pathv) -- cgit v1.2.3