1/*
2 Copyright 2008 Intel Corporation
3
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7*/
8#ifndef BOOST_POLYGON_RECTANGLE_DATA_HPP
9#define BOOST_POLYGON_RECTANGLE_DATA_HPP
10
11#include "isotropy.hpp"
12//interval
13#include "interval_data.hpp"
14
15namespace boost { namespace polygon{
16
17template <typename T>
18class rectangle_data {
19public:
20 typedef T coordinate_type;
21 typedef interval_data<T> interval_type;
22 inline rectangle_data():ranges_() {}
23 inline rectangle_data(T xl, T yl, T xh, T yh):ranges_() {
24 if(xl > xh) std::swap(xl, xh);
25 if(yl > yh) std::swap(yl, yh);
26 ranges_[HORIZONTAL] = interval_data<T>(xl, xh);
27 ranges_[VERTICAL] = interval_data<T>(yl, yh);
28 }
29 template <typename interval_type_1, typename interval_type_2>
30 inline rectangle_data(const interval_type_1& hrange,
31 const interval_type_2& vrange):ranges_() {
32 set(HORIZONTAL, hrange); set(VERTICAL, vrange); }
33
34 inline rectangle_data(const rectangle_data& that):ranges_() { (*this) = that; }
35 inline rectangle_data& operator=(const rectangle_data& that) {
36 ranges_[0] = that.ranges_[0]; ranges_[1] = that.ranges_[1]; return *this;
37 }
38 template <typename T2>
39 inline rectangle_data& operator=(const T2& rvalue);
40
41 template <typename T2>
42 inline bool operator==(const T2& rvalue) const;
43 template <typename T2>
44 inline bool operator!=(const T2& rvalue) const { return !((*this) == rvalue); }
45
46 inline interval_data<coordinate_type> get(orientation_2d orient) const {
47 return ranges_[orient.to_int()]; }
48 inline coordinate_type get(direction_2d dir) const {
49 return ranges_[orientation_2d(dir).to_int()].get(direction_1d(dir));
50 }
51 inline void set(direction_2d dir, coordinate_type value) {
52 return ranges_[orientation_2d(dir).to_int()].set(direction_1d(dir), value);
53 }
54 template <typename interval_type_1>
55 inline void set(orientation_2d orient, const interval_type_1& interval);
56private:
57 interval_data<coordinate_type> ranges_[2];
58};
59
60
61}
62}
63#endif
64

source code of boost/boost/polygon/rectangle_data.hpp