Jet
v1.3.3
|
Parallel version of hash grid-based 2-D point searcher. More...
#include <jet/point_parallel_hash_grid_searcher2.h>
Classes | |
class | Builder |
Front-end to create PointParallelHashGridSearcher2 objects step by step. More... | |
Public Member Functions | |
PointParallelHashGridSearcher2 (const Size2 &resolution, double gridSpacing) | |
Constructs hash grid with given resolution and grid spacing. More... | |
PointParallelHashGridSearcher2 (size_t resolutionX, size_t resolutionY, double gridSpacing) | |
Constructs hash grid with given resolution and grid spacing. More... | |
PointParallelHashGridSearcher2 (const PointParallelHashGridSearcher2 &other) | |
Copy constructor. More... | |
void | build (const ConstArrayAccessor1< Vector2D > &points) override |
Builds internal acceleration structure for given points list. More... | |
void | forEachNearbyPoint (const Vector2D &origin, double radius, const ForEachNearbyPointFunc &callback) const override |
bool | hasNearbyPoint (const Vector2D &origin, double radius) const override |
const std::vector< size_t > & | keys () const |
Returns the hash key list. More... | |
const std::vector< size_t > & | startIndexTable () const |
Returns the start index table. More... | |
const std::vector< size_t > & | endIndexTable () const |
Returns the end index table. More... | |
const std::vector< size_t > & | sortedIndices () const |
Returns the sorted indices of the points. More... | |
size_t | getHashKeyFromBucketIndex (const Point2I &bucketIndex) const |
Point2I | getBucketIndex (const Vector2D &position) const |
PointNeighborSearcher2Ptr | clone () const override |
Creates a new instance of the object with same properties than original. More... | |
PointParallelHashGridSearcher2 & | operator= (const PointParallelHashGridSearcher2 &other) |
Assignment operator. More... | |
void | set (const PointParallelHashGridSearcher2 &other) |
Copy from the other instance. More... | |
void | serialize (std::vector< uint8_t > *buffer) const override |
Serializes the neighbor searcher into the buffer. More... | |
void | deserialize (const std::vector< uint8_t > &buffer) override |
Deserializes the neighbor searcher from the buffer. More... | |
![]() | |
PointNeighborSearcher2 () | |
Default constructor. More... | |
virtual | ~PointNeighborSearcher2 () |
Destructor. More... | |
virtual std::string | typeName () const =0 |
Returns the type name of the derived class. More... | |
![]() | |
Serializable ()=default | |
virtual | ~Serializable ()=default |
Static Public Member Functions | |
static Builder | builder () |
Returns builder fox PointParallelHashGridSearcher2. More... | |
Friends | |
class | PointParallelHashGridSearcher2Tests |
Additional Inherited Members | |
![]() | |
typedef std::function< void(size_t, const Vector2D &)> | ForEachNearbyPointFunc |
Parallel version of hash grid-based 2-D point searcher.
This class implements parallel version of 2-D point searcher by using hash grid for its internal acceleration data structure. Each point is recorded to its corresponding bucket where the hashing function is 2-D grid mapping.
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2 | ( | const Size2 & | resolution, |
double | gridSpacing | ||
) |
Constructs hash grid with given resolution and grid spacing.
This constructor takes hash grid resolution and its grid spacing as its input parameters. The grid spacing must be 2x or greater than search radius.
[in] | resolution | The resolution. |
[in] | gridSpacing | The grid spacing. |
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2 | ( | size_t | resolutionX, |
size_t | resolutionY, | ||
double | gridSpacing | ||
) |
Constructs hash grid with given resolution and grid spacing.
This constructor takes hash grid resolution and its grid spacing as its input parameters. The grid spacing must be 2x or greater than search radius.
[in] | resolutionX | The resolution x. |
[in] | resolutionY | The resolution y. |
[in] | gridSpacing | The grid spacing. |
jet::PointParallelHashGridSearcher2::PointParallelHashGridSearcher2 | ( | const PointParallelHashGridSearcher2 & | other | ) |
Copy constructor.
|
overridevirtual |
Builds internal acceleration structure for given points list.
This function builds the hash grid for given points in parallel.
[in] | points | The points to be added. |
Implements jet::PointNeighborSearcher2.
|
static |
Returns builder fox PointParallelHashGridSearcher2.
|
overridevirtual |
Creates a new instance of the object with same properties than original.
Implements jet::PointNeighborSearcher2.
|
overridevirtual |
Deserializes the neighbor searcher from the buffer.
Implements jet::Serializable.
const std::vector<size_t>& jet::PointParallelHashGridSearcher2::endIndexTable | ( | ) | const |
Returns the end index table.
The end index table maps the hash grid bucket index to starting index of the sorted point list. Assume the hash key list looks like:
Then startIndexTable and endIndexTable should be like:
So that endIndexTable[i] - startIndexTable[i] is the number points in i-th table bucket.
|
overridevirtual |
Invokes the callback function for each nearby point around the origin within given radius.
[in] | origin | The origin position. |
[in] | radius | The search radius. |
[in] | callback | The callback function. |
Implements jet::PointNeighborSearcher2.
Gets the bucket index from a point.
[in] | position | The position of the point. |
size_t jet::PointParallelHashGridSearcher2::getHashKeyFromBucketIndex | ( | const Point2I & | bucketIndex | ) | const |
Returns the hash value for given 2-D bucket index.
[in] | bucketIndex | The bucket index. |
|
overridevirtual |
Returns true if there are any nearby points for given origin within radius.
[in] | origin | The origin. |
[in] | radius | The radius. |
Implements jet::PointNeighborSearcher2.
const std::vector<size_t>& jet::PointParallelHashGridSearcher2::keys | ( | ) | const |
Returns the hash key list.
The hash key list maps sorted point index i to its hash key value. The sorting order is based on the key value itself.
PointParallelHashGridSearcher2& jet::PointParallelHashGridSearcher2::operator= | ( | const PointParallelHashGridSearcher2 & | other | ) |
Assignment operator.
|
overridevirtual |
Serializes the neighbor searcher into the buffer.
Implements jet::Serializable.
void jet::PointParallelHashGridSearcher2::set | ( | const PointParallelHashGridSearcher2 & | other | ) |
Copy from the other instance.
const std::vector<size_t>& jet::PointParallelHashGridSearcher2::sortedIndices | ( | ) | const |
Returns the sorted indices of the points.
When the hash grid is built, it sorts the points in hash key order. But rather than sorting the original points, this class keeps the shuffled indices of the points. The list this function returns maps sorted index i to original index j.
const std::vector<size_t>& jet::PointParallelHashGridSearcher2::startIndexTable | ( | ) | const |
Returns the start index table.
The start index table maps the hash grid bucket index to starting index of the sorted point list. Assume the hash key list looks like:
Then startIndexTable and endIndexTable should be like:
So that endIndexTable[i] - startIndexTable[i] is the number points in i-th table bucket.
|
friend |