60 BSTNode* node = findBestLeaf(event, m_root);
63 node = insertNewLeaf(event, node);
89 if (m_utilities.newSiteToLeft(event, leftLeaf->
getEvent(), rightLeaf->
getEvent()))
92 node = findBestLeaf(event, node->getRightChild());
108 m_nodeVec.push_back(
BSTNode(event));
109 node = &m_nodeVec.back();
127 m_nodeVec.push_back(
BSTNode(event));
129 BSTNode* newLeaf = &m_nodeVec.back();
131 m_nodeVec.push_back(
BSTNode(*node));
133 BSTNode* leftLeaf = &m_nodeVec.back();
135 m_nodeVec.push_back(
BSTNode(event));
137 BSTNode* breakNode = &m_nodeVec.back();
139 m_nodeVec.push_back(
BSTNode(event));
141 BSTNode* topNode = &m_nodeVec.back();
153 else m_root = topNode;
220 if (node == sibling) sibling = nodeParent->
getLeftChild();
287 rebalance(grandParent);
300 countNodes(m_root, nodeCount);
309 countLeaves(m_root, leafCount);
323 std::cout <<
"****** Tree has one branch but not the other! *******" << std::endl;
387 const double tolerance(1.
e-5);
399 if (breakPoint + tolerance < lastBreakPointY)
401 std::cout <<
" #####>> Beach line check gets bad breakpoint, last: " << lastBreakPointY <<
", new: " << breakPoint <<
", roots: " << roots.first <<
"/" << roots.second << std::endl;
405 std::cout << std::endl;
411 std::cout << std::endl;
416 lastBreakPointY = breakPoint;
417 lastBreakPoint = node;
459 if (nBadCompares > 0) std::cout <<
"=======>> Beach line check resulted in " << nBadCompares <<
" bad compares of " << nBreakPoints <<
" break points checked, with " << nLeaves <<
" leaves" << std::endl;
511 std::cout <<
"****** Found a node which only one child: " << node <<
", L/R: " << node->
getLeftChild() <<
"/" << node->
getRightChild() << std::endl;
529 std::cout <<
" --> node depth: " << getTreeDepth(node) <<
", left/right: " << depthLeft <<
"/" << node->
getLeftChild()->
getDepth() <<
", " << depthRight <<
"/" << node->
getRightChild()->
getDepth() <<
", parent/depth " << node->
getParent() <<
"/" << getTreeDepth(node->
getParent()) << std::endl;
533 if (depthLeft - depthRight > 2) node = rotateWithLeftChild(node);
534 else if (depthRight - depthLeft > 2) node = rotateWithRightChild(node);
558 else m_root = newTopNode;
590 else m_root = newTopNode;
void checkBeachLine(double) const
BSTNode * rotateWithLeftChild(BSTNode *)
void setRightChild(BSTNode *node)
void setSuccessor(BSTNode *node)
BSTNode class definiton specifically for use in constructing Voronoi diagrams. We are trying to follo...
void rebalance(BSTNode *)
Tree balancing functions.
BSTNode * getParent() const
int getTreeDepth(const BSTNode *) const
This recovers the depth of longest branch in the tree below input node.
Represents the beachline implemented as a self balancing binary search tree.
BSTNode * findBestLeaf(const IEvent *event) const
BSTNode * getAssociated() const
BSTNode * insertNewLeaf(IEvent *)
void setLeftChild(BSTNode *node)
virtual double yPos() const =0
void setParent(BSTNode *node)
Allow setting of the points.
BSTNode * getRightChild() const
virtual void setBSTNode(BSTNode *)=0
int traverseBeachLeft(BSTNode *) const
BSTNode * removeLeaf(BSTNode *)
void setAssociated(BSTNode *node)
virtual bool isValid() const =0
int traverseBeachRight(BSTNode *) const
virtual double xPos() const =0
int getDepth() const
recover the data members
int traverseBeach() const
BSTNode * getPredecessor() const
BSTNode * rotateWithRightChild(BSTNode *)
std::pair< double, double > RootsPair
void setFace(dcel2d::Face *face)
void setPredecessor(BSTNode *node)
virtual void setInvalid() const =0
Interface for configuring the particular algorithm tool.
IEvent * getEvent() const
BSTNode * getSuccessor() const
BSTNode * getLeftChild() const
Event finding and building.
void setHalfEdge(dcel2d::HalfEdge *half)