Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:28:40

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_ITERATOR_COMPACT_TO_POINTS_HPP
0009 #define BOOST_POLYGON_ITERATOR_COMPACT_TO_POINTS_HPP
0010 namespace boost { namespace polygon{
0011 template <typename iterator_type, typename point_type>
0012 class iterator_compact_to_points {
0013 private:
0014   iterator_type iter_;
0015   iterator_type iter_end_;
0016   point_type pt_;
0017   typename point_traits<point_type>::coordinate_type firstX_;
0018   orientation_2d orient_;
0019 public:
0020   typedef std::forward_iterator_tag iterator_category;
0021   typedef point_type value_type;
0022   typedef std::ptrdiff_t difference_type;
0023   typedef const point_type* pointer; //immutable
0024   typedef const point_type& reference; //immutable
0025 
0026   inline iterator_compact_to_points() : iter_(), iter_end_(), pt_(), firstX_(), orient_() {}
0027   inline iterator_compact_to_points(iterator_type iter, iterator_type iter_end) :
0028     iter_(iter), iter_end_(iter_end), pt_(), firstX_(), orient_(HORIZONTAL) {
0029     if(iter_ != iter_end_) {
0030       firstX_ = *iter_;
0031       x(pt_, firstX_);
0032       ++iter_;
0033       if(iter_ != iter_end_) {
0034         y(pt_, *iter_);
0035       }
0036     }
0037   }
0038   //use bitwise copy and assign provided by the compiler
0039   inline iterator_compact_to_points& operator++() {
0040     iterator_type prev_iter = iter_;
0041     ++iter_;
0042     if(iter_ == iter_end_) {
0043       if(x(pt_) != firstX_) {
0044         iter_ = prev_iter;
0045         x(pt_, firstX_);
0046       }
0047     } else {
0048       set(pt_, orient_, *iter_);
0049       orient_.turn_90();
0050     }
0051     return *this;
0052   }
0053   inline const iterator_compact_to_points operator++(int) {
0054     iterator_compact_to_points tmp(*this);
0055     ++(*this);
0056     return tmp;
0057   }
0058   inline bool operator==(const iterator_compact_to_points& that) const {
0059     if (iter_ == iter_end_) {
0060       return iter_ == that.iter_;
0061     }
0062     return (iter_ == that.iter_) && (x(pt_) == x(that.pt_));
0063   }
0064   inline bool operator!=(const iterator_compact_to_points& that) const {
0065     if (iter_ == iter_end_) {
0066       return iter_ != that.iter_;
0067     }
0068     return (iter_ != that.iter_) || (x(pt_) != x(that.pt_));
0069   }
0070   inline reference operator*() const { return pt_; }
0071 };
0072 }
0073 }
0074 #endif