Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:55:23

0001 /*
0002   Copyright 2008 Intel Corporation
0003 
0004   Use, modification and distribution are subject to the Boost Software License,
0005   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006   http://www.boost.org/LICENSE_1_0.txt).
0007 */
0008 #ifndef BOOST_POLYGON_POLYGON_90_DATA_HPP
0009 #define BOOST_POLYGON_POLYGON_90_DATA_HPP
0010 namespace boost { namespace polygon{
0011 struct polygon_90_concept;
0012 template <typename T>
0013 class polygon_90_data {
0014 public:
0015   typedef polygon_90_concept geometry_type;
0016   typedef T coordinate_type;
0017   typedef typename std::vector<coordinate_type>::const_iterator compact_iterator_type;
0018   typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
0019   typedef typename coordinate_traits<T>::area_type area_type;
0020 
0021   inline polygon_90_data() : coords_() {} //do nothing default constructor
0022 
0023   // initialize a polygon from x,y values, it is assumed that the first is an x
0024   // and that the input is a well behaved polygon
0025   template<class iT>
0026   inline polygon_90_data& set(iT begin_point, iT end_point) {
0027     return set_compact(iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(begin_point, end_point),
0028                        iterator_points_to_compact<iT, typename std::iterator_traits<iT>::value_type>(end_point, end_point));
0029   }
0030 
0031   template<class iT>
0032   inline polygon_90_data& set_compact(iT input_begin, iT input_end) {
0033     coords_.clear();  //just in case there was some old data there
0034     while(input_begin != input_end) {
0035        coords_.insert(coords_.end(), *input_begin);
0036        ++input_begin;
0037     }
0038     return *this;
0039   }
0040 
0041   // copy constructor (since we have dynamic memory)
0042   inline polygon_90_data(const polygon_90_data& that) : coords_(that.coords_) {}
0043 
0044   // assignment operator (since we have dynamic memory do a deep copy)
0045   inline polygon_90_data& operator=(const polygon_90_data& that) {
0046     coords_ = that.coords_;
0047     return *this;
0048   }
0049 
0050   template <typename T2>
0051   inline polygon_90_data& operator=(const T2& rvalue);
0052 
0053   // assignment operator (since we have dynamic memory do a deep copy)
0054   inline bool operator==(const polygon_90_data& that) const {
0055     return coords_ == that.coords_;
0056   }
0057 
0058   // get begin iterator, returns a pointer to a const Unit
0059   inline iterator_type begin() const { return iterator_type(coords_.begin(), coords_.end()); }
0060 
0061   // get end iterator, returns a pointer to a const Unit
0062   inline iterator_type end() const { return iterator_type(coords_.end(), coords_.end()); }
0063 
0064   // get begin iterator, returns a pointer to a const Unit
0065   inline compact_iterator_type begin_compact() const { return coords_.begin(); }
0066 
0067   // get end iterator, returns a pointer to a const Unit
0068   inline compact_iterator_type end_compact() const { return coords_.end(); }
0069 
0070   inline std::size_t size() const { return coords_.size(); }
0071 
0072 private:
0073   std::vector<coordinate_type> coords_;
0074 };
0075 
0076 
0077 }
0078 }
0079 #endif