Adaptagrams
|
#include <util.h>
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... | |
T | 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... | |
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.
|
inline |
Construct a NearbyObjectFinder that looks for objects within a given threshold.
[in] | threshold | The radius of the /open/ neighbourhoods in which to search. |
|
inline |
Add a new object, and say what its x,y-coords are.
[in] | x | the x-coordinate of the object |
[in] | y | the y-coordinate of the object |
[in] | obj | the object |
Referenced by dialect::Graph::buildUniqueBendPoints().
|
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.
[in] | x | target x-coord |
[in] | y | target y-coord |
References Avoid::Point::x, and Avoid::Point::y.
Referenced by dialect::Graph::buildUniqueBendPoints().