Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/polygon/interval_data.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Polygon library interval_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_INTERVAL_DATA_HPP | |
13 #define BOOST_POLYGON_INTERVAL_DATA_HPP | |
14 | |
15 #include "isotropy.hpp" | |
16 #include "interval_concept.hpp" | |
17 | |
18 namespace boost { | |
19 namespace polygon { | |
20 | |
21 template <typename T> | |
22 class interval_data { | |
23 public: | |
24 typedef T coordinate_type; | |
25 | |
26 interval_data() | |
27 #ifndef BOOST_POLYGON_MSVC | |
28 : coords_() | |
29 #endif | |
30 {} | |
31 | |
32 interval_data(coordinate_type low, coordinate_type high) { | |
33 coords_[LOW] = low; | |
34 coords_[HIGH] = high; | |
35 } | |
36 | |
37 interval_data(const interval_data& that) { | |
38 coords_[0] = that.coords_[0]; | |
39 coords_[1] = that.coords_[1]; | |
40 } | |
41 | |
42 interval_data& operator=(const interval_data& that) { | |
43 coords_[0] = that.coords_[0]; | |
44 coords_[1] = that.coords_[1]; | |
45 return *this; | |
46 } | |
47 | |
48 template <typename IntervalType> | |
49 interval_data& operator=(const IntervalType& that) { | |
50 assign(*this, that); | |
51 return *this; | |
52 } | |
53 | |
54 coordinate_type get(direction_1d dir) const { | |
55 return coords_[dir.to_int()]; | |
56 } | |
57 | |
58 void set(direction_1d dir, coordinate_type value) { | |
59 coords_[dir.to_int()] = value; | |
60 } | |
61 | |
62 coordinate_type low() const { | |
63 return coords_[0]; | |
64 } | |
65 | |
66 interval_data& low(coordinate_type value) { | |
67 coords_[LOW] = value; | |
68 return *this; | |
69 } | |
70 | |
71 coordinate_type high() const { | |
72 return coords_[1]; | |
73 } | |
74 | |
75 interval_data& high(coordinate_type value) { | |
76 coords_[HIGH] = value; | |
77 return *this; | |
78 } | |
79 | |
80 bool operator==(const interval_data& that) const { | |
81 return low() == that.low() && high() == that.high(); | |
82 } | |
83 | |
84 bool operator!=(const interval_data& that) const { | |
85 return low() != that.low() || high() != that.high(); | |
86 } | |
87 | |
88 bool operator<(const interval_data& that) const { | |
89 if (coords_[0] != that.coords_[0]) { | |
90 return coords_[0] < that.coords_[0]; | |
91 } | |
92 return coords_[1] < that.coords_[1]; | |
93 } | |
94 | |
95 bool operator<=(const interval_data& that) const { | |
96 return !(that < *this); | |
97 } | |
98 | |
99 bool operator>(const interval_data& that) const { | |
100 return that < *this; | |
101 } | |
102 | |
103 bool operator>=(const interval_data& that) const { | |
104 return !((*this) < that); | |
105 } | |
106 | |
107 private: | |
108 coordinate_type coords_[2]; | |
109 }; | |
110 | |
111 template <typename CType> | |
112 struct geometry_concept< interval_data<CType> > { | |
113 typedef interval_concept type; | |
114 }; | |
115 } // polygon | |
116 } // boost | |
117 | |
118 #endif // BOOST_POLYGON_INTERVAL_DATA_HPP |