1 #ifndef MSP_GEOMETRY_SHAPE_H_
2 #define MSP_GEOMETRY_SHAPE_H_
5 #include <msp/linal/vector.h>
10 template<typename T, unsigned D>
13 template<typename T, unsigned D>
16 template<typename T, unsigned D>
20 Base class and interface for geometric shapes. Shapes may be bounded or
21 unbounded. They are always considered to be solid, i.e. have a distinct inside
24 template<typename T, unsigned D>
32 virtual Shape *clone() const = 0;
34 virtual HyperBox<T, D> get_axis_aligned_bounding_box() const = 0;
35 virtual bool contains(const LinAl::Vector<T, D> &) const = 0;
36 virtual bool check_intersection(const Ray<T, D> &) const = 0;
37 virtual unsigned get_max_ray_intersections() const = 0;
38 virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const = 0;
39 std::vector<SurfacePoint<T, D> > get_intersections(const Ray<T, D> &) const;
42 template<typename T, unsigned D>
43 std::vector<SurfacePoint<T, D> > Shape<T, D>::get_intersections(const Ray<T, D> &ray) const
45 unsigned max_isect = get_max_ray_intersections();
46 std::vector<SurfacePoint<T, D> > points(max_isect);
47 unsigned count = get_intersections(ray, &points[0], max_isect);
52 } // namespace Geometry