Loading...
Searching...
No Matches
PointKdTreeSearcher.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_KDTREE_SEARCHER_HPP
12#define CUBBYFLOW_POINT_KDTREE_SEARCHER_HPP
13
16#include <Core/Utils/Macros.hpp>
17
18namespace CubbyFlow
19{
26template <size_t N>
28{
29 public:
31
32 class Builder;
33
36
39
41 ~PointKdTreeSearcher() override = default;
42
45
48
51
54
58 double maxSearchRadius) override;
59
69 const Vector<double, N>& origin, double radius,
70 const ForEachNearbyPointFunc& callback) const override;
71
82 double radius) const override;
83
90 [[nodiscard]] std::shared_ptr<PointNeighborSearcher<N>> Clone()
91 const override;
92
95
97 void Serialize(std::vector<uint8_t>* buffer) const override;
98
100 void Deserialize(const std::vector<uint8_t>& buffer) override;
101
104
105 private:
106 template <size_t M = N>
110
111 template <size_t M = N>
115
116 template <size_t M = N>
120
121 template <size_t M = N>
125
126 KdTree<double, N> m_tree;
127};
128
131
134
137
140
144template <size_t N>
147{
148 public:
150 Builder() = default;
151
153 ~Builder() override = default;
154
156 Builder(const Builder& other) = delete;
157
159 Builder(Builder&& other) noexcept = delete;
160
162 Builder& operator=(const Builder& other) = delete;
163
165 Builder& operator=(Builder&& other) noexcept = delete;
166
169
171 std::shared_ptr<PointKdTreeSearcher<N>> MakeShared() const;
172
174 std::shared_ptr<PointNeighborSearcher<N>> BuildPointNeighborSearcher()
175 const override;
176};
177} // namespace CubbyFlow
178
179#endif
#define CUBBYFLOW_REQUIRES(...)
Definition Macros.hpp:81
#define CUBBYFLOW_NEIGHBOR_SEARCHER_TYPE_NAME(DerivedClassName, N)
Definition PointNeighborSearcher.hpp:163
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
Generic k-d tree structure.
Definition KdTree.hpp:23
Definition Matrix.hpp:30
Front-end to create PointKdTreeSearcher objects step by step.
Definition PointKdTreeSearcher.hpp:147
Builder & operator=(Builder &&other) noexcept=delete
Deleted move assignment operator.
std::shared_ptr< PointKdTreeSearcher< N > > MakeShared() const
Builds shared pointer of PointKdTreeSearcher instance.
~Builder() override=default
Default virtual destructor.
Builder(Builder &&other) noexcept=delete
Deleted move constructor.
Builder(const Builder &other)=delete
Deleted copy constructor.
PointKdTreeSearcher Build() const
Builds PointKdTreeSearcher instance.
Builder & operator=(const Builder &other)=delete
Deleted copy assignment operator.
Builder()=default
Default constructor.
std::shared_ptr< PointNeighborSearcher< N > > BuildPointNeighborSearcher() const override
Returns shared pointer of PointNeighborSearcher3 type.
KdTree-based N-D point searcher.
Definition PointKdTreeSearcher.hpp:28
void Deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the neighbor searcher from the buffer.
PointKdTreeSearcher & operator=(const PointKdTreeSearcher &other)
Copy assignment operator.
bool HasNearbyPoint(const Vector< double, N > &origin, double radius) const override
PointKdTreeSearcher()=default
Constructs an empty kD-tree instance.
static Builder GetBuilder()
Returns builder fox PointKdTreeSearcher.
void Set(const PointKdTreeSearcher &other)
Copy from the other instance.
~PointKdTreeSearcher() override=default
Default virtual destructor.
PointKdTreeSearcher & operator=(PointKdTreeSearcher &&other) noexcept
Move assignment operator.
void Build(const ConstArrayView1< Vector< double, N > > &points, double maxSearchRadius) override
void ForEachNearbyPoint(const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const override
PointKdTreeSearcher(const PointKdTreeSearcher &other)
Copy constructor.
void Serialize(std::vector< uint8_t > *buffer) const override
Serializes the neighbor searcher into the buffer.
PointKdTreeSearcher(PointKdTreeSearcher &&other) noexcept
Move constructor.
std::shared_ptr< PointNeighborSearcher< N > > Clone() const override
Creates a new instance of the object with same properties than original.
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
Definition pybind11Utils.hpp:22
std::shared_ptr< PointKdTreeSearcher2 > PointKdTreeSearcher2Ptr
Shared pointer for the PointKdTreeSearcher2 type.
Definition PointKdTreeSearcher.hpp:136
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719
std::shared_ptr< PointKdTreeSearcher3 > PointKdTreeSearcher3Ptr
Shared pointer for the PointKdTreeSearcher3 type.
Definition PointKdTreeSearcher.hpp:139