35 namespace energybased {
39 template<
typename IntType,
int Dim>
71 IntType mortonNr[Dim];
77 return mortonComparerLess<IntType, Dim>(mortonNr, other.
mortonNr);
83 return mortonComparerEqual<IntType, Dim>(mortonNr, other.
mortonNr);
118 void setPoint(
int i,
int d, IntType value);
179 template<
typename IntType,
int Dim>
190 template<
typename IntType,
int Dim>
198 template<
typename IntType,
int Dim>
206 template<
typename IntType,
int Dim>
220 template<
typename IntType,
int Dim>
229 template<
typename IntType,
int Dim>
239 Node& leaf = leafLayer[i];
240 Node& innerNode = innerLayer[i];
245 while ((j < m_numPoints) &&
257 if (j < m_numPoints) {
264 innerNode.
child[0] = i;
265 innerNode.
child[1] = j;
268 innerNode.
next = m_numPoints + j;
271 innerLayer[i].
next = 0;
281 innerLayer[last].
next = 0;
286 template<
typename IntType,
int Dim>
300 template<
typename IntType,
int Dim>
314 template<
typename IntType,
int Dim>
318 while (
node(curr).next &&
node(
node(curr).next).level < maxLevel) {
322 if (
node(curr).level ==
node(next).level) {
325 if (
node(curr).level <
node(next).level) {
349 template<
typename IntType,
int Dim>
356 template<
typename IntType,
int Dim>
372 template<
typename IntType,
int Dim>
MortonEntry * m_mortonOrder
The order to be sorted.
int child[MaxNumChildrenPerNode]
index of the children
int countPoints() const
Just for fun: traverse the tree and count the points in the leaves.
void prepareMortonOrder()
Prepares the morton numbers for sorting.
int numPoints(int i) const
returns the number of points covered by this subtree
int level
the level of the node in a complete quadtree
void adjustPointInfo(int curr)
used to update the first and numPoints of inner nodes by linkNodes
Implentation of the reduced quadtree for Dim dimensions.
int ref
index in the original point order
Point * m_points
The input set.
void allocate(int n)
Allocates memory for n points.
int numChilds
number of children
int numPoints() const
returns the number of points the quadtree contains
void linkNodes()
The Recursive Bottom-Up Construction (recursion start)
The entry in the sorted order for a point.
DTree(int numPoints)
constructor
Node * m_nodes
Memory for all 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
void sort(T *array, int size, LessThan lt)
Node & node(int i)
Just to access the nodes a little bit easier.
int numChilds(int i) const
returns the number of children of node i
void deallocate()
Releases memory.
void mergeWithNext(int curr)
Merges curr with next node in the chain (used by linkNodes)
void build()
Does all required steps except the allocate, deallocate, randomPoints.
void prepareNodeLayer()
Prepares both the leaf and inner node layer.
int point(int i, int j) const
returns the index of the jth point covered by i's subtree.
int firstPoint
the first point in the sorted order covered by this subtree
int rootIndex() const
returns the index of the root node
int numPoints
the number of points covered by this subtree
int maxNumNodes() const
returns the maximum number of nodes (and the max index of a node)
const Point & point(int i) const
returns the ith point in the input sequence
int m_numPoints
Total number of points.
int next
the next node on the same layer (leaf or inner node layer)
bool operator==(const MortonEntry &other) const
equal comparer for the construction algorithm
void sortMortonNumbers()
Sorts the points by morton number.
The namespace for all OGDF objects.
bool operator<(const MortonEntry &other) const
less comparator for sort
static constexpr int MaxNumChildrenPerNode
the maximum number of children per node = 2^d
int m_rootIndex
The index of the root node.
Container::value_type sum(const Container &values)
Returns the sum of an iterable container of given values.
const Node & node(int i) const
Just to access the nodes a little bit easier.
IntType mortonNr[Dim]
the morton number of the point
The point class with integer coords.