Loading...
Searching...
No Matches
PointSimpleListSearcher.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_SIMPLE_LIST_SEARCHER_HPP
12#define CUBBYFLOW_POINT_SIMPLE_LIST_SEARCHER_HPP
13
15
16namespace CubbyFlow
17{
25template <size_t N>
27{
28 public:
30
31 class Builder;
32
35
38
40 ~PointSimpleListSearcher() override = default;
41
44
47
50
54
66 double maxSearchRadius) override;
67
77 const Vector<double, N>& origin, double radius,
78 const ForEachNearbyPointFunc& callback) const override;
79
90 double radius) const override;
91
98 [[nodiscard]] std::shared_ptr<PointNeighborSearcher<N>> Clone()
99 const override;
100
103
105 void Serialize(std::vector<uint8_t>* buffer) const override;
106
108 void Deserialize(const std::vector<uint8_t>& buffer) override;
109
112
113 private:
114 template <size_t M = N>
115 static std::enable_if_t<M == 2, void> Serialize(
117 std::vector<uint8_t>* buffer);
118
119 template <size_t M = N>
120 static std::enable_if_t<M == 3, void> Serialize(
122 std::vector<uint8_t>* buffer);
123
124 template <size_t M = N>
125 static std::enable_if_t<M == 2, void> Deserialize(
126 const std::vector<uint8_t>& buffer,
128
129 template <size_t M = N>
130 static std::enable_if_t<M == 3, void> Deserialize(
131 const std::vector<uint8_t>& buffer,
133
134 Array1<Vector<double, N>> m_points;
135};
136
139
142
144using PointSimpleListSearcher2Ptr = std::shared_ptr<PointSimpleListSearcher<2>>;
145
147using PointSimpleListSearcher3Ptr = std::shared_ptr<PointSimpleListSearcher<3>>;
148
152template <size_t N>
155{
156 public:
158 Builder() = default;
159
161 ~Builder() override = default;
162
164 Builder(const Builder& other) = delete;
165
167 Builder(Builder&& other) noexcept = delete;
168
170 Builder& operator=(const Builder& other) = delete;
171
173 Builder& operator=(Builder&& other) noexcept = delete;
174
177
179 std::shared_ptr<PointSimpleListSearcher<N>> MakeShared() const;
180
182 std::shared_ptr<PointNeighborSearcher<N>> BuildPointNeighborSearcher()
183 const override;
184};
185} // namespace CubbyFlow
186
187#endif
#define CUBBYFLOW_NEIGHBOR_SEARCHER_TYPE_NAME(DerivedClassName, N)
Definition PointNeighborSearcher.hpp:163
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
Definition Matrix.hpp:30
Abstract base class for N-D point neighbor searcher builders.
Definition PointNeighborSearcher.hpp:120
Abstract base class for N-D neighbor point searcher.
Definition PointNeighborSearcher.hpp:33
std::function< void(size_t, const Vector< double, N > &)> ForEachNearbyPointFunc
Definition PointNeighborSearcher.hpp:38
Front-end to create PointSimpleListSearcher objects step by step.
Definition PointSimpleListSearcher.hpp:155
Builder & operator=(Builder &&other) noexcept=delete
Deleted move assignment operator.
std::shared_ptr< PointNeighborSearcher< N > > BuildPointNeighborSearcher() const override
Returns shared pointer of PointNeighborSearcher type.
PointSimpleListSearcher< N > Build() const
Builds PointSimpleListSearcher instance.
std::shared_ptr< PointSimpleListSearcher< N > > MakeShared() const
Builds shared pointer of PointSimpleListSearcher instance.
Builder()=default
Default constructor.
Builder & operator=(const Builder &other)=delete
Deleted copy assignment operator.
~Builder() override=default
Default virtual destructor.
Builder(const Builder &other)=delete
Deleted copy constructor.
Builder(Builder &&other) noexcept=delete
Deleted move constructor.
Simple ad-hoc N-D point searcher.
Definition PointSimpleListSearcher.hpp:27
PointSimpleListSearcher(const PointSimpleListSearcher &other)
Copy constructor.
PointSimpleListSearcher()=default
Default constructor.
void Serialize(std::vector< uint8_t > *buffer) const override
Serializes the neighbor searcher into the buffer.
PointSimpleListSearcher(PointSimpleListSearcher &&other) noexcept
Move constructor.
void Build(const ConstArrayView1< Vector< double, N > > &points, double maxSearchRadius) override
Builds internal structure for given points list and max search radius.
void Set(const PointSimpleListSearcher &other)
Copy from the other instance.
std::shared_ptr< PointNeighborSearcher< N > > Clone() const override
Creates a new instance of the object with same properties than original.
~PointSimpleListSearcher() override=default
Default virtual destructor.
static Builder GetBuilder()
Returns builder fox PointSimpleListSearcher.
bool HasNearbyPoint(const Vector< double, N > &origin, double radius) const override
PointSimpleListSearcher & operator=(const PointSimpleListSearcher &other)
Copy assignment operator.
void Deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the neighbor searcher from the buffer.
void ForEachNearbyPoint(const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const override
PointSimpleListSearcher & operator=(PointSimpleListSearcher &&other) noexcept
Move assignment operator.
Definition pybind11Utils.hpp:21
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
std::shared_ptr< PointSimpleListSearcher< 3 > > PointSimpleListSearcher3Ptr
Shared pointer for the PointSimpleListSearcher3 type.
Definition PointSimpleListSearcher.hpp:147
std::shared_ptr< PointSimpleListSearcher< 2 > > PointSimpleListSearcher2Ptr
Shared pointer for the PointSimpleListSearcher2 type.
Definition PointSimpleListSearcher.hpp:144