diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2012-02-19 11:14:03 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2012-02-19 11:14:03 +0000 |
| commit | f61fc22a2f4a646e4c96b8155e2dee1f2981037c (patch) | |
| tree | 1a7dc88ca57cd6f3980e82c4c978b43f9408a7d2 /src | |
| parent | fix crash on non-finite stroke widths (diff) | |
| download | inkscape-f61fc22a2f4a646e4c96b8155e2dee1f2981037c.tar.gz inkscape-f61fc22a2f4a646e4c96b8155e2dee1f2981037c.zip | |
move helper/recthull.h to 2geom/rect-hull.h
(bzr r10996)
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/2geom/Makefile_insert | 1 | ||||
| -rw-r--r-- | src/2geom/rect-hull.h | 69 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 2 | ||||
| -rw-r--r-- | src/helper/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/helper/Makefile_insert | 1 | ||||
| -rw-r--r-- | src/helper/recthull.h | 59 | ||||
| -rw-r--r-- | src/selection.cpp | 2 |
8 files changed, 73 insertions, 63 deletions
diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index b1c30f678..9a4cb9efd 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -103,6 +103,7 @@ set(2geom_SRC quadtree.h ray.h rect.h + rect-hull.h region.h sbasis-2d.h sbasis-curve.h diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index e3b6fcdab..1adc0a0c8 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -79,6 +79,7 @@ 2geom/ray.h \ 2geom/rect.cpp \ 2geom/rect.h \ + 2geom/rect-hull.h \ 2geom/region.cpp \ 2geom/region.h \ 2geom/sbasis-2d.cpp \ diff --git a/src/2geom/rect-hull.h b/src/2geom/rect-hull.h new file mode 100644 index 000000000..074fad29f --- /dev/null +++ b/src/2geom/rect-hull.h @@ -0,0 +1,69 @@ +/* + * Copyright 2004 MenTaLguY <mental@rydia.net> + * + * This code is licensed under the GNU GPL; see COPYING for more information. + */ + +#ifndef GEOM_RECT_HULL_H +#define GEOM_RECT_HULL_H + +#include <2geom/rect.h> + +namespace Geom { + +/** + * A class representing a rectangular convex hull of a set of points. + */ +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.unionWith(r); + } + void add(RectHull const &h) { + if (h._bounds) { + add(*h._bounds); + } + } + + OptRect const &bounds() const { + return _bounds; + } + +private: + OptRect _bounds; +}; + +} /* namespace Geom */ + +#endif // GEOM_RECT_HULL_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 53d14200a..cecde3fa0 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -22,7 +22,7 @@ #include <gtk/gtk.h> #include "helper/sp-marshal.h" -#include <helper/recthull.h> +#include <2geom/rect-hull.h> #include <2geom/affine.h> #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index b59cf03ba..dbb361c72 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -35,7 +35,6 @@ set(helper_SRC gnome-utils.h pixbuf-ops.h png-write.h - recthull.h stlport.h stock-items.h unit-menu.h diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 7110c2025..0efb5d6ce 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -15,7 +15,6 @@ ink_common_sources += \ helper/helper-forward.h \ helper/png-write.cpp \ helper/png-write.h \ - helper/recthull.h \ helper/sp-marshal.cpp \ helper/sp-marshal.h \ helper/unit-menu.cpp \ diff --git a/src/helper/recthull.h b/src/helper/recthull.h deleted file mode 100644 index d82450ce8..000000000 --- a/src/helper/recthull.h +++ /dev/null @@ -1,59 +0,0 @@ -#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.unionWith(r); - } - void add(RectHull const &h) { - if (h._bounds) { - add(*h._bounds); - } - } - - OptRect const &bounds() const { - return _bounds; - } - -private: - OptRect _bounds; -}; - -} /* namespace Geom */ - -#endif diff --git a/src/selection.cpp b/src/selection.cpp index 45d8c43f2..068c1c00e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -25,7 +25,7 @@ #include "desktop-handles.h" #include "document.h" #include "selection.h" -#include "helper/recthull.h" +#include <2geom/rect-hull.h> #include "xml/repr.h" #include "preferences.h" |
