annotate DEPENDENCIES/generic/include/boost/polygon/point_data.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Polygon library point_data.hpp header file
Chris@16 2
Chris@16 3 // Copyright (c) Intel Corporation 2008.
Chris@16 4 // Copyright (c) 2008-2012 Simonson Lucanus.
Chris@16 5 // Copyright (c) 2012-2012 Andrii Sydorchuk.
Chris@16 6
Chris@16 7 // See http://www.boost.org for updates, documentation, and revision history.
Chris@16 8 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 10 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 11
Chris@16 12 #ifndef BOOST_POLYGON_POINT_DATA_HPP
Chris@16 13 #define BOOST_POLYGON_POINT_DATA_HPP
Chris@16 14
Chris@16 15 #include "isotropy.hpp"
Chris@16 16 #include "point_concept.hpp"
Chris@16 17
Chris@16 18 namespace boost {
Chris@16 19 namespace polygon {
Chris@16 20
Chris@16 21 template <typename T>
Chris@16 22 class point_data {
Chris@16 23 public:
Chris@16 24 typedef T coordinate_type;
Chris@16 25
Chris@16 26 point_data()
Chris@16 27 #ifndef BOOST_POLYGON_MSVC
Chris@16 28 : coords_()
Chris@16 29 #endif
Chris@16 30 {}
Chris@16 31
Chris@16 32 point_data(coordinate_type x, coordinate_type y) {
Chris@16 33 coords_[HORIZONTAL] = x;
Chris@16 34 coords_[VERTICAL] = y;
Chris@16 35 }
Chris@16 36
Chris@16 37 explicit point_data(const point_data& that) {
Chris@16 38 coords_[0] = that.coords_[0];
Chris@16 39 coords_[1] = that.coords_[1];
Chris@16 40 }
Chris@16 41
Chris@16 42 point_data& operator=(const point_data& that) {
Chris@16 43 coords_[0] = that.coords_[0];
Chris@16 44 coords_[1] = that.coords_[1];
Chris@16 45 return *this;
Chris@16 46 }
Chris@16 47
Chris@101 48 #ifdef __GNUC__
Chris@101 49 // "explicit" to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63356
Chris@16 50 template <typename PointType>
Chris@16 51 explicit point_data(const PointType& that) {
Chris@16 52 *this = that;
Chris@16 53 }
Chris@101 54 #else // __GNUC__
Chris@101 55 template <typename PointType>
Chris@101 56 point_data(const PointType& that) {
Chris@101 57 *this = that;
Chris@101 58 }
Chris@101 59 #endif // __GNUC__
Chris@16 60
Chris@16 61 template <typename PointType>
Chris@16 62 point_data& operator=(const PointType& that) {
Chris@16 63 assign(*this, that);
Chris@16 64 return *this;
Chris@16 65 }
Chris@16 66
Chris@16 67 // TODO(asydorchuk): Deprecated.
Chris@16 68 template <typename CT>
Chris@16 69 point_data(const point_data<CT>& that) {
Chris@16 70 coords_[HORIZONTAL] = (coordinate_type)that.x();
Chris@16 71 coords_[VERTICAL] = (coordinate_type)that.y();
Chris@16 72 }
Chris@16 73
Chris@16 74 coordinate_type get(orientation_2d orient) const {
Chris@16 75 return coords_[orient.to_int()];
Chris@16 76 }
Chris@16 77
Chris@16 78 void set(orientation_2d orient, coordinate_type value) {
Chris@16 79 coords_[orient.to_int()] = value;
Chris@16 80 }
Chris@16 81
Chris@16 82 coordinate_type x() const {
Chris@16 83 return coords_[HORIZONTAL];
Chris@16 84 }
Chris@16 85
Chris@16 86 point_data& x(coordinate_type value) {
Chris@16 87 coords_[HORIZONTAL] = value;
Chris@16 88 return *this;
Chris@16 89 }
Chris@16 90
Chris@16 91 coordinate_type y() const {
Chris@16 92 return coords_[VERTICAL];
Chris@16 93 }
Chris@16 94
Chris@16 95 point_data& y(coordinate_type value) {
Chris@16 96 coords_[VERTICAL] = value;
Chris@16 97 return *this;
Chris@16 98 }
Chris@16 99
Chris@16 100 bool operator==(const point_data& that) const {
Chris@16 101 return (coords_[0] == that.coords_[0]) &&
Chris@16 102 (coords_[1] == that.coords_[1]);
Chris@16 103 }
Chris@16 104
Chris@16 105 bool operator!=(const point_data& that) const {
Chris@16 106 return !(*this == that);
Chris@16 107 }
Chris@16 108
Chris@16 109 bool operator<(const point_data& that) const {
Chris@16 110 return (coords_[0] < that.coords_[0]) ||
Chris@16 111 ((coords_[0] == that.coords_[0]) &&
Chris@16 112 (coords_[1] < that.coords_[1]));
Chris@16 113 }
Chris@16 114
Chris@16 115 bool operator<=(const point_data& that) const {
Chris@16 116 return !(that < *this);
Chris@16 117 }
Chris@16 118
Chris@16 119 bool operator>(const point_data& that) const {
Chris@16 120 return that < *this;
Chris@16 121 }
Chris@16 122
Chris@16 123 bool operator>=(const point_data& that) const {
Chris@16 124 return !(*this < that);
Chris@16 125 }
Chris@16 126
Chris@16 127 private:
Chris@16 128 coordinate_type coords_[2];
Chris@16 129 };
Chris@16 130
Chris@16 131 template <typename CType>
Chris@16 132 struct geometry_concept< point_data<CType> > {
Chris@16 133 typedef point_concept type;
Chris@16 134 };
Chris@16 135 } // polygon
Chris@16 136 } // boost
Chris@16 137
Chris@16 138 #endif // BOOST_POLYGON_POINT_DATA_HPP