Jet  v1.3.3
point_parallel_hash_grid_searcher2.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_POINT_PARALLEL_HASH_GRID_SEARCHER2_H_
8 #define INCLUDE_JET_POINT_PARALLEL_HASH_GRID_SEARCHER2_H_
9 
11 #include <jet/point2.h>
12 #include <jet/size2.h>
13 #include <vector>
14 
15 class PointParallelHashGridSearcher2Tests;
16 
17 namespace jet {
18 
27  public:
29 
30  class Builder;
31 
43  const Size2& resolution, double gridSpacing);
44 
57  size_t resolutionX,
58  size_t resolutionY,
59  double gridSpacing);
60 
63 
71  void build(const ConstArrayAccessor1<Vector2D>& points) override;
72 
82  const Vector2D& origin,
83  double radius,
84  const ForEachNearbyPointFunc& callback) const override;
85 
96  const Vector2D& origin, double radius) const override;
97 
106  const std::vector<size_t>& keys() const;
107 
131  const std::vector<size_t>& startIndexTable() const;
132 
156  const std::vector<size_t>& endIndexTable() const;
157 
168  const std::vector<size_t>& sortedIndices() const;
169 
177  size_t getHashKeyFromBucketIndex(const Point2I& bucketIndex) const;
178 
186  Point2I getBucketIndex(const Vector2D& position) const;
187 
195 
198  const PointParallelHashGridSearcher2& other);
199 
202 
204  void serialize(std::vector<uint8_t>* buffer) const override;
205 
207  void deserialize(const std::vector<uint8_t>& buffer) override;
208 
210  static Builder builder();
211 
212  private:
214 
215  double _gridSpacing = 1.0;
216  Point2I _resolution = Point2I(1, 1);
217  std::vector<Vector2D> _points;
218  std::vector<size_t> _keys;
219  std::vector<size_t> _startIndexTable;
220  std::vector<size_t> _endIndexTable;
221  std::vector<size_t> _sortedIndices;
222 
223  size_t getHashKeyFromPosition(const Vector2D& position) const;
224 
225  void getNearbyKeys(const Vector2D& position, size_t* bucketIndices) const;
226 };
227 
229 typedef std::shared_ptr<PointParallelHashGridSearcher2>
231 
238  public:
240  Builder& withResolution(const Size2& resolution);
241 
243  Builder& withGridSpacing(double gridSpacing);
244 
247 
250 
253 
254  private:
255  Size2 _resolution{64, 64};
256  double _gridSpacing = 1.0;
257 };
258 
259 } // namespace jet
260 
261 #endif // INCLUDE_JET_POINT_PARALLEL_HASH_GRID_SEARCHER2_H_
jet::Point< T, 2 >
2-D point class.
Definition: point2.h:23
jet::PointParallelHashGridSearcher2::set
void set(const PointParallelHashGridSearcher2 &other)
Copy from the other instance.
jet::Point2I
Point2< ssize_t > Point2I
Integer-type 2D point.
Definition: point2.h:298
JET_NEIGHBOR_SEARCHER2_TYPE_NAME
#define JET_NEIGHBOR_SEARCHER2_TYPE_NAME(DerivedClassName)
Definition: point_neighbor_searcher2.h:95
jet::PointParallelHashGridSearcher2Ptr
std::shared_ptr< PointParallelHashGridSearcher2 > PointParallelHashGridSearcher2Ptr
Shared pointer for the PointParallelHashGridSearcher2 type.
Definition: point_parallel_hash_grid_searcher2.h:230
jet::ConstArrayAccessor< T, 1 >
1-D read-only array accessor class.
Definition: array_accessor1.h:184
point_neighbor_searcher2.h
jet::PointNeighborSearcher2Ptr
std::shared_ptr< PointNeighborSearcher2 > PointNeighborSearcher2Ptr
Shared pointer for the PointNeighborSearcher2 type.
Definition: point_neighbor_searcher2.h:82
jet::PointParallelHashGridSearcher2::forEachNearbyPoint
void forEachNearbyPoint(const Vector2D &origin, double radius, const ForEachNearbyPointFunc &callback) const override
jet::PointParallelHashGridSearcher2::getHashKeyFromBucketIndex
size_t getHashKeyFromBucketIndex(const Point2I &bucketIndex) const
size2.h
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2
PointParallelHashGridSearcher2(const Size2 &resolution, double gridSpacing)
Constructs hash grid with given resolution and grid spacing.
jet::PointParallelHashGridSearcher2::getBucketIndex
Point2I getBucketIndex(const Vector2D &position) const
jet::PointParallelHashGridSearcher2::operator=
PointParallelHashGridSearcher2 & operator=(const PointParallelHashGridSearcher2 &other)
Assignment operator.
jet::PointParallelHashGridSearcher2::Builder::build
PointParallelHashGridSearcher2 build() const
Builds PointParallelHashGridSearcher2 instance.
jet
Definition: advection_solver2.h:18
jet::PointParallelHashGridSearcher2::Builder::withResolution
Builder & withResolution(const Size2 &resolution)
Returns builder with resolution.
jet::PointParallelHashGridSearcher2::clone
PointNeighborSearcher2Ptr clone() const override
Creates a new instance of the object with same properties than original.
jet::PointParallelHashGridSearcher2::sortedIndices
const std::vector< size_t > & sortedIndices() const
Returns the sorted indices of the points.
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2Tests
friend class PointParallelHashGridSearcher2Tests
Definition: point_parallel_hash_grid_searcher2.h:213
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2
PointParallelHashGridSearcher2(size_t resolutionX, size_t resolutionY, double gridSpacing)
Constructs hash grid with given resolution and grid spacing.
jet::PointParallelHashGridSearcher2
Parallel version of hash grid-based 2-D point searcher.
Definition: point_parallel_hash_grid_searcher2.h:26
jet::PointParallelHashGridSearcher2::Builder
Front-end to create PointParallelHashGridSearcher2 objects step by step.
Definition: point_parallel_hash_grid_searcher2.h:237
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::PointParallelHashGridSearcher2::builder
static Builder builder()
Returns builder fox PointParallelHashGridSearcher2.
jet::PointNeighborSearcher2::ForEachNearbyPointFunc
std::function< void(size_t, const Vector2D &)> ForEachNearbyPointFunc
Definition: point_neighbor_searcher2.h:33
jet::PointParallelHashGridSearcher2::endIndexTable
const std::vector< size_t > & endIndexTable() const
Returns the end index table.
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2
PointParallelHashGridSearcher2(const PointParallelHashGridSearcher2 &other)
Copy constructor.
jet::PointParallelHashGridSearcher2::Builder::buildPointNeighborSearcher
PointNeighborSearcher2Ptr buildPointNeighborSearcher() const override
Returns shared pointer of PointNeighborSearcher3 type.
jet::PointNeighborSearcherBuilder2
Abstract base class for 2-D point neighbor searcher builders.
Definition: point_neighbor_searcher2.h:85
jet::Size2
2-D size class.
Definition: size2.h:19
jet::PointParallelHashGridSearcher2::startIndexTable
const std::vector< size_t > & startIndexTable() const
Returns the start index table.
jet::PointParallelHashGridSearcher2::hasNearbyPoint
bool hasNearbyPoint(const Vector2D &origin, double radius) const override
jet::PointParallelHashGridSearcher2::build
void build(const ConstArrayAccessor1< Vector2D > &points) override
Builds internal acceleration structure for given points list.
jet::PointParallelHashGridSearcher2::serialize
void serialize(std::vector< uint8_t > *buffer) const override
Serializes the neighbor searcher into the buffer.
jet::PointNeighborSearcher2
Abstract base class for 2-D neighbor point searcher.
Definition: point_neighbor_searcher2.h:28
jet::PointParallelHashGridSearcher2::keys
const std::vector< size_t > & keys() const
Returns the hash key list.
jet::PointParallelHashGridSearcher2::Builder::makeShared
PointParallelHashGridSearcher2Ptr makeShared() const
Builds shared pointer of PointParallelHashGridSearcher2 instance.
jet::PointParallelHashGridSearcher2::deserialize
void deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the neighbor searcher from the buffer.
jet::PointParallelHashGridSearcher2::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacing)
Returns builder with grid spacing.
point2.h