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_WITH_HOLES_DATA_HPP
9 #define BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP
10 namespace boost { namespace polygon{
11 #include "isotropy.hpp"
12 #include "polygon_90_data.hpp"
13 struct polygon_90_with_holes_concept;
15 class polygon_90_with_holes_data {
17 typedef polygon_90_with_holes_concept geometry_type;
18 typedef T coordinate_type;
19 typedef typename polygon_90_data<T>::iterator_type iterator_type;
20 typedef typename polygon_90_data<T>::compact_iterator_type compact_iterator_type;
21 typedef typename std::list<polygon_90_data<coordinate_type> >::const_iterator iterator_holes_type;
22 typedef polygon_90_data<coordinate_type> hole_type;
23 typedef typename coordinate_traits<T>::area_type area_type;
24 typedef point_data<T> point_type;
26 // default constructor of point does not initialize x and y
27 inline polygon_90_with_holes_data() : self_(), holes_() {} //do nothing default constructor
29 // initialize a polygon from x,y values, it is assumed that the first is an x
30 // and that the input is a well behaved polygon
32 inline polygon_90_with_holes_data& set(iT input_begin, iT input_end) {
33 self_.set(input_begin, input_end);
37 // initialize a polygon from x,y values, it is assumed that the first is an x
38 // and that the input is a well behaved polygon
40 inline polygon_90_with_holes_data& set_compact(iT input_begin, iT input_end) {
41 self_.set_compact(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_90_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_compact((*input_begin).begin_compact(), (*input_begin).end_compact());
57 // copy constructor (since we have dynamic memory)
58 inline polygon_90_with_holes_data(const polygon_90_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_90_with_holes_data& operator=(const polygon_90_with_holes_data& that) {
68 template <typename T2>
69 inline polygon_90_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 // get begin iterator, returns a pointer to a const coordinate_type
82 inline const compact_iterator_type begin_compact() const {
83 return self_.begin_compact();
86 // get end iterator, returns a pointer to a const coordinate_type
87 inline const compact_iterator_type end_compact() const {
88 return self_.end_compact();
91 inline std::size_t size() const {
95 // get begin iterator, returns a pointer to a const polygon
96 inline const iterator_holes_type begin_holes() const {
97 return holes_.begin();
100 // get end iterator, returns a pointer to a const polygon
101 inline const iterator_holes_type end_holes() const {
105 inline std::size_t size_holes() const {
106 return holes_.size();
110 polygon_90_data<coordinate_type> self_;
111 std::list<hole_type> holes_;