diff options
| author | Ted Gould <ted@gould.cx> | 2008-10-11 15:16:23 +0000 |
|---|---|---|
| committer | Ted Gould <ted@canonical.com> | 2008-10-11 15:16:23 +0000 |
| commit | 2f5eb047d9e05be5e68549ef6b75070d2faa7d2f (patch) | |
| tree | ca2e94164b6d7aaebfc17196ca46bfc825a7665a /src/helper | |
| parent | Merge from trunk. (diff) | |
| download | inkscape-2f5eb047d9e05be5e68549ef6b75070d2faa7d2f.tar.gz inkscape-2f5eb047d9e05be5e68549ef6b75070d2faa7d2f.zip | |
Merging from trunk
(bzr r6884)
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/geom.cpp | 24 | ||||
| -rw-r--r-- | src/helper/geom.h | 11 | ||||
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 2 | ||||
| -rw-r--r-- | src/helper/png-write.cpp | 2 | ||||
| -rw-r--r-- | src/helper/recthull.h | 59 |
5 files changed, 96 insertions, 2 deletions
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index caa169a27..84f967860 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -494,8 +494,32 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) return output; } +namespace Geom { + +bool transform_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) { + return + NR_DF_TEST_CLOSE(m0[0], m1[0], epsilon) && + NR_DF_TEST_CLOSE(m0[1], m1[1], epsilon) && + NR_DF_TEST_CLOSE(m0[2], m1[2], epsilon) && + NR_DF_TEST_CLOSE(m0[3], m1[3], epsilon); +} + + +bool translate_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) { + return NR_DF_TEST_CLOSE(m0[4], m1[4], epsilon) && NR_DF_TEST_CLOSE(m0[5], m1[5], epsilon); +} +bool matrix_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon) { + return transform_equalp(m0, m1, epsilon) && translate_equalp(m0, m1, epsilon); +} + +} //end namespace Geom +/* +The following predefined objects are for reference +and comparison. +*/ +Geom::Matrix GEOM_MATRIX_IDENTITY = Geom::identity(); /* Local Variables: diff --git a/src/helper/geom.h b/src/helper/geom.h index e4cb38fa7..4cda22a1c 100644 --- a/src/helper/geom.h +++ b/src/helper/geom.h @@ -25,6 +25,17 @@ void pathv_matrix_point_bbox_wind_distance ( Geom::PathVector const & pathv, Geo Geom::PathVector pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ); +/* +The following predefined objects are for reference +and comparison. They are defined in helper/geom.cpp +*/ +extern Geom::Matrix GEOM_MATRIX_IDENTITY; + +namespace Geom{ +bool transform_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon); +bool translate_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon); +bool matrix_equalp(Geom::Matrix const &m0, Geom::Matrix const &m1, Geom::Coord const epsilon); +} #endif // INKSCAPE_HELPER_GEOM_H /* diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index ee5f72161..9d795c575 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -123,7 +123,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); - gc.transform.set_identity(); + gc.transform.setIdentity(); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 10fa7d403..dd405b7d9 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -325,7 +325,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data) bbox.y1 = row + num_rows; /* Update to renderable state */ NRGC gc(NULL); - gc.transform.set_identity(); + gc.transform.setIdentity(); nr_arena_item_invoke_update(ebp->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); diff --git a/src/helper/recthull.h b/src/helper/recthull.h new file mode 100644 index 000000000..59649cfb6 --- /dev/null +++ b/src/helper/recthull.h @@ -0,0 +1,59 @@ +#ifndef SEEN_GEOM_RECT_HULL_H +#define SEEN_GEOM_RECT_HULL_H + +/* ex:set et ts=4 sw=4: */ + +/* + * A class representing the convex hull of a set of points. + * + * Copyright 2004 MenTaLguY <mental@rydia.net> + * + * This code is licensed under the GNU GPL; see COPYING for more information. + */ + +#include <2geom/rect.h> + +namespace Geom { + +class RectHull { +public: + RectHull() : _bounds() {} + explicit RectHull(Point const &p) : _bounds(Rect(p, p)) {} + + boost::optional<Point> midpoint() const { + if (_bounds) { + return _bounds->midpoint(); + } else { + return boost::optional<Point>(); + } + } + + void add(Point const &p) { + if (_bounds) { + _bounds->expandTo(p); + } else { + _bounds = Rect(p, p); + } + } + void add(Rect const &r) { + // Note that this is a hack. when convexhull actually works + // you will need to add all four points. + _bounds = unify(_bounds, r); + } + void add(RectHull const &h) { + if (h._bounds) { + add(*h._bounds); + } + } + + boost::optional<Rect> const &bounds() const { + return _bounds; + } + +private: + boost::optional<Rect> _bounds; +}; + +} /* namespace Geom */ + +#endif |
