From bab616f9eaa2b4d31683a3545f417393ec770bc0 Mon Sep 17 00:00:00 2001 From: zzzzrrr Date: Fri, 23 Apr 2010 13:11:13 -0400 Subject: [PATCH] general cleanup --- poly2tri/sweep/sweep.cc | 3 +-- poly2tri/sweep/sweep_context.cc | 7 ++++++- poly2tri/sweep/sweep_context.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/poly2tri/sweep/sweep.cc b/poly2tri/sweep/sweep.cc index 6add81f..4cea046 100644 --- a/poly2tri/sweep/sweep.cc +++ b/poly2tri/sweep/sweep.cc @@ -32,7 +32,6 @@ #include "sweep_context.h" #include "advancing_front.h" #include "../common/utils.h" -#include namespace p2t { @@ -40,7 +39,7 @@ namespace p2t { void Sweep::Triangulate(SweepContext& tcx) { tcx.InitTriangulation(); - tcx.CreateAdvancingFront(); + tcx.CreateAdvancingFront(nodes_); // Sweep points; build mesh SweepPoints(tcx); // Clean up diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index 4da7323..184ebb0 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -119,7 +119,7 @@ Node& SweepContext::LocateNode(Point& point) return *front_->LocateNode(point.x); } -void SweepContext::CreateAdvancingFront() +void SweepContext::CreateAdvancingFront(std::vector nodes) { Node *head, *middle, *tail; // Initial triangle @@ -132,6 +132,11 @@ void SweepContext::CreateAdvancingFront() tail = new Node(*triangle->GetPoint(2)); front_ = new AdvancingFront(*head, *tail); + // Memory management :) + nodes.push_back(head); + nodes.push_back(middle); + nodes.push_back(tail); + // TODO: More intuitive if head is middles next and not previous? // so swap head and tail head->next = middle; diff --git a/poly2tri/sweep/sweep_context.h b/poly2tri/sweep/sweep_context.h index b70e853..fcc7a3d 100644 --- a/poly2tri/sweep/sweep_context.h +++ b/poly2tri/sweep/sweep_context.h @@ -69,7 +69,7 @@ Node& LocateNode(Point& point); void RemoveNode(Node* node); -void CreateAdvancingFront(); +void CreateAdvancingFront(std::vector nodes); /// Try to map a node to all sides of this triangle that don't have a neighbor void MapTriangleToNodes(Triangle& t);