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