X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fcompositeshape.h;h=55467d762993add17cbc4fe74ae7bfda2f776c22;hb=5e5a34537e5f2efc71181f2bf6878c3e2e62b398;hp=4c640be22f4c5045076b9659ce7734d517f1127c;hpb=09cc3a8648dd20e9a07d669b353c4a120b67c1c4;p=libs%2Fmath.git diff --git a/source/geometry/compositeshape.h b/source/geometry/compositeshape.h index 4c640be..55467d7 100644 --- a/source/geometry/compositeshape.h +++ b/source/geometry/compositeshape.h @@ -3,7 +3,6 @@ #include #include -#include "boundingbox.h" #include "shape.h" namespace Msp { @@ -23,10 +22,10 @@ protected: CompositeShape() { } CompositeShape(const Shape &, const Shape &); - CompositeShape(const CompositeShape &); - CompositeShape &operator=(const CompositeShape &); template void init_from_iter_range(const Iter &, const Iter &); + CompositeShape(const CompositeShape &); + CompositeShape &operator=(const CompositeShape &); public: virtual ~CompositeShape(); @@ -56,11 +55,22 @@ inline void CompositeShape::init_from_iter_range(const Iter &begin, con } template -inline CompositeShape::CompositeShape(const CompositeShape &other) +inline CompositeShape::CompositeShape(const CompositeShape &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 +inline CompositeShape &CompositeShape::operator=(const CompositeShape &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