Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
LinearQuadtreeBuilder.h
Go to the documentation of this file.
1
32#pragma once
33
36
37#include <cstdint>
38
39namespace ogdf {
40namespace fast_multipole_embedder {
41
44public:
47 : firstInner(0)
48 , firstLeaf(0)
49 , lastInner(0)
50 , lastLeaf(0)
51 , numInnerNodes(0)
52 , numLeaves(0)
53 , tree(treeRef)
56 }
57
59 void build();
60
63
66
69
72
75
78
83 } else {
84 firstInner = curr;
85 }
88 }
89
91 if (tree.isLeaf(curr)) {
92 return;
93 } else {
94 restoreChain(tree.child(curr, 0));
95 tree.setFirstPoint(curr, tree.firstPoint(tree.child(curr, 0)));
97 for (uint32_t i = 1; i < tree.numberOfChilds(curr); i++) {
98 restoreChain(tree.child(curr, i));
99 }
100
101 uint32_t lastPoint = tree.firstPoint(tree.child(curr, tree.numberOfChilds(curr) - 1))
102 + tree.numberOfPoints(tree.child(curr, tree.numberOfChilds(curr) - 1));
103 tree.setNumberOfPoints(curr, lastPoint - tree.firstPoint(curr));
104 }
105 }
106
107 inline void restoreChain() {
109 numInnerNodes = 0;
110 if (!tree.isLeaf(tree.root())) {
112 }
115 }
116 }
117
120 // 64 bit version
121#if 0
122 // FIXME: a < 0 is always true (PointID is unsigned int)
123 if (a < 0) return 64;
124#endif
125 if (b >= tree.numberOfPoints()) {
126 return 64;
127 }
128 uint32_t res = (32 - ((mostSignificantBit(tree.mortonNr(a) ^ tree.mortonNr(b))) / 2));
129 return res;
130 }
131
134
138 uint32_t numLeaves;
139
143};
144
145}
146}
Definition of utility functions for FME layout.
Declaration of class LinearQuadtree.
uint32_t CAL(LinearQuadtree::PointID a, LinearQuadtree::PointID b)
returns the level of the first common ancestor of a and b
void mergeWithNext(LinearQuadtree::NodeID curr)
merges the node curr with curr's next node by appending the next nodes children to curr except the fi...
void restorePushBackChain(LinearQuadtree::NodeID curr)
used by restore chain
LinearQuadtree::NodeID buildHierarchy(LinearQuadtree::NodeID curr, uint32_t maxLevel)
the new link-only recursive builder
LinearQuadtreeBuilder(LinearQuadtree &treeRef)
constructor
void prepareTree(LinearQuadtree::PointID begin, LinearQuadtree::PointID end)
prepares the node and leaf layer from position begin until end (excluding end)
void prepareTree()
prepares the node and leaf layer for the complete tree from 0 to n (excluding n)
void prepareNodeAndLeaf(LinearQuadtree::PointID leafPos, LinearQuadtree::PointID nextLeafPos)
prepares the node and leaf layer at position leafPos where nextLeafPos is the next position
void buildHierarchy()
the main function for the new link-only recursive builder
void setFirstPoint(NodeID nodeID, PointID firstPoint)
uint32_t numberOfChilds(NodeID nodeID) const
returns the number of children of node nodeID. for an inner node this is 1..4 and can be accessed by ...
NodeID child(NodeID nodeID, uint32_t i) const
returns the i th child index of node nodeID
void setNumberOfPoints(NodeID nodeID, uint32_t numPoints)
sets the number of nodes containted in node nodeID
NodeID root() const
returns the index of the root
bool isLeaf(NodeID nodeID) const
returns true if the given node index is a leaf
void setNextNode(NodeID nodeID, NodeID next)
uint32_t numberOfPoints(NodeID nodeID) const
returns the number of points contained in the subtree of node nodeID
uint32_t mostSignificantBit(T n)
returns the index of the most signficant bit set. 0 = most signif, bitlength-1 = least signif
Definition FastUtils.h:174
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)