Loading...
Searching...
No Matches
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
16
17#include <functional>
18#include <memory>
19#include <string>
20
21namespace CubbyFlow
22{
31template <size_t N>
33{
34 public:
38 std::function<void(size_t, const Vector<double, N>&)>;
39
42
44 ~PointNeighborSearcher() override = default;
45
48
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
112using PointNeighborSearcher2Ptr = std::shared_ptr<PointNeighborSearcher2>;
113
115using PointNeighborSearcher3Ptr = std::shared_ptr<PointNeighborSearcher3>;
116
118template <size_t N>
120{
121 public:
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>>
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
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
virtual std::shared_ptr< PointNeighborSearcher< N > > BuildPointNeighborSearcher() const =0
Returns shared pointer of PointNeighborSearcher type.
virtual ~PointNeighborSearcherBuilder()=default
Default virtual destructor.
PointNeighborSearcherBuilder()=default
Default constructor.
PointNeighborSearcherBuilder & operator=(const PointNeighborSearcherBuilder &other)=delete
Deleted copy assignment operator.
PointNeighborSearcherBuilder(PointNeighborSearcherBuilder &&other) noexcept=delete
Deleted move constructor.
PointNeighborSearcherBuilder & operator=(PointNeighborSearcherBuilder &&other) noexcept=delete
Deleted move assignment operator.
PointNeighborSearcherBuilder(const PointNeighborSearcherBuilder &other)=delete
Deleted copy constructor.
Abstract base class for N-D neighbor point searcher.
Definition PointNeighborSearcher.hpp:33
virtual bool HasNearbyPoint(const Vector< double, N > &origin, double radius) const =0
virtual void Build(const ConstArrayView1< Vector< double, N > > &points)
Builds internal acceleration structure for given points list.
virtual void Build(const ConstArrayView1< Vector< double, N > > &points, double maxSearchRadius)=0
PointNeighborSearcher & operator=(const PointNeighborSearcher &other)=default
Default copy assignment operator.
virtual std::shared_ptr< PointNeighborSearcher > Clone() const =0
Creates a new instance of the object with same properties than original.
PointNeighborSearcher(const PointNeighborSearcher &other)=default
Default copy constructor.
PointNeighborSearcher(PointNeighborSearcher &&other) noexcept=default
Default move constructor.
PointNeighborSearcher & operator=(PointNeighborSearcher &&other) noexcept=default
Default move assignment operator.
virtual void ForEachNearbyPoint(const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const =0
std::function< void(size_t, const Vector< double, N > &)> ForEachNearbyPointFunc
Definition PointNeighborSearcher.hpp:38
virtual std::string TypeName() const =0
Returns the type name of the derived class.
PointNeighborSearcher()=default
Default constructor.
~PointNeighborSearcher() override=default
Default virtual destructor.
Abstract base class for any serializable class.
Definition Serialization.hpp:22
Definition pybind11Utils.hpp:21
std::shared_ptr< PointNeighborSearcher3 > PointNeighborSearcher3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition PointNeighborSearcher.hpp:115
std::shared_ptr< PointNeighborSearcherBuilder3 > PointNeighborSearcherBuilder3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition PointNeighborSearcher.hpp:161
std::shared_ptr< PointNeighborSearcher2 > PointNeighborSearcher2Ptr
Shared pointer for the PointNeighborSearcher2 type.
Definition PointNeighborSearcher.hpp:112
std::shared_ptr< PointNeighborSearcherBuilder2 > PointNeighborSearcherBuilder2Ptr
Shared pointer for the PointNeighborSearcher2 type.
Definition PointNeighborSearcher.hpp:157
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738