From 1271d6b84841e575355c9f6873d2158c2fd26c40 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Mon, 28 May 2018 13:56:27 +0200 Subject: [PATCH] Overload operator<< for Point --- poly2tri/common/shapes.cc | 9 +++++---- poly2tri/common/shapes.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/poly2tri/common/shapes.cc b/poly2tri/common/shapes.cc index f3471dd..163328e 100644 --- a/poly2tri/common/shapes.cc +++ b/poly2tri/common/shapes.cc @@ -35,6 +35,10 @@ namespace p2t { +std::ostream& operator<<(std::ostream& out, const Point& point) { + return out << point.x << "," << point.y; +} + Triangle::Triangle(Point& a, Point& b, Point& c) { points_[0] = &a; points_[1] = &b; points_[2] = &c; @@ -358,10 +362,7 @@ Triangle& Triangle::NeighborAcross(const Point& opoint) void Triangle::DebugPrint() { - using namespace std; - cout << points_[0]->x << "," << points_[0]->y << " "; - cout << points_[1]->x << "," << points_[1]->y << " "; - cout << points_[2]->x << "," << points_[2]->y << endl; + std::cout << *points_[0] << " " << *points_[1] << " " << *points_[2] << std::endl; } } diff --git a/poly2tri/common/shapes.h b/poly2tri/common/shapes.h index e72cefa..d26ef72 100644 --- a/poly2tri/common/shapes.h +++ b/poly2tri/common/shapes.h @@ -119,6 +119,8 @@ struct Point { }; +std::ostream& operator<<(std::ostream&, const Point&); + // Represents a simple polygon's edge struct Edge {