summaryrefslogtreecommitdiffstats
path: root/src/2geom/intersection.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/2geom/intersection.h')
-rw-r--r--src/2geom/intersection.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/2geom/intersection.h b/src/2geom/intersection.h
index 848797682..ae4b50dd1 100644
--- a/src/2geom/intersection.h
+++ b/src/2geom/intersection.h
@@ -92,7 +92,7 @@ private:
};
-// TODO: move into new header
+// TODO: move into new header?
template <typename T>
struct ShapeTraits {
typedef Coord TimeType;
@@ -101,6 +101,24 @@ struct ShapeTraits {
typedef Intersection<> IntersectionType;
};
+template <typename A, typename B> inline
+std::vector< Intersection<A, B> > transpose(std::vector< Intersection<B, A> > const &in) {
+ std::vector< Intersection<A, B> > result;
+ for (std::size_t i = 0; i < in.size(); ++i) {
+ result.push_back(Intersection<A, B>(in[i].second, in[i].first, in[i].point()));
+ }
+ return result;
+}
+
+template <typename T> inline
+void transpose_in_place(std::vector< Intersection<T, T> > &xs) {
+ for (std::size_t i = 0; i < xs.size(); ++i) {
+ std::swap(xs[i].first, xs[i].second);
+ }
+}
+
+typedef Intersection<> ShapeIntersection;
+
} // namespace Geom