Jet  v1.3.3
point_parallel_hash_grid_searcher3.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_SEARCHER3_H_
8 #define INCLUDE_JET_POINT_PARALLEL_HASH_GRID_SEARCHER3_H_
9 
11 #include <jet/point3.h>
12 #include <jet/size3.h>
13 #include <vector>
14 
15 namespace jet {
16 
25  public:
27 
28  class Builder;
29 
41  const Size3& resolution, double gridSpacing);
42 
56  size_t resolutionX,
57  size_t resolutionY,
58  size_t resolutionZ,
59  double gridSpacing);
60 
63 
71  void build(const ConstArrayAccessor1<Vector3D>& points) override;
72 
82  const Vector3D& origin,
83  double radius,
84  const ForEachNearbyPointFunc& callback) const override;
85 
96  const Vector3D& 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 Point3I& bucketIndex) const;
178 
186  Point3I getBucketIndex(const Vector3D& position) const;
187 
195 
198  const PointParallelHashGridSearcher3& 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:
213  double _gridSpacing = 1.0;
214  Point3I _resolution = Point3I(1, 1, 1);
215  std::vector<Vector3D> _points;
216  std::vector<size_t> _keys;
217  std::vector<size_t> _startIndexTable;
218  std::vector<size_t> _endIndexTable;
219  std::vector<size_t> _sortedIndices;
220 
221  size_t getHashKeyFromPosition(const Vector3D& position) const;
222 
223  void getNearbyKeys(const Vector3D& position, size_t* bucketIndices) const;
224 };
225 
227 typedef std::shared_ptr<PointParallelHashGridSearcher3>
229 
236  public:
238  Builder& withResolution(const Size3& resolution);
239 
241  Builder& withGridSpacing(double gridSpacing);
242 
245 
248 
251 
252  private:
253  Size3 _resolution{64, 64, 64};
254  double _gridSpacing = 1.0;
255 };
256 
257 } // namespace jet
258 
259 #endif // INCLUDE_JET_POINT_PARALLEL_HASH_GRID_SEARCHER3_H_
jet::PointParallelHashGridSearcher3::forEachNearbyPoint
void forEachNearbyPoint(const Vector3D &origin, double radius, const ForEachNearbyPointFunc &callback) const override
jet::PointParallelHashGridSearcher3::endIndexTable
const std::vector< size_t > & endIndexTable() const
Returns the end index table.
jet::PointParallelHashGridSearcher3::PointParallelHashGridSearcher3
PointParallelHashGridSearcher3(const Size3 &resolution, double gridSpacing)
Constructs hash grid with given resolution and grid spacing.
jet::PointParallelHashGridSearcher3::Builder::build
PointParallelHashGridSearcher3 build() const
Builds PointParallelHashGridSearcher3 instance.
jet::PointParallelHashGridSearcher3::operator=
PointParallelHashGridSearcher3 & operator=(const PointParallelHashGridSearcher3 &other)
Assignment operator.
jet::ConstArrayAccessor< T, 1 >
1-D read-only array accessor class.
Definition: array_accessor1.h:184
jet::PointParallelHashGridSearcher3::builder
static Builder builder()
Returns builder fox PointParallelHashGridSearcher3.
jet::Point3I
Point3< ssize_t > Point3I
Integer-type 3D point.
Definition: point3.h:306
size3.h
jet::PointParallelHashGridSearcher3::keys
const std::vector< size_t > & keys() const
Returns the hash key list.
jet::PointParallelHashGridSearcher3::PointParallelHashGridSearcher3
PointParallelHashGridSearcher3(size_t resolutionX, size_t resolutionY, size_t resolutionZ, double gridSpacing)
Constructs hash grid with given resolution and grid spacing.
jet::PointParallelHashGridSearcher3::getBucketIndex
Point3I getBucketIndex(const Vector3D &position) const
jet::PointParallelHashGridSearcher3Ptr
std::shared_ptr< PointParallelHashGridSearcher3 > PointParallelHashGridSearcher3Ptr
Shared pointer for the PointParallelHashGridSearcher3 type.
Definition: point_parallel_hash_grid_searcher3.h:228
point_neighbor_searcher3.h
jet::PointParallelHashGridSearcher3::hasNearbyPoint
bool hasNearbyPoint(const Vector3D &origin, double radius) const override
jet::PointParallelHashGridSearcher3::startIndexTable
const std::vector< size_t > & startIndexTable() const
Returns the start index table.
point3.h
jet
Definition: advection_solver2.h:18
jet::PointParallelHashGridSearcher3::Builder::buildPointNeighborSearcher
PointNeighborSearcher3Ptr buildPointNeighborSearcher() const override
Returns shared pointer of PointNeighborSearcher3 type.
jet::PointParallelHashGridSearcher3::getHashKeyFromBucketIndex
size_t getHashKeyFromBucketIndex(const Point3I &bucketIndex) const
jet::PointParallelHashGridSearcher3::deserialize
void deserialize(const std::vector< uint8_t > &buffer) override
Deserializes the neighbor searcher from the buffer.
jet::PointNeighborSearcher3
Abstract base class for 3-D neighbor point searcher.
Definition: point_neighbor_searcher3.h:28
jet::PointNeighborSearcher3::ForEachNearbyPointFunc
std::function< void(size_t, const Vector3D &)> ForEachNearbyPointFunc
Definition: point_neighbor_searcher3.h:33
JET_NEIGHBOR_SEARCHER3_TYPE_NAME
#define JET_NEIGHBOR_SEARCHER3_TYPE_NAME(DerivedClassName)
Definition: point_neighbor_searcher3.h:95
jet::Size3
3-D size class.
Definition: size3.h:19
jet::PointParallelHashGridSearcher3::clone
PointNeighborSearcher3Ptr clone() const override
Creates a new instance of the object with same properties than original.
jet::PointParallelHashGridSearcher3::set
void set(const PointParallelHashGridSearcher3 &other)
Copy from the other instance.
jet::PointParallelHashGridSearcher3::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacing)
Returns builder with grid spacing.
jet::Point< T, 3 >
3-D point class.
Definition: point3.h:23
jet::PointParallelHashGridSearcher3::serialize
void serialize(std::vector< uint8_t > *buffer) const override
Serializes the neighbor searcher into the buffer.
jet::PointNeighborSearcher3Ptr
std::shared_ptr< PointNeighborSearcher3 > PointNeighborSearcher3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition: point_neighbor_searcher3.h:82
jet::PointParallelHashGridSearcher3::Builder::withResolution
Builder & withResolution(const Size3 &resolution)
Returns builder with resolution.
jet::PointParallelHashGridSearcher3
Parallel version of hash grid-based 3-D point searcher.
Definition: point_parallel_hash_grid_searcher3.h:24
jet::PointParallelHashGridSearcher3::Builder
Front-end to create PointParallelHashGridSearcher3 objects step by step.
Definition: point_parallel_hash_grid_searcher3.h:235
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::PointNeighborSearcherBuilder3
Abstract base class for 3-D point neighbor searcher builders.
Definition: point_neighbor_searcher3.h:85
jet::PointParallelHashGridSearcher3::PointParallelHashGridSearcher3
PointParallelHashGridSearcher3(const PointParallelHashGridSearcher3 &other)
Copy constructor.
jet::PointParallelHashGridSearcher3::sortedIndices
const std::vector< size_t > & sortedIndices() const
Returns the sorted indices of the points.
jet::PointParallelHashGridSearcher3::Builder::makeShared
PointParallelHashGridSearcher3Ptr makeShared() const
Builds shared pointer of PointParallelHashGridSearcher3 instance.
jet::PointParallelHashGridSearcher3::build
void build(const ConstArrayAccessor1< Vector3D > &points) override
Builds internal acceleration structure for given points list.