]> 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 ce2f7873d6aed3eeff7304e67abe7598b5c274c7..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>
@@ -79,10 +80,25 @@ inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfaceP
 {
        unsigned count = shape->get_intersections(ray, points, size);
        for(unsigned i=0; i<count; ++i)
+       {
                points[i].normal = -points[i].normal;
+               points[i].entry = !points[i].entry;
+       }
        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