Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 08:58:14

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_DATA_HPP
0009 #define BOOST_POLYGON_POLYGON_DATA_HPP
0010 namespace boost { namespace polygon{
0011 struct polygon_concept;
0012 template <typename T>
0013 class polygon_data {
0014 public:
0015   typedef polygon_concept geometry_type;
0016   typedef T coordinate_type;
0017   typedef typename std::vector<point_data<coordinate_type> >::const_iterator iterator_type;
0018   typedef typename coordinate_traits<T>::coordinate_distance area_type;
0019   typedef point_data<T> point_type;
0020 
0021   inline polygon_data() : coords_() {} //do nothing default constructor
0022 
0023   template<class iT>
0024   inline polygon_data(iT input_begin, iT input_end) : coords_(input_begin, input_end) {}
0025 
0026   template<class iT>
0027   inline polygon_data& set(iT input_begin, iT input_end) {
0028     coords_.clear();  //just in case there was some old data there
0029     coords_.insert(coords_.end(), input_begin, input_end);
0030     return *this;
0031   }
0032 
0033   // copy constructor (since we have dynamic memory)
0034   inline polygon_data(const polygon_data& that) : coords_(that.coords_) {}
0035 
0036   // assignment operator (since we have dynamic memory do a deep copy)
0037   inline polygon_data& operator=(const polygon_data& that) {
0038     coords_ = that.coords_;
0039     return *this;
0040   }
0041 
0042   template <typename T2>
0043   inline polygon_data& operator=(const T2& rvalue);
0044 
0045   inline bool operator==(const polygon_data& that) const {
0046     if(coords_.size() != that.coords_.size()) return false;
0047     for(std::size_t i = 0; i < coords_.size(); ++i) {
0048       if(coords_[i] != that.coords_[i]) return false;
0049     }
0050     return true;
0051   }
0052 
0053   inline bool operator!=(const polygon_data& that) const { return !((*this) == that); }
0054 
0055   // get begin iterator, returns a pointer to a const Unit
0056   inline iterator_type begin() const { return coords_.begin(); }
0057 
0058   // get end iterator, returns a pointer to a const Unit
0059   inline iterator_type end() const { return coords_.end(); }
0060 
0061   inline std::size_t size() const { return coords_.size(); }
0062 
0063 public:
0064   std::vector<point_data<coordinate_type> > coords_;
0065 };
0066 
0067 }
0068 }
0069 #endif