X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fgeometry%2Funion.h;fp=source%2Fgeometry%2Funion.h;h=fadeff2ac9270dd71718aade2e733504e6a44e5b;hb=68389c29cf88d6522dcfa00b5e2a5166e3947210;hp=0000000000000000000000000000000000000000;hpb=1e34b120f1229b1390cee67c917829715615ccd0;p=libs%2Fmath.git diff --git a/source/geometry/union.h b/source/geometry/union.h new file mode 100644 index 0000000..fadeff2 --- /dev/null +++ b/source/geometry/union.h @@ -0,0 +1,62 @@ +#ifndef MSP_GEOMETRY_UNION_H_ +#define MSP_GEOMETRY_UNION_H_ + +#include "compositeshape.h" + +namespace Msp { +namespace Geometry { + +/** +Joins component shapes together into one. +*/ +template +struct UnionOps +{ + static HyperBox combine_aabb(const HyperBox &, const HyperBox &); + static bool init_inside() { return false; } + static bool combine_inside(bool a, bool b) { return a || b; } + static bool is_inside_decided(bool a) { return a; } + static bool init_surface() { return true; } + static bool combine_surface(bool a, bool b) { return a && !b; } +}; + +template +class Union: public CompositeShape > +{ +public: + Union(const Shape &, const Shape &); + Union(const std::vector *> &); + + virtual Union *clone() const; +}; + +template +inline Union::Union(const Shape &s1, const Shape &s2): + CompositeShape >(s1, s2) +{ } + +template +inline Union::Union(const std::vector *> &s): + CompositeShape >(s) +{ } + +template +inline Union *Union::clone() const +{ + return new Union(this->shapes); +} + + +template +inline HyperBox UnionOps::combine_aabb(const HyperBox &box1, const HyperBox &box2) +{ + LinAl::Vector dimensions; + for(unsigned i=0; i(dimensions); +} + +} // namespace Geometry +} // namespace Msp + +#endif