58 BSTNode* node = findBestLeaf(event, m_root);
61 node = insertNewLeaf(event, node);
86 if (m_utilities.newSiteToLeft(event, leftLeaf->
getEvent(), rightLeaf->
getEvent()))
89 node = findBestLeaf(event, node->getRightChild());
104 m_nodeVec.push_back(
BSTNode(event));
105 node = &m_nodeVec.back();
122 m_nodeVec.push_back(
BSTNode(event));
124 BSTNode* newLeaf = &m_nodeVec.back();
126 m_nodeVec.push_back(
BSTNode(*node));
128 BSTNode* leftLeaf = &m_nodeVec.back();
133 BSTNode* breakNode = &m_nodeVec.back();
138 BSTNode* topNode = &m_nodeVec.back();
199 checkBeachLine(newLeaf->
getEvent()->
xPos() - 0.00000001);
218 if (node == sibling) sibling = nodeParent->
getLeftChild();
283 rebalance(grandParent);
296 countNodes(m_root, nodeCount);
305 countLeaves(m_root, leafCount);
317 std::cout <<
"****** Tree has one branch but not the other! *******" << std::endl;
375 double lastBreakPointY = -std::numeric_limits<double>::max();
382 const double tolerance(1.
e-5);
390 double breakPoint = m_utilities.computeBreak(
393 if (breakPoint + tolerance < lastBreakPointY) {
394 std::cout <<
" #####>> Beach line check gets bad breakpoint, last: " << lastBreakPointY
395 <<
", new: " << breakPoint <<
", roots: " << roots.first <<
"/" << roots.second
397 std::cout <<
" Current left arc x,y: " 403 std::cout <<
", left: " 406 std::cout <<
", right: " 408 std::cout << std::endl;
409 if (lastBreakPoint) {
410 std::cout <<
" Previous left arc x,y: " 416 std::cout <<
", left: " 419 std::cout <<
", right: " 421 std::cout << std::endl;
426 lastBreakPointY = breakPoint;
427 lastBreakPoint = node;
442 std::cout <<
" --> Successor tree/beach mismatch, leaf # " << nLeaves
443 <<
", node: " << node <<
", " << node->
getEvent()->
xPos() <<
"/" 446 std::cout <<
" temp: " << temp <<
", " << temp->
getEvent()->
xPos() <<
"/" 462 std::cout <<
" --> Predecessor tree/beach mismatch, leaf # " << nLeaves
463 <<
", node: " << node <<
", " << node->
getEvent()->
xPos() <<
"/" 466 std::cout <<
" temp: " << temp <<
", " << temp->
getEvent()->
xPos() <<
"/" 480 if (nBadCompares > 0)
481 std::cout <<
"=======>> Beach line check resulted in " << nBadCompares <<
" bad compares of " 482 << nBreakPoints <<
" break points checked, with " << nLeaves <<
" leaves" 531 std::cout <<
"****** Found a node which only one child: " << node
549 std::cout <<
" --> node depth: " << getTreeDepth(node)
552 <<
", parent/depth " << node->
getParent() <<
"/" 553 << getTreeDepth(node->
getParent()) << std::endl;
557 if (depthLeft - depthRight > 2)
558 node = rotateWithLeftChild(node);
559 else if (depthRight - depthLeft > 2)
560 node = rotateWithRightChild(node);
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
std::pair< double, double > RootsPair
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 *)
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)