Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:48:00

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_45_WITH_HOLES_DATA_HPP
0009 #define BOOST_POLYGON_POLYGON_45_WITH_HOLES_DATA_HPP
0010 #include "isotropy.hpp"
0011 #include "polygon_45_data.hpp"
0012 namespace boost { namespace polygon{
0013 struct polygon_45_with_holes_concept;
0014 template <typename T>
0015 class polygon_45_with_holes_data {
0016 public:
0017   typedef polygon_45_with_holes_concept geometry_type;
0018   typedef T coordinate_type;
0019   typedef typename polygon_45_data<T>::iterator_type iterator_type;
0020   typedef typename std::list<polygon_45_data<coordinate_type> >::const_iterator iterator_holes_type;
0021   typedef polygon_45_data<coordinate_type> hole_type;
0022   typedef typename coordinate_traits<T>::coordinate_distance area_type;
0023   typedef point_data<T> point_type;
0024 
0025   // default constructor of point does not initialize x and y
0026   inline polygon_45_with_holes_data() : self_(), holes_() {} //do nothing default constructor
0027 
0028   template<class iT>
0029   inline polygon_45_with_holes_data(iT input_begin, iT input_end) : self_(), holes_() {
0030     set(input_begin, input_end);
0031   }
0032 
0033   template<class iT, typename hiT>
0034   inline polygon_45_with_holes_data(iT input_begin, iT input_end, hiT holes_begin, hiT holes_end) : self_(), holes_() {
0035     set(input_begin, input_end);
0036     set_holes(holes_begin, holes_end);
0037   }
0038 
0039   template<class iT>
0040   inline polygon_45_with_holes_data& set(iT input_begin, iT input_end) {
0041     self_.set(input_begin, input_end);
0042     return *this;
0043   }
0044 
0045   // initialize a polygon from x,y values, it is assumed that the first is an x
0046   // and that the input is a well behaved polygon
0047   template<class iT>
0048   inline polygon_45_with_holes_data& set_holes(iT input_begin, iT input_end) {
0049     holes_.clear();  //just in case there was some old data there
0050     for( ; input_begin != input_end; ++ input_begin) {
0051        holes_.push_back(hole_type());
0052        holes_.back().set((*input_begin).begin(), (*input_begin).end());
0053     }
0054     return *this;
0055   }
0056 
0057   // copy constructor (since we have dynamic memory)
0058   inline polygon_45_with_holes_data(const polygon_45_with_holes_data& that) : self_(that.self_),
0059                                                                   holes_(that.holes_) {}
0060 
0061   // assignment operator (since we have dynamic memory do a deep copy)
0062   inline polygon_45_with_holes_data& operator=(const polygon_45_with_holes_data& that) {
0063     self_ = that.self_;
0064     holes_ = that.holes_;
0065     return *this;
0066   }
0067 
0068   template <typename T2>
0069   inline polygon_45_with_holes_data& operator=(const T2& rvalue);
0070 
0071   // get begin iterator, returns a pointer to a const coordinate_type
0072   inline const iterator_type begin() const {
0073     return self_.begin();
0074   }
0075 
0076   // get end iterator, returns a pointer to a const coordinate_type
0077   inline const iterator_type end() const {
0078     return self_.end();
0079   }
0080 
0081   inline std::size_t size() const {
0082     return self_.size();
0083   }
0084 
0085   // get begin iterator, returns a pointer to a const polygon
0086   inline const iterator_holes_type begin_holes() const {
0087     return holes_.begin();
0088   }
0089 
0090   // get end iterator, returns a pointer to a const polygon
0091   inline const iterator_holes_type end_holes() const {
0092     return holes_.end();
0093   }
0094 
0095   inline std::size_t size_holes() const {
0096     return holes_.size();
0097   }
0098 
0099 public:
0100   polygon_45_data<coordinate_type> self_;
0101   std::list<hole_type> holes_;
0102 };
0103 
0104 
0105 }
0106 }
0107 #endif