From f02adf79d5fa69f8132c8bb27cdede593a9caba8 Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Thu, 28 Oct 2010 01:14:51 +0200 Subject: [PATCH] provide specific bounds method for Paths because paths can be closed or open. Path::size() is named somewhat wrong... (already committed to 2geom upstream) --- src/2geom/crossing.cpp | 12 ++++++++++++ src/2geom/crossing.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/2geom/crossing.cpp b/src/2geom/crossing.cpp index d717a4ed5..91180a939 100644 --- a/src/2geom/crossing.cpp +++ b/src/2geom/crossing.cpp @@ -113,6 +113,18 @@ CrossingGraph create_crossing_graph(std::vector const &p, Crossings const */ //} +// provide specific method for Paths because paths can be closed or open. Path::size() is named somewhat wrong... +std::vector bounds(Path const &a) { + std::vector rs; + for (unsigned i = 0; i < a.size_default(); i++) { + OptRect bb = a[i].boundsFast(); + if (bb) { + rs.push_back(*bb); + } + } + return rs; +} + void merge_crossings(Crossings &a, Crossings &b, unsigned i) { Crossings n; sort_crossings(b, i); diff --git a/src/2geom/crossing.h b/src/2geom/crossing.h index 427848033..593ce3662 100644 --- a/src/2geom/crossing.h +++ b/src/2geom/crossing.h @@ -40,6 +40,7 @@ #include <2geom/rect.h> #include <2geom/sweep.h> #include +#include <2geom/path.h> namespace Geom { @@ -137,6 +138,8 @@ std::vector bounds(C const &a) { } return rs; } +// provide specific method for Paths because paths can be closed or open. Path::size() is named somewhat wrong... +std::vector bounds(Path const &a); inline void sort_crossings(Crossings &cr, unsigned ix) { std::sort(cr.begin(), cr.end(), CrossingOrder(ix)); } -- 2.30.2