IntersectionQueryEngine.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_INTERSECTION_QUERY_ENGINE_HPP
12 #define CUBBYFLOW_INTERSECTION_QUERY_ENGINE_HPP
13 
15 #include <Core/Geometry/Ray.hpp>
16 #include <Core/Matrix/Matrix.hpp>
17 
18 #include <functional>
19 #include <limits>
20 
21 namespace CubbyFlow
22 {
24 template <typename T, size_t N>
26 {
27  const T* item = nullptr;
28  double distance = std::numeric_limits<double>::max();
29 };
30 
32 template <typename T>
34 
36 template <typename T>
38 
40 template <typename T, size_t N>
42  std::function<double(const T&, const Vector<double, N>&)>;
43 
45 template <typename T>
47 
49 template <typename T>
51 
53 template <typename T, size_t N>
55  std::function<bool(const T&, const BoundingBox<double, N>&)>;
56 
58 template <typename T>
60 
62 template <typename T>
64 
66 template <typename T, size_t N>
68  std::function<bool(const T&, const Ray<double, N>&)>;
69 
71 template <typename T>
73 
75 template <typename T>
77 
79 template <typename T, size_t N>
81  std::function<double(const T&, const Ray<double, N>&)>;
82 
84 template <typename T>
86 
88 template <typename T>
90 
92 template <typename T>
93 using IntersectionVisitorFunc = std::function<void(const T&)>;
94 
96 template <typename T, size_t N>
98 {
99  public:
101  IntersectionQueryEngine() = default;
102 
104  virtual ~IntersectionQueryEngine() = default;
105 
107  IntersectionQueryEngine(const IntersectionQueryEngine& other) = default;
108 
110  IntersectionQueryEngine(IntersectionQueryEngine&& other) noexcept = default;
111 
113  IntersectionQueryEngine& operator=(const IntersectionQueryEngine& other) =
114  default;
115 
117  IntersectionQueryEngine& operator=(
118  IntersectionQueryEngine&& other) noexcept = default;
119 
121  [[nodiscard]] virtual bool Intersects(
122  const BoundingBox<double, N>& box,
123  const BoxIntersectionTestFunc<T, N>& testFunc) const = 0;
124 
126  [[nodiscard]] virtual bool Intersects(
127  const Ray<double, N>& ray,
128  const RayIntersectionTestFunc<T, N>& testFunc) const = 0;
129 
131  virtual void ForEachIntersectingItem(
132  const BoundingBox<double, N>& box,
133  const BoxIntersectionTestFunc<T, N>& testFunc,
134  const IntersectionVisitorFunc<T>& visitorFunc) const = 0;
135 
137  virtual void ForEachIntersectingItem(
138  const Ray<double, N>& ray,
139  const RayIntersectionTestFunc<T, N>& testFunc,
140  const IntersectionVisitorFunc<T>& visitorFunc) const = 0;
141 
143  [[nodiscard]] virtual ClosestIntersectionQueryResult<T, N>
144  ClosestIntersection(const Ray<double, N>& ray,
145  const GetRayIntersectionFunc<T, N>& testFunc) const = 0;
146 };
147 
149 template <typename T>
151 
153 template <typename T>
155 
156 } // namespace CubbyFlow
157 
158 #endif
Class for N-D ray.
Definition: Ray.hpp:25
std::function< double(const T &, const Vector< double, N > &)> ClosestIntersectionDistanceFunc
N-D closest intersection distance measure function.
Definition: IntersectionQueryEngine.hpp:42
ClosestIntersectionDistanceFunc< T, 3 > ClosestIntersectionDistanceFunc3
3-D closestIntersectionDistanceFunc.
Definition: IntersectionQueryEngine.hpp:50
ClosestIntersectionDistanceFunc< T, 2 > ClosestIntersectionDistanceFunc2
2-D closestIntersectionDistanceFunc.
Definition: IntersectionQueryEngine.hpp:46
N-D closest intersection query result.
Definition: IntersectionQueryEngine.hpp:25
Definition: pybind11Utils.hpp:20
GetRayIntersectionFunc< T, 2 > GetRayIntersectionFunc2
2-D ray-item closest intersection evaluation function.
Definition: IntersectionQueryEngine.hpp:85
RayIntersectionTestFunc< T, 3 > RayIntersectionTestFunc3
3-D ray-item intersection test function.
Definition: IntersectionQueryEngine.hpp:76
std::function< bool(const T &, const BoundingBox< double, N > &)> BoxIntersectionTestFunc
N-D box-item intersection test function.
Definition: IntersectionQueryEngine.hpp:55
double distance
Definition: IntersectionQueryEngine.hpp:28
GetRayIntersectionFunc< T, 3 > GetRayIntersectionFunc3
3-D ray-item closest intersection evaluation function.
Definition: IntersectionQueryEngine.hpp:89
Abstract base class for N-D intersection test query engine.
Definition: IntersectionQueryEngine.hpp:97
BoxIntersectionTestFunc< T, 2 > BoxIntersectionTestFunc2
2-D box-item intersection test function.
Definition: IntersectionQueryEngine.hpp:59
BoxIntersectionTestFunc< T, 3 > BoxIntersectionTestFunc3
3-D box-item intersection test function.
Definition: IntersectionQueryEngine.hpp:63
RayIntersectionTestFunc< T, 2 > RayIntersectionTestFunc2
2-D ray-item intersection test function.
Definition: IntersectionQueryEngine.hpp:72
const T * item
Definition: IntersectionQueryEngine.hpp:27
std::function< bool(const T &, const Ray< double, N > &)> RayIntersectionTestFunc
N-D ray-item intersection test function.
Definition: IntersectionQueryEngine.hpp:68
std::function< double(const T &, const Ray< double, N > &)> GetRayIntersectionFunc
N-D ray-item closest intersection evaluation function.
Definition: IntersectionQueryEngine.hpp:81
std::function< void(const T &)> IntersectionVisitorFunc
Visitor function which is invoked for each intersecting item.
Definition: IntersectionQueryEngine.hpp:93