Chris@16: /* Chris@16: Copyright 2008 Intel Corporation Chris@16: Chris@16: Use, modification and distribution are subject to the Boost Software License, Chris@16: Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: http://www.boost.org/LICENSE_1_0.txt). Chris@16: */ Chris@16: #ifndef BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP Chris@16: #define BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP Chris@16: namespace boost { namespace polygon{ Chris@16: #include "isotropy.hpp" Chris@16: #include "polygon_90_data.hpp" Chris@16: struct polygon_90_with_holes_concept; Chris@16: template Chris@16: class polygon_90_with_holes_data { Chris@16: public: Chris@16: typedef polygon_90_with_holes_concept geometry_type; Chris@16: typedef T coordinate_type; Chris@16: typedef typename polygon_90_data::iterator_type iterator_type; Chris@16: typedef typename polygon_90_data::compact_iterator_type compact_iterator_type; Chris@16: typedef typename std::list >::const_iterator iterator_holes_type; Chris@16: typedef polygon_90_data hole_type; Chris@16: typedef typename coordinate_traits::area_type area_type; Chris@16: typedef point_data point_type; Chris@16: Chris@16: // default constructor of point does not initialize x and y Chris@16: inline polygon_90_with_holes_data() : self_(), holes_() {} //do nothing default constructor Chris@16: Chris@16: // initialize a polygon from x,y values, it is assumed that the first is an x Chris@16: // and that the input is a well behaved polygon Chris@16: template Chris@16: inline polygon_90_with_holes_data& set(iT input_begin, iT input_end) { Chris@16: self_.set(input_begin, input_end); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // initialize a polygon from x,y values, it is assumed that the first is an x Chris@16: // and that the input is a well behaved polygon Chris@16: template Chris@16: inline polygon_90_with_holes_data& set_compact(iT input_begin, iT input_end) { Chris@16: self_.set_compact(input_begin, input_end); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // initialize a polygon from x,y values, it is assumed that the first is an x Chris@16: // and that the input is a well behaved polygon Chris@16: template Chris@16: inline polygon_90_with_holes_data& set_holes(iT input_begin, iT input_end) { Chris@16: holes_.clear(); //just in case there was some old data there Chris@16: for( ; input_begin != input_end; ++ input_begin) { Chris@16: holes_.push_back(hole_type()); Chris@16: holes_.back().set_compact((*input_begin).begin_compact(), (*input_begin).end_compact()); Chris@16: } Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // copy constructor (since we have dynamic memory) Chris@16: inline polygon_90_with_holes_data(const polygon_90_with_holes_data& that) : self_(that.self_), Chris@16: holes_(that.holes_) {} Chris@16: Chris@16: // assignment operator (since we have dynamic memory do a deep copy) Chris@16: inline polygon_90_with_holes_data& operator=(const polygon_90_with_holes_data& that) { Chris@16: self_ = that.self_; Chris@16: holes_ = that.holes_; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: template Chris@16: inline polygon_90_with_holes_data& operator=(const T2& rvalue); Chris@16: Chris@16: // get begin iterator, returns a pointer to a const coordinate_type Chris@16: inline const iterator_type begin() const { Chris@16: return self_.begin(); Chris@16: } Chris@16: Chris@16: // get end iterator, returns a pointer to a const coordinate_type Chris@16: inline const iterator_type end() const { Chris@16: return self_.end(); Chris@16: } Chris@16: Chris@16: // get begin iterator, returns a pointer to a const coordinate_type Chris@16: inline const compact_iterator_type begin_compact() const { Chris@16: return self_.begin_compact(); Chris@16: } Chris@16: Chris@16: // get end iterator, returns a pointer to a const coordinate_type Chris@16: inline const compact_iterator_type end_compact() const { Chris@16: return self_.end_compact(); Chris@16: } Chris@16: Chris@16: inline std::size_t size() const { Chris@16: return self_.size(); Chris@16: } Chris@16: Chris@16: // get begin iterator, returns a pointer to a const polygon Chris@16: inline const iterator_holes_type begin_holes() const { Chris@16: return holes_.begin(); Chris@16: } Chris@16: Chris@16: // get end iterator, returns a pointer to a const polygon Chris@16: inline const iterator_holes_type end_holes() const { Chris@16: return holes_.end(); Chris@16: } Chris@16: Chris@16: inline std::size_t size_holes() const { Chris@16: return holes_.size(); Chris@16: } Chris@16: Chris@16: private: Chris@16: polygon_90_data self_; Chris@16: std::list holes_; Chris@16: }; Chris@16: } Chris@16: } Chris@16: #endif