Loading...
Searching...
No Matches
PointParallelHashGridSearcher.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_PARALLEL_HASH_GRID_SEARCHER_HPP
12#define CUBBYFLOW_POINT_PARALLEL_HASH_GRID_SEARCHER_HPP
13
16#include <Core/Utils/Macros.hpp>
17
18namespace CubbyFlow
19{
27template <size_t N>
29{
30 public:
32
33 class Builder;
34
37
49 double gridSpacing);
50
52 ~PointParallelHashGridSearcher() override = default;
53
56
60
64
68
76 void Build(const ConstArrayView1<Vector<double, N>>& points) override;
77
88 double maxSearchRadius) override;
89
99 const Vector<double, N>& origin, double radius,
100 const ForEachNearbyPointFunc& callback) const override;
101
112 double radius) const override;
113
123
148
173
185
192 [[nodiscard]] std::shared_ptr<PointNeighborSearcher<N>> Clone()
193 const override;
194
197
199 void Serialize(std::vector<uint8_t>* buffer) const override;
200
202 void Deserialize(const std::vector<uint8_t>& buffer) override;
203
206
207 private:
209
210 template <size_t M = N>
214
215 template <size_t M = N>
219
220 template <size_t M = N>
224
225 template <size_t M = N>
229
230 double m_gridSpacing = 1.0;
231 Vector<ssize_t, N> m_resolution = Vector<ssize_t, N>::MakeConstant(1);
232 Array1<Vector<double, N>> m_points;
233 Array1<size_t> m_keys;
234 Array1<size_t> m_startIndexTable;
235 Array1<size_t> m_endIndexTable;
236 Array1<size_t> m_sortedIndices;
237};
238
241
244
248
252
257template <size_t N>
260{
261 public:
263 Builder() = default;
264
266 ~Builder() override = default;
267
269 Builder(const Builder& other) = delete;
270
272 Builder(Builder&& other) noexcept = delete;
273
275 Builder& operator=(const Builder& other) = delete;
276
278 Builder& operator=(Builder&& other) noexcept = delete;
279
282
285
288
290 std::shared_ptr<PointParallelHashGridSearcher<N>> MakeShared() const;
291
293 std::shared_ptr<PointNeighborSearcher<N>> BuildPointNeighborSearcher()
294 const override;
295
296 private:
298 double m_gridSpacing = 1.0;
299};
300} // namespace CubbyFlow
301
302#endif
#define CUBBYFLOW_REQUIRES(...)
Definition Macros.hpp:81
#define CUBBYFLOW_NEIGHBOR_SEARCHER_TYPE_NAME(DerivedClassName, N)
Definition PointNeighborSearcher.hpp:163
Definition Array.hpp:36
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
static std::enable_if_t< IsMatrixSizeStatic< Rows, Cols >(), D > MakeConstant(ValueType val)
Makes a static matrix with constant entries.
Definition MatrixDenseBase-Impl.hpp:152
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 PointParallelHashGridSearcher objects step by step.
Definition PointParallelHashGridSearcher.hpp:260
Builder & WithResolution(const Vector< size_t, N > &resolution)
Returns builder with resolution.
std::shared_ptr< PointParallelHashGridSearcher< N > > MakeShared() const
Builds shared pointer of PointParallelHashGridSearcher instance.
PointParallelHashGridSearcher< N > Build() const
Builds PointParallelHashGridSearcher instance.
std::shared_ptr< PointNeighborSearcher< N > > BuildPointNeighborSearcher() const override
Returns shared pointer of PointNeighborSearcher type.
Builder & operator=(Builder &&other) noexcept=delete
Deleted move assignment operator.
Builder & WithGridSpacing(double gridSpacing)
Returns builder with grid spacing.
~Builder() override=default
Default virtual destructor.
Builder & operator=(const Builder &other)=delete
Deleted copy assignment operator.
Builder(Builder &&other) noexcept=delete
Deleted move constructor.
Builder(const Builder &other)=delete
Deleted copy constructor.
Parallel version of hash grid-based N-D point searcher.
Definition PointParallelHashGridSearcher.hpp:29
void Serialize(std::vector< uint8_t > *buffer) const override
Serializes the neighbor searcher into the buffer.
bool HasNearbyPoint(const Vector< double, N > &origin, double radius) const override
~PointParallelHashGridSearcher() override=default
Default virtual destructor.
static Builder GetBuilder()
Returns builder fox PointParallelHashGridSearcher.
PointParallelHashGridSearcher & operator=(PointParallelHashGridSearcher &&other) noexcept
Move assignment operator.
void ForEachNearbyPoint(const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const override
friend class PointParallelHashGridSearcherTests
Definition PointParallelHashGridSearcher.hpp:208
void Build(const ConstArrayView1< Vector< double, N > > &points, double maxSearchRadius) override
Builds internal acceleration structure for given points list and max search radius.
PointParallelHashGridSearcher(const Vector< size_t, N > &resolution, double gridSpacing)
Constructs hash grid with given resolution and grid spacing.
std::shared_ptr< PointNeighborSearcher< N > > Clone() const override
Creates a new instance of the object with same properties than original.
PointParallelHashGridSearcher(PointParallelHashGridSearcher &&other) noexcept
Move constructor.
void Deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the neighbor searcher from the buffer.
ConstArrayView1< size_t > StartIndexTable() const
Returns the start index table.
ConstArrayView1< size_t > Keys() const
Returns the hash key list.
void Build(const ConstArrayView1< Vector< double, N > > &points) override
Builds internal acceleration structure for given points list.
PointParallelHashGridSearcher(const PointParallelHashGridSearcher &other)
Copy constructor.
ConstArrayView1< size_t > EndIndexTable() const
Returns the end index table.
PointParallelHashGridSearcher & operator=(const PointParallelHashGridSearcher &other)
Copy assignment operator.
void Set(const PointParallelHashGridSearcher &other)
Copy from the other instance.
ConstArrayView1< size_t > SortedIndices() const
Returns the sorted indices of the points.
Definition pybind11Utils.hpp:22
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:719
std::shared_ptr< PointParallelHashGridSearcher2 > PointParallelHashGridSearcher2Ptr
Shared pointer for the PointParallelHashGridSearcher2 type.
Definition PointParallelHashGridSearcher.hpp:247
std::shared_ptr< PointParallelHashGridSearcher3 > PointParallelHashGridSearcher3Ptr
Shared pointer for the PointParallelHashGridSearcher3 type.
Definition PointParallelHashGridSearcher.hpp:251