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_WITH_HOLES_DATA_HPP
|
Chris@16
|
9 #define BOOST_POLYGON_POLYGON_45_WITH_HOLES_DATA_HPP
|
Chris@16
|
10 #include "isotropy.hpp"
|
Chris@16
|
11 #include "polygon_45_data.hpp"
|
Chris@16
|
12 namespace boost { namespace polygon{
|
Chris@16
|
13 struct polygon_45_with_holes_concept;
|
Chris@16
|
14 template <typename T>
|
Chris@16
|
15 class polygon_45_with_holes_data {
|
Chris@16
|
16 public:
|
Chris@16
|
17 typedef polygon_45_with_holes_concept geometry_type;
|
Chris@16
|
18 typedef T coordinate_type;
|
Chris@16
|
19 typedef typename polygon_45_data<T>::iterator_type iterator_type;
|
Chris@16
|
20 typedef typename std::list<polygon_45_data<coordinate_type> >::const_iterator iterator_holes_type;
|
Chris@16
|
21 typedef polygon_45_data<coordinate_type> hole_type;
|
Chris@16
|
22 typedef typename coordinate_traits<T>::coordinate_distance area_type;
|
Chris@16
|
23 typedef point_data<T> point_type;
|
Chris@16
|
24
|
Chris@16
|
25 // default constructor of point does not initialize x and y
|
Chris@16
|
26 inline polygon_45_with_holes_data() : self_(), holes_() {} //do nothing default constructor
|
Chris@16
|
27
|
Chris@16
|
28 template<class iT>
|
Chris@16
|
29 inline polygon_45_with_holes_data(iT input_begin, iT input_end) : self_(), holes_() {
|
Chris@16
|
30 set(input_begin, input_end);
|
Chris@16
|
31 }
|
Chris@16
|
32
|
Chris@16
|
33 template<class iT, typename hiT>
|
Chris@16
|
34 inline polygon_45_with_holes_data(iT input_begin, iT input_end, hiT holes_begin, hiT holes_end) : self_(), holes_() {
|
Chris@16
|
35 set(input_begin, input_end);
|
Chris@16
|
36 set_holes(holes_begin, holes_end);
|
Chris@16
|
37 }
|
Chris@16
|
38
|
Chris@16
|
39 template<class iT>
|
Chris@16
|
40 inline polygon_45_with_holes_data& set(iT input_begin, iT input_end) {
|
Chris@16
|
41 self_.set(input_begin, input_end);
|
Chris@16
|
42 return *this;
|
Chris@16
|
43 }
|
Chris@16
|
44
|
Chris@16
|
45 // initialize a polygon from x,y values, it is assumed that the first is an x
|
Chris@16
|
46 // and that the input is a well behaved polygon
|
Chris@16
|
47 template<class iT>
|
Chris@16
|
48 inline polygon_45_with_holes_data& set_holes(iT input_begin, iT input_end) {
|
Chris@16
|
49 holes_.clear(); //just in case there was some old data there
|
Chris@16
|
50 for( ; input_begin != input_end; ++ input_begin) {
|
Chris@16
|
51 holes_.push_back(hole_type());
|
Chris@16
|
52 holes_.back().set((*input_begin).begin(), (*input_begin).end());
|
Chris@16
|
53 }
|
Chris@16
|
54 return *this;
|
Chris@16
|
55 }
|
Chris@16
|
56
|
Chris@16
|
57 // copy constructor (since we have dynamic memory)
|
Chris@16
|
58 inline polygon_45_with_holes_data(const polygon_45_with_holes_data& that) : self_(that.self_),
|
Chris@16
|
59 holes_(that.holes_) {}
|
Chris@16
|
60
|
Chris@16
|
61 // assignment operator (since we have dynamic memory do a deep copy)
|
Chris@16
|
62 inline polygon_45_with_holes_data& operator=(const polygon_45_with_holes_data& that) {
|
Chris@16
|
63 self_ = that.self_;
|
Chris@16
|
64 holes_ = that.holes_;
|
Chris@16
|
65 return *this;
|
Chris@16
|
66 }
|
Chris@16
|
67
|
Chris@16
|
68 template <typename T2>
|
Chris@16
|
69 inline polygon_45_with_holes_data& operator=(const T2& rvalue);
|
Chris@16
|
70
|
Chris@16
|
71 // get begin iterator, returns a pointer to a const coordinate_type
|
Chris@16
|
72 inline const iterator_type begin() const {
|
Chris@16
|
73 return self_.begin();
|
Chris@16
|
74 }
|
Chris@16
|
75
|
Chris@16
|
76 // get end iterator, returns a pointer to a const coordinate_type
|
Chris@16
|
77 inline const iterator_type end() const {
|
Chris@16
|
78 return self_.end();
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 inline std::size_t size() const {
|
Chris@16
|
82 return self_.size();
|
Chris@16
|
83 }
|
Chris@16
|
84
|
Chris@16
|
85 // get begin iterator, returns a pointer to a const polygon
|
Chris@16
|
86 inline const iterator_holes_type begin_holes() const {
|
Chris@16
|
87 return holes_.begin();
|
Chris@16
|
88 }
|
Chris@16
|
89
|
Chris@16
|
90 // get end iterator, returns a pointer to a const polygon
|
Chris@16
|
91 inline const iterator_holes_type end_holes() const {
|
Chris@16
|
92 return holes_.end();
|
Chris@16
|
93 }
|
Chris@16
|
94
|
Chris@16
|
95 inline std::size_t size_holes() const {
|
Chris@16
|
96 return holes_.size();
|
Chris@16
|
97 }
|
Chris@16
|
98
|
Chris@16
|
99 public:
|
Chris@16
|
100 polygon_45_data<coordinate_type> self_;
|
Chris@16
|
101 std::list<hole_type> holes_;
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104
|
Chris@16
|
105 }
|
Chris@16
|
106 }
|
Chris@16
|
107 #endif
|