1 #ifndef MSP_GEOMETRY_NEGATION_H_
2 #define MSP_GEOMETRY_NEGATION_H_
4 #include "boundingbox.h"
11 Negates a shape. Not particulary useful on its own, but can be used together
12 with Intersection to cut holes.
14 template<typename T, unsigned D>
15 class Negation: public Shape<T, D>
21 Negation(const Shape<T, D> &);
23 virtual Negation *clone() const;
25 const Shape<T, D> &get_shape() const { return *shape; }
27 virtual BoundingBox<T, D> get_axis_aligned_bounding_box() const;
28 virtual bool contains(const LinAl::Vector<T, D> &) const;
29 virtual unsigned get_max_ray_intersections() const { return shape->get_max_ray_intersections(); }
30 virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
33 template<typename T, unsigned D>
34 inline Negation<T, D>::Negation(const Shape<T, D> &s):
38 template<typename T, unsigned D>
39 inline Negation<T, D> *Negation<T, D>::clone() const
41 return new Negation<T, D>(*shape);
44 template<typename T, unsigned D>
45 inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
47 return ~shape->get_axis_aligned_bounding_box();
50 template<typename T, unsigned D>
51 inline bool Negation<T, D>::contains(const LinAl::Vector<T, D> &point) const
53 return !shape->contains(point);
56 template<typename T, unsigned D>
57 inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
59 unsigned count = shape->get_intersections(ray, points, size);
60 for(unsigned i=0; i<count; ++i)
61 points[i].normal = -points[i].normal;
65 } // namespace Geometry