diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-24 19:53:33 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-24 19:53:33 +0000 |
| commit | 5a37f06c70e0e4e2519812564f4dcdced7c0246a (patch) | |
| tree | f959f73813cb6f968072aee1100323b24e294136 /src/helper/geom.cpp | |
| parent | update to trunk (diff) | |
| parent | Fix a bug continuing a bezier path whith a LPE one like spiro or bspline on a... (diff) | |
| download | inkscape-5a37f06c70e0e4e2519812564f4dcdced7c0246a.tar.gz inkscape-5a37f06c70e0e4e2519812564f4dcdced7c0246a.zip | |
update to trunk
(bzr r13879.1.17)
Diffstat (limited to 'src/helper/geom.cpp')
| -rw-r--r-- | src/helper/geom.cpp | 57 |
1 files changed, 9 insertions, 48 deletions
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 91689375f..ecb330b01 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -15,8 +15,7 @@ #include <typeinfo> #include <2geom/pathvector.h> #include <2geom/path.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include <2geom/transforms.h> #include <2geom/rect.h> #include <2geom/coord.h> @@ -266,14 +265,13 @@ geom_cubic_bbox_wind_distance (Geom::Coord x000, Geom::Coord y000, Geom::Coord tolerance) { Geom::Coord x0, y0, x1, y1, len2; - int needdist, needwind, needline; + int needdist, needwind; const Geom::Coord Px = pt[X]; const Geom::Coord Py = pt[Y]; needdist = 0; needwind = 0; - needline = 0; if (bbox) cubic_bbox (x000, y000, x001, y001, x011, y011, x111, y111, *bbox); @@ -303,8 +301,6 @@ geom_cubic_bbox_wind_distance (Geom::Coord x000, Geom::Coord y000, /* fixme: (Lauris) */ if (((y1 - y0) > 5.0) || ((x1 - x0) > 5.0)) { needdist = 1; - } else { - needline = 1; } } } @@ -315,8 +311,6 @@ geom_cubic_bbox_wind_distance (Geom::Coord x000, Geom::Coord y000, /* fixme: (Lauris) */ if (((y1 - y0) > 5.0) || ((x1 - x0) > 5.0)) { needwind = 1; - } else { - needline = 1; } } } @@ -345,7 +339,7 @@ geom_cubic_bbox_wind_distance (Geom::Coord x000, Geom::Coord y000, geom_cubic_bbox_wind_distance (x000, y000, x00t, y00t, x0tt, y0tt, xttt, yttt, pt, NULL, wind, best, tolerance); geom_cubic_bbox_wind_distance (xttt, yttt, x1tt, y1tt, x11t, y11t, x111, y111, pt, NULL, wind, best, tolerance); - } else if (1 || needline) { + } else { geom_line_wind_distance (x000, y000, x111, y111, pt, wind, best); } } @@ -473,8 +467,8 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { output.push_back( Geom::Path() ); + output.back().setStitching(true); output.back().start( pit->initialPoint() ); - output.back().close( pit->closed() ); for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { if (is_straight_curve(*cit)) { @@ -488,10 +482,13 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) } else { // convert all other curve types to cubicbeziers Geom::Path cubicbezier_path = Geom::cubicbezierpath_from_sbasis(cit->toSBasis(), 0.1); + cubicbezier_path.close(false); output.back().append(cubicbezier_path); } } } + + output.back().close( pit->closed() ); } return output; @@ -525,8 +522,7 @@ pathv_to_linear( Geom::PathVector const &pathv, double /*maxdisp*/) } else { /* all others must be Bezier curves */ Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&*cit); - Geom::CubicBezier b((*curve)[0], (*curve)[1], (*curve)[2], (*curve)[3]); - std::vector<Geom::Point> bzrpoints = b.points(); + std::vector<Geom::Point> bzrpoints = curve->controlPoints(); Geom::Point A = bzrpoints[0]; Geom::Point B = bzrpoints[1]; Geom::Point C = bzrpoints[2]; @@ -584,7 +580,7 @@ pathv_to_cubicbezier( Geom::PathVector const &pathv) pitCubic.appendNew<Geom::LineSegment>( pitCubic.initialPoint() ); pitCubic.close(true); } - for (Geom::Path::const_iterator cit = pitCubic.begin(); cit != pitCubic.end_open(); ++cit) { + for (Geom::Path::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); @@ -854,41 +850,6 @@ recursive_bezier4(const double x1, const double y1, recursive_bezier4(x1234, y1234, x234, y234, x34, y34, x4, y4, m_points, level + 1); } - -/** - * rounds all corners of the rectangle 'outwards', i.e. x0 and y0 are floored, x1 and y1 are ceiled. - */ -void round_rectangle_outwards(Geom::Rect & rect) { - Geom::Interval ints[2]; - for (int i=0; i < 2; i++) { - ints[i] = Geom::Interval(std::floor(rect[i][0]), std::ceil(rect[i][1])); - } - rect = Geom::Rect(ints[0], ints[1]); -} - - -namespace Geom { - -bool transform_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) { - return - Geom::are_near(m0[0], m1[0], epsilon) && - Geom::are_near(m0[1], m1[1], epsilon) && - Geom::are_near(m0[2], m1[2], epsilon) && - Geom::are_near(m0[3], m1[3], epsilon); -} - - -bool translate_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) { - return Geom::are_near(m0[4], m1[4], epsilon) && Geom::are_near(m0[5], m1[5], epsilon); -} - - -bool matrix_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) { - return transform_equalp(m0, m1, epsilon) && translate_equalp(m0, m1, epsilon); -} - -} //end namespace Geom - /* Local Variables: mode:c++ |
