File indexing completed on 2025-01-18 09:48:03
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_POLYGON_RECTANGLE_DATA_HPP
0009 #define BOOST_POLYGON_RECTANGLE_DATA_HPP
0010
0011 #include "isotropy.hpp"
0012
0013 #include "interval_data.hpp"
0014
0015 namespace boost { namespace polygon{
0016
0017 template <typename T>
0018 class rectangle_data {
0019 public:
0020 typedef T coordinate_type;
0021 typedef interval_data<T> interval_type;
0022 inline rectangle_data():ranges_() {}
0023 inline rectangle_data(T xl, T yl, T xh, T yh):ranges_() {
0024 if(xl > xh) std::swap(xl, xh);
0025 if(yl > yh) std::swap(yl, yh);
0026 ranges_[HORIZONTAL] = interval_data<T>(xl, xh);
0027 ranges_[VERTICAL] = interval_data<T>(yl, yh);
0028 }
0029 template <typename interval_type_1, typename interval_type_2>
0030 inline rectangle_data(const interval_type_1& hrange,
0031 const interval_type_2& vrange):ranges_() {
0032 set(HORIZONTAL, hrange); set(VERTICAL, vrange); }
0033
0034 inline rectangle_data(const rectangle_data& that):ranges_() { (*this) = that; }
0035 inline rectangle_data& operator=(const rectangle_data& that) {
0036 ranges_[0] = that.ranges_[0]; ranges_[1] = that.ranges_[1]; return *this;
0037 }
0038 template <typename T2>
0039 inline rectangle_data& operator=(const T2& rvalue);
0040
0041 template <typename T2>
0042 inline bool operator==(const T2& rvalue) const;
0043 template <typename T2>
0044 inline bool operator!=(const T2& rvalue) const { return !((*this) == rvalue); }
0045
0046 inline interval_data<coordinate_type> get(orientation_2d orient) const {
0047 return ranges_[orient.to_int()]; }
0048 inline coordinate_type get(direction_2d dir) const {
0049 return ranges_[orientation_2d(dir).to_int()].get(direction_1d(dir));
0050 }
0051 inline void set(direction_2d dir, coordinate_type value) {
0052 return ranges_[orientation_2d(dir).to_int()].set(direction_1d(dir), value);
0053 }
0054 template <typename interval_type_1>
0055 inline void set(orientation_2d orient, const interval_type_1& interval);
0056 private:
0057 interval_data<coordinate_type> ranges_[2];
0058 };
0059
0060
0061 }
0062 }
0063 #endif