From fdefc2f70e029b0e9ebd7be933b9a7dd58b80fb3 Mon Sep 17 00:00:00 2001 From: Tom Hulton-Harrop Date: Thu, 30 Mar 2023 22:56:46 +0100 Subject: [PATCH] add const overload for GetPoint Signed-off-by: Tom Hulton-Harrop --- poly2tri/common/shapes.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/poly2tri/common/shapes.h b/poly2tri/common/shapes.h index d78aa87..b6ade60 100644 --- a/poly2tri/common/shapes.h +++ b/poly2tri/common/shapes.h @@ -161,6 +161,7 @@ bool constrained_edge[3]; bool delaunay_edge[3]; Point* GetPoint(int index); +const Point* GetPoint(int index) const; Point* PointCW(const Point& point); Point* PointCCW(const Point& point); Point* OppositePoint(Triangle& t, const Point& p); @@ -288,11 +289,17 @@ inline Point Cross(double s, const Point& a) return Point(-s * a.y, s * a.x); } -inline Point* Triangle::GetPoint(int index) +inline const Point* Triangle::GetPoint(int index) const { return points_[index]; } +inline Point* Triangle::GetPoint(int index) +{ + return const_cast( + static_cast(*this).GetPoint(index)); +} + inline Triangle* Triangle::GetNeighbor(int index) { return neighbors_[index];