Allolib  1.0
C++ Components For Interactive Multimedia
al::HashSpace::Query Struct Reference

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/spatial/al_HashSpace.hpp>

Classes

struct  Result
 

Public Types

typedef std::vector< ResultResults
 
typedef Results::iterator Iterator
 

Public Member Functions

 Query (uint32_t maxResults=128)
 
int operator() (const HashSpace &space, const Vec3d center, double maxRadius, double minRadius=0.)
 
int operator() (const HashSpace &space, const Object *obj, double maxRadius, double minRadius=0.)
 
int operator() (const HashSpace &space, Vec3d center)
 
int operator() (const HashSpace &space, const Object *obj)
 
Objectnearest (const HashSpace &space, const Object *obj)
 
unsigned size () const
 get number of results:
 
Objectoperator[] (unsigned i) const
 get each result:
 
double distanceSquared (unsigned i) const
 
double distance (unsigned i) const
 
Queryclear ()
 
QuerymaxResults (uint32_t i)
 set the maximum number of desired results
 
uint32_t maxResults () const
 get the maximum number of desired results
 
Iterator begin ()
 std::vector interface:
 
Iterator end ()
 
Results & results ()
 

Protected Attributes

uint32_t mMaxResults
 
Results mObjects
 

Detailed Description

Query functor
create and re-use a query functor to find neighbors
Query query;
query.clear(); // do this if you want to re-use the query object
query(space, Vec3d(0, 0, 0), 10);
for (int i=0; i<query.size(); i++) {
Object * o = query[i];
...
}
Vec< 3, double > Vec3d
double 3-vector
Definition: al_Vec.hpp:60
Query(uint32_t maxResults=128)

Definition at line 121 of file al_HashSpace.hpp.

Constructor & Destructor Documentation

◆ Query()

al::HashSpace::Query::Query ( uint32_t  maxResults = 128)
inline

Constructor

Parameters
maxResultsthe maximum number of results to find

Definition at line 142 of file al_HashSpace.hpp.

Member Function Documentation

◆ clear()

Query& al::HashSpace::Query::clear ( )
inline

clear is separated from the main query operation, to support aggregating queries in series typically however you would want to clear() and then call the query.

Definition at line 194 of file al_HashSpace.hpp.

◆ nearest()

HashSpace::Object * al::HashSpace::Query::nearest ( const HashSpace space,
const Object obj 
)
inline

finds nearest neighbor of an object

Definition at line 464 of file al_HashSpace.hpp.

◆ operator()() [1/2]

int al::HashSpace::Query::operator() ( const HashSpace space,
const Vec3d  center,
double  maxRadius,
double  minRadius = 0. 
)
inline

The main method of the query object finds the neighbors of a given point, within given distances the matches will be roughly (not exactly) sorted by distance

Parameters
spacethe HashSpace object to search in
centerfinds objects near to this point
objfinds objects near to this object
maxRadiusfinds objects if they are nearer this distance the maximum permissible value of radius is space.maxRadius()
minRadiusfinds objects if they are beyond this distance
Returns
the number of results found

Definition at line 374 of file al_HashSpace.hpp.

◆ operator()() [2/2]

int al::HashSpace::Query::operator() ( const HashSpace space,
Vec3d  center 
)
inline

finds all the neighbors of the given point, up to maxResults() the matches will be roughly (not exactly) sorted by distance

Parameters
spacethe HashSpace object to search in
centerfinds objects near to this point
objfinds objects near to this object

Definition at line 362 of file al_HashSpace.hpp.


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