Adaptagrams
Public Member Functions | List of all members
dialect::NearbyObjectFinder< T > Class Template Reference

#include <util.h>

Collaboration diagram for dialect::NearbyObjectFinder< T >:
Collaboration graph

Public Member Functions

 NearbyObjectFinder (double threshold)
 Construct a NearbyObjectFinder that looks for objects within a given threshold. More...
 
void addObject (double x, double y, T obj)
 Add a new object, and say what its x,y-coords are. More...
 
findObject (double x, double y)
 Check to see if any object has been stored yet in the open neighbourhood centred at the given coordinates, and with radius equal to the threshold. If so, return it. Otherwise return a value-initialized object of type T. More...
 

Detailed Description

template<typename T>
class dialect::NearbyObjectFinder< T >

Suppose you are working with some objects A1, A2, ... each of which has a point (x, y) associated with it. For each new object Ai, you want to check whether there is already another object Aj whose coordinates are almost the same, within a given threshold.

A NearbyObjectFinder can be used for this problem. Construct it with the desired threshold. Before adding any new object to it, use its 'findObject' method to see whether it already has an object with both x and y within the threshold of the x and y for the new object. If not, then add the object using the 'addObject' method.

Note: a NearbyObjectFinder looks for objects in the /open/ neighbourhood of a given point, with radius equal to the threshold.

Constructor & Destructor Documentation

◆ NearbyObjectFinder()

template<typename T>
dialect::NearbyObjectFinder< T >::NearbyObjectFinder ( double  threshold)
inline

Construct a NearbyObjectFinder that looks for objects within a given threshold.

Parameters
[in]thresholdThe radius of the /open/ neighbourhoods in which to search.

Member Function Documentation

◆ addObject()

template<typename T>
void dialect::NearbyObjectFinder< T >::addObject ( double  x,
double  y,
obj 
)
inline

Add a new object, and say what its x,y-coords are.

Parameters
[in]xthe x-coordinate of the object
[in]ythe y-coordinate of the object
[in]objthe object

Referenced by dialect::Graph::buildUniqueBendPoints().

Here is the caller graph for this function:

◆ findObject()

template<typename T>
T dialect::NearbyObjectFinder< T >::findObject ( double  x,
double  y 
)
inline

Check to see if any object has been stored yet in the open neighbourhood centred at the given coordinates, and with radius equal to the threshold. If so, return it. Otherwise return a value-initialized object of type T.

Parameters
[in]xtarget x-coord
[in]ytarget y-coord
Returns
copy of object stored under nearby coords, or value-initialised object of type T if none present.

References Avoid::Point::x, and Avoid::Point::y.

Referenced by dialect::Graph::buildUniqueBendPoints().

Here is the caller graph for this function:

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