annotate DEPENDENCIES/generic/include/boost/polygon/point_data.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
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@16 48 template <typename PointType>
Chris@16 49 explicit point_data(const PointType& that) {
Chris@16 50 *this = that;
Chris@16 51 }
Chris@16 52
Chris@16 53 template <typename PointType>
Chris@16 54 point_data& operator=(const PointType& that) {
Chris@16 55 assign(*this, that);
Chris@16 56 return *this;
Chris@16 57 }
Chris@16 58
Chris@16 59 // TODO(asydorchuk): Deprecated.
Chris@16 60 template <typename CT>
Chris@16 61 point_data(const point_data<CT>& that) {
Chris@16 62 coords_[HORIZONTAL] = (coordinate_type)that.x();
Chris@16 63 coords_[VERTICAL] = (coordinate_type)that.y();
Chris@16 64 }
Chris@16 65
Chris@16 66 coordinate_type get(orientation_2d orient) const {
Chris@16 67 return coords_[orient.to_int()];
Chris@16 68 }
Chris@16 69
Chris@16 70 void set(orientation_2d orient, coordinate_type value) {
Chris@16 71 coords_[orient.to_int()] = value;
Chris@16 72 }
Chris@16 73
Chris@16 74 coordinate_type x() const {
Chris@16 75 return coords_[HORIZONTAL];
Chris@16 76 }
Chris@16 77
Chris@16 78 point_data& x(coordinate_type value) {
Chris@16 79 coords_[HORIZONTAL] = value;
Chris@16 80 return *this;
Chris@16 81 }
Chris@16 82
Chris@16 83 coordinate_type y() const {
Chris@16 84 return coords_[VERTICAL];
Chris@16 85 }
Chris@16 86
Chris@16 87 point_data& y(coordinate_type value) {
Chris@16 88 coords_[VERTICAL] = value;
Chris@16 89 return *this;
Chris@16 90 }
Chris@16 91
Chris@16 92 bool operator==(const point_data& that) const {
Chris@16 93 return (coords_[0] == that.coords_[0]) &&
Chris@16 94 (coords_[1] == that.coords_[1]);
Chris@16 95 }
Chris@16 96
Chris@16 97 bool operator!=(const point_data& that) const {
Chris@16 98 return !(*this == that);
Chris@16 99 }
Chris@16 100
Chris@16 101 bool operator<(const point_data& that) const {
Chris@16 102 return (coords_[0] < that.coords_[0]) ||
Chris@16 103 ((coords_[0] == that.coords_[0]) &&
Chris@16 104 (coords_[1] < that.coords_[1]));
Chris@16 105 }
Chris@16 106
Chris@16 107 bool operator<=(const point_data& that) const {
Chris@16 108 return !(that < *this);
Chris@16 109 }
Chris@16 110
Chris@16 111 bool operator>(const point_data& that) const {
Chris@16 112 return that < *this;
Chris@16 113 }
Chris@16 114
Chris@16 115 bool operator>=(const point_data& that) const {
Chris@16 116 return !(*this < that);
Chris@16 117 }
Chris@16 118
Chris@16 119 private:
Chris@16 120 coordinate_type coords_[2];
Chris@16 121 };
Chris@16 122
Chris@16 123 template <typename CType>
Chris@16 124 struct geometry_concept< point_data<CType> > {
Chris@16 125 typedef point_concept type;
Chris@16 126 };
Chris@16 127 } // polygon
Chris@16 128 } // boost
Chris@16 129
Chris@16 130 #endif // BOOST_POLYGON_POINT_DATA_HPP