template<typename T, unsigned D>
struct IntersectionOps
{
- static HyperBox<T, D> combine_aabb(const HyperBox<T, D> &, const HyperBox<T, D> &);
+ static BoundingBox<T, D> combine_aabb(const BoundingBox<T, D> &a, const BoundingBox<T, D> &b) { return a&b; }
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; }
template<typename T, unsigned D>
class Intersection: public CompositeShape<T, D, IntersectionOps<T, D> >
{
+private:
+ Intersection() { }
public:
Intersection(const Shape<T, D> &, const Shape<T, D> &);
- Intersection(const std::vector<Shape<T, D> *> &);
+
+ template<typename Iter>
+ static Intersection from_iterator_range(const Iter &, const Iter &);
virtual Intersection *clone() const;
};
template<typename T, unsigned D>
-Intersection<T, D>::Intersection(const Shape<T, D> &s1, const Shape<T, D> &s2):
+inline Intersection<T, D>::Intersection(const Shape<T, D> &s1, const Shape<T, D> &s2):
CompositeShape<T, D, IntersectionOps<T, D> >(s1, s2)
{ }
template<typename T, unsigned D>
-Intersection<T, D>::Intersection(const std::vector<Shape<T, D> *> &s):
- CompositeShape<T, D, IntersectionOps<T, D> >(s)
-{ }
-
-template<typename T, unsigned D>
-Intersection<T, D> *Intersection<T, D>::clone() const
+template<typename Iter>
+inline Intersection<T, D> Intersection<T, D>::from_iterator_range(const Iter &begin, const Iter &end)
{
- return new Intersection<T, D>(this->shapes);
+ Intersection<T, D> shape;
+ shape.init_from_iter_range(begin, end);
+ return shape;
}
-
template<typename T, unsigned D>
-inline HyperBox<T, D> IntersectionOps<T, D>::combine_aabb(const HyperBox<T, D> &box1, const HyperBox<T, D> &box2)
+inline Intersection<T, D> *Intersection<T, D>::clone() const
{
- LinAl::Vector<T, D> dimensions;
- for(unsigned i=0; i<D; ++i)
- dimensions[i] = std::min(box1.get_dimension(i), box2.get_dimension(i));
- return HyperBox<T, D>(dimensions);
+ return new Intersection<T, D>(*this);
}
} // namespace Geometry