X-Git-Url: http://git.tdb.fi/?p=libs%2Fmath.git;a=blobdiff_plain;f=source%2Fgeometry%2Fextrudedshape.h;h=e702f90a7a0f844d93f417b53d38a8c6aea2359a;hp=78dfa4911463e57951eaa0ca4524c223ab9ce9b5;hb=a29d2c17ca70a3ed5df1e863c92ccd851d5dba6b;hpb=7de28b9c89ca4554f5c12746f481f5b385529479 diff --git a/source/geometry/extrudedshape.h b/source/geometry/extrudedshape.h index 78dfa49..e702f90 100644 --- a/source/geometry/extrudedshape.h +++ b/source/geometry/extrudedshape.h @@ -35,6 +35,7 @@ public: virtual bool contains(const LinAl::Vector &) const; virtual unsigned get_max_ray_intersections() const; virtual unsigned get_intersections(const Ray &, SurfacePoint *, unsigned) const; + virtual Coverage get_coverage(const BoundingBox &) const; }; template @@ -187,6 +188,24 @@ inline unsigned ExtrudedShape::get_intersections(const Ray &ray, Sur return n; } +template +inline Coverage ExtrudedShape::get_coverage(const BoundingBox &bbox) const +{ + T half_length = length/T(2); + if(bbox.get_maximum_coordinate(D-1)<-half_length || bbox.get_minimum_coordinate(D-1)>half_length) + return NO_COVERAGE; + + BoundingBox base_bbox(bbox.get_minimum_point().template slice(0), bbox.get_maximum_point().template slice(0)); + Coverage coverage = base->get_coverage(base_bbox); + if(coverage==NO_COVERAGE) + return NO_COVERAGE; + + if(bbox.get_minimum_coordinate(D-1)<-half_length || bbox.get_maximum_coordinate(D-1)>half_length) + return PARTIAL_COVERAGE; + else + return coverage; +} + } // namespace Geometry } // namespace Msp