Back to home page

EIC code displayed by LXR

 
 

    


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

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_WITH_HOLES_DATA_HPP
0009 #define BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP
0010 namespace boost { namespace polygon{
0011 #include "isotropy.hpp"
0012 #include "polygon_90_data.hpp"
0013 struct polygon_90_with_holes_concept;
0014 template <typename T>
0015 class polygon_90_with_holes_data {
0016 public:
0017   typedef polygon_90_with_holes_concept geometry_type;
0018   typedef T coordinate_type;
0019   typedef typename polygon_90_data<T>::iterator_type iterator_type;
0020   typedef typename polygon_90_data<T>::compact_iterator_type compact_iterator_type;
0021   typedef typename std::list<polygon_90_data<coordinate_type> >::const_iterator iterator_holes_type;
0022   typedef polygon_90_data<coordinate_type> hole_type;
0023   typedef typename coordinate_traits<T>::area_type area_type;
0024   typedef point_data<T> point_type;
0025 
0026   // default constructor of point does not initialize x and y
0027   inline polygon_90_with_holes_data() : self_(), holes_() {} //do nothing default constructor
0028 
0029   // initialize a polygon from x,y values, it is assumed that the first is an x
0030   // and that the input is a well behaved polygon
0031   template<class iT>
0032   inline polygon_90_with_holes_data& set(iT input_begin, iT input_end) {
0033     self_.set(input_begin, input_end);
0034     return *this;
0035   }
0036 
0037   // initialize a polygon from x,y values, it is assumed that the first is an x
0038   // and that the input is a well behaved polygon
0039   template<class iT>
0040   inline polygon_90_with_holes_data& set_compact(iT input_begin, iT input_end) {
0041     self_.set_compact(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_90_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_compact((*input_begin).begin_compact(), (*input_begin).end_compact());
0053     }
0054     return *this;
0055   }
0056 
0057   // copy constructor (since we have dynamic memory)
0058   inline polygon_90_with_holes_data(const polygon_90_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_90_with_holes_data& operator=(const polygon_90_with_holes_data& that) {
0063     self_ = that.self_;
0064     holes_ = that.holes_;
0065     return *this;
0066   }
0067 
0068   template <typename T2>
0069   inline polygon_90_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   // get begin iterator, returns a pointer to a const coordinate_type
0082   inline const compact_iterator_type begin_compact() const {
0083     return self_.begin_compact();
0084   }
0085 
0086   // get end iterator, returns a pointer to a const coordinate_type
0087   inline const compact_iterator_type end_compact() const {
0088     return self_.end_compact();
0089   }
0090 
0091   inline std::size_t size() const {
0092     return self_.size();
0093   }
0094 
0095   // get begin iterator, returns a pointer to a const polygon
0096   inline const iterator_holes_type begin_holes() const {
0097     return holes_.begin();
0098   }
0099 
0100   // get end iterator, returns a pointer to a const polygon
0101   inline const iterator_holes_type end_holes() const {
0102     return holes_.end();
0103   }
0104 
0105   inline std::size_t size_holes() const {
0106     return holes_.size();
0107   }
0108 
0109 private:
0110   polygon_90_data<coordinate_type> self_;
0111   std::list<hole_type> holes_;
0112 };
0113 }
0114 }
0115 #endif