#ifndef MSP_GEOMETRY_COMPOSITESHAPE_H_
#define MSP_GEOMETRY_COMPOSITESHAPE_H_
+#include <stdexcept>
#include <vector>
#include "shape.h"
ShapeArray shapes;
+ CompositeShape() { }
CompositeShape(const Shape<T, D> &, const Shape<T, D> &);
- CompositeShape(const ShapeArray &);
CompositeShape(const CompositeShape &);
CompositeShape &operator=(const CompositeShape &);
+ template<typename Iter>
+ void init_from_iter_range(const Iter &, const Iter &);
public:
virtual ~CompositeShape();
virtual HyperBox<T, D> get_axis_aligned_bounding_box() const;
virtual bool contains(const LinAl::Vector<T, D> &) const;
- virtual bool check_intersection(const Ray<T, D> &) const;
virtual unsigned get_max_ray_intersections() const;
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
};
}
template<typename T, unsigned D, typename O>
-inline CompositeShape<T, D, O>::CompositeShape(const ShapeArray &s)
+template<typename Iter>
+inline void CompositeShape<T, D, O>::init_from_iter_range(const Iter &begin, const Iter &end)
{
- if(s.empty())
- throw std::invalid_argument("CompositeShape::CompositeShape");
+ if(begin==end)
+ throw std::invalid_argument("CompositeShape::init_from_iter_range");
- shapes.reserve(s.size());
- for(typename ShapeArray::const_iterator i=s.begin(); i!=s.end(); ++i)
+ for(Iter i=begin; i!=end; ++i)
+ shapes.push_back((*i)->clone());
+}
+
+template<typename T, unsigned D, typename O>
+inline CompositeShape<T, D, O>::CompositeShape(const CompositeShape<T, D, O> &other)
+{
+ shapes.reserve(other.shapes.size());
+ for(typename ShapeArray::const_iterator i=other.shapes.begin(); i!=other.shapes.end(); ++i)
shapes.push_back((*i)->clone());
}
return inside;
}
-template<typename T, unsigned D, typename O>
-inline bool CompositeShape<T, D, O>::check_intersection(const Ray<T, D> &ray) const
-{
- return get_intersections(ray, 0, 1);
-}
-
template<typename T, unsigned D, typename O>
inline unsigned CompositeShape<T, D, O>::get_max_ray_intersections() const
{