polygon_45_data.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright 2008 Intel Corporation
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. #ifndef BOOST_POLYGON_POLYGON_45_DATA_HPP
  8. #define BOOST_POLYGON_POLYGON_45_DATA_HPP
  9. #include "isotropy.hpp"
  10. namespace boost { namespace polygon{
  11. struct polygon_45_concept;
  12. template <typename T> class polygon_data;
  13. template <typename T>
  14. class polygon_45_data {
  15. public:
  16. typedef polygon_45_concept geometry_type;
  17. typedef T coordinate_type;
  18. typedef typename std::vector<point_data<coordinate_type> >::const_iterator iterator_type;
  19. typedef typename coordinate_traits<T>::coordinate_distance area_type;
  20. typedef point_data<T> point_type;
  21. inline polygon_45_data() : coords_() {} //do nothing default constructor
  22. template<class iT>
  23. inline polygon_45_data(iT input_begin, iT input_end) : coords_(input_begin, input_end) {}
  24. template<class iT>
  25. inline polygon_45_data& set(iT input_begin, iT input_end) {
  26. coords_.clear(); //just in case there was some old data there
  27. coords_.insert(coords_.end(), input_begin, input_end);
  28. return *this;
  29. }
  30. // copy constructor (since we have dynamic memory)
  31. inline polygon_45_data(const polygon_45_data& that) : coords_(that.coords_) {}
  32. // assignment operator (since we have dynamic memory do a deep copy)
  33. inline polygon_45_data& operator=(const polygon_45_data& that) {
  34. coords_ = that.coords_;
  35. return *this;
  36. }
  37. template <typename T2>
  38. inline polygon_45_data& operator=(const T2& rvalue);
  39. inline bool operator==(const polygon_45_data& that) const {
  40. if(coords_.size() != that.coords_.size()) return false;
  41. for(std::size_t i = 0; i < coords_.size(); ++i) {
  42. if(coords_[i] != that.coords_[i]) return false;
  43. }
  44. return true;
  45. }
  46. inline bool operator!=(const polygon_45_data& that) const { return !((*this) == that); }
  47. // get begin iterator, returns a pointer to a const Unit
  48. inline iterator_type begin() const { return coords_.begin(); }
  49. // get end iterator, returns a pointer to a const Unit
  50. inline iterator_type end() const { return coords_.end(); }
  51. inline std::size_t size() const { return coords_.size(); }
  52. public:
  53. std::vector<point_data<coordinate_type> > coords_;
  54. };
  55. }
  56. }
  57. #endif