X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fintersection.h;h=0e555b03f7086185076ca904512605b0ae204e08;hb=4fc002747e8138501d08942be247e60cd99ac404;hp=53c25c22e6380a5b8ec2cb777ff96fdf9752d4f6;hpb=68389c29cf88d6522dcfa00b5e2a5166e3947210;p=libs%2Fmath.git diff --git a/source/geometry/intersection.h b/source/geometry/intersection.h index 53c25c2..0e555b0 100644 --- a/source/geometry/intersection.h +++ b/source/geometry/intersection.h @@ -6,54 +6,48 @@ namespace Msp { namespace Geometry { -/** -Forms a shape from the common parts of component shapes. -*/ template struct IntersectionOps { - static HyperBox combine_aabb(const HyperBox &, const HyperBox &); - static bool init_inside() { return true; } - 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; } + static BoundingBox combine_aabb(const BoundingBox &a, const BoundingBox &b) { return a&b; } + static bool shortcircuit(bool c) { return !c; } }; +/** +Forms a shape from the common parts of component shapes. +*/ template class Intersection: public CompositeShape > { +private: + Intersection() { } public: Intersection(const Shape &, const Shape &); - Intersection(const std::vector *> &); + + template + static Intersection from_iterator_range(const Iter &, const Iter &); virtual Intersection *clone() const; }; template -Intersection::Intersection(const Shape &s1, const Shape &s2): +inline Intersection::Intersection(const Shape &s1, const Shape &s2): CompositeShape >(s1, s2) { } template -Intersection::Intersection(const std::vector *> &s): - CompositeShape >(s) -{ } - -template -Intersection *Intersection::clone() const +template +inline Intersection Intersection::from_iterator_range(const Iter &begin, const Iter &end) { - return new Intersection(this->shapes); + Intersection shape; + shape.init_from_iter_range(begin, end); + return shape; } - template -inline HyperBox IntersectionOps::combine_aabb(const HyperBox &box1, const HyperBox &box2) +inline Intersection *Intersection::clone() const { - LinAl::Vector dimensions; - for(unsigned i=0; i(dimensions); + return new Intersection(*this); } } // namespace Geometry