X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fnegation.h;h=91802f8bce9906cfdadcae3bc7382c6e193cb423;hb=44bd1d1ab256d397be4e2169c4ca5efdd0569d31;hp=0fc01964b869efd4d841f2bee439da3feffb24d8;hpb=68389c29cf88d6522dcfa00b5e2a5166e3947210;p=libs%2Fmath.git diff --git a/source/geometry/negation.h b/source/geometry/negation.h index 0fc0196..91802f8 100644 --- a/source/geometry/negation.h +++ b/source/geometry/negation.h @@ -18,16 +18,19 @@ private: public: Negation(const Shape &); + Negation(const Negation &); + Negation &operator=(const Negation &); + ~Negation(); virtual Negation *clone() const; const Shape &get_shape() const { return *shape; } - virtual HyperBox get_axis_aligned_bounding_box() const; + virtual BoundingBox get_axis_aligned_bounding_box(unsigned = 0) const; virtual bool contains(const LinAl::Vector &) const; - virtual bool check_intersection(const Ray &) const; virtual unsigned get_max_ray_intersections() const { return shape->get_max_ray_intersections(); } virtual unsigned get_intersections(const Ray &, SurfacePoint *, unsigned) const; + virtual Coverage get_coverage(const BoundingBox &) const; }; template @@ -36,28 +39,40 @@ inline Negation::Negation(const Shape &s): { } template -inline Negation *Negation::clone() const +inline Negation::Negation(const Negation &other): + shape(other.shape->clone()) +{ } + +template +inline Negation &Negation::operator=(const Negation &other) { - return new Negation(*shape); + delete shape; + shape = other.shape->clone(); + return *this; } template -inline HyperBox Negation::get_axis_aligned_bounding_box() const +inline Negation::~Negation() { - // XXX How do we handle this correctly? In particular negation of a negation? - return HyperBox(); + delete shape; } template -inline bool Negation::contains(const LinAl::Vector &point) const +inline Negation *Negation::clone() const { - return !shape->contains(point); + return new Negation(*shape); } template -inline bool Negation::check_intersection(const Ray &ray) const +inline BoundingBox Negation::get_axis_aligned_bounding_box(unsigned detail) const { - return get_intersections(ray, 0, 1); + return ~shape->get_axis_aligned_bounding_box(detail); +} + +template +inline bool Negation::contains(const LinAl::Vector &point) const +{ + return !shape->contains(point); } template @@ -65,10 +80,25 @@ inline unsigned Negation::get_intersections(const Ray &ray, SurfaceP { unsigned count = shape->get_intersections(ray, points, size); for(unsigned i=0; i +inline Coverage Negation::get_coverage(const BoundingBox &bbox) const +{ + Coverage coverage = shape->get_coverage(bbox); + if(coverage==FULL_COVERAGE) + return NO_COVERAGE; + else if(coverage==NO_COVERAGE) + return FULL_COVERAGE; + else + return PARTIAL_COVERAGE; +} + } // namespace Geometry } // namespace Msp