Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

LinearQuadtreeBuilder.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 
37 namespace ogdf {
38 namespace fast_multipole_embedder {
39 
42 {
43 public:
45  explicit LinearQuadtreeBuilder(LinearQuadtree& treeRef) : tree(treeRef) { n = tree.numberOfPoints(); }
46 
48  void build();
49 
52 
55 
57  void prepareTree();
58 
61 
64 
66  void buildHierarchy();
67 
70  {
72  restoreChainLastNode = curr;
73  numInnerNodes++;
74  }
75 
77  {
78  if (tree.isLeaf(curr))
79  return;
80  else
81  {
82  restoreChain(tree.child(curr,0));
83  tree.setFirstPoint(curr, tree.firstPoint(tree.child(curr, 0)));
85  for (uint32_t i = 1; i < tree.numberOfChilds(curr); i++)
86  restoreChain(tree.child(curr, i));
87 
88  uint32_t lastPoint = tree.firstPoint(tree.child(curr, tree.numberOfChilds(curr)-1)) + tree.numberOfPoints(tree.child(curr, tree.numberOfChilds(curr)-1));
89  tree.setNumberOfPoints(curr, lastPoint - tree.firstPoint(curr));
90  }
91  }
92 
93  inline void restoreChain()
94  {
96  numInnerNodes = 0;
97  if (!tree.isLeaf(tree.root()))
101  }
102 
105  {
106  // 64 bit version
107 #if 0
108  // FIXME: a < 0 is always true (PointID is unsigned int)
109  if (a < 0) return 64;
110 #endif
111  if (b>=tree.numberOfPoints()) return 64;
112  uint32_t res = (32-((mostSignificantBit(tree.mortonNr(a) ^ tree.mortonNr(b)))/2));
113  return res;
114  }
115 
118 
121  uint32_t numInnerNodes;
122  uint32_t numLeaves;
123 
127 };
128 
129 }
130 }
void restorePushBackChain(LinearQuadtree::NodeID curr)
used by restore chain
uint32_t numberOfPoints(NodeID nodeID) const
returns the number of points contained in the subtree of node nodeID
void prepareTree()
prepares the node and leaf layer for the complete tree from 0 to n (excluding n)
NodeID root() const
returns the index of the root
Definition of utility functions for FME layout.
NodeID child(NodeID nodeID, uint32_t i) const
returns the i th child index of node nodeID
void setNextNode(NodeID nodeID, NodeID next)
void setFirstPoint(NodeID nodeID, PointID firstPoint)
uint32_t CAL(LinearQuadtree::PointID a, LinearQuadtree::PointID b)
returns the level of the first common ancestor of a and b
Declaration of class LinearQuadtree.
uint32_t mostSignificantBit(T n)
returns the index of the most signficant bit set. 0 = most signif, bitlength-1 = least signif ...
Definition: FastUtils.h:165
void prepareNodeAndLeaf(LinearQuadtree::PointID leafPos, LinearQuadtree::PointID nextLeafPos)
prepares the node and leaf layer at position leafPos where nextLeafPos is the next position ...
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 ...
LinearQuadtreeBuilder(LinearQuadtree &treeRef)
constructor
void setNumberOfPoints(NodeID nodeID, uint32_t numPoints)
sets the number of nodes containted in node nodeID
bool isLeaf(NodeID nodeID) const
returns true if the given node index is a leaf
The namespace for all OGDF objects.
MortonNR mortonNr(PointID point) const
void mergeWithNext(LinearQuadtree::NodeID curr)
merges the node curr with curr&#39;s next node by appending the next nodes children to curr except the fi...
void buildHierarchy()
the main function for the new link-only recursive builder