2 Copyright 2008 Intel Corporation
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).
8 #ifndef BOOST_POLYGON_POLYGON_90_DATA_HPP
9 #define BOOST_POLYGON_POLYGON_90_DATA_HPP
10 namespace boost { namespace polygon{
11 struct polygon_90_concept;
13 class polygon_90_data {
15 typedef polygon_90_concept geometry_type;
16 typedef T coordinate_type;
17 typedef typename std::vector<coordinate_type>::const_iterator compact_iterator_type;
18 typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
19 typedef typename coordinate_traits<T>::area_type area_type;
21 inline polygon_90_data() : coords_() {} //do nothing default constructor
23 // initialize a polygon from x,y values, it is assumed that the first is an x
24 // and that the input is a well behaved polygon
26 inline polygon_90_data& set(iT begin_point, iT end_point) {
27 return set_compact(iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(begin_point, end_point),
28 iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(end_point, end_point));
32 inline polygon_90_data& set_compact(iT input_begin, iT input_end) {
33 coords_.clear(); //just in case there was some old data there
34 while(input_begin != input_end) {
35 coords_.insert(coords_.end(), *input_begin);
41 // copy constructor (since we have dynamic memory)
42 inline polygon_90_data(const polygon_90_data& that) : coords_(that.coords_) {}
44 // assignment operator (since we have dynamic memory do a deep copy)
45 inline polygon_90_data& operator=(const polygon_90_data& that) {
46 coords_ = that.coords_;
50 template <typename T2>
51 inline polygon_90_data& operator=(const T2& rvalue);
53 // assignment operator (since we have dynamic memory do a deep copy)
54 inline bool operator==(const polygon_90_data& that) const {
55 return coords_ == that.coords_;
58 // get begin iterator, returns a pointer to a const Unit
59 inline iterator_type begin() const { return iterator_type(coords_.begin(), coords_.end()); }
61 // get end iterator, returns a pointer to a const Unit
62 inline iterator_type end() const { return iterator_type(coords_.end(), coords_.end()); }
64 // get begin iterator, returns a pointer to a const Unit
65 inline compact_iterator_type begin_compact() const { return coords_.begin(); }
67 // get end iterator, returns a pointer to a const Unit
68 inline compact_iterator_type end_compact() const { return coords_.end(); }
70 inline std::size_t size() const { return coords_.size(); }
73 std::vector<coordinate_type> coords_;