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_POLYGON_45_DATA_HPP |
9 | #define BOOST_POLYGON_POLYGON_45_DATA_HPP |
10 | #include "isotropy.hpp" |
11 | namespace boost { namespace polygon{ |
12 | struct polygon_45_concept; |
13 | template <typename T> class polygon_data; |
14 | template <typename T> |
15 | class polygon_45_data { |
16 | public: |
17 | typedef polygon_45_concept geometry_type; |
18 | typedef T coordinate_type; |
19 | typedef typename std::vector<point_data<coordinate_type> >::const_iterator iterator_type; |
20 | typedef typename coordinate_traits<T>::coordinate_distance area_type; |
21 | typedef point_data<T> point_type; |
22 | |
23 | inline polygon_45_data() : coords_() {} //do nothing default constructor |
24 | |
25 | template<class iT> |
26 | inline polygon_45_data(iT input_begin, iT input_end) : coords_(input_begin, input_end) {} |
27 | |
28 | template<class iT> |
29 | inline polygon_45_data& set(iT input_begin, iT input_end) { |
30 | coords_.clear(); //just in case there was some old data there |
31 | coords_.insert(coords_.end(), input_begin, input_end); |
32 | return *this; |
33 | } |
34 | |
35 | // copy constructor (since we have dynamic memory) |
36 | inline polygon_45_data(const polygon_45_data& that) : coords_(that.coords_) {} |
37 | |
38 | // assignment operator (since we have dynamic memory do a deep copy) |
39 | inline polygon_45_data& operator=(const polygon_45_data& that) { |
40 | coords_ = that.coords_; |
41 | return *this; |
42 | } |
43 | |
44 | template <typename T2> |
45 | inline polygon_45_data& operator=(const T2& rvalue); |
46 | |
47 | inline bool operator==(const polygon_45_data& that) const { |
48 | if(coords_.size() != that.coords_.size()) return false; |
49 | for(std::size_t i = 0; i < coords_.size(); ++i) { |
50 | if(coords_[i] != that.coords_[i]) return false; |
51 | } |
52 | return true; |
53 | } |
54 | |
55 | inline bool operator!=(const polygon_45_data& that) const { return !((*this) == that); } |
56 | |
57 | // get begin iterator, returns a pointer to a const Unit |
58 | inline iterator_type begin() const { return coords_.begin(); } |
59 | |
60 | // get end iterator, returns a pointer to a const Unit |
61 | inline iterator_type end() const { return coords_.end(); } |
62 | |
63 | inline std::size_t size() const { return coords_.size(); } |
64 | |
65 | public: |
66 | std::vector<point_data<coordinate_type> > coords_; |
67 | }; |
68 | |
69 | |
70 | } |
71 | } |
72 | #endif |
73 | |