From 1cf81227c4cd96456101212e012faf6147186d47 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Mon, 26 Jan 2015 15:35:38 +0000 Subject: [PATCH 1/2] Simplify behavior of SweepContext::InitEdges --- contrib/poly2tri/poly2tri/sweep/sweep_context.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index c9dd5a8c4..4fd1ac365 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -97,10 +97,10 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { int num_points = polyline.size(); - for (int i = 0; i < num_points; i++) { - int j = i < num_points - 1 ? i + 1 : 0; - edge_list.push_back(new Edge(*polyline[i], *polyline[j])); + for (int i = 0; i < num_points - 1; i++) { + edge_list.push_back(new Edge(*polyline[i], *polyline[i + 1])); } + edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); } Point* SweepContext::GetPoint(const int& index) From 00d561982cdaea71395a000e8de15f96d11fa89d Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Mon, 26 Jan 2015 15:38:12 +0000 Subject: [PATCH 2/2] Use size_t instead of int for number of points This squashes warnings under Visual Studio 12 --- contrib/poly2tri/poly2tri/sweep/sweep_context.cc | 4 ++-- contrib/poly2tri/poly2tri/sweep/sweep_context.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index 4fd1ac365..672303c53 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -96,8 +96,8 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { - int num_points = polyline.size(); - for (int i = 0; i < num_points - 1; i++) { + std::size_t num_points = polyline.size(); + for (std::size_t i = 0; i < num_points - 1; i++) { edge_list.push_back(new Edge(*polyline[i], *polyline[i + 1])); } edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.h b/contrib/poly2tri/poly2tri/sweep/sweep_context.h index 266408dc2..4b098e860 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.h +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.h @@ -64,7 +64,7 @@ void set_tail(Point* p1); Point* tail(); -int point_count(); +std::size_t point_count(); Node& LocateNode(Point& point); @@ -156,7 +156,7 @@ inline AdvancingFront* SweepContext::front() return front_; } -inline int SweepContext::point_count() +inline std::size_t SweepContext::point_count() { return points_.size(); }