CubbyFlow::PointParallelHashGridSearcher< N > Class Template Referencefinal

Parallel version of hash grid-based N-D point searcher. More...

#include <Core/Searcher/PointParallelHashGridSearcher.hpp>

Inheritance diagram for CubbyFlow::PointParallelHashGridSearcher< N >:
CubbyFlow::PointNeighborSearcher< N > CubbyFlow::Serializable

Classes

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

Public Member Functions

 PointParallelHashGridSearcher (const Vector< size_t, N > &resolution, double gridSpacing)
 Constructs hash grid with given resolution and grid spacing. More...
 
 ~PointParallelHashGridSearcher () override=default
 Default virtual destructor. More...
 
 PointParallelHashGridSearcher (const PointParallelHashGridSearcher &other)
 Copy constructor. More...
 
 PointParallelHashGridSearcher (PointParallelHashGridSearcher &&other) noexcept
 Move constructor. More...
 
PointParallelHashGridSearcheroperator= (const PointParallelHashGridSearcher &other)
 Copy assignment operator. More...
 
PointParallelHashGridSearcheroperator= (PointParallelHashGridSearcher &&other) noexcept
 Move assignment operator. More...
 
void Build (const ConstArrayView1< Vector< double, N >> &points) override
 Builds internal acceleration structure for given points list. More...
 
void Build (const ConstArrayView1< Vector< double, N >> &points, double maxSearchRadius) override
 Builds internal acceleration structure for given points list and max search radius. More...
 
void ForEachNearbyPoint (const Vector< double, N > &origin, double radius, const ForEachNearbyPointFunc &callback) const override
 
bool HasNearbyPoint (const Vector< double, N > &origin, double radius) const override
 
ConstArrayView1< size_t > Keys () const
 Returns the hash key list. More...
 
ConstArrayView1< size_t > StartIndexTable () const
 Returns the start index table. More...
 
ConstArrayView1< size_t > EndIndexTable () const
 Returns the end index table. More...
 
ConstArrayView1< size_t > SortedIndices () const
 Returns the sorted indices of the points. More...
 
std::shared_ptr< PointNeighborSearcher< N > > Clone () const override
 Creates a new instance of the object with same properties than original. More...
 
void Set (const PointParallelHashGridSearcher &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 CubbyFlow::PointNeighborSearcher< N >
 PointNeighborSearcher ()=default
 Default constructor. More...
 
 ~PointNeighborSearcher () override=default
 Default virtual destructor. More...
 
 PointNeighborSearcher (const PointNeighborSearcher &other)=default
 Default copy constructor. More...
 
 PointNeighborSearcher (PointNeighborSearcher &&other) noexcept=default
 Default move constructor. More...
 
PointNeighborSearcheroperator= (const PointNeighborSearcher &other)=default
 Default copy assignment operator. More...
 
PointNeighborSearcheroperator= (PointNeighborSearcher &&other) noexcept=default
 Default move assignment operator. More...
 
virtual std::string TypeName () const =0
 Returns the type name of the derived class. More...
 
- Public Member Functions inherited from CubbyFlow::Serializable
 Serializable ()=default
 Default constructor. More...
 
 Serializable (const Serializable &)=default
 Default copy constructor. More...
 
 Serializable (Serializable &&) noexcept=default
 Default move constructor. More...
 
virtual ~Serializable ()=default
 Default virtual destructor. More...
 
Serializableoperator= (const Serializable &)=default
 Default copy assignment operator. More...
 
Serializableoperator= (Serializable &&) noexcept=default
 Default move assignment operator. More...
 

Static Public Member Functions

static Builder GetBuilder ()
 Returns builder fox PointParallelHashGridSearcher. More...
 

Friends

class PointParallelHashGridSearcherTests
 

Additional Inherited Members

- Public Types inherited from CubbyFlow::PointNeighborSearcher< N >
using ForEachNearbyPointFunc = std::function< void(size_t, const Vector< double, N > &)>
 

Detailed Description

template<size_t N>
class CubbyFlow::PointParallelHashGridSearcher< N >

Parallel version of hash grid-based N-D point searcher.

This class implements parallel version of N-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 N-D grid mapping.

Constructor & Destructor Documentation

◆ PointParallelHashGridSearcher() [1/3]

template<size_t N>
CubbyFlow::PointParallelHashGridSearcher< N >::PointParallelHashGridSearcher ( const Vector< size_t, N > &  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.

◆ ~PointParallelHashGridSearcher()

template<size_t N>
CubbyFlow::PointParallelHashGridSearcher< N >::~PointParallelHashGridSearcher ( )
overridedefault

Default virtual destructor.

◆ PointParallelHashGridSearcher() [2/3]

Copy constructor.

◆ PointParallelHashGridSearcher() [3/3]

Move constructor.

Member Function Documentation

◆ Build() [1/2]

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::Build ( const ConstArrayView1< Vector< double, N >> &  points)
overridevirtual

Builds internal acceleration structure for given points list.

This function builds the hash grid for given points in parallel.

Parameters
[in]pointsThe points to be added.

Reimplemented from CubbyFlow::PointNeighborSearcher< N >.

◆ Build() [2/2]

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::Build ( const ConstArrayView1< Vector< double, N >> &  points,
double  maxSearchRadius 
)
overridevirtual

Builds internal acceleration structure for given points list and max search radius.

This function builds the hash grid for given points in parallel.

Parameters
[in]pointsThe points to be added.
[in]maxSearchRadiusMax search radius.

Implements CubbyFlow::PointNeighborSearcher< N >.

◆ Clone()

template<size_t N>
std::shared_ptr<PointNeighborSearcher<N> > CubbyFlow::PointParallelHashGridSearcher< N >::Clone ( ) const
overridevirtual

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

Returns
Copy of this object.

Implements CubbyFlow::PointNeighborSearcher< N >.

◆ Deserialize()

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::Deserialize ( const std::vector< uint8_t > &  buffer)
overridevirtual

Deserializes the neighbor searcher from the buffer.

Implements CubbyFlow::Serializable.

◆ EndIndexTable()

template<size_t N>
ConstArrayView1<size_t> CubbyFlow::PointParallelHashGridSearcher< N >::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:

[5|8|8|10|10|10]

Then startIndexTable and endIndexTable should be like:

[.....|0|...|1|..|3|..]
[.....|1|...|3|..|6|..]
^5 ^8 ^10

So that endIndexTable[i] - startIndexTable[i] is the number points in i-th table bucket.

Returns
The end index table.

◆ ForEachNearbyPoint()

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::ForEachNearbyPoint ( const Vector< double, N > &  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 CubbyFlow::PointNeighborSearcher< N >.

◆ GetBuilder()

template<size_t N>
static Builder CubbyFlow::PointParallelHashGridSearcher< N >::GetBuilder ( )
static

Returns builder fox PointParallelHashGridSearcher.

◆ HasNearbyPoint()

template<size_t N>
bool CubbyFlow::PointParallelHashGridSearcher< N >::HasNearbyPoint ( const Vector< double, N > &  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 CubbyFlow::PointNeighborSearcher< N >.

◆ Keys()

template<size_t N>
ConstArrayView1<size_t> CubbyFlow::PointParallelHashGridSearcher< N >::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.

Returns
The hash key list.

◆ operator=() [1/2]

Copy assignment operator.

◆ operator=() [2/2]

template<size_t N>
PointParallelHashGridSearcher& CubbyFlow::PointParallelHashGridSearcher< N >::operator= ( PointParallelHashGridSearcher< N > &&  other)
noexcept

Move assignment operator.

◆ Serialize()

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::Serialize ( std::vector< uint8_t > *  buffer) const
overridevirtual

Serializes the neighbor searcher into the buffer.

Implements CubbyFlow::Serializable.

◆ Set()

template<size_t N>
void CubbyFlow::PointParallelHashGridSearcher< N >::Set ( const PointParallelHashGridSearcher< N > &  other)

Copy from the other instance.

◆ SortedIndices()

template<size_t N>
ConstArrayView1<size_t> CubbyFlow::PointParallelHashGridSearcher< N >::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.

Returns
The sorted indices of the points.

◆ StartIndexTable()

template<size_t N>
ConstArrayView1<size_t> CubbyFlow::PointParallelHashGridSearcher< N >::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:

[5|8|8|10|10|10]

Then startIndexTable and endIndexTable should be like:

[.....|0|...|1|..|3|..]
[.....|1|...|3|..|6|..]
^5 ^8 ^10

So that endIndexTable[i] - startIndexTable[i] is the number points in i-th table bucket.

Returns
The start index table.

Friends And Related Function Documentation

◆ PointParallelHashGridSearcherTests

template<size_t N>
friend class PointParallelHashGridSearcherTests
friend

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