1 #ifndef MSP_GEOMETRY_NEGATION_H_
2 #define MSP_GEOMETRY_NEGATION_H_
10 Negates a shape. Not particulary useful on its own, but can be used together
11 with Intersection to cut holes.
13 template<typename T, unsigned D>
14 class Negation: public Shape<T, D>
20 Negation(const Shape<T, D> &);
22 virtual Negation *clone() const;
24 const Shape<T, D> &get_shape() const { return *shape; }
26 virtual BoundingBox<T, D> get_axis_aligned_bounding_box() const;
27 virtual bool contains(const LinAl::Vector<T, D> &) const;
28 virtual unsigned get_max_ray_intersections() const { return shape->get_max_ray_intersections(); }
29 virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
32 template<typename T, unsigned D>
33 inline Negation<T, D>::Negation(const Shape<T, D> &s):
37 template<typename T, unsigned D>
38 inline Negation<T, D> *Negation<T, D>::clone() const
40 return new Negation<T, D>(*shape);
43 template<typename T, unsigned D>
44 inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
46 return ~shape->get_axis_aligned_bounding_box();
49 template<typename T, unsigned D>
50 inline bool Negation<T, D>::contains(const LinAl::Vector<T, D> &point) const
52 return !shape->contains(point);
55 template<typename T, unsigned D>
56 inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
58 unsigned count = shape->get_intersections(ray, points, size);
59 for(unsigned i=0; i<count; ++i)
60 points[i].normal = -points[i].normal;
64 } // namespace Geometry