public:
Negation(const Shape<T, D> &);
+ Negation(const Negation &);
+ Negation &operator=(const Negation &);
+ ~Negation();
virtual Negation *clone() const;
const Shape<T, D> &get_shape() const { return *shape; }
- virtual HyperBox<T, D> get_axis_aligned_bounding_box() const;
+ virtual BoundingBox<T, D> get_axis_aligned_bounding_box(unsigned = 0) const;
virtual bool contains(const LinAl::Vector<T, D> &) const;
- virtual bool check_intersection(const Ray<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>
{ }
template<typename T, unsigned D>
-inline Negation<T, D> *Negation<T, D>::clone() const
+inline Negation<T, D>::Negation(const Negation<T, D> &other):
+ shape(other.shape->clone())
+{ }
+
+template<typename T, unsigned D>
+inline Negation<T, D> &Negation<T, D>::operator=(const Negation<T, D> &other)
{
- return new Negation<T, D>(*shape);
+ delete shape;
+ shape = other.shape->clone();
+ return *this;
}
template<typename T, unsigned D>
-inline HyperBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box() const
+inline Negation<T, D>::~Negation()
{
- // XXX How do we handle this correctly? In particular negation of a negation?
- return HyperBox<T, D>();
+ delete shape;
}
template<typename T, unsigned D>
-inline bool Negation<T, D>::contains(const LinAl::Vector<T, D> &point) const
+inline Negation<T, D> *Negation<T, D>::clone() const
{
- return !shape->contains(point);
+ return new Negation<T, D>(*shape);
}
template<typename T, unsigned D>
-inline bool Negation<T, D>::check_intersection(const Ray<T, D> &ray) const
+inline BoundingBox<T, D> Negation<T, D>::get_axis_aligned_bounding_box(unsigned detail) const
{
- return get_intersections(ray, 0, 1);
+ return ~shape->get_axis_aligned_bounding_box(detail);
+}
+
+template<typename T, unsigned D>
+inline bool Negation<T, D>::contains(const LinAl::Vector<T, D> &point) const
+{
+ return !shape->contains(point);
}
template<typename T, unsigned D>
{
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 coverage;
+}
+
} // namespace Geometry
} // namespace Msp