diff --git a/poly2tri/sweep/sweep.cc b/poly2tri/sweep/sweep.cc index 734526c..e6059fd 100644 --- a/poly2tri/sweep/sweep.cc +++ b/poly2tri/sweep/sweep.cc @@ -88,7 +88,7 @@ Node& Sweep::PointEvent(SweepContext& tcx, Point& point) // x value than node due to how we fetch nodes from the front if (point.x <= node.point->x + EPSILON) { Fill(tcx, node); - tcx.RemoveNode(&node); + delete &node; } //tcx.AddNode(new_node); @@ -535,19 +535,27 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node) if (o == CW) { return; } + Node *temp = node; node = node->next; + delete temp; } else if (node->next == tcx.basin.right_node) { Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point); if (o == CCW) { return; } + Node *temp = node; node = node->prev; + delete temp; } else { // Continue with the neighbor node with lowest Y value if (node->prev->point->y < node->next->point->y) { + Node *temp = node; node = node->prev; + delete temp; } else { + Node *temp = node; node = node->next; + delete temp; } } @@ -700,8 +708,9 @@ void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) } else{ // Next is convex } - } - } + } + } + } void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p) diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index e3ccef6..4da7323 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -130,7 +130,6 @@ void SweepContext::CreateAdvancingFront() head = new Node(*triangle->GetPoint(1), *triangle); middle = new Node(*triangle->GetPoint(0), *triangle); tail = new Node(*triangle->GetPoint(2)); - front_ = new AdvancingFront(*head, *tail); // TODO: More intuitive if head is middles next and not previous?