summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2012-02-19 19:56:03 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2012-02-19 19:56:03 +0000
commit5014662ec90a3ec0eb1c5fc261063415eb3f09e0 (patch)
tree237e911051fa8be167957d3bbfaf0a9a70006d8d /src
parentbad bug in 2geom (diff)
downloadinkscape-5014662ec90a3ec0eb1c5fc261063415eb3f09e0.tar.gz
inkscape-5014662ec90a3ec0eb1c5fc261063415eb3f09e0.zip
remove superfluous RectHull
(bzr r11001)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/CMakeLists.txt1
-rw-r--r--src/2geom/Makefile_insert1
-rw-r--r--src/2geom/rect-hull.h69
-rw-r--r--src/display/sp-canvas.cpp17
-rw-r--r--src/selection.cpp16
5 files changed, 11 insertions, 93 deletions
diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt
index 9a4cb9efd..b1c30f678 100644
--- a/src/2geom/CMakeLists.txt
+++ b/src/2geom/CMakeLists.txt
@@ -103,7 +103,6 @@ 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 1adc0a0c8..e3b6fcdab 100644
--- a/src/2geom/Makefile_insert
+++ b/src/2geom/Makefile_insert
@@ -79,7 +79,6 @@
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
deleted file mode 100644
index 074fad29f..000000000
--- a/src/2geom/rect-hull.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 cecde3fa0..580b214f0 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 <2geom/rect-hull.h>
+#include <2geom/rect.h>
#include <2geom/affine.h>
#include "display/sp-canvas.h"
#include "display/sp-canvas-group.h"
@@ -972,26 +972,19 @@ void SPCanvasGroup::destroy(GtkObject *object)
void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
- Geom::RectHull corners(Geom::Point(0, 0));
- bool empty=true;
+ Geom::OptRect bounds;
for (GList *list = group->items; list; list = list->next) {
SPCanvasItem *i = (SPCanvasItem *)list->data;
sp_canvas_item_invoke_update (i, affine, flags);
- if ( i->x2 > i->x1 && i->y2 > i->y1 ) {
- if (empty) {
- corners = Geom::RectHull(Geom::Point(i->x1, i->y1));
- empty = false;
- } else {
- corners.add(Geom::Point(i->x1, i->y1));
- }
- corners.add(Geom::Point(i->x2, i->y2));
+ if ( (i->x2 > i->x1) && (i->y2 > i->y1) ) {
+ bounds.expandTo(Geom::Point(i->x1, i->y1));
+ bounds.expandTo(Geom::Point(i->x2, i->y2));
}
}
- Geom::OptRect const bounds = corners.bounds();
if (bounds) {
item->x1 = bounds->min()[Geom::X];
item->y1 = bounds->min()[Geom::Y];
diff --git a/src/selection.cpp b/src/selection.cpp
index 068c1c00e..d769b402c 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -25,7 +25,7 @@
#include "desktop-handles.h"
#include "document.h"
#include "selection.h"
-#include <2geom/rect-hull.h>
+#include <2geom/rect.h>
#include "xml/repr.h"
#include "preferences.h"
@@ -476,18 +476,14 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(Sna
std::vector<Inkscape::SnapCandidatePoint> pHull;
if (!p.empty()) {
- std::vector<Inkscape::SnapCandidatePoint>::iterator i;
- Geom::RectHull cvh((p.front()).getPoint());
- for (i = p.begin(); i != p.end(); ++i) {
+ Geom::Rect cvh((p.front()).getPoint(), (p.front()).getPoint());
+ for (std::vector<Inkscape::SnapCandidatePoint>::iterator i = p.begin(); i != p.end(); ++i) {
// these are the points we get back
- cvh.add((*i).getPoint());
+ cvh.expandTo((*i).getPoint());
}
- Geom::OptRect rHull = cvh.bounds();
- if (rHull) {
- for ( unsigned i = 0 ; i < 4 ; ++i ) {
- pHull.push_back(Inkscape::SnapCandidatePoint(rHull->corner(i), SNAPSOURCE_CONVEX_HULL_CORNER));
- }
+ for ( unsigned i = 0 ; i < 4 ; ++i ) {
+ pHull.push_back(Inkscape::SnapCandidatePoint(cvh.corner(i), SNAPSOURCE_CONVEX_HULL_CORNER));
}
}