MAJOR=4
MINOR=53
DEVNAME=tty53
  E   ˆl–Ãa¾”êh¥2 ¸&®6â˜´o�þDË�‘få �-Æ1 ÏÂ…M>&ÿÁ_‹I|¥�+ýÿ¹ä³ÁÀ ?÷     /*
  Copyright 2008 Intel Corporation

  Use, modification and distribution are subject to the Boost Software License,
  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  http://www.boost.org/LICENSE_1_0.txt).
*/
#ifndef BOOST_POLYGON_SCAN_ARBITRARY_HPP
#define BOOST_POLYGON_SCAN_ARBITRARY_HPP
#ifdef BOOST_POLYGON_DEBUG_FILE
#include <fstream>
#endif
#include "polygon_sort_adaptor.hpp"
namespace boost { namespace polygon{

  template <typename Unit>
  class line_intersection : public scanline_base<Unit> {
  private:
    typedef typename scanline_base<Unit>::Point Point;

    //the first point is the vertex and and second point establishes the slope of an edge eminating from the vertex
    //typedef std::pair<Point, Point> half_edge;
    typedef typename scanline_base<Unit>::half_edge half_edge;

    //scanline comparator functor
    typedef typename scanline_base<Unit>::less_half_edge less_half_edge;
    typedef typename scanline_base<Unit>::less_point less_point;

    //when parallel half edges are encounterd the set of segments is expanded
    //when a edge leaves the scanline it is removed from the set
    //when the set is empty the element is removed from the map
    typedef int segment_id;
    typedef std::pair<half_edge, std::set<segment_id> > scanline_element;
    typedef std::map<half_edge, std::set<segment_id>, less_half_edge> edge_scanline;
    typedef typename edge_scanline::iterator iterator;

//     std::map<Unit, std::set<segment_id> > vertical_data_;
//     edge_scanline edge_scanline_;
//     Unit x_;
//     int just_before_;
//     segment_id segment_id_;
//     std::vector<std::pair<half_edge, int> > event_edges_;
//     std::set<Point> intersection_queue_;
  public:
//     inline line_intersection() : vertical_data_(), edge_scanline_(), x_((std::numeric_limits<Unit>::max)()), just_before_(0), segment_id_(0), event_edges_(), intersection_queue_() {
//       less_half_edge lessElm(&x_, &just_before_);
//       edge_scanline_ = edge_scanline(lessElm);
//     }
//     inline line_intersection(const line_intersection& that) : vertical_data_(), edge_scanline_(), x_(), just_before_(), segment_id_(), event_edges_(), intersection_queue_() { (*this) = that; }
//     inline line_intersection& operator=(const line_intersection& that) {
//       x_ = that.x_;
//       just_before_ = that.just_before_;
//       segment_id_ = that.segment_id_;

//       //I cannot simply copy that.edge_scanline_ to this edge_scanline_ becuase the functor store pointers to other members!
//       less_half_edge lessElm(&x_, &just_before_);
//       edge_scanline_ = edge_scanline(lessElm);

//       edge_scanline_.insert(that.edge_scanline_.begin(), that.edge_scanline_.end());
//       return *this;
//     }

//     static inline void between(Point pt, Point pt1, Point pt2) {
//       less_point lp;
//       if(lp(pt1, pt2))
//         return lp(pt, pt2) && lp(pt1, pt);
//       return lp(pt, pt1) && lp(pt2, pt);
//     }

    template <typename iT>
    static inline void compute_histogram_in_y(iT begin, iT end, std::size_t size, std::vector<std::pair<Unit, std::pair<std::size_t, std::size_t> > >& histogram) {
      std::vector<std::pair<Unit, int> > ends;
      ends.reserve(size * 2);
      for(iT itr = begin ; itr != end; ++itr) {
        int count = (*itr).first.first.y() < (*itr).first.second.y() ? 1 : -1;
        ends.push_back(std::make_pair((*itr).first.first.y(), count));
        ends.push_back(std::make_pair((*itr).first.second.y(), -count));
      }
      polygon_sort(ends.begin(), ends.end());
      histogram.reserve(ends.size());
      histogram.push_back(std::make_pair(ends.front().first, std::make_pair(0, 0)));
      for(typename std::vector<std::pair<Unit, int> >::iterator itr = ends.begin(); itr != ends.end(); ++itr) {
        if((*itr).first != histogram.back().first) {
          histogram.push_back(std::make_pair((*itr).first, histogram.back().second));
        }
        if((*itr).secon