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 init_inside() { return true; }
14 static bool combine_inside(bool a, bool b) { return a && b; }
15 static bool is_inside_decided(bool a) { return !a; }
16 static bool init_surface() { return true; }
17 static bool combine_surface(bool a, bool b) { return a && b; }
21 Forms a shape from the common parts of component shapes.
23 template<typename T, unsigned D>
24 class Intersection: public CompositeShape<T, D, IntersectionOps<T, D> >
29 Intersection(const Shape<T, D> &, const Shape<T, D> &);
31 template<typename Iter>
32 static Intersection from_iterator_range(const Iter &, const Iter &);
34 virtual Intersection *clone() const;
37 template<typename T, unsigned D>
38 inline Intersection<T, D>::Intersection(const Shape<T, D> &s1, const Shape<T, D> &s2):
39 CompositeShape<T, D, IntersectionOps<T, D> >(s1, s2)
42 template<typename T, unsigned D>
43 template<typename Iter>
44 inline Intersection<T, D> Intersection<T, D>::from_iterator_range(const Iter &begin, const Iter &end)
46 Intersection<T, D> shape;
47 shape.init_from_iter_range(begin, end);
51 template<typename T, unsigned D>
52 inline Intersection<T, D> *Intersection<T, D>::clone() const
54 return new Intersection<T, D>(*this);
57 } // namespace Geometry