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