35 namespace energybased {
89 void setPoint(
int i,
int d,
double coord);
95 void computeWSPD(
IWSPD* m_pIWSPD);
110 void updateBoundingBox();
113 void updateTreeGridPoints();
116 void updateTreeNodeGeometry();
119 void updateTreeNodeGeometry(
int curr);
122 void wspdRecursive(
int a);
125 void wspdRecursive(
int a,
int b);
128 bool areWellSeparated(
int a,
int b)
const;
155 double m_bboxMin[Dim];
158 double m_bboxMax[Dim];
164 : m_numPoints(numPoints)
165 , m_wspdSeparationFactor(1.0)
166 , m_wspdSeparationFactorPlus2Squared_cached(9.0)
172 for (
int i = 0; i < Dim; i++) {
269 if (
node(small_node).radius_sq >
node(large_node).radius_sq) {
270 std::swap(small_node, large_node);
285 double r_max_sq = std::max(
node(a).radius_sq,
node(b).radius_sq);
288 double dist_sq = 0.0;
291 for (
int d = 0; d < Dim; d++) {
307 return dist_sq > s * s * r_max_sq;
318 double r_max_sq = std::max(
node(a).radius_sq,
node(b).radius_sq);
323 double dist_sq = dx_0 * dx_0 + dx_1 * dx_1;
333 double r_max_sq = std::max(
node(a).radius_sq,
node(b).radius_sq);
339 double dist_sq = dx_0 * dx_0 + dx_1 * dx_1 + dx_2 * dx_2;
360 for (
int d = 0; d < Dim; d++) {
366 for (
int d = 0; d < Dim; d++) {
377 for (
int d = 0; d < Dim; d++) {
384 for (
int d = 1; d < Dim; d++) {
385 quad_size = std::max(quad_size,
m_bboxMax[d] - m_bboxMin[d]);
388 const double factor = (double)(0xffffffff);
390 double scale = factor / quad_size;
393 for (
int d = 0; d < Dim; d++) {
396 double nx = ((
point(i).
x[d] - m_bboxMin[d] + 0.01) / quad_size + 0.02);
398 double nx = ((
point(i).
x[d] - m_bboxMin[d]) * scale);
401 unsigned int ix =
static_cast<unsigned int>(nx);
433 for (
int d = 0; d < Dim; d++) {
438 for (
int d = 0; d < Dim; d++) {
446 for (
int d = 0; d < Dim; d++) {
452 for (
int d = 0; d < Dim; d++) {
463 for (
int d = 0; d < Dim; d++) {
const Tree & tree() const
returns the corresponding Dtree
int numPoints(int i) const
returns the number of points covered by this subtree
void allocate()
allocate mem
void updateBoundingBox()
updates the bounding box by iterating over all points
void updateTreeNodeGeometry()
updates the geometry of the quadtree nodes
Implentation of the reduced quadtree for Dim dimensions.
double x[Dim]
center of cell circle
void updateTreeGridPoints()
updates the integer grid points in the quadtree
void wspdRecursive(int a)
the unary recursive function generating the binary calls
int m_numPoints
number of points
double x[Dim]
coords of the point
void setSeparationFactor(double s)
sets the parameter s of the WSPD (default is 1.0)
NodeData * m_nodeData
geometry for the quadtree nodes
int child(int i, int j) const
returns the index of the j th child of node i
void setPoint(int i, int d, IntType value)
sets the point to the given grid coords
world coordinates of the points
int numChilds(int i) const
returns the number of children of node i
double m_bboxMin[Dim]
the bounding box min coord of the point set
PointData * m_pointData
point data
void build()
Does all required steps except the allocate, deallocate, randomPoints.
const NodeData & node(int i) const
returns the data for a quadtree
void update()
call this when the point set has been updated.
double min_x[Dim]
bounding box min coord
double m_wspdSeparationFactor
the separation factor for the ws predicate
double m_wspdSeparationFactorPlus2Squared_cached
a cached value for the ws test
double randomDouble(double low, double high)
Returns a random double value from the interval [low, high).
double m_bboxMax[Dim]
the bounding box max coord of the point set
DTree< IntType, Dim > Tree
void setPoint(int i, int d, double coord)
sets the point to the given coords
int rootIndex() const
returns the index of the root node
double max_x[Dim]
bounding box min coord
void computeWSPD(IWSPD *m_pIWSPD)
double radius_sq
radius of the cell
int maxNumNodes() const
returns the maximum number of nodes (and the max index of a node)
double separationFactor() const
returns the parameter s of the WSPD (default is 1.0)
Basic declarations, included by all source files.
void deallocate()
free mem
geometry for the quadtree nodes
bool areWellSeparated(int a, int b) const
predicate for determining if cells are well-separated
The namespace for all OGDF objects.
NodeData & node(int i)
returns the data for a quadtree
virtual void onWellSeparatedPair(int aIndex, int bIndex)=0
called by the WSPD for a pair that is well separated
Tree * m_pTree
the quadtree this wspd is working on
const PointData & point(int i) const
return ith point
DTreeWSPD(int numPoints)
constructs a new WSPD for numPoints