X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fshape.h;h=7b1d190b5a762b82c7213a012e58190c7ba8d66c;hb=313e10c1dcf5504789cc145166aece93d8141212;hp=1f8176418a4e9a948b460701e6e682d56ae31771;hpb=9260eee3126731c1e6b54ce3407be757d0d71716;p=libs%2Fmath.git diff --git a/source/geometry/shape.h b/source/geometry/shape.h index 1f81764..7b1d190 100644 --- a/source/geometry/shape.h +++ b/source/geometry/shape.h @@ -16,6 +16,11 @@ class Ray; template class SurfacePoint; +/** +Base class and interface for geometric shapes. Shapes may be bounded or +unbounded. They are always considered to be solid, i.e. have a distinct inside +and an outside. +*/ template class Shape { @@ -28,14 +33,20 @@ public: 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; + bool check_intersection(const Ray &) const; 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 +inline bool Shape::check_intersection(const Ray &ray) const +{ + return get_intersections(ray, 0, 1); +} + +template +inline std::vector > Shape::get_intersections(const Ray &ray) const { unsigned max_isect = get_max_ray_intersections(); std::vector > points(max_isect);