Loading...
Searching...
No Matches
ListQueryEngine-Impl.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_IMPL_HPP
12#define CUBBYFLOW_LIST_QUERY_ENGINE_IMPL_HPP
13
14namespace CubbyFlow
15{
16template <typename T, size_t N>
18{
19 m_items.Append(item);
20}
21
22template <typename T, size_t N>
24{
25 m_items.Append(items);
26}
27
28template <typename T, size_t N>
32{
33 return std::any_of(m_items.begin(), m_items.end(),
34 [&](const T& item) { return testFunc(item, box); });
35}
36
37template <typename T, size_t N>
39 const Ray<double, N>& ray,
41{
42 return std::any_of(m_items.begin(), m_items.end(),
43 [&](const T& item) { return testFunc(item, ray); });
44}
45
46template <typename T, size_t N>
51{
52 for (const auto& item : m_items)
53 {
54 if (testFunc(item, box))
55 {
56 visitorFunc(item);
57 }
58 }
59}
60
61template <typename T, size_t N>
65{
66 for (const auto& item : m_items)
67 {
68 if (testFunc(item, ray))
69 {
70 visitorFunc(item);
71 }
72 }
73}
74
75template <typename T, size_t N>
77 const Ray<double, N>& ray,
79{
81
82 for (const auto& item : m_items)
83 {
84 if (double dist = testFunc(item, ray); dist < best.distance)
85 {
86 best.distance = dist;
87 best.item = &item;
88 }
89 }
90
91 return best;
92}
93
94template <typename T, size_t N>
96 const Vector<double, N>& pt,
98{
100
101 for (const auto& item : m_items)
102 {
103 if (double dist = distanceFunc(item, pt); dist < best.distance)
104 {
105 best.item = &item;
106 best.distance = dist;
107 }
108 }
109
110 return best;
111}
112} // namespace CubbyFlow
113
114#endif
void Add(const T &item)
Adds an item to the container.
Definition ListQueryEngine-Impl.hpp:17
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
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
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
NearestNeighborQueryResult< T, N > Nearest(const Vector< double, N > &pt, const NearestNeighborDistanceFunc< T, N > &distanceFunc) const override
Definition ListQueryEngine-Impl.hpp:95
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738