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_WITH_HOLES_DATA_HPP
9 #define BOOST_POLYGON_POLYGON_WITH_HOLES_DATA_HPP
10 #include "isotropy.hpp"
11 #include "polygon_data.hpp"
12 namespace boost { namespace polygon{
13 struct polygon_with_holes_concept;
15 class polygon_with_holes_data {
17 typedef polygon_with_holes_concept geometry_type;
18 typedef T coordinate_type;
19 typedef typename polygon_data<T>::iterator_type iterator_type;
20 typedef typename std::list<polygon_data<coordinate_type> >::const_iterator iterator_holes_type;
21 typedef polygon_data<coordinate_type> hole_type;
22 typedef typename coordinate_traits<T>::coordinate_distance area_type;
23 typedef point_data<T> point_type;
25 // default constructor of point does not initialize x and y
26 inline polygon_with_holes_data() : self_(), holes_() {} //do nothing default constructor
29 inline polygon_with_holes_data(iT input_begin, iT input_end) : self_(), holes_() {
30 set(input_begin, input_end);
33 template<class iT, typename hiT>
34 inline polygon_with_holes_data(iT input_begin, iT input_end, hiT holes_begin, hiT holes_end) : self_(), holes_() {
35 set(input_begin, input_end);
36 set_holes(holes_begin, holes_end);
40 inline polygon_with_holes_data& set(iT input_begin, iT input_end) {
41 self_.set(input_begin, input_end);
45 // initialize a polygon from x,y values, it is assumed that the first is an x
46 // and that the input is a well behaved polygon
48 inline polygon_with_holes_data& set_holes(iT input_begin, iT input_end) {
49 holes_.clear(); //just in case there was some old data there
50 for( ; input_begin != input_end; ++ input_begin) {
51 holes_.push_back(hole_type());
52 holes_.back().set((*input_begin).begin(), (*input_begin).end());
57 // copy constructor (since we have dynamic memory)
58 inline polygon_with_holes_data(const polygon_with_holes_data& that) : self_(that.self_),
59 holes_(that.holes_) {}
61 // assignment operator (since we have dynamic memory do a deep copy)
62 inline polygon_with_holes_data& operator=(const polygon_with_holes_data& that) {
68 template <typename T2>
69 inline polygon_with_holes_data& operator=(const T2& rvalue);
71 // get begin iterator, returns a pointer to a const coordinate_type
72 inline const iterator_type begin() const {
76 // get end iterator, returns a pointer to a const coordinate_type
77 inline const iterator_type end() const {
81 inline std::size_t size() const {
85 // get begin iterator, returns a pointer to a const polygon
86 inline const iterator_holes_type begin_holes() const {
87 return holes_.begin();
90 // get end iterator, returns a pointer to a const polygon
91 inline const iterator_holes_type end_holes() const {
95 inline std::size_t size_holes() const {
100 polygon_data<coordinate_type> self_;
101 std::list<hole_type> holes_;