diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index 672303c53..c9dd5a8c4 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -96,11 +96,11 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { - 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])); + 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])); } - edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); } Point* SweepContext::GetPoint(const int& index) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.h b/contrib/poly2tri/poly2tri/sweep/sweep_context.h index 4b098e860..266408dc2 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(); -std::size_t point_count(); +int point_count(); Node& LocateNode(Point& point); @@ -156,7 +156,7 @@ inline AdvancingFront* SweepContext::front() return front_; } -inline std::size_t SweepContext::point_count() +inline int SweepContext::point_count() { return points_.size(); }