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::ranges::any_of(
34 m_items,
35 [&testFunc, &box](const T& item) { return testFunc(item, box); });
36}
37
38template <typename T, size_t N>
40 const Ray<double, N>& ray,
42{
43 return std::ranges::any_of(
44 m_items,
45 [&testFunc, &ray](const T& item) { return testFunc(item, ray); });
46}
47
48template <typename T, size_t N>
53{
54 for (const auto& item : m_items)
55 {
56 if (testFunc(item, box))
57 {
58 visitorFunc(item);
59 }
60 }
61}
62
63template <typename T, size_t N>
67{
68 for (const auto& item : m_items)
69 {
70 if (testFunc(item, ray))
71 {
72 visitorFunc(item);
73 }
74 }
75}
76
77template <typename T, size_t N>
79 const Ray<double, N>& ray,
81{
83
84 for (const auto& item : m_items)
85 {
86 if (double dist = testFunc(item, ray); dist < best.distance)
87 {
88 best.distance = dist;
89 best.item = &item;
90 }
91 }
92
93 return best;
94}
95
96template <typename T, size_t N>
98 const Vector<double, N>& pt,
100{
102
103 for (const auto& item : m_items)
104 {
105 if (double dist = distanceFunc(item, pt); dist < best.distance)
106 {
107 best.item = &item;
108 best.distance = dist;
109 }
110 }
111
112 return best;
113}
114} // namespace CubbyFlow
115
116#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:78
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:49
NearestNeighborQueryResult< T, N > Nearest(const Vector< double, N > &pt, const NearestNeighborDistanceFunc< T, N > &distanceFunc) const override
Definition ListQueryEngine-Impl.hpp:97
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:22
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719