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_DATA_HPP Chris@16: #define BOOST_POLYGON_POLYGON_90_DATA_HPP Chris@16: namespace boost { namespace polygon{ Chris@16: struct polygon_90_concept; Chris@16: template Chris@16: class polygon_90_data { Chris@16: public: Chris@16: typedef polygon_90_concept geometry_type; Chris@16: typedef T coordinate_type; Chris@16: typedef typename std::vector::const_iterator compact_iterator_type; Chris@16: typedef iterator_compact_to_points > iterator_type; Chris@16: typedef typename coordinate_traits::area_type area_type; Chris@16: Chris@16: inline polygon_90_data() : coords_() {} //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_data& set(iT begin_point, iT end_point) { Chris@16: return set_compact(iterator_points_to_compact::value_type>(begin_point, end_point), Chris@16: iterator_points_to_compact::value_type>(end_point, end_point)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline polygon_90_data& set_compact(iT input_begin, iT input_end) { Chris@16: coords_.clear(); //just in case there was some old data there Chris@16: while(input_begin != input_end) { Chris@16: coords_.insert(coords_.end(), *input_begin); Chris@16: ++input_begin; Chris@16: } Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // copy constructor (since we have dynamic memory) Chris@16: inline polygon_90_data(const polygon_90_data& that) : coords_(that.coords_) {} Chris@16: Chris@16: // assignment operator (since we have dynamic memory do a deep copy) Chris@16: inline polygon_90_data& operator=(const polygon_90_data& that) { Chris@16: coords_ = that.coords_; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: template Chris@16: inline polygon_90_data& operator=(const T2& rvalue); Chris@16: Chris@16: // assignment operator (since we have dynamic memory do a deep copy) Chris@16: inline bool operator==(const polygon_90_data& that) const { Chris@16: return coords_ == that.coords_; Chris@16: } Chris@16: Chris@16: // get begin iterator, returns a pointer to a const Unit Chris@16: inline iterator_type begin() const { return iterator_type(coords_.begin(), coords_.end()); } Chris@16: Chris@16: // get end iterator, returns a pointer to a const Unit Chris@16: inline iterator_type end() const { return iterator_type(coords_.end(), coords_.end()); } Chris@16: Chris@16: // get begin iterator, returns a pointer to a const Unit Chris@16: inline compact_iterator_type begin_compact() const { return coords_.begin(); } Chris@16: Chris@16: // get end iterator, returns a pointer to a const Unit Chris@16: inline compact_iterator_type end_compact() const { return coords_.end(); } Chris@16: Chris@16: inline std::size_t size() const { return coords_.size(); } Chris@16: Chris@16: private: Chris@16: std::vector coords_; Chris@16: }; Chris@16: Chris@16: Chris@16: } Chris@16: } Chris@16: #endif