]> git.tdb.fi Git - libs/math.git/blobdiff - source/geometry/negation.h
Add a function to test whether a shapes covers a bounding box
[libs/math.git] / source / geometry / negation.h
index 8e2b3f41a6d7c30681026176330d0ed1a04d965e..d90c4deb5a7de767b2f36cb0ed165d53f8a5c851 100644 (file)
@@ -30,6 +30,7 @@ public:
        virtual bool contains(const LinAl::Vector<T, D> &) const;
        virtual unsigned get_max_ray_intersections() const { return shape->get_max_ray_intersections(); }
        virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
+       virtual Coverage get_coverage(const BoundingBox<T, D> &) const;
 };
 
 template<typename T, unsigned D>
@@ -86,6 +87,18 @@ inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
        return count;
 }
 
+template<typename T, unsigned D>
+inline Coverage Negation<T, D>::get_coverage(const BoundingBox<T, D> &bbox) const
+{
+       Coverage coverage = shape->get_coverage(bbox);
+       if(coverage==FULL_COVERAGE)
+               return NO_COVERAGE;
+       else if(coverage==NO_COVERAGE)
+               return FULL_COVERAGE;
+       else
+               return PARTIAL_COVERAGE;
+}
+
 } // namespace Geometry
 } // namespace Msp