]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/intersection.h
Rewrite composite shape vector constructors with iterator ranges
[libs/math.git] / source / geometry / intersection.h
index 53c25c22e6380a5b8ec2cb777ff96fdf9752d4f6..c20aae126d1b021552d430df5fc05a5c1a8ad205 100644 (file)
@@ -23,27 +23,35 @@ struct IntersectionOps
 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 Iter>
+inline Intersection<T, D> Intersection<T, D>::from_iterator_range(const Iter &begin, const Iter &end)
+{
+       Intersection<T, D> shape;
+       shape.init_from_iter_range(begin, end);
+       return shape;
+}
 
 template<typename T, unsigned D>
-Intersection<T, D> *Intersection<T, D>::clone() const
+inline Intersection<T, D> *Intersection<T, D>::clone() const
 {
-       return new Intersection<T, D>(this->shapes);
+       return new Intersection<T, D>(*this);
 }