1 // Boost.Polygon library point_data.hpp header file
3 // Copyright (c) Intel Corporation 2008.
4 // Copyright (c) 2008-2012 Simonson Lucanus.
5 // Copyright (c) 2012-2012 Andrii Sydorchuk.
7 // See http://www.boost.org for updates, documentation, and revision history.
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_POLYGON_POINT_DATA_HPP
13 #define BOOST_POLYGON_POINT_DATA_HPP
15 #include "isotropy.hpp"
16 #include "point_concept.hpp"
24 typedef T coordinate_type;
27 #ifndef BOOST_POLYGON_MSVC
32 point_data(coordinate_type x, coordinate_type y) {
33 coords_[HORIZONTAL] = x;
34 coords_[VERTICAL] = y;
37 explicit point_data(const point_data& that) {
38 coords_[0] = that.coords_[0];
39 coords_[1] = that.coords_[1];
42 point_data& operator=(const point_data& that) {
43 coords_[0] = that.coords_[0];
44 coords_[1] = that.coords_[1];
48 #if defined(__GNUC__) && __GNUC__ < 6
49 // "explicit" to work around a bug in GCC < 6: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63356
50 template <typename PointType>
51 explicit point_data(const PointType& that) {
55 template <typename PointType>
56 point_data(const PointType& that) {
59 #endif // __GNUC__ < 6
61 template <typename PointType>
62 point_data& operator=(const PointType& that) {
67 // TODO(asydorchuk): Deprecated.
68 template <typename CT>
69 point_data(const point_data<CT>& that) {
70 coords_[HORIZONTAL] = (coordinate_type)that.x();
71 coords_[VERTICAL] = (coordinate_type)that.y();
74 coordinate_type get(orientation_2d orient) const {
75 return coords_[orient.to_int()];
78 void set(orientation_2d orient, coordinate_type value) {
79 coords_[orient.to_int()] = value;
82 coordinate_type x() const {
83 return coords_[HORIZONTAL];
86 point_data& x(coordinate_type value) {
87 coords_[HORIZONTAL] = value;
91 coordinate_type y() const {
92 return coords_[VERTICAL];
95 point_data& y(coordinate_type value) {
96 coords_[VERTICAL] = value;
100 bool operator==(const point_data& that) const {
101 return (coords_[0] == that.coords_[0]) &&
102 (coords_[1] == that.coords_[1]);
105 bool operator!=(const point_data& that) const {
106 return !(*this == that);
109 bool operator<(const point_data& that) const {
110 return (coords_[0] < that.coords_[0]) ||
111 ((coords_[0] == that.coords_[0]) &&
112 (coords_[1] < that.coords_[1]));
115 bool operator<=(const point_data& that) const {
116 return !(that < *this);
119 bool operator>(const point_data& that) const {
123 bool operator>=(const point_data& that) const {
124 return !(*this < that);
128 coordinate_type coords_[2];
131 template <typename CType>
132 struct geometry_concept< point_data<CType> > {
133 typedef point_concept type;
138 #endif // BOOST_POLYGON_POINT_DATA_HPP