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_90_WITH_HOLES_DATA_HPP
|
Chris@16
|
9 #define BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP
|
Chris@16
|
10 namespace boost { namespace polygon{
|
Chris@16
|
11 #include "isotropy.hpp"
|
Chris@16
|
12 #include "polygon_90_data.hpp"
|
Chris@16
|
13 struct polygon_90_with_holes_concept;
|
Chris@16
|
14 template <typename T>
|
Chris@16
|
15 class polygon_90_with_holes_data {
|
Chris@16
|
16 public:
|
Chris@16
|
17 typedef polygon_90_with_holes_concept geometry_type;
|
Chris@16
|
18 typedef T coordinate_type;
|
Chris@16
|
19 typedef typename polygon_90_data<T>::iterator_type iterator_type;
|
Chris@16
|
20 typedef typename polygon_90_data<T>::compact_iterator_type compact_iterator_type;
|
Chris@16
|
21 typedef typename std::list<polygon_90_data<coordinate_type> >::const_iterator iterator_holes_type;
|
Chris@16
|
22 typedef polygon_90_data<coordinate_type> hole_type;
|
Chris@16
|
23 typedef typename coordinate_traits<T>::area_type area_type;
|
Chris@16
|
24 typedef point_data<T> point_type;
|
Chris@16
|
25
|
Chris@16
|
26 // default constructor of point does not initialize x and y
|
Chris@16
|
27 inline polygon_90_with_holes_data() : self_(), holes_() {} //do nothing default constructor
|
Chris@16
|
28
|
Chris@16
|
29 // initialize a polygon from x,y values, it is assumed that the first is an x
|
Chris@16
|
30 // and that the input is a well behaved polygon
|
Chris@16
|
31 template<class iT>
|
Chris@16
|
32 inline polygon_90_with_holes_data& set(iT input_begin, iT input_end) {
|
Chris@16
|
33 self_.set(input_begin, input_end);
|
Chris@16
|
34 return *this;
|
Chris@16
|
35 }
|
Chris@16
|
36
|
Chris@16
|
37 // initialize a polygon from x,y values, it is assumed that the first is an x
|
Chris@16
|
38 // and that the input is a well behaved polygon
|
Chris@16
|
39 template<class iT>
|
Chris@16
|
40 inline polygon_90_with_holes_data& set_compact(iT input_begin, iT input_end) {
|
Chris@16
|
41 self_.set_compact(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_90_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_compact((*input_begin).begin_compact(), (*input_begin).end_compact());
|
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_90_with_holes_data(const polygon_90_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_90_with_holes_data& operator=(const polygon_90_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_90_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 // get begin iterator, returns a pointer to a const coordinate_type
|
Chris@16
|
82 inline const compact_iterator_type begin_compact() const {
|
Chris@16
|
83 return self_.begin_compact();
|
Chris@16
|
84 }
|
Chris@16
|
85
|
Chris@16
|
86 // get end iterator, returns a pointer to a const coordinate_type
|
Chris@16
|
87 inline const compact_iterator_type end_compact() const {
|
Chris@16
|
88 return self_.end_compact();
|
Chris@16
|
89 }
|
Chris@16
|
90
|
Chris@16
|
91 inline std::size_t size() const {
|
Chris@16
|
92 return self_.size();
|
Chris@16
|
93 }
|
Chris@16
|
94
|
Chris@16
|
95 // get begin iterator, returns a pointer to a const polygon
|
Chris@16
|
96 inline const iterator_holes_type begin_holes() const {
|
Chris@16
|
97 return holes_.begin();
|
Chris@16
|
98 }
|
Chris@16
|
99
|
Chris@16
|
100 // get end iterator, returns a pointer to a const polygon
|
Chris@16
|
101 inline const iterator_holes_type end_holes() const {
|
Chris@16
|
102 return holes_.end();
|
Chris@16
|
103 }
|
Chris@16
|
104
|
Chris@16
|
105 inline std::size_t size_holes() const {
|
Chris@16
|
106 return holes_.size();
|
Chris@16
|
107 }
|
Chris@16
|
108
|
Chris@16
|
109 private:
|
Chris@16
|
110 polygon_90_data<coordinate_type> self_;
|
Chris@16
|
111 std::list<hole_type> holes_;
|
Chris@16
|
112 };
|
Chris@16
|
113 }
|
Chris@16
|
114 }
|
Chris@16
|
115 #endif
|