Skip to content

Commit

Permalink
Overload operator<< for Point
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed May 28, 2018
1 parent 66ff955 commit 1271d6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions poly2tri/common/shapes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

}
2 changes: 2 additions & 0 deletions poly2tri/common/shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct Point {

};

std::ostream& operator<<(std::ostream&, const Point&);

// Represents a simple polygon's edge
struct Edge {

Expand Down

0 comments on commit 1271d6b

Please sign in to comment.