#pragma once #include #ifdef DEBUG #include #endif namespace mapbox { namespace geometry { namespace wagyu { template struct point; template using point_ptr = point*; template using const_point_ptr = point* const; template struct ring; template using ring_ptr = ring*; template using const_ring_ptr = ring* const; template struct point { using coordinate_type = T; ring_ptr ring; T x; T y; point_ptr next; point_ptr prev; point(point&& p) : ring(std::move(p.ring)), x(std::move(p.x)), y(std::move(p.y)), next(std::move(p.next)), prev(std::move(p.prev)) { } point() : ring(nullptr), x(0), y(0), prev(this), next(this) { } point(T x_, T y_) : ring(nullptr), x(x_), y(y_), next(this), prev(this) { } point(ring_ptr ring_, mapbox::geometry::point const& pt) : ring(ring_), x(pt.x), y(pt.y), next(this), prev(this) { } point(ring_ptr ring_, mapbox::geometry::point const& pt, point_ptr before_this_point) : ring(ring_), x(pt.x), y(pt.y), next(before_this_point), prev(before_this_point->prev) { before_this_point->prev = this; prev->next = this; } }; template bool operator==(point const& lhs, point const& rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; } template bool operator==(mapbox::geometry::point const& lhs, point const& rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; } template bool operator==(point const& lhs, mapbox::geometry::point const& rhs) { return lhs.x == rhs.x && lhs.y == rhs.y; } template bool operator!=(point const& lhs, point const& rhs) { return lhs.x != rhs.x || lhs.y != rhs.y; } template bool operator!=(mapbox::geometry::point const& lhs, point const& rhs) { return lhs.x != rhs.x || lhs.y != rhs.y; } template bool operator!=(point const& lhs, mapbox::geometry::point const& rhs) { return lhs.x != rhs.x || lhs.y != rhs.y; } #ifdef DEBUG template inline std::basic_ostream& operator<<(std::basic_ostream& out, const point& p) { out << " point at: " << p.x << ", " << p.y; return out; } template inline std::basic_ostream& operator<<(std::basic_ostream& out, const mapbox::geometry::point& p) { out << " point at: " << p.x << ", " << p.y; return out; } #endif } } }