ListQueryEngine.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_LIST_QUERY_ENGINE_HPP
12 #define CUBBYFLOW_LIST_QUERY_ENGINE_HPP
13 
14 #include <Core/Array/Array.hpp>
15 #include <Core/Array/ArrayView.hpp>
18 
19 namespace CubbyFlow
20 {
22 template <typename T, size_t N>
23 class ListQueryEngine final : public IntersectionQueryEngine<T, N>,
24  public NearestNeighborQueryEngine<T, N>
25 {
26  public:
28  void Add(const T& item);
29 
31  void Add(const ConstArrayView1<T>& items);
32 
34  [[nodiscard]] bool Intersects(
35  const BoundingBox<double, N>& box,
36  const BoxIntersectionTestFunc<T, N>& testFunc) const override;
37 
39  [[nodiscard]] bool Intersects(
40  const Ray<double, N>& ray,
41  const RayIntersectionTestFunc<T, N>& testFunc) const override;
42 
45  const BoundingBox<double, N>& box,
46  const BoxIntersectionTestFunc<T, N>& testFunc,
47  const IntersectionVisitorFunc<T>& visitorFunc) const override;
48 
51  const Ray<double, N>& ray,
52  const RayIntersectionTestFunc<T, N>& testFunc,
53  const IntersectionVisitorFunc<T>& visitorFunc) const override;
54 
57  const Ray<double, N>& ray,
58  const GetRayIntersectionFunc<T, N>& testFunc) const override;
59 
63  const Vector<double, N>& pt,
64  const NearestNeighborDistanceFunc<T, N>& distanceFunc) const override;
65 
66  private:
67  Array1<T> m_items;
68 };
69 
71 template <typename T>
73 
75 template <typename T>
77 } // namespace CubbyFlow
78 
80 
81 #endif
void Add(const T &item)
Adds an item to the container.
Definition: ListQueryEngine-Impl.hpp:17
N-D nearest neighbor query result.
Definition: NearestNeighborQueryEngine.hpp:23
Class for N-D ray.
Definition: Ray.hpp:25
NearestNeighborQueryResult< T, N > Nearest(const Vector< double, N > &pt, const NearestNeighborDistanceFunc< T, N > &distanceFunc) const override
Definition: ListQueryEngine-Impl.hpp:95
Definition: Matrix.hpp:27
N-D closest intersection query result.
Definition: IntersectionQueryEngine.hpp:25
Definition: pybind11Utils.hpp:20
ClosestIntersectionQueryResult< T, N > ClosestIntersection(const Ray< double, N > &ray, const GetRayIntersectionFunc< T, N > &testFunc) const override
Returns the closest intersection for given ray.
Definition: ListQueryEngine-Impl.hpp:76
Ad-hoc list-based N-D intersection/nearest-neighbor query engine.
Definition: ListQueryEngine.hpp:23
Definition: Array-Impl.hpp:19
std::function< bool(const T &, const BoundingBox< double, N > &)> BoxIntersectionTestFunc
N-D box-item intersection test function.
Definition: IntersectionQueryEngine.hpp:55
Abstract base class for N-D intersection test query engine.
Definition: IntersectionQueryEngine.hpp:97
void ForEachIntersectingItem(const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const override
Invokes visitorFunc for every intersecting items.
Definition: ListQueryEngine-Impl.hpp:47
Generic N-dimensional array class interface.
Definition: Array.hpp:32
Abstract base class for N-D nearest neighbor query engine.
Definition: NearestNeighborQueryEngine.hpp:52
std::function< double(const T &, const Vector< double, N > &)> NearestNeighborDistanceFunc
N-D nearest neighbor distance measure function.
Definition: NearestNeighborQueryEngine.hpp:40
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
bool Intersects(const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc) const override
Returns true if given box intersects with any of the stored items.
Definition: ListQueryEngine-Impl.hpp:29
std::function< void(const T &)> IntersectionVisitorFunc
Visitor function which is invoked for each intersecting item.
Definition: IntersectionQueryEngine.hpp:93