Mercurial > hg > vamp-build-and-test
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Polygon library point_data.hpp header file | |
2 | |
3 // Copyright (c) Intel Corporation 2008. | |
4 // Copyright (c) 2008-2012 Simonson Lucanus. | |
5 // Copyright (c) 2012-2012 Andrii Sydorchuk. | |
6 | |
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) | |
11 | |
12 #ifndef BOOST_POLYGON_POINT_DATA_HPP | |
13 #define BOOST_POLYGON_POINT_DATA_HPP | |
14 | |
15 #include "isotropy.hpp" | |
16 #include "point_concept.hpp" | |
17 | |
18 namespace boost { | |
19 namespace polygon { | |
20 | |
21 template <typename T> | |
22 class point_data { | |
23 public: | |
24 typedef T coordinate_type; | |
25 | |
26 point_data() | |
27 #ifndef BOOST_POLYGON_MSVC | |
28 : coords_() | |
29 #endif | |
30 {} | |
31 | |
32 point_data(coordinate_type x, coordinate_type y) { | |
33 coords_[HORIZONTAL] = x; | |
34 coords_[VERTICAL] = y; | |
35 } | |
36 | |
37 explicit point_data(const point_data& that) { | |
38 coords_[0] = that.coords_[0]; | |
39 coords_[1] = that.coords_[1]; | |
40 } | |
41 | |
42 point_data& operator=(const point_data& that) { | |
43 coords_[0] = that.coords_[0]; | |
44 coords_[1] = that.coords_[1]; | |
45 return *this; | |
46 } | |
47 | |
48 template <typename PointType> | |
49 explicit point_data(const PointType& that) { | |
50 *this = that; | |
51 } | |
52 | |
53 template <typename PointType> | |
54 point_data& operator=(const PointType& that) { | |
55 assign(*this, that); | |
56 return *this; | |
57 } | |
58 | |
59 // TODO(asydorchuk): Deprecated. | |
60 template <typename CT> | |
61 point_data(const point_data<CT>& that) { | |
62 coords_[HORIZONTAL] = (coordinate_type)that.x(); | |
63 coords_[VERTICAL] = (coordinate_type)that.y(); | |
64 } | |
65 | |
66 coordinate_type get(orientation_2d orient) const { | |
67 return coords_[orient.to_int()]; | |
68 } | |
69 | |
70 void set(orientation_2d orient, coordinate_type value) { | |
71 coords_[orient.to_int()] = value; | |
72 } | |
73 | |
74 coordinate_type x() const { | |
75 return coords_[HORIZONTAL]; | |
76 } | |
77 | |
78 point_data& x(coordinate_type value) { | |
79 coords_[HORIZONTAL] = value; | |
80 return *this; | |
81 } | |
82 | |
83 coordinate_type y() const { | |
84 return coords_[VERTICAL]; | |
85 } | |
86 | |
87 point_data& y(coordinate_type value) { | |
88 coords_[VERTICAL] = value; | |
89 return *this; | |
90 } | |
91 | |
92 bool operator==(const point_data& that) const { | |
93 return (coords_[0] == that.coords_[0]) && | |
94 (coords_[1] == that.coords_[1]); | |
95 } | |
96 | |
97 bool operator!=(const point_data& that) const { | |
98 return !(*this == that); | |
99 } | |
100 | |
101 bool operator<(const point_data& that) const { | |
102 return (coords_[0] < that.coords_[0]) || | |
103 ((coords_[0] == that.coords_[0]) && | |
104 (coords_[1] < that.coords_[1])); | |
105 } | |
106 | |
107 bool operator<=(const point_data& that) const { | |
108 return !(that < *this); | |
109 } | |
110 | |
111 bool operator>(const point_data& that) const { | |
112 return that < *this; | |
113 } | |
114 | |
115 bool operator>=(const point_data& that) const { | |
116 return !(*this < that); | |
117 } | |
118 | |
119 private: | |
120 coordinate_type coords_[2]; | |
121 }; | |
122 | |
123 template <typename CType> | |
124 struct geometry_concept< point_data<CType> > { | |
125 typedef point_concept type; | |
126 }; | |
127 } // polygon | |
128 } // boost | |
129 | |
130 #endif // BOOST_POLYGON_POINT_DATA_HPP |