Code

provide specific bounds method for Paths because paths can be closed or open. Path...
authorJohan Engelen <goejendaagh@zonnet.nl>
Wed, 27 Oct 2010 23:14:51 +0000 (01:14 +0200)
committerJohan Engelen <goejendaagh@zonnet.nl>
Wed, 27 Oct 2010 23:14:51 +0000 (01:14 +0200)
src/2geom/crossing.cpp
src/2geom/crossing.h

index d717a4ed560c6dbe4b3b17e37caf3ea3288efa84..91180a939f8b076b8e52b6a925d8080b86994f1b 100644 (file)
@@ -113,6 +113,18 @@ CrossingGraph create_crossing_graph(std::vector<Path> const &p, Crossings const
 */
 //}
 
+// provide specific method for Paths because paths can be closed or open. Path::size() is named somewhat wrong...
+std::vector<Rect> bounds(Path const &a) {
+    std::vector<Rect> 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);
index 427848033dc22150733afaad60d43bd5e8785f26..593ce366257f5c4edec007601d1cfd9baf43a7b9 100644 (file)
@@ -40,6 +40,7 @@
 #include <2geom/rect.h>
 #include <2geom/sweep.h>
 #include <boost/optional/optional.hpp>
+#include <2geom/path.h>
 
 namespace Geom {
 
@@ -137,6 +138,8 @@ std::vector<Rect> 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<Rect> bounds(Path const &a);
 
 inline void sort_crossings(Crossings &cr, unsigned ix) { std::sort(cr.begin(), cr.end(), CrossingOrder(ix)); }