CompositeShape() { }
CompositeShape(const Shape<T, D> &, const Shape<T, D> &);
- CompositeShape(const CompositeShape &);
- CompositeShape &operator=(const CompositeShape &);
template<typename Iter>
void init_from_iter_range(const Iter &, const Iter &);
+ CompositeShape(const CompositeShape &);
+ CompositeShape &operator=(const CompositeShape &);
public:
virtual ~CompositeShape();
- virtual HyperBox<T, D> get_axis_aligned_bounding_box() const;
+ virtual BoundingBox<T, D> get_axis_aligned_bounding_box() const;
virtual bool contains(const LinAl::Vector<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 CompositeShape<T, D, O> &other)
+inline CompositeShape<T, D, O>::CompositeShape(const CompositeShape<T, D, O> &other):
+ shapes(other.shapes)
{
- shapes.reserve(other.shapes.size());
- for(typename ShapeArray::const_iterator i=other.shapes.begin(); i!=other.shapes.end(); ++i)
- shapes.push_back((*i)->clone());
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ *i = (*i)->clone();
+}
+
+template<typename T, unsigned D, typename O>
+inline CompositeShape<T, D, O> &CompositeShape<T, D, O>::operator=(const CompositeShape<T, D, O> &other)
+{
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ delete *i;
+
+ shapes = other.shapes;
+ for(typename ShapeArray::iterator i=shapes.begin(); i!=shapes.end(); ++i)
+ *i = (*i)->clone();
}
template<typename T, unsigned D, typename O>
}
template<typename T, unsigned D, typename O>
-inline HyperBox<T, D> CompositeShape<T, D, O>::get_axis_aligned_bounding_box() const
+inline BoundingBox<T, D> CompositeShape<T, D, O>::get_axis_aligned_bounding_box() const
{
- HyperBox<T, D> aabb;
+ BoundingBox<T, D> aabb;
for(typename ShapeArray::const_iterator i=shapes.begin(); i!=shapes.end(); ++i)
{
if(i==shapes.begin())