PointNeighborSearcher.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_POINT_NEIGHBOR_SEARCHER_HPP
12 #define CUBBYFLOW_POINT_NEIGHBOR_SEARCHER_HPP
13 
14 #include <Core/Matrix/Matrix.hpp>
16 
17 #include <functional>
18 #include <memory>
19 #include <string>
20 
21 namespace CubbyFlow
22 {
31 template <size_t N>
33 {
34  public:
38  std::function<void(size_t, const Vector<double, N>&)>;
39 
41  PointNeighborSearcher() = default;
42 
44  ~PointNeighborSearcher() override = default;
45 
47  PointNeighborSearcher(const PointNeighborSearcher& other) = default;
48 
50  PointNeighborSearcher(PointNeighborSearcher&& other) noexcept = default;
51 
54  default;
55 
58  default;
59 
61  [[nodiscard]] virtual std::string TypeName() const = 0;
62 
64  virtual void Build(const ConstArrayView1<Vector<double, N>>& points);
65 
68  virtual void Build(const ConstArrayView1<Vector<double, N>>& points,
69  double maxSearchRadius) = 0;
70 
79  virtual void ForEachNearbyPoint(
80  const Vector<double, N>& origin, double radius,
81  const ForEachNearbyPointFunc& callback) const = 0;
82 
92  [[nodiscard]] virtual bool HasNearbyPoint(const Vector<double, N>& origin,
93  double radius) const = 0;
94 
101  [[nodiscard]] virtual std::shared_ptr<PointNeighborSearcher> Clone()
102  const = 0;
103 };
104 
107 
110 
112 using PointNeighborSearcher2Ptr = std::shared_ptr<PointNeighborSearcher2>;
113 
115 using PointNeighborSearcher3Ptr = std::shared_ptr<PointNeighborSearcher3>;
116 
118 template <size_t N>
120 {
121  public:
123  PointNeighborSearcherBuilder() = default;
124 
126  virtual ~PointNeighborSearcherBuilder() = default;
127 
130  delete;
131 
134  PointNeighborSearcherBuilder&& other) noexcept = delete;
135 
138  const PointNeighborSearcherBuilder& other) = delete;
139 
142  PointNeighborSearcherBuilder&& other) noexcept = delete;
143 
145  [[nodiscard]] virtual std::shared_ptr<PointNeighborSearcher<N>>
146  BuildPointNeighborSearcher() const = 0;
147 };
148 
151 
154 
157  std::shared_ptr<PointNeighborSearcherBuilder2>;
158 
161  std::shared_ptr<PointNeighborSearcherBuilder3>;
162 
163 #define CUBBYFLOW_NEIGHBOR_SEARCHER_TYPE_NAME(DerivedClassName, N) \
164  [[nodiscard]] std::string TypeName() const override \
165  { \
166  return #DerivedClassName + std::to_string(N); \
167  }
168 } // namespace CubbyFlow
169 
170 #endif
Abstract base class for any serializable class.
Definition: Serialization.hpp:21
virtual bool HasNearbyPoint(const Vector< double, N > &origin, double radius) const =0
std::shared_ptr< PointNeighborSearcher3 > PointNeighborSearcher3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition: PointNeighborSearcher.hpp:115
virtual void Build(const ConstArrayView1< Vector< double, N >> &points)
Builds internal acceleration structure for given points list.
Abstract base class for N-D point neighbor searcher builders.
Definition: PointNeighborSearcher.hpp:119
std::function< void(size_t, const Vector< double, N > &)> ForEachNearbyPointFunc
Definition: PointNeighborSearcher.hpp:38
Abstract base class for N-D neighbor point searcher.
Definition: PointNeighborSearcher.hpp:32
Definition: Matrix.hpp:27
PointNeighborSearcher & operator=(const PointNeighborSearcher &other)=default
Default copy assignment operator.
Definition: pybind11Utils.hpp:20
PointNeighborSearcher()=default
Default constructor.
std::shared_ptr< PointNeighborSearcherBuilder3 > PointNeighborSearcherBuilder3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition: PointNeighborSearcher.hpp:161
virtual void ForEachNearbyPoint(const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const =0
Generic N-dimensional array class interface.
Definition: Array.hpp:32
virtual std::string TypeName() const =0
Returns the type name of the derived class.
std::shared_ptr< PointNeighborSearcherBuilder2 > PointNeighborSearcherBuilder2Ptr
Shared pointer for the PointNeighborSearcher2 type.
Definition: PointNeighborSearcher.hpp:157
~PointNeighborSearcher() override=default
Default virtual destructor.
std::shared_ptr< PointNeighborSearcher2 > PointNeighborSearcher2Ptr
Shared pointer for the PointNeighborSearcher2 type.
Definition: PointNeighborSearcher.hpp:112
virtual std::shared_ptr< PointNeighborSearcher > Clone() const =0
Creates a new instance of the object with same properties than original.