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