Chris@16: // Boost.Polygon library interval_data.hpp header file Chris@16: Chris@16: // Copyright (c) Intel Corporation 2008. Chris@16: // Copyright (c) 2008-2012 Simonson Lucanus. Chris@16: // Copyright (c) 2012-2012 Andrii Sydorchuk. Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_POLYGON_INTERVAL_DATA_HPP Chris@16: #define BOOST_POLYGON_INTERVAL_DATA_HPP Chris@16: Chris@16: #include "isotropy.hpp" Chris@16: #include "interval_concept.hpp" Chris@16: Chris@16: namespace boost { Chris@16: namespace polygon { Chris@16: Chris@16: template Chris@16: class interval_data { Chris@16: public: Chris@16: typedef T coordinate_type; Chris@16: Chris@16: interval_data() Chris@16: #ifndef BOOST_POLYGON_MSVC Chris@16: : coords_() Chris@16: #endif Chris@16: {} Chris@16: Chris@16: interval_data(coordinate_type low, coordinate_type high) { Chris@16: coords_[LOW] = low; Chris@16: coords_[HIGH] = high; Chris@16: } Chris@16: Chris@16: interval_data(const interval_data& that) { Chris@16: coords_[0] = that.coords_[0]; Chris@16: coords_[1] = that.coords_[1]; Chris@16: } Chris@16: Chris@16: interval_data& operator=(const interval_data& that) { Chris@16: coords_[0] = that.coords_[0]; Chris@16: coords_[1] = that.coords_[1]; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: template Chris@16: interval_data& operator=(const IntervalType& that) { Chris@16: assign(*this, that); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: coordinate_type get(direction_1d dir) const { Chris@16: return coords_[dir.to_int()]; Chris@16: } Chris@16: Chris@16: void set(direction_1d dir, coordinate_type value) { Chris@16: coords_[dir.to_int()] = value; Chris@16: } Chris@16: Chris@16: coordinate_type low() const { Chris@16: return coords_[0]; Chris@16: } Chris@16: Chris@16: interval_data& low(coordinate_type value) { Chris@16: coords_[LOW] = value; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: coordinate_type high() const { Chris@16: return coords_[1]; Chris@16: } Chris@16: Chris@16: interval_data& high(coordinate_type value) { Chris@16: coords_[HIGH] = value; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: bool operator==(const interval_data& that) const { Chris@16: return low() == that.low() && high() == that.high(); Chris@16: } Chris@16: Chris@16: bool operator!=(const interval_data& that) const { Chris@16: return low() != that.low() || high() != that.high(); Chris@16: } Chris@16: Chris@16: bool operator<(const interval_data& that) const { Chris@16: if (coords_[0] != that.coords_[0]) { Chris@16: return coords_[0] < that.coords_[0]; Chris@16: } Chris@16: return coords_[1] < that.coords_[1]; Chris@16: } Chris@16: Chris@16: bool operator<=(const interval_data& that) const { Chris@16: return !(that < *this); Chris@16: } Chris@16: Chris@16: bool operator>(const interval_data& that) const { Chris@16: return that < *this; Chris@16: } Chris@16: Chris@16: bool operator>=(const interval_data& that) const { Chris@16: return !((*this) < that); Chris@16: } Chris@16: Chris@16: private: Chris@16: coordinate_type coords_[2]; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct geometry_concept< interval_data > { Chris@16: typedef interval_concept type; Chris@16: }; Chris@16: } // polygon Chris@16: } // boost Chris@16: Chris@16: #endif // BOOST_POLYGON_INTERVAL_DATA_HPP