1 // Boost.Polygon library interval_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_INTERVAL_DATA_HPP
13 #define BOOST_POLYGON_INTERVAL_DATA_HPP
15 #include "isotropy.hpp"
16 #include "interval_concept.hpp"
24 typedef T coordinate_type;
27 #ifndef BOOST_POLYGON_MSVC
32 interval_data(coordinate_type low, coordinate_type high) {
37 interval_data(const interval_data& that) {
38 coords_[0] = that.coords_[0];
39 coords_[1] = that.coords_[1];
42 interval_data& operator=(const interval_data& that) {
43 coords_[0] = that.coords_[0];
44 coords_[1] = that.coords_[1];
48 template <typename IntervalType>
49 interval_data& operator=(const IntervalType& that) {
54 coordinate_type get(direction_1d dir) const {
55 return coords_[dir.to_int()];
58 void set(direction_1d dir, coordinate_type value) {
59 coords_[dir.to_int()] = value;
62 coordinate_type low() const {
66 interval_data& low(coordinate_type value) {
71 coordinate_type high() const {
75 interval_data& high(coordinate_type value) {
76 coords_[HIGH] = value;
80 bool operator==(const interval_data& that) const {
81 return low() == that.low() && high() == that.high();
84 bool operator!=(const interval_data& that) const {
85 return low() != that.low() || high() != that.high();
88 bool operator<(const interval_data& that) const {
89 if (coords_[0] != that.coords_[0]) {
90 return coords_[0] < that.coords_[0];
92 return coords_[1] < that.coords_[1];
95 bool operator<=(const interval_data& that) const {
96 return !(that < *this);
99 bool operator>(const interval_data& that) const {
103 bool operator>=(const interval_data& that) const {
104 return !((*this) < that);
108 coordinate_type coords_[2];
111 template <typename CType>
112 struct geometry_concept< interval_data<CType> > {
113 typedef interval_concept type;
118 #endif // BOOST_POLYGON_INTERVAL_DATA_HPP