Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:55:21

0001 // Boost.Polygon library interval_data.hpp header file
0002 
0003 // Copyright (c) Intel Corporation 2008.
0004 // Copyright (c) 2008-2012 Simonson Lucanus.
0005 // Copyright (c) 2012-2012 Andrii Sydorchuk.
0006 
0007 // See http://www.boost.org for updates, documentation, and revision history.
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_POLYGON_INTERVAL_DATA_HPP
0013 #define BOOST_POLYGON_INTERVAL_DATA_HPP
0014 
0015 #include "isotropy.hpp"
0016 #include "interval_concept.hpp"
0017 
0018 namespace boost {
0019 namespace polygon {
0020 
0021 template <typename T>
0022 class interval_data {
0023  public:
0024   typedef T coordinate_type;
0025 
0026   interval_data()
0027 #ifndef BOOST_POLYGON_MSVC
0028     : coords_()
0029 #endif
0030   {}
0031 
0032   interval_data(coordinate_type low, coordinate_type high) {
0033     coords_[LOW] = low;
0034     coords_[HIGH] = high;
0035   }
0036 
0037   interval_data(const interval_data& that) {
0038     coords_[0] = that.coords_[0];
0039     coords_[1] = that.coords_[1];
0040   }
0041 
0042   interval_data& operator=(const interval_data& that) {
0043     coords_[0] = that.coords_[0];
0044     coords_[1] = that.coords_[1];
0045     return *this;
0046   }
0047 
0048   template <typename IntervalType>
0049   interval_data& operator=(const IntervalType& that) {
0050     assign(*this, that);
0051     return *this;
0052   }
0053 
0054   coordinate_type get(direction_1d dir) const {
0055     return coords_[dir.to_int()];
0056   }
0057 
0058   void set(direction_1d dir, coordinate_type value) {
0059     coords_[dir.to_int()] = value;
0060   }
0061 
0062   coordinate_type low() const {
0063     return coords_[0];
0064   }
0065 
0066   interval_data& low(coordinate_type value) {
0067     coords_[LOW] = value;
0068     return *this;
0069   }
0070 
0071   coordinate_type high() const {
0072     return coords_[1];
0073   }
0074 
0075   interval_data& high(coordinate_type value) {
0076     coords_[HIGH] = value;
0077     return *this;
0078   }
0079 
0080   bool operator==(const interval_data& that) const {
0081     return low() == that.low() && high() == that.high();
0082   }
0083 
0084   bool operator!=(const interval_data& that) const {
0085     return low() != that.low() || high() != that.high();
0086   }
0087 
0088   bool operator<(const interval_data& that) const {
0089     if (coords_[0] != that.coords_[0]) {
0090       return coords_[0] < that.coords_[0];
0091     }
0092     return coords_[1] < that.coords_[1];
0093   }
0094 
0095   bool operator<=(const interval_data& that) const {
0096     return !(that < *this);
0097   }
0098 
0099   bool operator>(const interval_data& that) const {
0100     return that < *this;
0101   }
0102 
0103   bool operator>=(const interval_data& that) const {
0104     return !((*this) < that);
0105   }
0106 
0107  private:
0108   coordinate_type coords_[2];
0109 };
0110 
0111 template <typename CType>
0112 struct geometry_concept< interval_data<CType> > {
0113   typedef interval_concept type;
0114 };
0115 }  // polygon
0116 }  // boost
0117 
0118 #endif  // BOOST_POLYGON_INTERVAL_DATA_HPP