X-Git-Url: http://git.tdb.fi/?p=libs%2Fmath.git;a=blobdiff_plain;f=source%2Fgeometry%2Fshape.h;h=1f8176418a4e9a948b460701e6e682d56ae31771;hp=528a77ca6d97d42e748bb4a47a17f88508394bfa;hb=9260eee3126731c1e6b54ce3407be757d0d71716;hpb=6843cbaeaca73ecdbebe852b7e7899ce48f8a83c diff --git a/source/geometry/shape.h b/source/geometry/shape.h index 528a77c..1f81764 100644 --- a/source/geometry/shape.h +++ b/source/geometry/shape.h @@ -1,6 +1,9 @@ #ifndef MSP_GEOMETRY_SHAPE_H_ #define MSP_GEOMETRY_SHAPE_H_ +#include +#include + namespace Msp { namespace Geometry { @@ -10,6 +13,9 @@ class HyperBox; template class Ray; +template +class SurfacePoint; + template class Shape { @@ -21,9 +27,23 @@ public: virtual Shape *clone() const = 0; virtual HyperBox get_axis_aligned_bounding_box() const = 0; + virtual bool contains(const LinAl::Vector &) const = 0; virtual bool check_intersection(const Ray &) const = 0; + virtual unsigned get_max_ray_intersections() const = 0; + virtual unsigned get_intersections(const Ray &, SurfacePoint *, unsigned) const = 0; + std::vector > get_intersections(const Ray &) const; }; +template +std::vector > Shape::get_intersections(const Ray &ray) const +{ + unsigned max_isect = get_max_ray_intersections(); + std::vector > points(max_isect); + unsigned count = get_intersections(ray, &points[0], max_isect); + points.resize(count); + return points; +} + } // namespace Geometry } // namespace Msp