virtual HyperBox<T, D> get_axis_aligned_bounding_box() 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;
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
};
return inside;
}
-template<typename T, unsigned D, typename O>
-inline bool CompositeShape<T, D, O>::check_intersection(const Ray<T, D> &ray) const
-{
- return get_intersections(ray, 0, 1);
-}
-
template<typename T, unsigned D, typename O>
inline unsigned CompositeShape<T, D, O>::get_max_ray_intersections() const
{
virtual HyperBox<T, D> get_axis_aligned_bounding_box() 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;
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
};
return base->contains(LinAl::Vector<T, D-1>(point));
}
-template<typename T, unsigned D>
-inline bool ExtrudedShape<T, D>::check_intersection(const Ray<T, D> &ray) const
-{
- return get_intersections(ray, 0, 1);
-}
-
template<typename T, unsigned D>
inline unsigned ExtrudedShape<T, D>::get_max_ray_intersections() const
{
virtual HyperBox<T, D> get_axis_aligned_bounding_box() const { return *this; }
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 2; }
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
};
return true;
}
-template<typename T, unsigned D>
-inline bool HyperBox<T, D>::check_intersection(const Ray<T, D> &ray) const
-{
- return get_intersections(ray, 0, 1);
-}
-
template<typename T, unsigned D>
inline unsigned HyperBox<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
{
virtual HyperBox<T, D> get_axis_aligned_bounding_box() 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 2; }
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const;
};
return inner_product(point, point)<=radius*radius;
}
-template<typename T, unsigned D>
-inline bool HyperSphere<T, D>::check_intersection(const Ray<T, D> &ray) const
-{
- T x = inner_product(ray.get_direction(), ray.get_start());
- if(x>0)
- return contains(ray.get_start());
- else
- return contains(ray.get_start()-ray.get_direction()*x);
-}
-
template<typename T, unsigned D>
inline unsigned HyperSphere<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
{
virtual HyperBox<T, D> get_axis_aligned_bounding_box() 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;
};
return !shape->contains(point);
}
-template<typename T, unsigned D>
-inline bool Negation<T, D>::check_intersection(const Ray<T, D> &ray) const
-{
- return get_intersections(ray, 0, 1);
-}
-
template<typename T, unsigned D>
inline unsigned Negation<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
{
virtual HyperBox<T, D> get_axis_aligned_bounding_box() const = 0;
virtual bool contains(const LinAl::Vector<T, D> &) const = 0;
- virtual bool check_intersection(const Ray<T, D> &) const = 0;
+ bool check_intersection(const Ray<T, D> &) const;
virtual unsigned get_max_ray_intersections() const = 0;
virtual unsigned get_intersections(const Ray<T, D> &, SurfacePoint<T, D> *, unsigned) const = 0;
std::vector<SurfacePoint<T, D> > get_intersections(const Ray<T, D> &) const;
};
template<typename T, unsigned D>
-std::vector<SurfacePoint<T, D> > Shape<T, D>::get_intersections(const Ray<T, D> &ray) const
+inline bool Shape<T, D>::check_intersection(const Ray<T, D> &ray) const
+{
+ return get_intersections(ray, 0, 1);
+}
+
+template<typename T, unsigned D>
+inline std::vector<SurfacePoint<T, D> > Shape<T, D>::get_intersections(const Ray<T, D> &ray) const
{
unsigned max_isect = get_max_ray_intersections();
std::vector<SurfacePoint<T, D> > points(max_isect);
private:
Ray<T, D> make_local_ray(const Ray<T, D> &) const;
public:
- 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;
};
return Ray<T, D>(inverse_trans.transform(ray.get_start()), local_dir, ray.get_limit()*distortion);
}
-template<typename T, unsigned D>
-inline bool TransformedShape<T, D>::check_intersection(const Ray<T, D> &ray) const
-{
- return shape->check_intersection(make_local_ray(ray));
-}
-
template<typename T, unsigned D>
inline unsigned TransformedShape<T, D>::get_intersections(const Ray<T, D> &ray, SurfacePoint<T, D> *points, unsigned size) const
{