1 #ifndef MSP_GEOMETRY_INTERSECTION_H_
2 #define MSP_GEOMETRY_INTERSECTION_H_
4 #include "compositeshape.h"
9 template<typename T, unsigned D>
10 struct IntersectionOps
12 static BoundingBox<T, D> combine_aabb(const BoundingBox<T, D> &a, const BoundingBox<T, D> &b) { return a&b; }
13 static bool shortcircuit(bool c) { return !c; }
17 Forms a shape from the common parts of component shapes.
19 template<typename T, unsigned D>
20 class Intersection: public CompositeShape<T, D, IntersectionOps<T, D> >
25 Intersection(const Shape<T, D> &, const Shape<T, D> &);
27 template<typename Iter>
28 static Intersection from_iterator_range(const Iter &, const Iter &);
30 virtual Intersection *clone() const;
33 template<typename T, unsigned D>
34 inline Intersection<T, D>::Intersection(const Shape<T, D> &s1, const Shape<T, D> &s2):
35 CompositeShape<T, D, IntersectionOps<T, D> >(s1, s2)
38 template<typename T, unsigned D>
39 template<typename Iter>
40 inline Intersection<T, D> Intersection<T, D>::from_iterator_range(const Iter &begin, const Iter &end)
42 Intersection<T, D> shape;
43 shape.init_from_iter_range(begin, end);
47 template<typename T, unsigned D>
48 inline Intersection<T, D> *Intersection<T, D>::clone() const
50 return new Intersection<T, D>(*this);
53 } // namespace Geometry