Jet  v1.3.3
Classes | Public Member Functions | Static Public Member Functions | List of all members
jet::PointHashGridSearcher2 Class Referencefinal

Hash grid-based 2-D point searcher. More...

#include <jet/point_hash_grid_searcher2.h>

Inheritance diagram for jet::PointHashGridSearcher2:
jet::PointNeighborSearcher2 jet::Serializable

Classes

class  Builder
 Front-end to create PointHashGridSearcher2 objects step by step. More...
 

Public Member Functions

 PointHashGridSearcher2 (const Size2 &resolution, double gridSpacing)
 Constructs hash grid with given resolution and grid spacing. More...
 
 PointHashGridSearcher2 (size_t resolutionX, size_t resolutionY, double gridSpacing)
 Constructs hash grid with given resolution and grid spacing. More...
 
 PointHashGridSearcher2 (const PointHashGridSearcher2 &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
 
void add (const Vector2D &point)
 Adds a single point to the hash grid. More...
 
const std::vector< std::vector< size_t > > & buckets () const
 Returns the internal bucket. 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...
 
PointHashGridSearcher2operator= (const PointHashGridSearcher2 &other)
 Assignment operator. More...
 
void set (const PointHashGridSearcher2 &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...
 
- Public Member Functions inherited from jet::PointNeighborSearcher2
 PointNeighborSearcher2 ()
 Default constructor. More...
 
virtual ~PointNeighborSearcher2 ()
 Destructor. More...
 
virtual std::string typeName () const =0
 Returns the type name of the derived class. More...
 
- Public Member Functions inherited from jet::Serializable
 Serializable ()=default
 
virtual ~Serializable ()=default
 

Static Public Member Functions

static Builder builder ()
 Returns builder fox PointHashGridSearcher2. More...
 

Additional Inherited Members

- Public Types inherited from jet::PointNeighborSearcher2
typedef std::function< void(size_t, const Vector2D &)> ForEachNearbyPointFunc
 

Detailed Description

Hash grid-based 2-D point searcher.

This class implements 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.

Constructor & Destructor Documentation

◆ PointHashGridSearcher2() [1/3]

jet::PointHashGridSearcher2::PointHashGridSearcher2 ( 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.

Parameters
[in]resolutionThe resolution.
[in]gridSpacingThe grid spacing.

◆ PointHashGridSearcher2() [2/3]

jet::PointHashGridSearcher2::PointHashGridSearcher2 ( 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.

Parameters
[in]resolutionXThe resolution x.
[in]resolutionYThe resolution y.
[in]gridSpacingThe grid spacing.

◆ PointHashGridSearcher2() [3/3]

jet::PointHashGridSearcher2::PointHashGridSearcher2 ( const PointHashGridSearcher2 other)

Copy constructor.

Member Function Documentation

◆ add()

void jet::PointHashGridSearcher2::add ( const Vector2D point)

Adds a single point to the hash grid.

This function adds a single point to the hash grid for future queries. It can be used for a hash grid that is already built by calling function PointHashGridSearcher2::build.

Parameters
[in]pointThe point to be added.

◆ buckets()

const std::vector<std::vector<size_t> >& jet::PointHashGridSearcher2::buckets ( ) const

Returns the internal bucket.

A bucket is a list of point indices that has same hash value. This function returns the (immutable) internal bucket structure.

Returns
List of buckets.

◆ build()

void jet::PointHashGridSearcher2::build ( const ConstArrayAccessor1< Vector2D > &  points)
overridevirtual

Builds internal acceleration structure for given points list.

Implements jet::PointNeighborSearcher2.

◆ builder()

static Builder jet::PointHashGridSearcher2::builder ( )
static

Returns builder fox PointHashGridSearcher2.

◆ clone()

PointNeighborSearcher2Ptr jet::PointHashGridSearcher2::clone ( ) const
overridevirtual

Creates a new instance of the object with same properties than original.

Returns
Copy of this object.

Implements jet::PointNeighborSearcher2.

◆ deserialize()

void jet::PointHashGridSearcher2::deserialize ( const std::vector< uint8_t > &  buffer)
overridevirtual

Deserializes the neighbor searcher from the buffer.

Implements jet::Serializable.

◆ forEachNearbyPoint()

void jet::PointHashGridSearcher2::forEachNearbyPoint ( const Vector2D origin,
double  radius,
const ForEachNearbyPointFunc callback 
) const
overridevirtual

Invokes the callback function for each nearby point around the origin within given radius.

Parameters
[in]originThe origin position.
[in]radiusThe search radius.
[in]callbackThe callback function.

Implements jet::PointNeighborSearcher2.

◆ getBucketIndex()

Point2I jet::PointHashGridSearcher2::getBucketIndex ( const Vector2D position) const

Gets the bucket index from a point.

Parameters
[in]positionThe position of the point.
Returns
The bucket index.

◆ getHashKeyFromBucketIndex()

size_t jet::PointHashGridSearcher2::getHashKeyFromBucketIndex ( const Point2I bucketIndex) const

Returns the hash value for given 2-D bucket index.

Parameters
[in]bucketIndexThe bucket index.
Returns
The hash key from bucket index.

◆ hasNearbyPoint()

bool jet::PointHashGridSearcher2::hasNearbyPoint ( const Vector2D origin,
double  radius 
) const
overridevirtual

Returns true if there are any nearby points for given origin within radius.

Parameters
[in]originThe origin.
[in]radiusThe radius.
Returns
True if has nearby point, false otherwise.

Implements jet::PointNeighborSearcher2.

◆ operator=()

PointHashGridSearcher2& jet::PointHashGridSearcher2::operator= ( const PointHashGridSearcher2 other)

Assignment operator.

◆ serialize()

void jet::PointHashGridSearcher2::serialize ( std::vector< uint8_t > *  buffer) const
overridevirtual

Serializes the neighbor searcher into the buffer.

Implements jet::Serializable.

◆ set()

void jet::PointHashGridSearcher2::set ( const PointHashGridSearcher2 other)

Copy from the other instance.


The documentation for this class was generated from the following file: