1 #ifndef MSP_GEOMETRY_UNION_H_
2 #define MSP_GEOMETRY_UNION_H_
4 #include "compositeshape.h"
10 Joins component shapes together into one.
12 template<typename T, unsigned D>
15 static HyperBox<T, D> combine_aabb(const HyperBox<T, D> &, const HyperBox<T, D> &);
16 static bool init_inside() { return false; }
17 static bool combine_inside(bool a, bool b) { return a || b; }
18 static bool is_inside_decided(bool a) { return a; }
19 static bool init_surface() { return true; }
20 static bool combine_surface(bool a, bool b) { return a && !b; }
23 template<typename T, unsigned D>
24 class Union: public CompositeShape<T, D, UnionOps<T, D> >
27 Union(const Shape<T, D> &, const Shape<T, D> &);
28 Union(const std::vector<Shape<T, D> *> &);
30 virtual Union *clone() const;
33 template<typename T, unsigned D>
34 inline Union<T, D>::Union(const Shape<T, D> &s1, const Shape<T, D> &s2):
35 CompositeShape<T, D, UnionOps<T, D> >(s1, s2)
38 template<typename T, unsigned D>
39 inline Union<T, D>::Union(const std::vector<Shape<T, D> *> &s):
40 CompositeShape<T, D, UnionOps<T, D> >(s)
43 template<typename T, unsigned D>
44 inline Union<T, D> *Union<T, D>::clone() const
46 return new Union<T, D>(this->shapes);
50 template<typename T, unsigned D>
51 inline HyperBox<T, D> UnionOps<T, D>::combine_aabb(const HyperBox<T, D> &box1, const HyperBox<T, D> &box2)
53 LinAl::Vector<T, D> dimensions;
54 for(unsigned i=0; i<D; ++i)
55 dimensions[i] = std::max(box1.get_dimension(i), box2.get_dimension(i));
56 return HyperBox<T, D>(dimensions);
59 } // namespace Geometry