IntersectionQueryEngine3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: IntersectionQueryEngine3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for 3-D intersection test query engine.
6 > Created Time: 2017/10/14
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_INTERSECTION_QUERY_ENGINE3_H
10 #define CUBBYFLOW_INTERSECTION_QUERY_ENGINE3_H
11 
13 #include <Core/Vector/Vector3.h>
14 
15 namespace CubbyFlow
16 {
18  template <typename T>
20  {
21  const T* item = nullptr;
22  double distance = std::numeric_limits<double>::max();
23  };
24 
26  template <typename T>
27  using ClosestIntersectionDistanceFunc3 = std::function<double(const T&, const Vector3D&)>;
28 
30  template <typename T>
31  using BoxIntersectionTestFunc3 = std::function<bool(const T&, const BoundingBox3D&)>;
32 
34  template <typename T>
35  using RayIntersectionTestFunc3 = std::function<bool(const T&, const Ray3D&)>;
36 
38  template <typename T>
39  using GetRayIntersectionFunc3 = std::function<double(const T&, const Ray3D&)>;
40 
42  template <typename T>
43  using IntersectionVisitorFunc3 = std::function<void(const T&)>;
44 
46  template <typename T>
48  {
49  public:
51  virtual bool IsIntersects(
52  const BoundingBox3D& box,
53  const BoxIntersectionTestFunc3<T>& testFunc) const = 0;
54 
56  virtual bool IsIntersects(
57  const Ray3D& ray,
58  const RayIntersectionTestFunc3<T>& testFunc) const = 0;
59 
61  virtual void ForEachIntersectingItem(
62  const BoundingBox3D& box, const BoxIntersectionTestFunc3<T>& testFunc,
63  const IntersectionVisitorFunc3<T>& visitorFunc) const = 0;
64 
66  virtual void ForEachIntersectingItem(
67  const Ray3D& ray, const RayIntersectionTestFunc3<T>& testFunc,
68  const IntersectionVisitorFunc3<T>& visitorFunc) const = 0;
69 
72  const Ray3D& ray, const GetRayIntersectionFunc3<T>& testFunc) const = 0;
73  };
74 }
75 
76 #endif
virtual ClosestIntersectionQueryResult3< T > GetClosestIntersection(const Ray3D &ray, const GetRayIntersectionFunc3< T > &testFunc) const =0
Returns the closest intersection for given ray.
virtual bool IsIntersects(const BoundingBox3D &box, const BoxIntersectionTestFunc3< T > &testFunc) const =0
Returns true if given box intersects with any of the stored items.
virtual void ForEachIntersectingItem(const BoundingBox3D &box, const BoxIntersectionTestFunc3< T > &testFunc, const IntersectionVisitorFunc3< T > &visitorFunc) const =0
Invokes visitorFunc for every intersecting items.
std::function< bool(const T &, const BoundingBox3D &)> BoxIntersectionTestFunc3
Box-item intersection test function.
Definition: IntersectionQueryEngine3.h:31
const T * item
Definition: IntersectionQueryEngine3.h:21
std::function< double(const T &, const Ray3D &)> GetRayIntersectionFunc3
Ray-item closest intersection evaluation function.
Definition: IntersectionQueryEngine3.h:39
double distance
Definition: IntersectionQueryEngine3.h:22
Definition: pybind11Utils.h:24
3-D axis-aligned bounding box class.
Definition: BoundingBox3.h:44
Closest intersection query result.
Definition: IntersectionQueryEngine3.h:19
std::function< double(const T &, const Vector3D &)> ClosestIntersectionDistanceFunc3
Closest intersection distance measure function.
Definition: IntersectionQueryEngine3.h:27
std::function< void(const T &)> IntersectionVisitorFunc3
Visitor function which is invoked for each intersecting item.
Definition: IntersectionQueryEngine3.h:43
std::function< bool(const T &, const Ray3D &)> RayIntersectionTestFunc3
Ray-item intersection test function.
Definition: IntersectionQueryEngine3.h:35
Class for 3-D ray.
Definition: Ray3.h:23
Abstract base class for 3-D intersection test query engine.
Definition: IntersectionQueryEngine3.h:47