35 namespace energybased {
39 template<
typename IntType,
int Dim>
69 IntType mortonNr[Dim];
75 return mortonComparerLess<IntType, Dim>(mortonNr, other.
mortonNr);
81 return mortonComparerEqual<IntType, Dim>(mortonNr, other.
mortonNr);
116 void setPoint(
int i,
int d, IntType value);
177 template<
typename IntType,
int Dim>
188 template<
typename IntType,
int Dim>
196 template<
typename IntType,
int Dim>
204 template<
typename IntType,
int Dim>
218 template<
typename IntType,
int Dim>
227 template<
typename IntType,
int Dim>
237 Node& leaf = leafLayer[i];
238 Node& innerNode = innerLayer[i];
243 while ((j < m_numPoints) &&
255 if (j < m_numPoints) {
262 innerNode.
child[0] = i;
263 innerNode.
child[1] = j;
266 innerNode.
next = m_numPoints + j;
269 innerLayer[i].
next = 0;
279 innerLayer[last].
next = 0;
284 template<
typename IntType,
int Dim>
298 template<
typename IntType,
int Dim>
312 template<
typename IntType,
int Dim>
316 while (
node(curr).next && (
node(
node(curr).next).level < maxLevel)) {
320 if (
node(curr).level ==
node(next).level) {
323 if (
node(curr).level <
node(next).level) {
347 template<
typename IntType,
int Dim>
354 template<
typename IntType,
int Dim>
370 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.
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.