delete point event node from memory

This commit is contained in:
zzzzrrr 2010-04-23 09:51:33 -04:00
parent 2ce7776ec2
commit fe67bffee8
2 changed files with 12 additions and 10 deletions

View File

@ -87,7 +87,7 @@ Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
// Only need to check +epsilon since point never have smaller
// x value than node due to how we fetch nodes from the front
if (point.x <= node.point->x + EPSILON) {
Fill(tcx, node);
Fill(tcx, node, true);
}
//tcx.AddNode(new_node);
@ -187,7 +187,7 @@ Node& Sweep::NewFrontTriangle(SweepContext& tcx, Point& point, Node& node)
* @param tcx
* @param node - middle node, that is the bottom of the hole
*/
void Sweep::Fill(SweepContext& tcx, Node& node)
void Sweep::Fill(SweepContext& tcx, Node& node, bool point_event)
{
Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
@ -207,8 +207,10 @@ void Sweep::Fill(SweepContext& tcx, Node& node)
tcx.MapTriangleToNodes(*triangle);
}
// TODO: delete node from memory
//tcx.RemoveNode(node);
if(point_event) {
tcx.RemoveNode(&node);
}
}
/**
@ -226,7 +228,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
while (node->next) {
double angle = HoleAngle(*node);
if (angle > M_PI_2 || angle < -M_PI_2) break;
Fill(tcx, *node);
Fill(tcx, *node, false);
node = node->next;
}
@ -236,7 +238,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
while (node->prev) {
double angle = HoleAngle(*node);
if (angle > M_PI_2 || angle < -M_PI_2) break;
Fill(tcx, *node);
Fill(tcx, *node, false);
node = node->prev;
}
@ -523,7 +525,7 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
return;
}
Fill(tcx, *node);
Fill(tcx, *node, false);
if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) {
return;
@ -606,7 +608,7 @@ void Sweep::FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
{
Fill(tcx, *node.next);
Fill(tcx, *node.next, false);
if (node.next->point != edge->p) {
// Next above or below edge?
if (Orient2d(*edge->q, *node.next->point, *edge->p) == CCW) {
@ -686,7 +688,7 @@ void Sweep::FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
{
Fill(tcx, *node.prev);
Fill(tcx, *node.prev, false);
if (node.prev->point != edge->p) {
// Next above or below edge?
if (Orient2d(*edge->q, *node.prev->point, *edge->p) == CW) {

View File

@ -64,7 +64,7 @@ void EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Poin
Node& NewFrontTriangle(SweepContext& tcx, Point& point, Node& node);
void Fill(SweepContext& tcx, Node& node);
void Fill(SweepContext& tcx, Node& node, bool point_event);
bool Legalize(SweepContext& tcx, Triangle& t);