$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54345 - in sandbox/gtl/boost/polygon: . detail
From: lucanus.j.simonson_at_[hidden]
Date: 2009-06-25 13:06:29
Author: ljsimons
Date: 2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
New Revision: 54345
URL: http://svn.boost.org/trac/boost/changeset/54345
Log:
added view_as, changed directory tree, fixed all macros
Added:
   sandbox/gtl/boost/polygon/detail/
   sandbox/gtl/boost/polygon/detail/boolean_op.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/boolean_op_45.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/iterator_compact_to_points.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/iterator_geometry_to_set.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/iterator_points_to_compact.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/max_cover.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_45_formation.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_45_set_view.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_45_touch.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_90_set_view.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_90_touch.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_arbitrary_formation.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_formation.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/polygon_set_view.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/property_merge.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/rectangle_formation.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/scan_arbitrary.hpp   (contents, props changed)
   sandbox/gtl/boost/polygon/detail/transform_detail.hpp   (contents, props changed)
Removed:
   sandbox/gtl/boost/polygon/boolean_op.hpp
   sandbox/gtl/boost/polygon/boolean_op_45.hpp
   sandbox/gtl/boost/polygon/iterator_compact_to_points.hpp
   sandbox/gtl/boost/polygon/iterator_geometry_to_set.hpp
   sandbox/gtl/boost/polygon/iterator_points_to_compact.hpp
   sandbox/gtl/boost/polygon/max_cover.hpp
   sandbox/gtl/boost/polygon/polygon_45_formation.hpp
   sandbox/gtl/boost/polygon/polygon_45_set_view.hpp
   sandbox/gtl/boost/polygon/polygon_45_touch.hpp
   sandbox/gtl/boost/polygon/polygon_90_set_view.hpp
   sandbox/gtl/boost/polygon/polygon_90_touch.hpp
   sandbox/gtl/boost/polygon/polygon_arbitrary_formation.hpp
   sandbox/gtl/boost/polygon/polygon_formation.hpp
   sandbox/gtl/boost/polygon/polygon_set_view.hpp
   sandbox/gtl/boost/polygon/property_merge.hpp
   sandbox/gtl/boost/polygon/rectangle_formation.hpp
   sandbox/gtl/boost/polygon/scan_arbitrary.hpp
   sandbox/gtl/boost/polygon/transform_detail.hpp
Text files modified: 
   sandbox/gtl/boost/polygon/gmp_override.hpp               |     4                                         
   sandbox/gtl/boost/polygon/gtl_boost_unit_test.cpp        |   218 +++++++++++++++++++---------            
   sandbox/gtl/boost/polygon/interval_concept.hpp           |     4                                         
   sandbox/gtl/boost/polygon/interval_data.hpp              |     4                                         
   sandbox/gtl/boost/polygon/interval_traits.hpp            |     4                                         
   sandbox/gtl/boost/polygon/isotropy.hpp                   |    36 ++++                                    
   sandbox/gtl/boost/polygon/point_3d_concept.hpp           |     3                                         
   sandbox/gtl/boost/polygon/point_3d_data.hpp              |     4                                         
   sandbox/gtl/boost/polygon/point_3d_traits.hpp            |     4                                         
   sandbox/gtl/boost/polygon/point_concept.hpp              |     4                                         
   sandbox/gtl/boost/polygon/point_traits.hpp               |     4                                         
   sandbox/gtl/boost/polygon/polygon.hpp                    |   223 ++--------------------------            
   sandbox/gtl/boost/polygon/polygon_45_data.hpp            |     7                                         
   sandbox/gtl/boost/polygon/polygon_45_set_concept.hpp     |    95 ++++++++++++                            
   sandbox/gtl/boost/polygon/polygon_45_set_data.hpp        |     7                                         
   sandbox/gtl/boost/polygon/polygon_45_set_traits.hpp      |     4                                         
   sandbox/gtl/boost/polygon/polygon_45_with_holes_data.hpp |     9                                         
   sandbox/gtl/boost/polygon/polygon_90_data.hpp            |     4                                         
   sandbox/gtl/boost/polygon/polygon_90_set_concept.hpp     |     9                                         
   sandbox/gtl/boost/polygon/polygon_90_set_data.hpp        |    23 ++                                      
   sandbox/gtl/boost/polygon/polygon_90_set_traits.hpp      |     4                                         
   sandbox/gtl/boost/polygon/polygon_90_with_holes_data.hpp |     9                                         
   sandbox/gtl/boost/polygon/polygon_data.hpp               |    83 ++++++++--                              
   sandbox/gtl/boost/polygon/polygon_set_concept.hpp        |   102 ++++++++++++-                           
   sandbox/gtl/boost/polygon/polygon_set_data.hpp           |    19 ++                                      
   sandbox/gtl/boost/polygon/polygon_set_traits.hpp         |     4                                         
   sandbox/gtl/boost/polygon/polygon_traits.hpp             |   309 +++++++++++++++++++++++++++++++++++++++ 
   sandbox/gtl/boost/polygon/polygon_with_holes_data.hpp    |   112 +++++++++++++                           
   sandbox/gtl/boost/polygon/rectangle_concept.hpp          |     4                                         
   sandbox/gtl/boost/polygon/rectangle_data.hpp             |     4                                         
   sandbox/gtl/boost/polygon/rectangle_traits.hpp           |     4                                         
   sandbox/gtl/boost/polygon/transform.hpp                  |     8                                         
   32 files changed, 968 insertions(+), 364 deletions(-)
Deleted: sandbox/gtl/boost/polygon/boolean_op.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/boolean_op.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,558 +0,0 @@
-/*
-  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 GTL_BOOLEAN_OP_HPP
-#define GTL_BOOLEAN_OP_HPP
-namespace boost { namespace polygon{
-namespace boolean_op {
-
-  //BooleanOp is the generic boolean operation scanline algorithm that provides
-  //all the simple boolean set operations on manhattan data.  By templatizing
-  //the intersection count of the input and algorithm internals it is extensible
-  //to multi-layer scans, properties and other advanced scanline operations above
-  //and beyond simple booleans.
-  //T must cast to int
-  template <class T, typename Unit>
-  class BooleanOp {
-  public:
-    typedef std::map<Unit, T> ScanData;
-    typedef std::pair<Unit, T> ElementType;
-  protected:
-    ScanData scanData_;
-    typename ScanData::iterator nextItr_;
-    T nullT_;
-  public:
-    inline BooleanOp () : scanData_(), nextItr_(), nullT_() { nextItr_ = scanData_.end(); nullT_ = 0; }
-    inline BooleanOp (T nullT) : scanData_(), nextItr_(), nullT_(nullT) { nextItr_ = scanData_.end(); }
-    inline BooleanOp (const BooleanOp& that) : scanData_(that.scanData_), nextItr_(),
-                                               nullT_(that.nullT_) { nextItr_ = scanData_.begin(); }
-    inline BooleanOp& operator=(const BooleanOp& that); 
-   
-    //moves scanline forward
-    inline void advanceScan() { nextItr_ = scanData_.begin(); }
-
-    //proceses the given interval and T data
-    //appends output edges to cT
-    template <class cT>
-    inline void processInterval(cT& outputContainer, interval_data<Unit> ivl, T deltaCount);
-   
-  private:
-    inline typename ScanData::iterator lookup_(Unit pos){
-      if(nextItr_ != scanData_.end() && nextItr_->first >= pos) {
-        return nextItr_;
-      }
-      return nextItr_ = scanData_.lower_bound(pos);
-    }
-    inline typename ScanData::iterator insert_(Unit pos, T count){ 
-      return nextItr_ = scanData_.insert(nextItr_, ElementType(pos, count)); 
-    } 
-    template <class cT>
-    inline void evaluateInterval_(cT& outputContainer, interval_data<Unit> ivl, T beforeCount, T afterCount);
-  };
-
-  class BinaryAnd {
-  public:
-    inline BinaryAnd() {}
-    inline bool operator()(int a, int b) { return (a > 0) & (b > 0); }
-  };
-  class BinaryOr {
-  public:
-    inline BinaryOr() {}
-    inline bool operator()(int a, int b) { return (a > 0) | (b > 0); }
-  };
-  class BinaryNot {
-  public:
-    inline BinaryNot() {}
-    inline bool operator()(int a, int b) { return (a > 0) & !(b > 0); }
-  };
-  class BinaryXor {
-  public:
-    inline BinaryXor() {}
-    inline bool operator()(int a, int b) { return (a > 0) ^ (b > 0); }
-  };
-
-  //BinaryCount is an array of two deltaCounts coming from two different layers
-  //of scan event data.  It is the merged count of the two suitable for consumption
-  //as the template argument of the BooleanOp algorithm because BinaryCount casts to int.
-  //T is a binary functor object that evaluates the array of counts and returns a logical 
-  //result of some operation on those values.
-  //BinaryCount supports many of the operators that work with int, particularly the
-  //binary operators, but cannot support less than or increment.
-  template <class T>
-  class BinaryCount {
-  public:
-    inline BinaryCount() : counts_() { counts_[0] = counts_[1] = 0; }
-    // constructs from two integers
-    inline BinaryCount(int countL, int countR) : counts_() { counts_[0] = countL, counts_[1] = countR; }
-    inline BinaryCount& operator=(int count) { counts_[0] = count, counts_[1] = count; return *this; }
-    inline BinaryCount& operator=(const BinaryCount& that); 
-    inline BinaryCount(const BinaryCount& that) : counts_() { *this = that; }
-    inline bool operator==(const BinaryCount& that) const;
-    inline bool operator!=(const BinaryCount& that) const { return !((*this) == that);}
-    inline BinaryCount& operator+=(const BinaryCount& that);
-    inline BinaryCount& operator-=(const BinaryCount& that);
-    inline BinaryCount operator+(const BinaryCount& that) const;
-    inline BinaryCount operator-(const BinaryCount& that) const;
-    inline BinaryCount operator-() const;
-    inline int& operator[](bool index) { return counts_[index]; }
-
-    //cast to int operator evaluates data using T binary functor
-    inline operator int() const { return T()(counts_[0], counts_[1]); }
-  private:
-    int counts_[2];
-  };
-
-  class UnaryCount {
-  public:
-    inline UnaryCount() : count_(0) {}
-    // constructs from two integers
-    inline explicit UnaryCount(int count) : count_(count) {}
-    inline UnaryCount& operator=(int count) { count_ = count; return *this; }
-    inline UnaryCount& operator=(const UnaryCount& that) { count_ = that.count_; return *this; }
-    inline UnaryCount(const UnaryCount& that) : count_(that.count_) {}
-    inline bool operator==(const UnaryCount& that) const { return count_ == that.count_; }
-    inline bool operator!=(const UnaryCount& that) const { return !((*this) == that);}
-    inline UnaryCount& operator+=(const UnaryCount& that) { count_ += that.count_; return *this; }
-    inline UnaryCount& operator-=(const UnaryCount& that) { count_ -= that.count_; return *this; }
-    inline UnaryCount operator+(const UnaryCount& that) const { UnaryCount tmp(*this); tmp += that; return tmp; }
-    inline UnaryCount operator-(const UnaryCount& that) const { UnaryCount tmp(*this); tmp -= that; return tmp; }
-    inline UnaryCount operator-() const { UnaryCount tmp; return tmp - *this; }
-
-    //cast to int operator evaluates data using T binary functor
-    inline operator int() const { return count_ % 2; }
-  private:
-    int count_;
-  };
-
-  template <class T, typename Unit>
-  inline BooleanOp<T, Unit>& BooleanOp<T, Unit>::operator=(const BooleanOp& that) { 
-    scanData_ = that.scanData_; 
-    nextItr_ = scanData_.begin();
-    nullT_ = that.nullT_;
-    return *this;
-  }
-   
-  //appends output edges to cT
-  template <class T, typename Unit>
-  template <class cT>
-  inline void BooleanOp<T, Unit>::processInterval(cT& outputContainer, interval_data<Unit> ivl, T deltaCount) {
-    typename ScanData::iterator lowItr = lookup_(ivl.low());
-    typename ScanData::iterator highItr = lookup_(ivl.high());
-    //add interval to scan data if it is past the end
-    if(lowItr == scanData_.end()) {
-      lowItr = insert_(ivl.low(), deltaCount);
-      highItr = insert_(ivl.high(), nullT_);
-      evaluateInterval_(outputContainer, ivl, nullT_, deltaCount);
-      return;
-    }
-    //ensure that highItr points to the end of the ivl
-    if(highItr == scanData_.end() || (*highItr).first > ivl.high()) {
-      T value = nullT_;
-      if(highItr != scanData_.begin()) {
-        --highItr;
-        value = highItr->second;
-      }
-      nextItr_ = highItr;
-      highItr = insert_(ivl.high(), value);
-    }
-    //split the low interval if needed
-    if(lowItr->first > ivl.low()) {
-      if(lowItr != scanData_.begin()) {
-        --lowItr;
-        nextItr_ = lowItr;
-        lowItr = insert_(ivl.low(), lowItr->second);
-      } else {
-        nextItr_ = lowItr;
-        lowItr = insert_(ivl.low(), nullT_);
-      }
-    }
-    //process scan data intersecting interval
-    for(typename ScanData::iterator itr = lowItr; itr != highItr; ){
-      T beforeCount = itr->second;
-      T afterCount = itr->second += deltaCount;
-      Unit low = itr->first;
-      ++itr;
-      Unit high = itr->first;
-      evaluateInterval_(outputContainer, interval_data<Unit>(low, high), beforeCount, afterCount);
-    }
-    //merge the bottom interval with the one below if they have the same count
-    if(lowItr != scanData_.begin()){
-      typename ScanData::iterator belowLowItr = lowItr;
-      --belowLowItr;
-      if(belowLowItr->second == lowItr->second) {
-        scanData_.erase(lowItr);
-      }
-    }
-    //merge the top interval with the one above if they have the same count
-    if(highItr != scanData_.begin()) {
-      typename ScanData::iterator beforeHighItr = highItr;
-      --beforeHighItr;
-      if(beforeHighItr->second == highItr->second) {
-        scanData_.erase(highItr);
-        highItr = beforeHighItr;
-        ++highItr;
-      }
-    }
-    nextItr_ = highItr;
-  }
-
-  template <class T, typename Unit>
-  template <class cT>
-  inline void BooleanOp<T, Unit>::evaluateInterval_(cT& outputContainer, interval_data<Unit> ivl, 
-                                              T beforeCount, T afterCount) {
-    bool before = (int)beforeCount > 0;
-    bool after = (int)afterCount > 0;
-    int value =  (!before & after) - (before & !after);
-    if(value) {
-      outputContainer.insert(outputContainer.end(), std::pair<interval_data<Unit>, int>(ivl, value));
-    }
-  }
-
-  template <class T>
-  inline BinaryCount<T>& BinaryCount<T>::operator=(const BinaryCount<T>& that) { 
-    counts_[0] = that.counts_[0];
-    counts_[1] = that.counts_[1];
-    return *this;
-  }
-  template <class T>
-  inline bool BinaryCount<T>::operator==(const BinaryCount<T>& that) const { 
-    return counts_[0] == that.counts_[0] &&
-      counts_[1] == that.counts_[1];
-  }
-  template <class T>
-  inline BinaryCount<T>& BinaryCount<T>::operator+=(const BinaryCount<T>& that) {
-    counts_[0] += that.counts_[0];
-    counts_[1] += that.counts_[1];
-    return *this;
-  }
-  template <class T>
-  inline BinaryCount<T>& BinaryCount<T>::operator-=(const BinaryCount<T>& that) {
-    counts_[0] += that.counts_[0];
-    counts_[1] += that.counts_[1];
-    return *this;
-  }
-  template <class T>
-  inline BinaryCount<T> BinaryCount<T>::operator+(const BinaryCount<T>& that) const {
-    BinaryCount retVal(*this);
-    retVal += that;
-    return retVal;
-  }
-  template <class T>
-  inline BinaryCount<T> BinaryCount<T>::operator-(const BinaryCount<T>& that) const {
-    BinaryCount retVal(*this);
-    retVal -= that;
-    return retVal;
-  }
-  template <class T>
-  inline BinaryCount<T> BinaryCount<T>::operator-() const {
-    return BinaryCount<T>() - *this;
-  }
-
-  //self contained unit test for BooleanOr algorithm
-  template <typename Unit>
-  inline bool testBooleanOr() {
-    BooleanOp<int, Unit> booleanOr;
-    //test one rectangle
-    std::vector<std::pair<interval_data<Unit>, int> > container;
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
-    if(container.size() != 2) { 
-      std::cout << "Test one rectangle, wrong output size\n";
-      return false;
-    }
-    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
-      std::cout << "Test one rectangle, first output wrong: Interval(" <<
-        container[0].first << "), " << container[0].second << std::endl;
-    }
-    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
-      std::cout << "Test one rectangle, second output wrong: Interval(" <<
-        container[1].first << "), " << container[1].second << std::endl;
-    }
-
-    //test two rectangles
-    container.clear();
-    booleanOr = BooleanOp<int, Unit>();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(5, 15), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(5, 15), -1);
-    if(container.size() != 4) {
-      std::cout << "Test two rectangles, wrong output size\n";
-      for(unsigned int i = 0; i < container.size(); ++i){
-              std::cout << container[i].first << "), " << container[i].second << std::endl;
-      }
-      return false;
-    }
-    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
-            std::cout << "Test two rectangles, first output wrong: Interval(" <<
-        container[0].first << "), " << container[0].second << std::endl;
-    }
-    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(10, 15), 1)) {
-            std::cout << "Test two rectangles, second output wrong: Interval(" <<
-        container[1].first << "), " << container[1].second << std::endl;
-    }
-    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 5), -1)) {
-            std::cout << "Test two rectangles, third output wrong: Interval(" <<
-        container[2].first << "), " << container[2].second << std::endl;
-    }
-    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(5, 15), -1)) {
-            std::cout << "Test two rectangles, fourth output wrong: Interval(" <<
-        container[3].first << "), " << container[3].second << std::endl;
-    }
-
-    //test two rectangles
-    container.clear();
-    booleanOr = BooleanOp<int, Unit>();
-    booleanOr.processInterval(container, interval_data<Unit>(5, 15), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(5, 15), -1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
-    if(container.size() != 4) {
-            std::cout << "Test other two rectangles, wrong output size\n";
-      for(unsigned int i = 0; i < container.size(); ++i){
-              std::cout << container[i].first << "), " << container[i].second << std::endl;
-      }
-      return false;
-    }
-    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(5, 15), 1)) {
-            std::cout << "Test other two rectangles, first output wrong: Interval(" <<
-        container[0].first << "), " << container[0].second << std::endl;
-    }
-    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 5), 1)) {
-            std::cout << "Test other two rectangles, second output wrong: Interval(" <<
-        container[1].first << "), " << container[1].second << std::endl;
-    }
-    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(10, 15), -1)) {
-            std::cout << "Test other two rectangles, third output wrong: Interval(" <<
-        container[2].first << "), " << container[2].second << std::endl;
-    }
-    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
-            std::cout << "Test other two rectangles, fourth output wrong: Interval(" <<
-        container[3].first << "), " << container[3].second << std::endl;
-    }
-
-    //test two nonoverlapping rectangles
-    container.clear();
-    booleanOr = BooleanOp<int, Unit>();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(15, 25), 1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
-    booleanOr.advanceScan();
-    booleanOr.processInterval(container, interval_data<Unit>(15, 25), -1);
-    if(container.size() != 4) {
-            std::cout << "Test two nonoverlapping rectangles, wrong output size\n";
-      return false;
-    }
-    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
-            std::cout << "Test two nonoverlapping rectangles, first output wrong: Interval(" <<
-        container[0].first << "), " << container[0].second << std::endl;
-    }
-    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(15, 25), 1)) {
-            std::cout << "Test two nonoverlapping rectangles, second output wrong: Interval(" <<
-        container[1].first << "), " << container[1].second << std::endl;
-    }
-    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
-            std::cout << "Test two nonoverlapping rectangles, third output wrong: Interval(" <<
-        container[2].first << "), " << container[2].second << std::endl;
-    }
-    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(15, 25), -1)) {
-            std::cout << "Test two nonoverlapping rectangles, fourth output wrong: Interval(" <<
-        container[3].first << "), " << container[3].second << std::endl;
-    }
-    return true;
-  }
-
-  template <class T, typename Unit, typename iterator_type_1, typename iterator_type_2>
-  inline void applyBooleanBinaryOp(std::vector<std::pair<Unit, std::pair<Unit, int> > >& output,
-                                   //const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input1,
-                                   //const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input2,
-                                   iterator_type_1 itr1, iterator_type_1 itr1_end,
-                                   iterator_type_2 itr2, iterator_type_2 itr2_end,
-                                   T defaultCount) {
-    BooleanOp<T, Unit> boolean(defaultCount);
-    //typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr1 = input1.begin();
-    //typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr2 = input2.begin();
-    std::vector<std::pair<interval_data<Unit>, int> > container;
-    //output.reserve((std::max)(input1.size(), input2.size()));
-
-    //consider eliminating dependecy on limits with bool flag for initial state
-    Unit UnitMax = (std::numeric_limits<Unit>::max)();
-    Unit prevCoord = UnitMax;
-    Unit prevPosition = UnitMax;
-    T count(defaultCount);
-    //define the starting point
-    if(itr1 != itr1_end) {
-      prevCoord = (*itr1).first;
-      prevPosition = (*itr1).second.first;
-      count[0] += (*itr1).second.second;
-    }
-    if(itr2 != itr2_end) {
-      if((*itr2).first < prevCoord || 
-         ((*itr2).first == prevCoord && (*itr2).second.first < prevPosition)) {
-        prevCoord = (*itr2).first;
-        prevPosition = (*itr2).second.first;
-        count = defaultCount;
-        count[1] += (*itr2).second.second;
-        ++itr2;
-      } else if((*itr2).first == prevCoord && (*itr2).second.first == prevPosition) {
-        count[1] += (*itr2).second.second;
-        ++itr2;
-        if(itr1 != itr1_end) ++itr1;
-      } else {
-        if(itr1 != itr1_end) ++itr1;
-      }
-    } else {
-      if(itr1 != itr1_end) ++itr1;
-    }
-    
-    while(itr1 != itr1_end || itr2 != itr2_end) {
-      Unit curCoord = UnitMax;
-      Unit curPosition = UnitMax;
-      T curCount(defaultCount);
-      if(itr1 != itr1_end) {
-        curCoord = (*itr1).first;
-        curPosition = (*itr1).second.first;
-        curCount[0] += (*itr1).second.second;
-      }
-      if(itr2 != itr2_end) {
-        if((*itr2).first < curCoord || 
-           ((*itr2).first == curCoord && (*itr2).second.first < curPosition)) {
-          curCoord = (*itr2).first;
-          curPosition = (*itr2).second.first;
-          curCount = defaultCount;
-          curCount[1] += (*itr2).second.second;
-          ++itr2;
-        } else if((*itr2).first == curCoord && (*itr2).second.first == curPosition) {
-          curCount[1] += (*itr2).second.second;
-          ++itr2;
-          if(itr1 != itr1_end) ++itr1;
-        } else {
-          if(itr1 != itr1_end) ++itr1;
-        }
-      } else {
-        ++itr1;
-      }
-
-      if(prevCoord != curCoord) {
-        boolean.advanceScan();
-        prevCoord = curCoord;
-        prevPosition = curPosition;
-        count = curCount;
-        continue;
-      }
-      if(curPosition != prevPosition && count != defaultCount) {
-        interval_data<Unit> ivl(prevPosition, curPosition);
-        container.clear();
-        boolean.processInterval(container, ivl, count);
-        for(unsigned int i = 0; i < container.size(); ++i) {
-          std::pair<interval_data<Unit>, int>& element = container[i];
-          if(!output.empty() && output.back().first == prevCoord && 
-             output.back().second.first == element.first.low() &&
-             output.back().second.second == element.second * -1) {
-            output.pop_back();
-          } else {
-            output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevCoord, std::pair<Unit, int>(element.first.low(), 
-                                                                                                    element.second)));
-          }
-          output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevCoord, std::pair<Unit, int>(element.first.high(), 
-                                                                                                  element.second * -1)));
-        }
-      }
-      prevPosition = curPosition;
-      count += curCount;
-    }
-  }
-
-  template <class T, typename Unit>
-  inline void applyBooleanBinaryOp(std::vector<std::pair<Unit, std::pair<Unit, int> > >& inputOutput,
-                                   const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input2,
-                                   T defaultCount) {
-    std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
-    applyBooleanBinaryOp(output, inputOutput, input2, defaultCount);
-    if(output.size() < inputOutput.size() / 2) {
-      inputOutput = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
-    } else {
-      inputOutput.clear();
-    }
-    inputOutput.insert(inputOutput.end(), output.begin(), output.end());
-  }
- 
-  template <typename Unit>
-  inline void applyUnaryXOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
-    BooleanOp<UnaryCount, Unit> booleanXOr;
-    
-  }
-
-  template <typename count_type = int>
-  struct default_arg_workaround {
-    template <typename Unit>
-    static inline void applyBooleanOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
-      BooleanOp<count_type, Unit> booleanOr;
-      std::vector<std::pair<interval_data<Unit>, int> > container;
-      std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
-      output.reserve(input.size());
-      //consider eliminating dependecy on limits with bool flag for initial state
-      Unit UnitMax = (std::numeric_limits<Unit>::max)();
-      Unit prevPos = UnitMax;
-      Unit prevY = UnitMax;
-      int count = 0;
-      for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = input.begin();
-          itr != input.end(); ++itr) {
-        Unit pos = (*itr).first;
-        Unit y = (*itr).second.first;
-        if(pos != prevPos) {
-          booleanOr.advanceScan();
-          prevPos = pos;
-          prevY = y;
-          count = (*itr).second.second;
-          continue;
-        }
-        if(y != prevY && count != 0) {
-          interval_data<Unit> ivl(prevY, y);
-          container.clear();
-          booleanOr.processInterval(container, ivl, count_type(count));
-          for(unsigned int i = 0; i < container.size(); ++i) {
-            std::pair<interval_data<Unit>, int>& element = container[i];
-            if(!output.empty() && output.back().first == prevPos && 
-               output.back().second.first == element.first.low() &&
-               output.back().second.second == element.second * -1) {
-              output.pop_back();
-            } else {
-              output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.low(), 
-                                                                                                    element.second)));
-            }
-            output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.high(), 
-                                                                                                  element.second * -1)));
-          }
-        }
-        prevY = y;
-        count += (*itr).second.second;
-      }
-      if(output.size() < input.size() / 2) {
-        input = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
-      } else {
-      input.clear();
-      } 
-      input.insert(input.end(), output.begin(), output.end());
-    }
-  };
-
-}
-
-}
-
-}
-#endif
Deleted: sandbox/gtl/boost/polygon/boolean_op_45.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/boolean_op_45.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,1359 +0,0 @@
-/*
-  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 GTL_BOOLEAN_OP_45_HPP
-#define GTL_BOOLEAN_OP_45_HPP
-namespace boost { namespace polygon{
-
-  template <typename Unit>
-  struct boolean_op_45 {
-    typedef point_data<Unit> Point;
-    typedef typename coordinate_traits<Unit>::manhattan_area_type LongUnit;
-
-    class Count2 {
-    public:
-      inline Count2() : counts() { counts[0] = counts[1] = 0; }
-      //inline Count2(int count) { counts[0] = counts[1] = count; }
-      inline Count2(int count1, int count2) : counts() { counts[0] = count1; counts[1] = count2; }
-      inline Count2(const Count2& count) : counts() { counts[0] = count.counts[0]; counts[1] = count.counts[1]; }
-      inline bool operator==(const Count2& count) const { return counts[0] == count.counts[0] && counts[1] == count.counts[1]; }
-      inline bool operator!=(const Count2& count) const { return !((*this) == count); }
-      inline Count2& operator=(int count) { counts[0] = counts[1] = count; return *this; }
-      inline Count2& operator=(const Count2& count) { counts[0] = count.counts[0]; counts[1] = count.counts[1]; return *this; }
-      inline int& operator[](bool index) { return counts[index]; }
-      inline int operator[](bool index) const {return counts[index]; }
-      inline Count2& operator+=(const Count2& count){
-        counts[0] += count[0];
-        counts[1] += count[1];
-        return *this;
-      }
-      inline Count2& operator-=(const Count2& count){
-        counts[0] -= count[0];
-        counts[1] -= count[1];
-        return *this;
-      }
-      inline Count2 operator+(const Count2& count) const {
-        return Count2(*this)+=count;
-      }
-      inline Count2 operator-(const Count2& count) const {
-        return Count2(*this)-=count;
-      }
-      inline Count2 invert() const {
-        return Count2(-counts[0], -counts[1]);
-      }
-    private:
-      int counts[2];
-    };
-
-    class Count1 {
-    public:
-      inline Count1() : count_(0) { }
-      inline Count1(int count) : count_(count) { }
-      inline Count1(const Count1& count) : count_(count.count_) { }
-      inline bool operator==(const Count1& count) const { return count_ == count.count_; }
-      inline bool operator!=(const Count1& count) const { return !((*this) == count); }
-      inline Count1& operator=(int count) { count_ = count; return *this; }
-      inline Count1& operator=(const Count1& count) { count_ = count.count_; return *this; }
-      inline Count1& operator+=(const Count1& count){
-        count_ += count.count_;
-        return *this;
-      }
-      inline Count1& operator-=(const Count1& count){
-        count_ -= count.count_;
-        return *this;
-      }
-      inline Count1 operator+(const Count1& count) const {
-        return Count1(*this)+=count;
-      }
-      inline Count1 operator-(const Count1& count) const {
-        return Count1(*this)-=count;
-      }
-      inline Count1 invert() const {
-        return Count1(-count_);
-      }
-      int count_;
-    };
-
-    //     inline std::ostream& operator<< (std::ostream& o, const Count2& c) {
-    //       o << c[0] << " " << c[1];
-    //       return o;
-    //     }
-
-    template <typename CountType>
-    class Scan45ElementT {
-    public:
-      Unit x;
-      Unit y;
-      int rise; //-1, 0, +1
-      mutable CountType count;
-      inline Scan45ElementT() : x(), y(), rise(), count() {}
-      inline Scan45ElementT(Unit xIn, Unit yIn, int riseIn, CountType countIn = CountType()) :
-        x(xIn), y(yIn), rise(riseIn), count(countIn) {}
-      inline Scan45ElementT(const Scan45ElementT& that) :
-        x(that.x), y(that.y), rise(that.rise), count(that.count) {}
-      inline Scan45ElementT& operator=(const Scan45ElementT& that) {
-        x = that.x; y = that.y; rise = that.rise; count = that.count; 
-        return *this;
-      }
-      inline Unit evalAtX(Unit xIn) const {
-        return y + rise * (xIn - x);
-      }
-
-      inline bool cross(Point& crossPoint, const Scan45ElementT& edge, Unit currentX) const {
-        Unit y1 = evalAtX(currentX);
-        Unit y2 = edge.evalAtX(currentX);
-        int rise1 = rise;
-        int rise2 = edge.rise;
-        if(rise > edge.rise){
-          if(y1 > y2) return false;
-        } else if(rise < edge.rise){
-          if(y2 > y1) return false;
-          std::swap(y1, y2);
-          std::swap(rise1, rise2);
-        } else { return false; }
-        if(rise1 == 1) {
-          if(rise2 == 0) {
-            crossPoint = Point(currentX + y2 - y1, y2);
-          } else {
-            //rise2 == -1
-            Unit delta = (y2 - y1)/2;
-            crossPoint = Point(currentX + delta, y1 + delta);
-          }
-        } else {
-          //rise1 == 0 and rise2 == -1
-          crossPoint = Point(currentX + y2 - y1, y1);
-        }
-        return true;
-      }
-    };
-    
-    typedef Scan45ElementT<Count2> Scan45Element;
-
-    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Element& c) {
-    //       o << c.x << " " << c.y << " " << c.rise << " " << c.count;
-    //       return o;
-    //     }
-
-    class lessScan45ElementRise : public std::binary_function<Scan45Element, Scan45Element, bool> {
-    public:
-      inline lessScan45ElementRise() {} //default constructor is only constructor
-      inline bool operator () (Scan45Element elm1, Scan45Element elm2) const {
-        return elm1.rise < elm2.rise;
-      }
-    };
-
-    template <typename CountType>
-    class lessScan45Element {
-    private:
-      Unit *x_; //x value at which to apply comparison
-      int *justBefore_;
-    public:
-      inline lessScan45Element() : x_(0), justBefore_(0) {}
-      inline lessScan45Element(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
-      inline lessScan45Element(const lessScan45Element& that) : x_(that.x_), justBefore_(that.justBefore_) {}
-      inline lessScan45Element& operator=(const lessScan45Element& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
-      inline bool operator () (const Scan45ElementT<CountType>& elm1, 
-                               const Scan45ElementT<CountType>& elm2) const {
-        Unit y1 = elm1.evalAtX(*x_);
-        Unit y2 = elm2.evalAtX(*x_);
-        if(y1 < y2) return true;
-        if(y1 == y2) {
-          //if justBefore is true we invert the result of the comparison of slopes
-          if(*justBefore_) {
-            return elm1.rise > elm2.rise;
-          } else {
-            return elm1.rise < elm2.rise;
-          }
-        }
-        return false;
-      }
-    };
-
-    template <typename CountType>
-    class Scan45CountT {
-    public:
-      inline Scan45CountT() : counts() {} //counts[0] = counts[1] = counts[2] = counts[3] = 0; }
-      inline Scan45CountT(CountType count) : counts() { counts[0] = counts[1] = counts[2] = counts[3] = count; }
-      inline Scan45CountT(const CountType& count1, const CountType& count2, const CountType& count3, 
-                          const CountType& count4) : counts() { 
-        counts[0] = count1; 
-        counts[1] = count2; 
-        counts[2] = count3;
-        counts[3] = count4; 
-      }
-      inline Scan45CountT(const Scan45CountT& count) : counts() { 
-        (*this) = count;
-      }
-      inline bool operator==(const Scan45CountT& count) const { 
-        for(unsigned int i = 0; i < 4; ++i) {
-          if(counts[i] != count.counts[i]) return false; 
-        }
-        return true;
-      }
-      inline bool operator!=(const Scan45CountT& count) const { return !((*this) == count); }
-      inline Scan45CountT& operator=(CountType count) { 
-        counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
-      inline Scan45CountT& operator=(const Scan45CountT& count) {
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] = count.counts[i]; 
-        }
-        return *this; 
-      }
-      inline CountType& operator[](int index) { return counts[index]; }
-      inline CountType operator[](int index) const {return counts[index]; }
-      inline Scan45CountT& operator+=(const Scan45CountT& count){
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] += count.counts[i]; 
-        }
-        return *this;
-      }
-      inline Scan45CountT& operator-=(const Scan45CountT& count){
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] -= count.counts[i]; 
-        }
-        return *this;
-      }
-      inline Scan45CountT operator+(const Scan45CountT& count) const {
-        return Scan45CountT(*this)+=count;
-      }
-      inline Scan45CountT operator-(const Scan45CountT& count) const {
-        return Scan45CountT(*this)-=count;
-      }
-      inline Scan45CountT invert() const {
-        return Scan45CountT(CountType())-=(*this);
-      }
-      inline Scan45CountT& operator+=(const Scan45ElementT<CountType>& element){
-        counts[element.rise+1] += element.count; return *this;
-      }
-    private:
-      CountType counts[4];
-    };
-
-    typedef Scan45CountT<Count2> Scan45Count;
-
-    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Count& c) {
-    //       o << c[0] << ", " << c[1] << ", ";
-    //       o << c[2] << ", " << c[3];
-    //       return o;
-    //     }
-
-
-    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Vertex& c) {
-    //       o << c.first << ": " << c.second;
-    //       return o;
-    //     }
-
-
-    //vetex45 is sortable
-    template <typename ct>
-    class Vertex45T {
-    public:
-      Point pt;
-      int rise; // 1, 0 or -1
-      ct count; //dxdydTheta
-      inline Vertex45T() : pt(), rise(), count() {}
-      inline Vertex45T(const Point& point, int riseIn, ct countIn) : pt(point), rise(riseIn), count(countIn) {}
-      inline Vertex45T(const Vertex45T& vertex) : pt(vertex.pt), rise(vertex.rise), count(vertex.count) {}
-      inline Vertex45T& operator=(const Vertex45T& vertex){ 
-        pt = vertex.pt; rise = vertex.rise; count = vertex.count; return *this; }
-      inline Vertex45T(const std::pair<Point, Point>& vertex) {}
-      inline Vertex45T& operator=(const std::pair<Point, Point>& vertex){ return *this; }
-      inline bool operator==(const Vertex45T& vertex) const {
-        return pt == vertex.pt && rise == vertex.rise && count == vertex.count; }
-      inline bool operator!=(const Vertex45T& vertex) const { return !((*this) == vertex); }
-      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
-      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
-      inline bool operator<(const Vertex45T& vertex) const {
-        if(pt.x() < vertex.pt.x()) return true;
-        if(pt.x() == vertex.pt.x()) {
-          if(pt.y() < vertex.pt.y()) return true;
-          if(pt.y() == vertex.pt.y()) { return rise < vertex.rise; }
-        }
-        return false;
-      }
-      inline bool operator>(const Vertex45T& vertex) const { return vertex < (*this); }
-      inline bool operator<=(const Vertex45T& vertex) const { return !((*this) > vertex); }
-      inline bool operator>=(const Vertex45T& vertex) const { return !((*this) < vertex); }
-      inline Unit evalAtX(Unit xIn) const { return pt.y() + rise * (xIn - pt.x()); }
-    };
-
-    typedef Vertex45T<int> Vertex45;
-
-    //     inline std::ostream& operator<< (std::ostream& o, const Vertex45& c) {
-    //       o << c.pt << " " << c.rise << " " << c.count;
-    //       return o;
-    //     }
-
-    //when scanning Vertex45 for polygon formation we need a scanline comparator functor
-    class lessVertex45 {
-    private:
-      Unit *x_; //x value at which to apply comparison
-      int *justBefore_;
-    public:
-      inline lessVertex45() : x_(0), justBefore_() {}
-      
-      inline lessVertex45(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
-      
-      inline lessVertex45(const lessVertex45& that) : x_(that.x_), justBefore_(that.justBefore_) {}
-      
-      inline lessVertex45& operator=(const lessVertex45& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
-      
-      template <typename ct>
-      inline bool operator () (const Vertex45T<ct>& elm1, const Vertex45T<ct>& elm2) const {
-        Unit y1 = elm1.evalAtX(*x_);
-        Unit y2 = elm2.evalAtX(*x_);
-        if(y1 < y2) return true;
-        if(y1 == y2) {
-          //if justBefore is true we invert the result of the comparison of slopes
-          if(*justBefore_) {
-            return elm1.rise > elm2.rise;
-          } else {
-            return elm1.rise < elm2.rise;
-          }
-        }
-        return false;
-      }
-    };
-
-    // 0 right to left
-    // 1 upper right to lower left
-    // 2 high to low
-    // 3 upper left to lower right
-    // 4 left to right
-    // 5 lower left to upper right
-    // 6 low to high
-    // 7 lower right to upper left
-    static inline int classifyEdge45(const Point& prevPt, const Point& nextPt) {
-      if(prevPt.x() == nextPt.x()) {
-        //2 or 6
-        return predicated_value(prevPt.y() < nextPt.y(), 6, 2);
-      }
-      if(prevPt.y() == nextPt.y()) {
-        //0 or 4
-        return predicated_value(prevPt.x() < nextPt.x(), 4, 0);
-      }
-      if(prevPt.x() < nextPt.x()) {
-        //3 or 5
-        return predicated_value(prevPt.y() < nextPt.y(), 5, 3);
-      }
-      //prevPt.x() > nextPt.y()
-      //1 or 7
-      return predicated_value(prevPt.y() < nextPt.y(), 7, 1);
-    }
-
-    template <int op, typename CountType>
-    static int applyLogic(CountType count1, CountType count2){
-      bool l1 = applyLogic<op>(count1);
-      bool l2 = applyLogic<op>(count2);
-      if(l1 && !l2)
-        return -1; //was true before and became false like a trailing edge
-      if(!l1 && l2)
-        return 1; //was false before and became true like a leading edge
-      return 0; //no change in logic between the two counts
-    }
-    template <int op>
-    static bool applyLogic(Count2 count) {
-      if(op == 0) { //apply or
-        return count[0] > 0 || count[1] > 0;
-      } else if(op == 1) { //apply and
-        return count[0] > 0 && count[1] > 0;
-      } else if(op == 2) { //apply not
-        return count[0] > 0 && !(count[1] > 0);
-      } else if(op == 3) { //apply xor
-        return (count[0] > 0) ^ (count[1] > 0);
-      } else
-        return false;
-    }
-
-    template <int op>
-    struct boolean_op_45_output_functor {
-      template <typename cT>
-      void operator()(cT& output, const Count2& count1, const Count2& count2, 
-                      const Point& pt, int rise, direction_1d end) {
-        int edgeType = applyLogic<op>(count1, count2);
-        if(edgeType) {
-          int multiplier = end == LOW ? -1 : 1;
-          //std::cout << "cross logic: " << edgeType << std::endl;
-          output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
-          //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
-        }
-      }
-    };
-
-    template <int op>
-    static bool applyLogic(Count1 count) {
-      if(op == 0) { //apply or
-        return count.count_ > 0;
-      } else if(op == 1) { //apply and
-        return count.count_ > 1;
-      } else if(op == 3) { //apply xor
-        return count.count_ % 2;
-      } else
-        return false;
-    }
-
-    template <int op>
-    struct unary_op_45_output_functor {
-      template <typename cT>
-      void operator()(cT& output, const Count1& count1, const Count1& count2, 
-                      const Point& pt, int rise, direction_1d end) {
-        int edgeType = applyLogic<op>(count1, count2);
-        if(edgeType) {
-          int multiplier = end == LOW ? -1 : 1;
-          //std::cout << "cross logic: " << edgeType << std::endl;
-          output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
-          //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
-        }
-      }
-    };
-
-    class lessScan45Vertex {
-    public:
-      inline lessScan45Vertex() {} //default constructor is only constructor
-      template <typename Scan45Vertex>
-      inline bool operator () (const Scan45Vertex& v1, const Scan45Vertex& v2) const {
-        return (v1.first.x() < v2.first.x()) || (v1.first.x() == v2.first.x() && v1.first.y() < v2.first.y());
-      }
-    };
-    template <typename S45V>
-    static inline void sortScan45Vector(S45V& vec) {
-      std::sort(vec.begin(), vec.end(), lessScan45Vertex());
-    }
-
-    template <typename CountType, typename output_functor>
-    class Scan45 {
-    public:
-      typedef Scan45CountT<CountType> Scan45Count;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      
-      //index is the index into the vertex
-      static inline Scan45Element getElement(const Scan45Vertex& vertex, int index) {
-        return Scan45Element(vertex.first.x(), vertex.first.y(), index - 1, vertex.second[index]);
-      }
-      
-      class lessScan45Point : public std::binary_function<Point, Point, bool> {
-      public:
-        inline lessScan45Point() {} //default constructor is only constructor
-        inline bool operator () (const Point& v1, const Point& v2) const {
-          return (v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y());
-        }
-      };
-      
-      typedef std::vector<Scan45Vertex> Scan45Vector;
-
-      //definitions
-      typedef std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> > Scan45Data;
-      typedef typename Scan45Data::iterator iterator;
-      typedef typename Scan45Data::const_iterator const_iterator;
-      typedef std::set<Point, lessScan45Point> CrossQueue;
-   
-      //data
-      Scan45Data scanData_;
-      CrossQueue crossQueue_;
-      Scan45Vector crossVector_;
-      Unit x_;
-      int justBefore_;
-    public:
-      inline Scan45() : scanData_(), crossQueue_(), crossVector_(), 
-                        x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
-        lessScan45Element<CountType>  lessElm(&x_, &justBefore_);
-        scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
-      }
-      inline Scan45(const Scan45& that) : scanData_(), crossQueue_(), crossVector_(), 
-                                          x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
-        (*this) = that; }
-      inline Scan45& operator=(const Scan45& that) {
-        x_ = that.x_;
-        justBefore_ = that.justBefore_;
-        crossQueue_ = that.crossQueue_; 
-        crossVector_ = that.crossVector_; 
-        lessScan45Element<CountType>  lessElm(&x_, &justBefore_);
-        scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
-        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
-          scanData_.insert(scanData_.end(), *itr);
-        }
-        return *this;
-      }
-   
-      //cT is an output container of Vertex45
-      //iT is an iterator over Scan45Vertex elements
-      template <class cT, class iT>
-      void scan(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "1\n";
-        while(inputBegin != inputEnd) {
-          //std::cout << "2\n";
-          //std::cout << "x_ = " << x_ << std::endl;
-          //std::cout << "scan line size: " << scanData_.size() << std::endl;
-          //for(iterator iter = scanData_.begin();
-          //     iter != scanData_.end(); ++iter) {
-          //   std::cout << "scan element\n";
-          //   std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
-          // }
-          // std::cout << "cross queue size: " << crossQueue_.size() << std::endl;
-          // std::cout << "cross vector size: " << crossVector_.size() << std::endl;
-          //for(CrossQueue::iterator cqitr = crossQueue_.begin(); cqitr != crossQueue_.end(); ++cqitr) {
-          //   std::cout << *cqitr << " ";
-          //} std::cout << std::endl;
-          Unit nextX = (*inputBegin).first.x();
-          if(!crossVector_.empty() && crossVector_[0].first.x() < nextX) nextX = crossVector_[0].first.x();
-          if(nextX != x_) {
-            //std::cout << "3\n";
-            //we need to move to the next scanline stop
-            //we need to process end events then cross events
-            //process end events
-            if(!crossQueue_.empty() &&
-               (*crossQueue_.begin()).x() < nextX) {
-              //std::cout << "4\n";
-              nextX = (std::min)(nextX, (*crossQueue_.begin()).x());
-            }
-            //std::cout << "6\n";
-            justBefore_ = true;
-            x_ = nextX;
-            advance_(output);
-            justBefore_ = false;
-            if(!crossVector_.empty() &&
-               nextX == (*inputBegin).first.x()) {
-              inputBegin = mergeCross_(inputBegin, inputEnd);
-            }
-            processEvent_(output, crossVector_.begin(), crossVector_.end());
-            crossVector_.clear();
-          } else {
-            //std::cout << "7\n";
-            //our scanline has progressed to the event that is next in the queue
-            inputBegin = processEvent_(output, inputBegin, inputEnd);
-          }
-        }
-        //std::cout << "done scanning\n";
-      }
-
-    private:
-      //functions
-
-      template <class cT>
-      inline void advance_(cT& output) {
-        //process all cross points on the cross queue at the current x_
-        //std::cout << "advance_\n";
-        std::vector<iterator> eraseVec;
-        while(!crossQueue_.empty() &&
-              (*crossQueue_.begin()).x() == x_){
-          //std::cout << "loop\n";
-          //pop point off the cross queue
-          Point crossPoint = *(crossQueue_.begin());
-          //std::cout << crossPoint << std::endl;
-          //for(iterator iter = scanData_.begin();
-          //    iter != scanData_.end(); ++iter) {
-          //  std::cout << "scan element\n";
-          //  std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
-          //}
-          crossQueue_.erase(crossQueue_.begin());
-          Scan45Vertex vertex(crossPoint, Scan45Count());
-          iterator lowIter = lookUp_(vertex.first.y());
-          //std::cout << "searching at: " << vertex.first.y() << std::endl;
-          //if(lowIter == scanData_.end()) std::cout << "could not find\n";
-          //else std::cout << "found: " << *lowIter << std::endl;
-          if(lowIter == scanData_.end() ||
-             lowIter->evalAtX(x_) != vertex.first.y()) {
-            //   std::cout << "skipping\n";
-            //there weren't any edges at this potential cross point
-            continue;
-          }
-          CountType countBelow;
-          iterator searchDownItr = lowIter;
-          while(searchDownItr != scanData_.begin()
-                && searchDownItr->evalAtX(x_) == vertex.first.y()) {
-            //get count from below
-            --searchDownItr;
-            countBelow = searchDownItr->count;
-          }
-          //std::cout << "Below Count: " << countBelow << std::endl;
-          Scan45Count count(countBelow);
-          unsigned int numEdges = 0;
-          iterator eraseItrs[3];
-          while(lowIter != scanData_.end() &&
-                lowIter->evalAtX(x_) == vertex.first.y()) {
-            for(int index = lowIter->rise +1; index >= 0; --index)
-              count[index] = lowIter->count;
-            //std::cout << count << std::endl;
-            eraseItrs[numEdges] = lowIter;
-            ++numEdges;
-            ++lowIter;
-          }
-          if(numEdges == 1) {
-            //look for the next crossing point and continue
-            //std::cout << "found only one edge\n";
-            findCross_(eraseItrs[0]);
-            continue;
-          }
-          //before we erase the elements we need to decide if they should be written out
-          CountType currentCount = countBelow;
-          for(unsigned int i = 0; i < numEdges; ++i) {
-            output_functor f;
-            f(output, currentCount, eraseItrs[i]->count, crossPoint, eraseItrs[i]->rise, LOW);
-            currentCount = eraseItrs[i]->count;
-          }
-          //schedule erase of the elements
-          for(unsigned int i = 0; i < numEdges; ++i) {
-            eraseVec.push_back(eraseItrs[i]);
-          }
-         
-          //take the derivative wrt theta of the count at the crossing point
-          vertex.second[2] = count[2] - countBelow;
-          vertex.second[1] = count[1] - count[2];
-          vertex.second[0] = count[0] - count[1];
-          //add the point, deriviative pair into the cross vector
-          //std::cout << "LOOK HERE!\n";
-          //std::cout << count << std::endl;
-          //std::cout << vertex << std::endl;
-          crossVector_.push_back(vertex);
-        }
-        //erase crossing elements
-        std::vector<iterator> searchVec;
-        for(unsigned int i = 0; i < eraseVec.size(); ++i) {
-          if(eraseVec[i] != scanData_.begin()) {
-            iterator searchItr = eraseVec[i];
-            --searchItr;
-            if(searchVec.empty() ||
-               searchVec.back() != searchItr)
-              searchVec.push_back(searchItr);
-          }
-          scanData_.erase(eraseVec[i]);
-        }
-        for(unsigned int i = 0; i < searchVec.size(); ++i) {
-          findCross_(searchVec[i]);
-        }
-      }
-   
-      template <class iT>
-      inline iT mergeCross_(iT inputBegin, iT inputEnd) {
-        Scan45Vector vec;
-        swap(vec, crossVector_);
-        iT mergeEnd = inputBegin;
-        unsigned int mergeCount = 0;
-        while(mergeEnd != inputEnd &&
-              (*mergeEnd).first.x() == x_) {
-          ++mergeCount;
-          ++mergeEnd;
-        }
-        crossVector_.reserve((std::max)(vec.capacity(), vec.size() + mergeCount));
-        for(unsigned int i = 0; i < vec.size(); ++i){
-          while(inputBegin != mergeEnd &&
-                (*inputBegin).first.y() < vec[i].first.y()) {
-            crossVector_.push_back(*inputBegin);
-            ++inputBegin;
-          }
-          crossVector_.push_back(vec[i]);
-        }
-        while(inputBegin != mergeEnd){
-          crossVector_.push_back(*inputBegin);
-          ++inputBegin;
-        }
-        return inputBegin;
-      }
-   
-      template <class cT, class iT>
-      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "processEvent_\n";
-        CountType verticalCount = CountType();
-        Point prevPoint;
-        iterator prevIter = scanData_.end();
-        while(inputBegin != inputEnd &&
-              (*inputBegin).first.x() == x_) {
-          //std::cout << (*inputBegin) << std::endl;
-          //std::cout << "loop\n";
-          Scan45Vertex vertex = *inputBegin;
-          //std::cout << vertex.first << std::endl;
-          //if vertical count propigating up fake a null event at the next element
-          if(verticalCount != CountType() && (prevIter != scanData_.end() &&
-                                              prevIter->evalAtX(x_) < vertex.first.y())) {
-            //std::cout << "faking null event\n";
-            vertex = Scan45Vertex(Point(x_, prevIter->evalAtX(x_)), Scan45Count());
-          } else { 
-            ++inputBegin; 
-            //std::cout << "after increment\n";
-            //accumulate overlapping changes in Scan45Count
-            while(inputBegin != inputEnd &&
-                  (*inputBegin).first.x() == x_ && 
-                  (*inputBegin).first.y() == vertex.first.y()) {
-              //std::cout << "accumulate\n";
-              vertex.second += (*inputBegin).second;
-              ++inputBegin;
-            }
-          }
-          //std::cout << vertex.second << std::endl;
-          //integrate vertex
-          CountType currentCount = verticalCount;// + vertex.second[0];
-          for(unsigned int i = 0; i < 3; ++i) {
-            vertex.second[i] = currentCount += vertex.second[i];
-          }
-          //std::cout << vertex.second << std::endl;
-          //vertex represents the change in state at this point
-         
-          //get counts at current vertex
-          CountType countBelow;
-          iterator lowIter = lookUp_(vertex.first.y());
-          if(lowIter != scanData_.begin()) {
-            //get count from below
-            --lowIter;
-            countBelow = lowIter->count;
-            ++lowIter;
-          }
-          //std::cout << "Count Below: " << countBelow[0] << " " << countBelow[1] << std::endl;
-          //std::cout << "vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
-          Scan45Count countAt(countBelow - verticalCount);
-          //check if the vertical edge should be written out
-          if(verticalCount != CountType()) {
-            output_functor f;
-            f(output, countBelow - verticalCount, countBelow, prevPoint, 2, HIGH);
-            f(output, countBelow - verticalCount, countBelow, vertex.first, 2, LOW);
-          }
-          currentCount = countBelow - verticalCount;
-          while(lowIter != scanData_.end() &&
-                lowIter->evalAtX(x_) == vertex.first.y()) {
-            for(unsigned int i = lowIter->rise + 1; i < 3; ++i) {
-              countAt[i] = lowIter->count;
-            }
-            Point lp(lowIter->x, lowIter->y);
-            if(lp != vertex.first) {
-              output_functor f;
-              f(output, currentCount, lowIter->count, vertex.first, lowIter->rise, LOW);
-            }
-            currentCount = lowIter->count;
-            iterator nextIter = lowIter;
-            ++nextIter;
-            //std::cout << "erase\n";
-            scanData_.erase(lowIter);
-            if(nextIter != scanData_.end())
-              findCross_(nextIter);
-            lowIter = nextIter;
-          }
-          verticalCount += vertex.second[3];
-          prevPoint = vertex.first;
-          //std::cout << "new vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
-          prevIter = lowIter;
-          //count represents the current state at this point
-          //std::cout << vertex.second << std::endl;
-          //std::cout << countAt << std::endl;
-          //std::cout << "ADD\n";
-          vertex.second += countAt;
-          //std::cout << vertex.second << std::endl;
-         
-          //add elements to the scanline
-          for(int i = 0; i < 3; ++i) {
-            if(vertex.second[i] != countBelow) {
-              //std::cout << "insert: " << vertex.first.x() << " " << vertex.first.y() << " " << i-1 <<
-              //  " " << vertex.second[i][0] << " " << vertex.second[i][1] << std::endl;
-              iterator insertIter = scanData_.insert(scanData_.end(), 
-                                                     Scan45ElementT<CountType>(vertex.first.x(), 
-                                                                               vertex.first.y(), 
-                                                                               i - 1, vertex.second[i]));
-              findCross_(insertIter);
-              output_functor f;
-              f(output, countBelow, vertex.second[i], vertex.first, i - 1, HIGH);
-            }
-            countBelow = vertex.second[i];
-          }
-        }
-        //std::cout << "end processEvent\n";
-        return inputBegin;
-      }
-   
-      //iter1 is horizontal
-      inline void scheduleCross0_(iterator iter1, iterator iter2) {
-        //std::cout << "0, ";
-        Unit y1 = iter1->evalAtX(x_);
-        Unit y2 = iter2->evalAtX(x_);
-        LongUnit delta = (LongUnit)abs((LongUnit)y1 - (LongUnit)y2);
-        if(delta + x_ <= (std::numeric_limits<Unit>::max)())
-          crossQueue_.insert(crossQueue_.end(), Point(x_ + delta, y1));
-        //std::cout <<  Point(x_ + delta, y1);
-      }
-
-      //neither iter is horizontal
-      inline void scheduleCross1_(iterator iter1, iterator iter2) {
-        //std::cout << "1, ";
-        Unit y1 = iter1->evalAtX(x_);
-        Unit y2 = iter2->evalAtX(x_);
-        //std::cout << y1 << " " << y2 << ": ";
-        //note that half the delta cannot exceed the positive inter range
-        LongUnit delta = y1;
-        delta -= y2;
-        Unit UnitMax = (std::numeric_limits<Unit>::max)();
-        if(delta & 1) {
-          //delta is odd, division by 2 will result in integer trunctaion
-          if(delta == 1) {
-            //the cross point is not on the integer grid and cannot be represented
-            //we must throw an exception
-            std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
-            throw(msg);
-          } else {
-            //note that result of this subtraction is always positive because itr1 is above itr2 in scanline
-            LongUnit halfDelta2 = (LongUnit)((((LongUnit)y1) - y2)/2); 
-            //note that halfDelta2 has been truncated
-            if(halfDelta2 + x_ <= UnitMax && halfDelta2 + y2 <= UnitMax) {
-              crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta2, y2+halfDelta2));
-              crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta2, y2+halfDelta2+1));
-            }
-          }
-        } else {
-          LongUnit halfDelta = (LongUnit)((((LongUnit)y1) - y2)/2); 
-          if(halfDelta + x_ <= UnitMax && halfDelta + y2 <= UnitMax)
-            crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta, y2+halfDelta));
-          //std::cout << Point(x_+halfDelta, y2+halfDelta);
-        }
-      }
-   
-      inline void findCross_(iterator iter) {
-        //std::cout << "find cross ";
-        iterator iteratorBelow = iter;
-        iterator iteratorAbove = iter;
-        if(iter != scanData_.begin() && iter->rise < 1) {
-          --iteratorBelow;
-          if(iter->rise == 0){
-            if(iteratorBelow->rise == 1) {
-              scheduleCross0_(iter, iteratorBelow);
-            } 
-          } else {
-            //iter->rise == -1
-            if(iteratorBelow->rise == 1) {
-              scheduleCross1_(iter, iteratorBelow);
-            } else if(iteratorBelow->rise == 0) {
-              scheduleCross0_(iteratorBelow, iter);
-            }
-          }
-        }
-        ++iteratorAbove;
-        if(iteratorAbove != scanData_.end() && iter->rise > -1) {
-          if(iter->rise == 0) {
-            if(iteratorAbove->rise == -1) {
-              scheduleCross0_(iter, iteratorAbove);
-            }
-          } else {
-            //iter->rise == 1
-            if(iteratorAbove->rise == -1) {
-              scheduleCross1_(iteratorAbove, iter);
-            } else if(iteratorAbove->rise == 0) {
-              scheduleCross0_(iteratorAbove, iter);
-            }
-          }
-        } 
-        //std::cout << std::endl; 
-      } 
-   
-      inline iterator lookUp_(Unit y){
-        //if just before then we need to look from 1 not -1
-        return scanData_.lower_bound(Scan45ElementT<CountType>(x_, y, -1+2*justBefore_));
-      }
-    };
-
-    template <typename CountType>
-    static inline void print45Data(const std::set<Scan45ElementT<CountType>, 
-                                   lessScan45Element<CountType> >& data) {
-      typename std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >::const_iterator iter;
-      for(iter = data.begin(); iter != data.end(); ++iter) {
-        std::cout << iter->x << " " << iter->y << " " << iter->rise << std::endl;
-      }
-    }
-
-    static inline bool testScan45Data() {
-      Unit x = 0;
-      int justBefore = false;
-      lessScan45Element<Count2> lessElm(&x, &justBefore);
-      std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > testData(lessElm);
-      //Unit size = testData.size();
-      typedef std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > Scan45Data;
-      typename Scan45Data::iterator itr10 = testData.insert(testData.end(), Scan45Element(0, 10, 1));
-      typename Scan45Data::iterator itr20 = testData.insert(testData.end(), Scan45Element(0, 20, 1));
-      typename Scan45Data::iterator itr30 = testData.insert(testData.end(), Scan45Element(0, 30, -1));
-      typename Scan45Data::iterator itr40 = testData.insert(testData.end(), Scan45Element(0, 40, -1));
-      typename Scan45Data::iterator itrA = testData.lower_bound(Scan45Element(0, 29, -1));
-      typename Scan45Data::iterator itr1 = testData.lower_bound(Scan45Element(0, 10, -1));
-      x = 4;
-      //now at 14 24 26 36
-      typename Scan45Data::iterator itrB = testData.lower_bound(Scan45Element(4, 29, -1));
-      typename Scan45Data::iterator itr2 = testData.lower_bound(Scan45Element(4, 14, -1));
-      if(itr1 != itr2) std::cout << "test1 failed\n";
-      if(itrA == itrB) std::cout << "test2 failed\n";
-      //remove crossing elements
-      testData.erase(itr20);
-      testData.erase(itr30);
-      x = 5;
-      itr20 = testData.insert(testData.end(), Scan45Element(0, 20, 1));
-      itr30 = testData.insert(testData.end(), Scan45Element(0, 30, -1));
-      //now at 15 25 25 35
-      typename Scan45Data::iterator itr = testData.begin();
-      if(itr != itr10) std::cout << "test3 failed\n";
-      ++itr;
-      if(itr != itr30) std::cout << "test4 failed\n";
-      ++itr;
-      if(itr != itr20) std::cout << "test5 failed\n";
-      ++itr;
-      if(itr != itr40) std::cout << "test6 failed\n";
-      std::cout << "done testing Scan45Data\n";
-      return true;
-    }
-   
-    static inline bool testScan45Rect() {
-      std::cout << "testing Scan45Rect\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 8
-      // result == 0 0 0 1
-      // result == 0 0 2 1
-      // result == 0 10 2 -1
-      // result == 0 10 0 -1
-      // result == 10 0 0 -1
-      // result == 10 0 2 -1
-      // result == 10 10 2 1
-      // result == 10 10 0 1
-      std::vector<Vertex45> reference;
-      reference.push_back(Vertex45(Point(0, 0), 0, 1));
-      reference.push_back(Vertex45(Point(0, 0), 2, 1));
-      reference.push_back(Vertex45(Point(0, 10), 2, -1));
-      reference.push_back(Vertex45(Point(0, 10), 0, -1));
-      reference.push_back(Vertex45(Point(10, 0), 0, -1));
-      reference.push_back(Vertex45(Point(10, 0), 2, -1));
-      reference.push_back(Vertex45(Point(10, 10), 2, 1));
-      reference.push_back(Vertex45(Point(10, 10), 0, 1));
-      if(result != reference) {
-        std::cout << "result size == " << result.size() << std::endl;
-        for(unsigned int i = 0; i < result.size(); ++i) {
-          //std::cout << "result == " << result[i]<< std::endl;
-        }
-        std::cout << "reference size == " << reference.size() << std::endl;
-        for(unsigned int i = 0; i < reference.size(); ++i) {
-          //std::cout << "reference == " << reference[i]<< std::endl;
-        }
-        return false;
-      }
-      std::cout << "done testing Scan45Rect\n";
-      return true;
-    }
-
-    static inline bool testScan45P1() {
-      std::cout << "testing Scan45P1\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), Count2(0, 0), ncount, ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), Count2(0, 0), ncount, ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,20), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 8
-      // result == 0 0 1 1
-      // result == 0 0 2 1
-      // result == 0 10 2 -1
-      // result == 0 10 1 -1
-      // result == 10 10 1 -1
-      // result == 10 10 2 -1
-      // result == 10 20 2 1
-      // result == 10 20 1 1
-      std::vector<Vertex45> reference;
-      reference.push_back(Vertex45(Point(0, 0), 1, 1));
-      reference.push_back(Vertex45(Point(0, 0), 2, 1));
-      reference.push_back(Vertex45(Point(0, 10), 2, -1));
-      reference.push_back(Vertex45(Point(0, 10), 1, -1));
-      reference.push_back(Vertex45(Point(10, 10), 1, -1));
-      reference.push_back(Vertex45(Point(10, 10), 2, -1));
-      reference.push_back(Vertex45(Point(10, 20), 2, 1));
-      reference.push_back(Vertex45(Point(10, 20), 1, 1));
-      if(result != reference) {
-        std::cout << "result size == " << result.size() << std::endl;
-        for(unsigned int i = 0; i < result.size(); ++i) {
-          //std::cout << "result == " << result[i]<< std::endl;
-        }
-        std::cout << "reference size == " << reference.size() << std::endl;
-        for(unsigned int i = 0; i < reference.size(); ++i) {
-          //std::cout << "reference == " << reference[i]<< std::endl;
-        }
-        return false;
-      }
-      std::cout << "done testing Scan45P1\n";
-      return true;
-    }
-
-    static inline bool testScan45P2() {
-      std::cout << "testing Scan45P2\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, count, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), ncount, count, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(20,10), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 8
-      // result == 0 0 0 1
-      // result == 0 0 1 -1
-      // result == 10 0 0 -1
-      // result == 10 0 1 1
-      // result == 10 10 1 1
-      // result == 10 10 0 -1
-      // result == 20 10 1 -1
-      // result == 20 10 0 1
-      std::vector<Vertex45> reference;
-      reference.push_back(Vertex45(Point(0, 0), 0, 1));
-      reference.push_back(Vertex45(Point(0, 0), 1, -1));
-      reference.push_back(Vertex45(Point(10, 0), 0, -1));
-      reference.push_back(Vertex45(Point(10, 0), 1, 1));
-      reference.push_back(Vertex45(Point(10, 10), 1, 1));
-      reference.push_back(Vertex45(Point(10, 10), 0, -1));
-      reference.push_back(Vertex45(Point(20, 10), 1, -1));
-      reference.push_back(Vertex45(Point(20, 10), 0, 1));
-      if(result != reference) {
-        std::cout << "result size == " << result.size() << std::endl;
-        for(unsigned int i = 0; i < result.size(); ++i) {
-          //std::cout << "result == " << result[i]<< std::endl;
-        }
-        std::cout << "reference size == " << reference.size() << std::endl;
-        for(unsigned int i = 0; i < reference.size(); ++i) {
-          //std::cout << "reference == " << reference[i]<< std::endl;
-        }
-        return false;
-      }
-      std::cout << "done testing Scan45P2\n";
-      return true;
-    }
-
-    static inline bool testScan45And() {
-      std::cout << "testing Scan45And\n";
-      Scan45<Count2, boolean_op_45_output_functor<1> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(2,2), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      vertices.push_back(Scan45Vertex(Point(2,12), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(12,2), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(12,12), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      //result size == 8
-      //result == 2 2 0 1
-      //result == 2 2 2 1
-      //result == 2 10 2 -1
-      //result == 2 10 0 -1
-      //result == 10 2 0 -1
-      //result == 10 2 2 -1
-      //result == 10 10 2 1
-      //result == 10 10 0 1
-      std::vector<Vertex45> reference;
-      reference.push_back(Vertex45(Point(2, 2), 0, 1));
-      reference.push_back(Vertex45(Point(2, 2), 2, 1));
-      reference.push_back(Vertex45(Point(2, 10), 2, -1));
-      reference.push_back(Vertex45(Point(2, 10), 0, -1));
-      reference.push_back(Vertex45(Point(10, 2), 0, -1));
-      reference.push_back(Vertex45(Point(10, 2), 2, -1));
-      reference.push_back(Vertex45(Point(10, 10), 2, 1));
-      reference.push_back(Vertex45(Point(10, 10), 0, 1));
-      if(result != reference) {
-        std::cout << "result size == " << result.size() << std::endl;
-        for(unsigned int i = 0; i < result.size(); ++i) {
-          //std::cout << "result == " << result[i]<< std::endl;
-        }
-        std::cout << "reference size == " << reference.size() << std::endl;
-        for(unsigned int i = 0; i < reference.size(); ++i) {
-          //std::cout << "reference == " << reference[i]<< std::endl;
-        }
-        return false;
-      }
-      std::cout << "done testing Scan45And\n";
-      return true;
-    }
-
-    static inline bool testScan45Star1() {
-      std::cout << "testing Scan45Star1\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(8,16), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(12,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(4,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-      vertices.push_back(Scan45Vertex(Point(4,16), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 24
-      // result == 0 8 -1 1
-      // result == 0 8 1 -1
-      // result == 4 0 1 1
-      // result == 4 0 2 1
-      // result == 4 4 2 -1
-      // result == 4 4 -1 -1
-      // result == 4 12 1 1
-      // result == 4 12 2 1
-      // result == 4 16 2 -1
-      // result == 4 16 -1 -1
-      // result == 6 2 1 -1
-      // result == 6 14 -1 1
-      // result == 6 2 -1 1
-      // result == 6 14 1 -1
-      // result == 8 0 -1 -1
-      // result == 8 0 2 -1
-      // result == 8 4 2 1
-      // result == 8 4 1 1
-      // result == 8 12 -1 -1
-      // result == 8 12 2 -1
-      // result == 8 16 2 1
-      // result == 8 16 1 1
-      // result == 12 8 1 -1
-      // result == 12 8 -1 1
-      if(result.size() != 24) {
-        //std::cout << "result size == " << result.size() << std::endl;
-        //std::cout << "reference size == " << 24 << std::endl;
-        return false;
-      }
-      std::cout << "done testing Scan45Star1\n";
-      return true;
-    }
-
-    static inline bool testScan45Star2() {
-      std::cout << "testing Scan45Star2\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 24
-      // result == 0 4 0 1
-      // result == 0 4 1 -1
-      // result == 0 8 -1 1
-      // result == 0 8 0 -1
-      // result == 2 6 1 1
-      // result == 2 6 -1 -1
-      // result == 4 4 0 -1
-      // result == 4 8 0 1
-      // result == 4 4 -1 1
-      // result == 4 8 1 -1
-      // result == 8 0 -1 -1
-      // result == 8 0 1 1
-      // result == 8 12 1 1
-      // result == 8 12 -1 -1
-      // result == 12 4 1 -1
-      // result == 12 8 -1 1
-      // result == 12 4 0 1
-      // result == 12 8 0 -1
-      // result == 14 6 -1 -1
-      // result == 14 6 1 1
-      // result == 16 4 0 -1
-      // result == 16 4 -1 1
-      // result == 16 8 1 -1
-      // result == 16 8 0 1
-      if(result.size() != 24) {
-        //std::cout << "result size == " << result.size() << std::endl;
-        //std::cout << "reference size == " << 24 << std::endl;
-        return false;
-      }
-      std::cout << "done testing Scan45Star2\n";
-      return true;
-    }
-
-    static inline bool testScan45Star3() {
-      std::cout << "testing Scan45Star3\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(8,16), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-
-      vertices.push_back(Scan45Vertex(Point(6,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      vertices.push_back(Scan45Vertex(Point(6,14), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(12,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(12,14), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(12,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(4,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
-      vertices.push_back(Scan45Vertex(Point(4,16), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 28
-      // result == 0 8 -1 1
-      // result == 0 8 1 -1
-      // result == 4 0 1 1
-      // result == 4 0 2 1
-      // result == 4 4 2 -1
-      // result == 4 4 -1 -1
-      // result == 4 12 1 1
-      // result == 4 12 2 1
-      // result == 4 16 2 -1
-      // result == 4 16 -1 -1
-      // result == 6 2 1 -1
-      // result == 6 14 -1 1
-      // result == 6 0 0 1
-      // result == 6 0 2 1
-      // result == 6 2 2 -1
-      // result == 6 14 1 -1
-      // result == 8 0 0 -1
-      // result == 8 0 0 1
-      // result == 8 14 0 -1
-      // result == 8 14 2 -1
-      // result == 8 16 2 1
-      // result == 8 16 1 1
-      // result == 12 0 0 -1
-      // result == 12 0 2 -1
-      // result == 12 8 2 1
-      // result == 12 8 2 -1
-      // result == 12 14 2 1
-      // result == 12 14 0 1
-      if(result.size() != 28) {
-        //std::cout << "result size == " << result.size() << std::endl;
-        //std::cout << "reference size == " << 28 << std::endl;
-        return false;
-      }
-
-      std::cout << "done testing Scan45Star3\n";
-      return true;
-    }
-
-    static inline bool testScan45Star4() {
-      std::cout << "testing Scan45Star4\n";
-      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
-      std::vector<Vertex45 > result;
-      typedef std::pair<Point, Scan45Count> Scan45Vertex;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-
-      vertices.push_back(Scan45Vertex(Point(0,6), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      vertices.push_back(Scan45Vertex(Point(0,12), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(16,6), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
-      vertices.push_back(Scan45Vertex(Point(16,12), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-      std::cout << "done scanning\n";
-      // result size == 28
-      // result == 0 4 0 1
-      // result == 0 4 1 -1
-      // result == 0 6 0 1
-      // result == 0 6 2 1
-      // result == 0 8 2 -1
-      // result == 0 8 2 1
-      // result == 0 12 2 -1
-      // result == 0 12 0 -1
-      // result == 2 6 1 1
-      // result == 2 6 0 -1
-      // result == 4 4 0 -1
-      // result == 4 4 -1 1
-      // result == 8 12 0 1
-      // result == 8 0 -1 -1
-      // result == 8 0 1 1
-      // result == 8 12 0 -1
-      // result == 12 4 1 -1
-      // result == 12 4 0 1
-      // result == 14 6 -1 -1
-      // result == 14 6 0 1
-      // result == 16 4 0 -1
-      // result == 16 4 -1 1
-      // result == 16 6 0 -1
-      // result == 16 6 2 -1
-      // result == 16 8 2 1
-      // result == 16 8 2 -1
-      // result == 16 12 2 1
-      // result == 16 12 0 1
-      if(result.size() != 28) {
-        //std::cout << "result size == " << result.size() << std::endl;
-        //std::cout << "reference size == " << 28 << std::endl;
-        return false;
-      }
-
-      std::cout << "done testing Scan45Star4\n";
-      return true;
-    }
-
-    static inline bool testScan45() {
-      if(!testScan45Rect()) return false;
-      if(!testScan45P1()) return false;
-      if(!testScan45P2()) return false;
-      if(!testScan45And()) return false;
-      if(!testScan45Star1()) return false;
-      if(!testScan45Star2()) return false;
-      if(!testScan45Star3()) return false;
-      if(!testScan45Star4()) return false;
-      return true;
-    }
-
-  };
-
-}
-
-}
-#endif
Added: sandbox/gtl/boost/polygon/detail/boolean_op.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/boolean_op.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,558 @@
+/*
+  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_BOOLEAN_OP_HPP
+#define BOOST_POLYGON_BOOLEAN_OP_HPP
+namespace boost { namespace polygon{
+namespace boolean_op {
+
+  //BooleanOp is the generic boolean operation scanline algorithm that provides
+  //all the simple boolean set operations on manhattan data.  By templatizing
+  //the intersection count of the input and algorithm internals it is extensible
+  //to multi-layer scans, properties and other advanced scanline operations above
+  //and beyond simple booleans.
+  //T must cast to int
+  template <class T, typename Unit>
+  class BooleanOp {
+  public:
+    typedef std::map<Unit, T> ScanData;
+    typedef std::pair<Unit, T> ElementType;
+  protected:
+    ScanData scanData_;
+    typename ScanData::iterator nextItr_;
+    T nullT_;
+  public:
+    inline BooleanOp () : scanData_(), nextItr_(), nullT_() { nextItr_ = scanData_.end(); nullT_ = 0; }
+    inline BooleanOp (T nullT) : scanData_(), nextItr_(), nullT_(nullT) { nextItr_ = scanData_.end(); }
+    inline BooleanOp (const BooleanOp& that) : scanData_(that.scanData_), nextItr_(),
+                                               nullT_(that.nullT_) { nextItr_ = scanData_.begin(); }
+    inline BooleanOp& operator=(const BooleanOp& that); 
+   
+    //moves scanline forward
+    inline void advanceScan() { nextItr_ = scanData_.begin(); }
+
+    //proceses the given interval and T data
+    //appends output edges to cT
+    template <class cT>
+    inline void processInterval(cT& outputContainer, interval_data<Unit> ivl, T deltaCount);
+   
+  private:
+    inline typename ScanData::iterator lookup_(Unit pos){
+      if(nextItr_ != scanData_.end() && nextItr_->first >= pos) {
+        return nextItr_;
+      }
+      return nextItr_ = scanData_.lower_bound(pos);
+    }
+    inline typename ScanData::iterator insert_(Unit pos, T count){ 
+      return nextItr_ = scanData_.insert(nextItr_, ElementType(pos, count)); 
+    } 
+    template <class cT>
+    inline void evaluateInterval_(cT& outputContainer, interval_data<Unit> ivl, T beforeCount, T afterCount);
+  };
+
+  class BinaryAnd {
+  public:
+    inline BinaryAnd() {}
+    inline bool operator()(int a, int b) { return (a > 0) & (b > 0); }
+  };
+  class BinaryOr {
+  public:
+    inline BinaryOr() {}
+    inline bool operator()(int a, int b) { return (a > 0) | (b > 0); }
+  };
+  class BinaryNot {
+  public:
+    inline BinaryNot() {}
+    inline bool operator()(int a, int b) { return (a > 0) & !(b > 0); }
+  };
+  class BinaryXor {
+  public:
+    inline BinaryXor() {}
+    inline bool operator()(int a, int b) { return (a > 0) ^ (b > 0); }
+  };
+
+  //BinaryCount is an array of two deltaCounts coming from two different layers
+  //of scan event data.  It is the merged count of the two suitable for consumption
+  //as the template argument of the BooleanOp algorithm because BinaryCount casts to int.
+  //T is a binary functor object that evaluates the array of counts and returns a logical 
+  //result of some operation on those values.
+  //BinaryCount supports many of the operators that work with int, particularly the
+  //binary operators, but cannot support less than or increment.
+  template <class T>
+  class BinaryCount {
+  public:
+    inline BinaryCount() : counts_() { counts_[0] = counts_[1] = 0; }
+    // constructs from two integers
+    inline BinaryCount(int countL, int countR) : counts_() { counts_[0] = countL, counts_[1] = countR; }
+    inline BinaryCount& operator=(int count) { counts_[0] = count, counts_[1] = count; return *this; }
+    inline BinaryCount& operator=(const BinaryCount& that); 
+    inline BinaryCount(const BinaryCount& that) : counts_() { *this = that; }
+    inline bool operator==(const BinaryCount& that) const;
+    inline bool operator!=(const BinaryCount& that) const { return !((*this) == that);}
+    inline BinaryCount& operator+=(const BinaryCount& that);
+    inline BinaryCount& operator-=(const BinaryCount& that);
+    inline BinaryCount operator+(const BinaryCount& that) const;
+    inline BinaryCount operator-(const BinaryCount& that) const;
+    inline BinaryCount operator-() const;
+    inline int& operator[](bool index) { return counts_[index]; }
+
+    //cast to int operator evaluates data using T binary functor
+    inline operator int() const { return T()(counts_[0], counts_[1]); }
+  private:
+    int counts_[2];
+  };
+
+  class UnaryCount {
+  public:
+    inline UnaryCount() : count_(0) {}
+    // constructs from two integers
+    inline explicit UnaryCount(int count) : count_(count) {}
+    inline UnaryCount& operator=(int count) { count_ = count; return *this; }
+    inline UnaryCount& operator=(const UnaryCount& that) { count_ = that.count_; return *this; }
+    inline UnaryCount(const UnaryCount& that) : count_(that.count_) {}
+    inline bool operator==(const UnaryCount& that) const { return count_ == that.count_; }
+    inline bool operator!=(const UnaryCount& that) const { return !((*this) == that);}
+    inline UnaryCount& operator+=(const UnaryCount& that) { count_ += that.count_; return *this; }
+    inline UnaryCount& operator-=(const UnaryCount& that) { count_ -= that.count_; return *this; }
+    inline UnaryCount operator+(const UnaryCount& that) const { UnaryCount tmp(*this); tmp += that; return tmp; }
+    inline UnaryCount operator-(const UnaryCount& that) const { UnaryCount tmp(*this); tmp -= that; return tmp; }
+    inline UnaryCount operator-() const { UnaryCount tmp; return tmp - *this; }
+
+    //cast to int operator evaluates data using T binary functor
+    inline operator int() const { return count_ % 2; }
+  private:
+    int count_;
+  };
+
+  template <class T, typename Unit>
+  inline BooleanOp<T, Unit>& BooleanOp<T, Unit>::operator=(const BooleanOp& that) { 
+    scanData_ = that.scanData_; 
+    nextItr_ = scanData_.begin();
+    nullT_ = that.nullT_;
+    return *this;
+  }
+   
+  //appends output edges to cT
+  template <class T, typename Unit>
+  template <class cT>
+  inline void BooleanOp<T, Unit>::processInterval(cT& outputContainer, interval_data<Unit> ivl, T deltaCount) {
+    typename ScanData::iterator lowItr = lookup_(ivl.low());
+    typename ScanData::iterator highItr = lookup_(ivl.high());
+    //add interval to scan data if it is past the end
+    if(lowItr == scanData_.end()) {
+      lowItr = insert_(ivl.low(), deltaCount);
+      highItr = insert_(ivl.high(), nullT_);
+      evaluateInterval_(outputContainer, ivl, nullT_, deltaCount);
+      return;
+    }
+    //ensure that highItr points to the end of the ivl
+    if(highItr == scanData_.end() || (*highItr).first > ivl.high()) {
+      T value = nullT_;
+      if(highItr != scanData_.begin()) {
+        --highItr;
+        value = highItr->second;
+      }
+      nextItr_ = highItr;
+      highItr = insert_(ivl.high(), value);
+    }
+    //split the low interval if needed
+    if(lowItr->first > ivl.low()) {
+      if(lowItr != scanData_.begin()) {
+        --lowItr;
+        nextItr_ = lowItr;
+        lowItr = insert_(ivl.low(), lowItr->second);
+      } else {
+        nextItr_ = lowItr;
+        lowItr = insert_(ivl.low(), nullT_);
+      }
+    }
+    //process scan data intersecting interval
+    for(typename ScanData::iterator itr = lowItr; itr != highItr; ){
+      T beforeCount = itr->second;
+      T afterCount = itr->second += deltaCount;
+      Unit low = itr->first;
+      ++itr;
+      Unit high = itr->first;
+      evaluateInterval_(outputContainer, interval_data<Unit>(low, high), beforeCount, afterCount);
+    }
+    //merge the bottom interval with the one below if they have the same count
+    if(lowItr != scanData_.begin()){
+      typename ScanData::iterator belowLowItr = lowItr;
+      --belowLowItr;
+      if(belowLowItr->second == lowItr->second) {
+        scanData_.erase(lowItr);
+      }
+    }
+    //merge the top interval with the one above if they have the same count
+    if(highItr != scanData_.begin()) {
+      typename ScanData::iterator beforeHighItr = highItr;
+      --beforeHighItr;
+      if(beforeHighItr->second == highItr->second) {
+        scanData_.erase(highItr);
+        highItr = beforeHighItr;
+        ++highItr;
+      }
+    }
+    nextItr_ = highItr;
+  }
+
+  template <class T, typename Unit>
+  template <class cT>
+  inline void BooleanOp<T, Unit>::evaluateInterval_(cT& outputContainer, interval_data<Unit> ivl, 
+                                              T beforeCount, T afterCount) {
+    bool before = (int)beforeCount > 0;
+    bool after = (int)afterCount > 0;
+    int value =  (!before & after) - (before & !after);
+    if(value) {
+      outputContainer.insert(outputContainer.end(), std::pair<interval_data<Unit>, int>(ivl, value));
+    }
+  }
+
+  template <class T>
+  inline BinaryCount<T>& BinaryCount<T>::operator=(const BinaryCount<T>& that) { 
+    counts_[0] = that.counts_[0];
+    counts_[1] = that.counts_[1];
+    return *this;
+  }
+  template <class T>
+  inline bool BinaryCount<T>::operator==(const BinaryCount<T>& that) const { 
+    return counts_[0] == that.counts_[0] &&
+      counts_[1] == that.counts_[1];
+  }
+  template <class T>
+  inline BinaryCount<T>& BinaryCount<T>::operator+=(const BinaryCount<T>& that) {
+    counts_[0] += that.counts_[0];
+    counts_[1] += that.counts_[1];
+    return *this;
+  }
+  template <class T>
+  inline BinaryCount<T>& BinaryCount<T>::operator-=(const BinaryCount<T>& that) {
+    counts_[0] += that.counts_[0];
+    counts_[1] += that.counts_[1];
+    return *this;
+  }
+  template <class T>
+  inline BinaryCount<T> BinaryCount<T>::operator+(const BinaryCount<T>& that) const {
+    BinaryCount retVal(*this);
+    retVal += that;
+    return retVal;
+  }
+  template <class T>
+  inline BinaryCount<T> BinaryCount<T>::operator-(const BinaryCount<T>& that) const {
+    BinaryCount retVal(*this);
+    retVal -= that;
+    return retVal;
+  }
+  template <class T>
+  inline BinaryCount<T> BinaryCount<T>::operator-() const {
+    return BinaryCount<T>() - *this;
+  }
+
+  //self contained unit test for BooleanOr algorithm
+  template <typename Unit>
+  inline bool testBooleanOr() {
+    BooleanOp<int, Unit> booleanOr;
+    //test one rectangle
+    std::vector<std::pair<interval_data<Unit>, int> > container;
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
+    if(container.size() != 2) { 
+      std::cout << "Test one rectangle, wrong output size\n";
+      return false;
+    }
+    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
+      std::cout << "Test one rectangle, first output wrong: Interval(" <<
+        container[0].first << "), " << container[0].second << std::endl;
+    }
+    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
+      std::cout << "Test one rectangle, second output wrong: Interval(" <<
+        container[1].first << "), " << container[1].second << std::endl;
+    }
+
+    //test two rectangles
+    container.clear();
+    booleanOr = BooleanOp<int, Unit>();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(5, 15), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(5, 15), -1);
+    if(container.size() != 4) {
+      std::cout << "Test two rectangles, wrong output size\n";
+      for(unsigned int i = 0; i < container.size(); ++i){
+              std::cout << container[i].first << "), " << container[i].second << std::endl;
+      }
+      return false;
+    }
+    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
+            std::cout << "Test two rectangles, first output wrong: Interval(" <<
+        container[0].first << "), " << container[0].second << std::endl;
+    }
+    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(10, 15), 1)) {
+            std::cout << "Test two rectangles, second output wrong: Interval(" <<
+        container[1].first << "), " << container[1].second << std::endl;
+    }
+    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 5), -1)) {
+            std::cout << "Test two rectangles, third output wrong: Interval(" <<
+        container[2].first << "), " << container[2].second << std::endl;
+    }
+    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(5, 15), -1)) {
+            std::cout << "Test two rectangles, fourth output wrong: Interval(" <<
+        container[3].first << "), " << container[3].second << std::endl;
+    }
+
+    //test two rectangles
+    container.clear();
+    booleanOr = BooleanOp<int, Unit>();
+    booleanOr.processInterval(container, interval_data<Unit>(5, 15), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(5, 15), -1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
+    if(container.size() != 4) {
+            std::cout << "Test other two rectangles, wrong output size\n";
+      for(unsigned int i = 0; i < container.size(); ++i){
+              std::cout << container[i].first << "), " << container[i].second << std::endl;
+      }
+      return false;
+    }
+    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(5, 15), 1)) {
+            std::cout << "Test other two rectangles, first output wrong: Interval(" <<
+        container[0].first << "), " << container[0].second << std::endl;
+    }
+    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 5), 1)) {
+            std::cout << "Test other two rectangles, second output wrong: Interval(" <<
+        container[1].first << "), " << container[1].second << std::endl;
+    }
+    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(10, 15), -1)) {
+            std::cout << "Test other two rectangles, third output wrong: Interval(" <<
+        container[2].first << "), " << container[2].second << std::endl;
+    }
+    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
+            std::cout << "Test other two rectangles, fourth output wrong: Interval(" <<
+        container[3].first << "), " << container[3].second << std::endl;
+    }
+
+    //test two nonoverlapping rectangles
+    container.clear();
+    booleanOr = BooleanOp<int, Unit>();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(15, 25), 1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(0, 10), -1);
+    booleanOr.advanceScan();
+    booleanOr.processInterval(container, interval_data<Unit>(15, 25), -1);
+    if(container.size() != 4) {
+            std::cout << "Test two nonoverlapping rectangles, wrong output size\n";
+      return false;
+    }
+    if(container[0] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), 1)) {
+            std::cout << "Test two nonoverlapping rectangles, first output wrong: Interval(" <<
+        container[0].first << "), " << container[0].second << std::endl;
+    }
+    if(container[1] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(15, 25), 1)) {
+            std::cout << "Test two nonoverlapping rectangles, second output wrong: Interval(" <<
+        container[1].first << "), " << container[1].second << std::endl;
+    }
+    if(container[2] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(0, 10), -1)) {
+            std::cout << "Test two nonoverlapping rectangles, third output wrong: Interval(" <<
+        container[2].first << "), " << container[2].second << std::endl;
+    }
+    if(container[3] != std::pair<interval_data<Unit>, int>(interval_data<Unit>(15, 25), -1)) {
+            std::cout << "Test two nonoverlapping rectangles, fourth output wrong: Interval(" <<
+        container[3].first << "), " << container[3].second << std::endl;
+    }
+    return true;
+  }
+
+  template <class T, typename Unit, typename iterator_type_1, typename iterator_type_2>
+  inline void applyBooleanBinaryOp(std::vector<std::pair<Unit, std::pair<Unit, int> > >& output,
+                                   //const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input1,
+                                   //const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input2,
+                                   iterator_type_1 itr1, iterator_type_1 itr1_end,
+                                   iterator_type_2 itr2, iterator_type_2 itr2_end,
+                                   T defaultCount) {
+    BooleanOp<T, Unit> boolean(defaultCount);
+    //typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr1 = input1.begin();
+    //typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr2 = input2.begin();
+    std::vector<std::pair<interval_data<Unit>, int> > container;
+    //output.reserve((std::max)(input1.size(), input2.size()));
+
+    //consider eliminating dependecy on limits with bool flag for initial state
+    Unit UnitMax = (std::numeric_limits<Unit>::max)();
+    Unit prevCoord = UnitMax;
+    Unit prevPosition = UnitMax;
+    T count(defaultCount);
+    //define the starting point
+    if(itr1 != itr1_end) {
+      prevCoord = (*itr1).first;
+      prevPosition = (*itr1).second.first;
+      count[0] += (*itr1).second.second;
+    }
+    if(itr2 != itr2_end) {
+      if((*itr2).first < prevCoord || 
+         ((*itr2).first == prevCoord && (*itr2).second.first < prevPosition)) {
+        prevCoord = (*itr2).first;
+        prevPosition = (*itr2).second.first;
+        count = defaultCount;
+        count[1] += (*itr2).second.second;
+        ++itr2;
+      } else if((*itr2).first == prevCoord && (*itr2).second.first == prevPosition) {
+        count[1] += (*itr2).second.second;
+        ++itr2;
+        if(itr1 != itr1_end) ++itr1;
+      } else {
+        if(itr1 != itr1_end) ++itr1;
+      }
+    } else {
+      if(itr1 != itr1_end) ++itr1;
+    }
+    
+    while(itr1 != itr1_end || itr2 != itr2_end) {
+      Unit curCoord = UnitMax;
+      Unit curPosition = UnitMax;
+      T curCount(defaultCount);
+      if(itr1 != itr1_end) {
+        curCoord = (*itr1).first;
+        curPosition = (*itr1).second.first;
+        curCount[0] += (*itr1).second.second;
+      }
+      if(itr2 != itr2_end) {
+        if((*itr2).first < curCoord || 
+           ((*itr2).first == curCoord && (*itr2).second.first < curPosition)) {
+          curCoord = (*itr2).first;
+          curPosition = (*itr2).second.first;
+          curCount = defaultCount;
+          curCount[1] += (*itr2).second.second;
+          ++itr2;
+        } else if((*itr2).first == curCoord && (*itr2).second.first == curPosition) {
+          curCount[1] += (*itr2).second.second;
+          ++itr2;
+          if(itr1 != itr1_end) ++itr1;
+        } else {
+          if(itr1 != itr1_end) ++itr1;
+        }
+      } else {
+        ++itr1;
+      }
+
+      if(prevCoord != curCoord) {
+        boolean.advanceScan();
+        prevCoord = curCoord;
+        prevPosition = curPosition;
+        count = curCount;
+        continue;
+      }
+      if(curPosition != prevPosition && count != defaultCount) {
+        interval_data<Unit> ivl(prevPosition, curPosition);
+        container.clear();
+        boolean.processInterval(container, ivl, count);
+        for(unsigned int i = 0; i < container.size(); ++i) {
+          std::pair<interval_data<Unit>, int>& element = container[i];
+          if(!output.empty() && output.back().first == prevCoord && 
+             output.back().second.first == element.first.low() &&
+             output.back().second.second == element.second * -1) {
+            output.pop_back();
+          } else {
+            output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevCoord, std::pair<Unit, int>(element.first.low(), 
+                                                                                                    element.second)));
+          }
+          output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevCoord, std::pair<Unit, int>(element.first.high(), 
+                                                                                                  element.second * -1)));
+        }
+      }
+      prevPosition = curPosition;
+      count += curCount;
+    }
+  }
+
+  template <class T, typename Unit>
+  inline void applyBooleanBinaryOp(std::vector<std::pair<Unit, std::pair<Unit, int> > >& inputOutput,
+                                   const std::vector<std::pair<Unit, std::pair<Unit, int> > >& input2,
+                                   T defaultCount) {
+    std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
+    applyBooleanBinaryOp(output, inputOutput, input2, defaultCount);
+    if(output.size() < inputOutput.size() / 2) {
+      inputOutput = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
+    } else {
+      inputOutput.clear();
+    }
+    inputOutput.insert(inputOutput.end(), output.begin(), output.end());
+  }
+ 
+  template <typename Unit>
+  inline void applyUnaryXOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
+    BooleanOp<UnaryCount, Unit> booleanXOr;
+    
+  }
+
+  template <typename count_type = int>
+  struct default_arg_workaround {
+    template <typename Unit>
+    static inline void applyBooleanOr(std::vector<std::pair<Unit, std::pair<Unit, int> > >& input) {
+      BooleanOp<count_type, Unit> booleanOr;
+      std::vector<std::pair<interval_data<Unit>, int> > container;
+      std::vector<std::pair<Unit, std::pair<Unit, int> > > output;
+      output.reserve(input.size());
+      //consider eliminating dependecy on limits with bool flag for initial state
+      Unit UnitMax = (std::numeric_limits<Unit>::max)();
+      Unit prevPos = UnitMax;
+      Unit prevY = UnitMax;
+      int count = 0;
+      for(typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::iterator itr = input.begin();
+          itr != input.end(); ++itr) {
+        Unit pos = (*itr).first;
+        Unit y = (*itr).second.first;
+        if(pos != prevPos) {
+          booleanOr.advanceScan();
+          prevPos = pos;
+          prevY = y;
+          count = (*itr).second.second;
+          continue;
+        }
+        if(y != prevY && count != 0) {
+          interval_data<Unit> ivl(prevY, y);
+          container.clear();
+          booleanOr.processInterval(container, ivl, count_type(count));
+          for(unsigned int i = 0; i < container.size(); ++i) {
+            std::pair<interval_data<Unit>, int>& element = container[i];
+            if(!output.empty() && output.back().first == prevPos && 
+               output.back().second.first == element.first.low() &&
+               output.back().second.second == element.second * -1) {
+              output.pop_back();
+            } else {
+              output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.low(), 
+                                                                                                    element.second)));
+            }
+            output.push_back(std::pair<Unit, std::pair<Unit, int> >(prevPos, std::pair<Unit, int>(element.first.high(), 
+                                                                                                  element.second * -1)));
+          }
+        }
+        prevY = y;
+        count += (*itr).second.second;
+      }
+      if(output.size() < input.size() / 2) {
+        input = std::vector<std::pair<Unit, std::pair<Unit, int> > >();
+      } else {
+      input.clear();
+      } 
+      input.insert(input.end(), output.begin(), output.end());
+    }
+  };
+
+}
+
+}
+
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/boolean_op_45.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/boolean_op_45.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,1359 @@
+/*
+  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_BOOLEAN_OP_45_HPP
+#define BOOST_POLYGON_BOOLEAN_OP_45_HPP
+namespace boost { namespace polygon{
+
+  template <typename Unit>
+  struct boolean_op_45 {
+    typedef point_data<Unit> Point;
+    typedef typename coordinate_traits<Unit>::manhattan_area_type LongUnit;
+
+    class Count2 {
+    public:
+      inline Count2() : counts() { counts[0] = counts[1] = 0; }
+      //inline Count2(int count) { counts[0] = counts[1] = count; }
+      inline Count2(int count1, int count2) : counts() { counts[0] = count1; counts[1] = count2; }
+      inline Count2(const Count2& count) : counts() { counts[0] = count.counts[0]; counts[1] = count.counts[1]; }
+      inline bool operator==(const Count2& count) const { return counts[0] == count.counts[0] && counts[1] == count.counts[1]; }
+      inline bool operator!=(const Count2& count) const { return !((*this) == count); }
+      inline Count2& operator=(int count) { counts[0] = counts[1] = count; return *this; }
+      inline Count2& operator=(const Count2& count) { counts[0] = count.counts[0]; counts[1] = count.counts[1]; return *this; }
+      inline int& operator[](bool index) { return counts[index]; }
+      inline int operator[](bool index) const {return counts[index]; }
+      inline Count2& operator+=(const Count2& count){
+        counts[0] += count[0];
+        counts[1] += count[1];
+        return *this;
+      }
+      inline Count2& operator-=(const Count2& count){
+        counts[0] -= count[0];
+        counts[1] -= count[1];
+        return *this;
+      }
+      inline Count2 operator+(const Count2& count) const {
+        return Count2(*this)+=count;
+      }
+      inline Count2 operator-(const Count2& count) const {
+        return Count2(*this)-=count;
+      }
+      inline Count2 invert() const {
+        return Count2(-counts[0], -counts[1]);
+      }
+    private:
+      int counts[2];
+    };
+
+    class Count1 {
+    public:
+      inline Count1() : count_(0) { }
+      inline Count1(int count) : count_(count) { }
+      inline Count1(const Count1& count) : count_(count.count_) { }
+      inline bool operator==(const Count1& count) const { return count_ == count.count_; }
+      inline bool operator!=(const Count1& count) const { return !((*this) == count); }
+      inline Count1& operator=(int count) { count_ = count; return *this; }
+      inline Count1& operator=(const Count1& count) { count_ = count.count_; return *this; }
+      inline Count1& operator+=(const Count1& count){
+        count_ += count.count_;
+        return *this;
+      }
+      inline Count1& operator-=(const Count1& count){
+        count_ -= count.count_;
+        return *this;
+      }
+      inline Count1 operator+(const Count1& count) const {
+        return Count1(*this)+=count;
+      }
+      inline Count1 operator-(const Count1& count) const {
+        return Count1(*this)-=count;
+      }
+      inline Count1 invert() const {
+        return Count1(-count_);
+      }
+      int count_;
+    };
+
+    //     inline std::ostream& operator<< (std::ostream& o, const Count2& c) {
+    //       o << c[0] << " " << c[1];
+    //       return o;
+    //     }
+
+    template <typename CountType>
+    class Scan45ElementT {
+    public:
+      Unit x;
+      Unit y;
+      int rise; //-1, 0, +1
+      mutable CountType count;
+      inline Scan45ElementT() : x(), y(), rise(), count() {}
+      inline Scan45ElementT(Unit xIn, Unit yIn, int riseIn, CountType countIn = CountType()) :
+        x(xIn), y(yIn), rise(riseIn), count(countIn) {}
+      inline Scan45ElementT(const Scan45ElementT& that) :
+        x(that.x), y(that.y), rise(that.rise), count(that.count) {}
+      inline Scan45ElementT& operator=(const Scan45ElementT& that) {
+        x = that.x; y = that.y; rise = that.rise; count = that.count; 
+        return *this;
+      }
+      inline Unit evalAtX(Unit xIn) const {
+        return y + rise * (xIn - x);
+      }
+
+      inline bool cross(Point& crossPoint, const Scan45ElementT& edge, Unit currentX) const {
+        Unit y1 = evalAtX(currentX);
+        Unit y2 = edge.evalAtX(currentX);
+        int rise1 = rise;
+        int rise2 = edge.rise;
+        if(rise > edge.rise){
+          if(y1 > y2) return false;
+        } else if(rise < edge.rise){
+          if(y2 > y1) return false;
+          std::swap(y1, y2);
+          std::swap(rise1, rise2);
+        } else { return false; }
+        if(rise1 == 1) {
+          if(rise2 == 0) {
+            crossPoint = Point(currentX + y2 - y1, y2);
+          } else {
+            //rise2 == -1
+            Unit delta = (y2 - y1)/2;
+            crossPoint = Point(currentX + delta, y1 + delta);
+          }
+        } else {
+          //rise1 == 0 and rise2 == -1
+          crossPoint = Point(currentX + y2 - y1, y1);
+        }
+        return true;
+      }
+    };
+    
+    typedef Scan45ElementT<Count2> Scan45Element;
+
+    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Element& c) {
+    //       o << c.x << " " << c.y << " " << c.rise << " " << c.count;
+    //       return o;
+    //     }
+
+    class lessScan45ElementRise : public std::binary_function<Scan45Element, Scan45Element, bool> {
+    public:
+      inline lessScan45ElementRise() {} //default constructor is only constructor
+      inline bool operator () (Scan45Element elm1, Scan45Element elm2) const {
+        return elm1.rise < elm2.rise;
+      }
+    };
+
+    template <typename CountType>
+    class lessScan45Element {
+    private:
+      Unit *x_; //x value at which to apply comparison
+      int *justBefore_;
+    public:
+      inline lessScan45Element() : x_(0), justBefore_(0) {}
+      inline lessScan45Element(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
+      inline lessScan45Element(const lessScan45Element& that) : x_(that.x_), justBefore_(that.justBefore_) {}
+      inline lessScan45Element& operator=(const lessScan45Element& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
+      inline bool operator () (const Scan45ElementT<CountType>& elm1, 
+                               const Scan45ElementT<CountType>& elm2) const {
+        Unit y1 = elm1.evalAtX(*x_);
+        Unit y2 = elm2.evalAtX(*x_);
+        if(y1 < y2) return true;
+        if(y1 == y2) {
+          //if justBefore is true we invert the result of the comparison of slopes
+          if(*justBefore_) {
+            return elm1.rise > elm2.rise;
+          } else {
+            return elm1.rise < elm2.rise;
+          }
+        }
+        return false;
+      }
+    };
+
+    template <typename CountType>
+    class Scan45CountT {
+    public:
+      inline Scan45CountT() : counts() {} //counts[0] = counts[1] = counts[2] = counts[3] = 0; }
+      inline Scan45CountT(CountType count) : counts() { counts[0] = counts[1] = counts[2] = counts[3] = count; }
+      inline Scan45CountT(const CountType& count1, const CountType& count2, const CountType& count3, 
+                          const CountType& count4) : counts() { 
+        counts[0] = count1; 
+        counts[1] = count2; 
+        counts[2] = count3;
+        counts[3] = count4; 
+      }
+      inline Scan45CountT(const Scan45CountT& count) : counts() { 
+        (*this) = count;
+      }
+      inline bool operator==(const Scan45CountT& count) const { 
+        for(unsigned int i = 0; i < 4; ++i) {
+          if(counts[i] != count.counts[i]) return false; 
+        }
+        return true;
+      }
+      inline bool operator!=(const Scan45CountT& count) const { return !((*this) == count); }
+      inline Scan45CountT& operator=(CountType count) { 
+        counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
+      inline Scan45CountT& operator=(const Scan45CountT& count) {
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] = count.counts[i]; 
+        }
+        return *this; 
+      }
+      inline CountType& operator[](int index) { return counts[index]; }
+      inline CountType operator[](int index) const {return counts[index]; }
+      inline Scan45CountT& operator+=(const Scan45CountT& count){
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] += count.counts[i]; 
+        }
+        return *this;
+      }
+      inline Scan45CountT& operator-=(const Scan45CountT& count){
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] -= count.counts[i]; 
+        }
+        return *this;
+      }
+      inline Scan45CountT operator+(const Scan45CountT& count) const {
+        return Scan45CountT(*this)+=count;
+      }
+      inline Scan45CountT operator-(const Scan45CountT& count) const {
+        return Scan45CountT(*this)-=count;
+      }
+      inline Scan45CountT invert() const {
+        return Scan45CountT(CountType())-=(*this);
+      }
+      inline Scan45CountT& operator+=(const Scan45ElementT<CountType>& element){
+        counts[element.rise+1] += element.count; return *this;
+      }
+    private:
+      CountType counts[4];
+    };
+
+    typedef Scan45CountT<Count2> Scan45Count;
+
+    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Count& c) {
+    //       o << c[0] << ", " << c[1] << ", ";
+    //       o << c[2] << ", " << c[3];
+    //       return o;
+    //     }
+
+
+    //     inline std::ostream& operator<< (std::ostream& o, const Scan45Vertex& c) {
+    //       o << c.first << ": " << c.second;
+    //       return o;
+    //     }
+
+
+    //vetex45 is sortable
+    template <typename ct>
+    class Vertex45T {
+    public:
+      Point pt;
+      int rise; // 1, 0 or -1
+      ct count; //dxdydTheta
+      inline Vertex45T() : pt(), rise(), count() {}
+      inline Vertex45T(const Point& point, int riseIn, ct countIn) : pt(point), rise(riseIn), count(countIn) {}
+      inline Vertex45T(const Vertex45T& vertex) : pt(vertex.pt), rise(vertex.rise), count(vertex.count) {}
+      inline Vertex45T& operator=(const Vertex45T& vertex){ 
+        pt = vertex.pt; rise = vertex.rise; count = vertex.count; return *this; }
+      inline Vertex45T(const std::pair<Point, Point>& vertex) {}
+      inline Vertex45T& operator=(const std::pair<Point, Point>& vertex){ return *this; }
+      inline bool operator==(const Vertex45T& vertex) const {
+        return pt == vertex.pt && rise == vertex.rise && count == vertex.count; }
+      inline bool operator!=(const Vertex45T& vertex) const { return !((*this) == vertex); }
+      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
+      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
+      inline bool operator<(const Vertex45T& vertex) const {
+        if(pt.x() < vertex.pt.x()) return true;
+        if(pt.x() == vertex.pt.x()) {
+          if(pt.y() < vertex.pt.y()) return true;
+          if(pt.y() == vertex.pt.y()) { return rise < vertex.rise; }
+        }
+        return false;
+      }
+      inline bool operator>(const Vertex45T& vertex) const { return vertex < (*this); }
+      inline bool operator<=(const Vertex45T& vertex) const { return !((*this) > vertex); }
+      inline bool operator>=(const Vertex45T& vertex) const { return !((*this) < vertex); }
+      inline Unit evalAtX(Unit xIn) const { return pt.y() + rise * (xIn - pt.x()); }
+    };
+
+    typedef Vertex45T<int> Vertex45;
+
+    //     inline std::ostream& operator<< (std::ostream& o, const Vertex45& c) {
+    //       o << c.pt << " " << c.rise << " " << c.count;
+    //       return o;
+    //     }
+
+    //when scanning Vertex45 for polygon formation we need a scanline comparator functor
+    class lessVertex45 {
+    private:
+      Unit *x_; //x value at which to apply comparison
+      int *justBefore_;
+    public:
+      inline lessVertex45() : x_(0), justBefore_() {}
+      
+      inline lessVertex45(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
+      
+      inline lessVertex45(const lessVertex45& that) : x_(that.x_), justBefore_(that.justBefore_) {}
+      
+      inline lessVertex45& operator=(const lessVertex45& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
+      
+      template <typename ct>
+      inline bool operator () (const Vertex45T<ct>& elm1, const Vertex45T<ct>& elm2) const {
+        Unit y1 = elm1.evalAtX(*x_);
+        Unit y2 = elm2.evalAtX(*x_);
+        if(y1 < y2) return true;
+        if(y1 == y2) {
+          //if justBefore is true we invert the result of the comparison of slopes
+          if(*justBefore_) {
+            return elm1.rise > elm2.rise;
+          } else {
+            return elm1.rise < elm2.rise;
+          }
+        }
+        return false;
+      }
+    };
+
+    // 0 right to left
+    // 1 upper right to lower left
+    // 2 high to low
+    // 3 upper left to lower right
+    // 4 left to right
+    // 5 lower left to upper right
+    // 6 low to high
+    // 7 lower right to upper left
+    static inline int classifyEdge45(const Point& prevPt, const Point& nextPt) {
+      if(prevPt.x() == nextPt.x()) {
+        //2 or 6
+        return predicated_value(prevPt.y() < nextPt.y(), 6, 2);
+      }
+      if(prevPt.y() == nextPt.y()) {
+        //0 or 4
+        return predicated_value(prevPt.x() < nextPt.x(), 4, 0);
+      }
+      if(prevPt.x() < nextPt.x()) {
+        //3 or 5
+        return predicated_value(prevPt.y() < nextPt.y(), 5, 3);
+      }
+      //prevPt.x() > nextPt.y()
+      //1 or 7
+      return predicated_value(prevPt.y() < nextPt.y(), 7, 1);
+    }
+
+    template <int op, typename CountType>
+    static int applyLogic(CountType count1, CountType count2){
+      bool l1 = applyLogic<op>(count1);
+      bool l2 = applyLogic<op>(count2);
+      if(l1 && !l2)
+        return -1; //was true before and became false like a trailing edge
+      if(!l1 && l2)
+        return 1; //was false before and became true like a leading edge
+      return 0; //no change in logic between the two counts
+    }
+    template <int op>
+    static bool applyLogic(Count2 count) {
+      if(op == 0) { //apply or
+        return count[0] > 0 || count[1] > 0;
+      } else if(op == 1) { //apply and
+        return count[0] > 0 && count[1] > 0;
+      } else if(op == 2) { //apply not
+        return count[0] > 0 && !(count[1] > 0);
+      } else if(op == 3) { //apply xor
+        return (count[0] > 0) ^ (count[1] > 0);
+      } else
+        return false;
+    }
+
+    template <int op>
+    struct boolean_op_45_output_functor {
+      template <typename cT>
+      void operator()(cT& output, const Count2& count1, const Count2& count2, 
+                      const Point& pt, int rise, direction_1d end) {
+        int edgeType = applyLogic<op>(count1, count2);
+        if(edgeType) {
+          int multiplier = end == LOW ? -1 : 1;
+          //std::cout << "cross logic: " << edgeType << std::endl;
+          output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
+          //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+        }
+      }
+    };
+
+    template <int op>
+    static bool applyLogic(Count1 count) {
+      if(op == 0) { //apply or
+        return count.count_ > 0;
+      } else if(op == 1) { //apply and
+        return count.count_ > 1;
+      } else if(op == 3) { //apply xor
+        return count.count_ % 2;
+      } else
+        return false;
+    }
+
+    template <int op>
+    struct unary_op_45_output_functor {
+      template <typename cT>
+      void operator()(cT& output, const Count1& count1, const Count1& count2, 
+                      const Point& pt, int rise, direction_1d end) {
+        int edgeType = applyLogic<op>(count1, count2);
+        if(edgeType) {
+          int multiplier = end == LOW ? -1 : 1;
+          //std::cout << "cross logic: " << edgeType << std::endl;
+          output.insert(output.end(), Vertex45(pt, rise, edgeType * multiplier));
+          //std::cout << "write out: " << crossPoint << " " << Point(eraseItrs[i]->x, eraseItrs[i]->y) << std::endl;
+        }
+      }
+    };
+
+    class lessScan45Vertex {
+    public:
+      inline lessScan45Vertex() {} //default constructor is only constructor
+      template <typename Scan45Vertex>
+      inline bool operator () (const Scan45Vertex& v1, const Scan45Vertex& v2) const {
+        return (v1.first.x() < v2.first.x()) || (v1.first.x() == v2.first.x() && v1.first.y() < v2.first.y());
+      }
+    };
+    template <typename S45V>
+    static inline void sortScan45Vector(S45V& vec) {
+      std::sort(vec.begin(), vec.end(), lessScan45Vertex());
+    }
+
+    template <typename CountType, typename output_functor>
+    class Scan45 {
+    public:
+      typedef Scan45CountT<CountType> Scan45Count;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      
+      //index is the index into the vertex
+      static inline Scan45Element getElement(const Scan45Vertex& vertex, int index) {
+        return Scan45Element(vertex.first.x(), vertex.first.y(), index - 1, vertex.second[index]);
+      }
+      
+      class lessScan45Point : public std::binary_function<Point, Point, bool> {
+      public:
+        inline lessScan45Point() {} //default constructor is only constructor
+        inline bool operator () (const Point& v1, const Point& v2) const {
+          return (v1.x() < v2.x()) || (v1.x() == v2.x() && v1.y() < v2.y());
+        }
+      };
+      
+      typedef std::vector<Scan45Vertex> Scan45Vector;
+
+      //definitions
+      typedef std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> > Scan45Data;
+      typedef typename Scan45Data::iterator iterator;
+      typedef typename Scan45Data::const_iterator const_iterator;
+      typedef std::set<Point, lessScan45Point> CrossQueue;
+   
+      //data
+      Scan45Data scanData_;
+      CrossQueue crossQueue_;
+      Scan45Vector crossVector_;
+      Unit x_;
+      int justBefore_;
+    public:
+      inline Scan45() : scanData_(), crossQueue_(), crossVector_(), 
+                        x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
+        lessScan45Element<CountType>  lessElm(&x_, &justBefore_);
+        scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
+      }
+      inline Scan45(const Scan45& that) : scanData_(), crossQueue_(), crossVector_(), 
+                                          x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
+        (*this) = that; }
+      inline Scan45& operator=(const Scan45& that) {
+        x_ = that.x_;
+        justBefore_ = that.justBefore_;
+        crossQueue_ = that.crossQueue_; 
+        crossVector_ = that.crossVector_; 
+        lessScan45Element<CountType>  lessElm(&x_, &justBefore_);
+        scanData_ = std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >(lessElm);
+        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
+          scanData_.insert(scanData_.end(), *itr);
+        }
+        return *this;
+      }
+   
+      //cT is an output container of Vertex45
+      //iT is an iterator over Scan45Vertex elements
+      template <class cT, class iT>
+      void scan(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "1\n";
+        while(inputBegin != inputEnd) {
+          //std::cout << "2\n";
+          //std::cout << "x_ = " << x_ << std::endl;
+          //std::cout << "scan line size: " << scanData_.size() << std::endl;
+          //for(iterator iter = scanData_.begin();
+          //     iter != scanData_.end(); ++iter) {
+          //   std::cout << "scan element\n";
+          //   std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
+          // }
+          // std::cout << "cross queue size: " << crossQueue_.size() << std::endl;
+          // std::cout << "cross vector size: " << crossVector_.size() << std::endl;
+          //for(CrossQueue::iterator cqitr = crossQueue_.begin(); cqitr != crossQueue_.end(); ++cqitr) {
+          //   std::cout << *cqitr << " ";
+          //} std::cout << std::endl;
+          Unit nextX = (*inputBegin).first.x();
+          if(!crossVector_.empty() && crossVector_[0].first.x() < nextX) nextX = crossVector_[0].first.x();
+          if(nextX != x_) {
+            //std::cout << "3\n";
+            //we need to move to the next scanline stop
+            //we need to process end events then cross events
+            //process end events
+            if(!crossQueue_.empty() &&
+               (*crossQueue_.begin()).x() < nextX) {
+              //std::cout << "4\n";
+              nextX = (std::min)(nextX, (*crossQueue_.begin()).x());
+            }
+            //std::cout << "6\n";
+            justBefore_ = true;
+            x_ = nextX;
+            advance_(output);
+            justBefore_ = false;
+            if(!crossVector_.empty() &&
+               nextX == (*inputBegin).first.x()) {
+              inputBegin = mergeCross_(inputBegin, inputEnd);
+            }
+            processEvent_(output, crossVector_.begin(), crossVector_.end());
+            crossVector_.clear();
+          } else {
+            //std::cout << "7\n";
+            //our scanline has progressed to the event that is next in the queue
+            inputBegin = processEvent_(output, inputBegin, inputEnd);
+          }
+        }
+        //std::cout << "done scanning\n";
+      }
+
+    private:
+      //functions
+
+      template <class cT>
+      inline void advance_(cT& output) {
+        //process all cross points on the cross queue at the current x_
+        //std::cout << "advance_\n";
+        std::vector<iterator> eraseVec;
+        while(!crossQueue_.empty() &&
+              (*crossQueue_.begin()).x() == x_){
+          //std::cout << "loop\n";
+          //pop point off the cross queue
+          Point crossPoint = *(crossQueue_.begin());
+          //std::cout << crossPoint << std::endl;
+          //for(iterator iter = scanData_.begin();
+          //    iter != scanData_.end(); ++iter) {
+          //  std::cout << "scan element\n";
+          //  std::cout << *iter << " " << iter->evalAtX(x_) << std::endl;
+          //}
+          crossQueue_.erase(crossQueue_.begin());
+          Scan45Vertex vertex(crossPoint, Scan45Count());
+          iterator lowIter = lookUp_(vertex.first.y());
+          //std::cout << "searching at: " << vertex.first.y() << std::endl;
+          //if(lowIter == scanData_.end()) std::cout << "could not find\n";
+          //else std::cout << "found: " << *lowIter << std::endl;
+          if(lowIter == scanData_.end() ||
+             lowIter->evalAtX(x_) != vertex.first.y()) {
+            //   std::cout << "skipping\n";
+            //there weren't any edges at this potential cross point
+            continue;
+          }
+          CountType countBelow;
+          iterator searchDownItr = lowIter;
+          while(searchDownItr != scanData_.begin()
+                && searchDownItr->evalAtX(x_) == vertex.first.y()) {
+            //get count from below
+            --searchDownItr;
+            countBelow = searchDownItr->count;
+          }
+          //std::cout << "Below Count: " << countBelow << std::endl;
+          Scan45Count count(countBelow);
+          unsigned int numEdges = 0;
+          iterator eraseItrs[3];
+          while(lowIter != scanData_.end() &&
+                lowIter->evalAtX(x_) == vertex.first.y()) {
+            for(int index = lowIter->rise +1; index >= 0; --index)
+              count[index] = lowIter->count;
+            //std::cout << count << std::endl;
+            eraseItrs[numEdges] = lowIter;
+            ++numEdges;
+            ++lowIter;
+          }
+          if(numEdges == 1) {
+            //look for the next crossing point and continue
+            //std::cout << "found only one edge\n";
+            findCross_(eraseItrs[0]);
+            continue;
+          }
+          //before we erase the elements we need to decide if they should be written out
+          CountType currentCount = countBelow;
+          for(unsigned int i = 0; i < numEdges; ++i) {
+            output_functor f;
+            f(output, currentCount, eraseItrs[i]->count, crossPoint, eraseItrs[i]->rise, LOW);
+            currentCount = eraseItrs[i]->count;
+          }
+          //schedule erase of the elements
+          for(unsigned int i = 0; i < numEdges; ++i) {
+            eraseVec.push_back(eraseItrs[i]);
+          }
+         
+          //take the derivative wrt theta of the count at the crossing point
+          vertex.second[2] = count[2] - countBelow;
+          vertex.second[1] = count[1] - count[2];
+          vertex.second[0] = count[0] - count[1];
+          //add the point, deriviative pair into the cross vector
+          //std::cout << "LOOK HERE!\n";
+          //std::cout << count << std::endl;
+          //std::cout << vertex << std::endl;
+          crossVector_.push_back(vertex);
+        }
+        //erase crossing elements
+        std::vector<iterator> searchVec;
+        for(unsigned int i = 0; i < eraseVec.size(); ++i) {
+          if(eraseVec[i] != scanData_.begin()) {
+            iterator searchItr = eraseVec[i];
+            --searchItr;
+            if(searchVec.empty() ||
+               searchVec.back() != searchItr)
+              searchVec.push_back(searchItr);
+          }
+          scanData_.erase(eraseVec[i]);
+        }
+        for(unsigned int i = 0; i < searchVec.size(); ++i) {
+          findCross_(searchVec[i]);
+        }
+      }
+   
+      template <class iT>
+      inline iT mergeCross_(iT inputBegin, iT inputEnd) {
+        Scan45Vector vec;
+        swap(vec, crossVector_);
+        iT mergeEnd = inputBegin;
+        unsigned int mergeCount = 0;
+        while(mergeEnd != inputEnd &&
+              (*mergeEnd).first.x() == x_) {
+          ++mergeCount;
+          ++mergeEnd;
+        }
+        crossVector_.reserve((std::max)(vec.capacity(), vec.size() + mergeCount));
+        for(unsigned int i = 0; i < vec.size(); ++i){
+          while(inputBegin != mergeEnd &&
+                (*inputBegin).first.y() < vec[i].first.y()) {
+            crossVector_.push_back(*inputBegin);
+            ++inputBegin;
+          }
+          crossVector_.push_back(vec[i]);
+        }
+        while(inputBegin != mergeEnd){
+          crossVector_.push_back(*inputBegin);
+          ++inputBegin;
+        }
+        return inputBegin;
+      }
+   
+      template <class cT, class iT>
+      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "processEvent_\n";
+        CountType verticalCount = CountType();
+        Point prevPoint;
+        iterator prevIter = scanData_.end();
+        while(inputBegin != inputEnd &&
+              (*inputBegin).first.x() == x_) {
+          //std::cout << (*inputBegin) << std::endl;
+          //std::cout << "loop\n";
+          Scan45Vertex vertex = *inputBegin;
+          //std::cout << vertex.first << std::endl;
+          //if vertical count propigating up fake a null event at the next element
+          if(verticalCount != CountType() && (prevIter != scanData_.end() &&
+                                              prevIter->evalAtX(x_) < vertex.first.y())) {
+            //std::cout << "faking null event\n";
+            vertex = Scan45Vertex(Point(x_, prevIter->evalAtX(x_)), Scan45Count());
+          } else { 
+            ++inputBegin; 
+            //std::cout << "after increment\n";
+            //accumulate overlapping changes in Scan45Count
+            while(inputBegin != inputEnd &&
+                  (*inputBegin).first.x() == x_ && 
+                  (*inputBegin).first.y() == vertex.first.y()) {
+              //std::cout << "accumulate\n";
+              vertex.second += (*inputBegin).second;
+              ++inputBegin;
+            }
+          }
+          //std::cout << vertex.second << std::endl;
+          //integrate vertex
+          CountType currentCount = verticalCount;// + vertex.second[0];
+          for(unsigned int i = 0; i < 3; ++i) {
+            vertex.second[i] = currentCount += vertex.second[i];
+          }
+          //std::cout << vertex.second << std::endl;
+          //vertex represents the change in state at this point
+         
+          //get counts at current vertex
+          CountType countBelow;
+          iterator lowIter = lookUp_(vertex.first.y());
+          if(lowIter != scanData_.begin()) {
+            //get count from below
+            --lowIter;
+            countBelow = lowIter->count;
+            ++lowIter;
+          }
+          //std::cout << "Count Below: " << countBelow[0] << " " << countBelow[1] << std::endl;
+          //std::cout << "vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
+          Scan45Count countAt(countBelow - verticalCount);
+          //check if the vertical edge should be written out
+          if(verticalCount != CountType()) {
+            output_functor f;
+            f(output, countBelow - verticalCount, countBelow, prevPoint, 2, HIGH);
+            f(output, countBelow - verticalCount, countBelow, vertex.first, 2, LOW);
+          }
+          currentCount = countBelow - verticalCount;
+          while(lowIter != scanData_.end() &&
+                lowIter->evalAtX(x_) == vertex.first.y()) {
+            for(unsigned int i = lowIter->rise + 1; i < 3; ++i) {
+              countAt[i] = lowIter->count;
+            }
+            Point lp(lowIter->x, lowIter->y);
+            if(lp != vertex.first) {
+              output_functor f;
+              f(output, currentCount, lowIter->count, vertex.first, lowIter->rise, LOW);
+            }
+            currentCount = lowIter->count;
+            iterator nextIter = lowIter;
+            ++nextIter;
+            //std::cout << "erase\n";
+            scanData_.erase(lowIter);
+            if(nextIter != scanData_.end())
+              findCross_(nextIter);
+            lowIter = nextIter;
+          }
+          verticalCount += vertex.second[3];
+          prevPoint = vertex.first;
+          //std::cout << "new vertical count: " << verticalCount[0] << " " << verticalCount[1] << std::endl;
+          prevIter = lowIter;
+          //count represents the current state at this point
+          //std::cout << vertex.second << std::endl;
+          //std::cout << countAt << std::endl;
+          //std::cout << "ADD\n";
+          vertex.second += countAt;
+          //std::cout << vertex.second << std::endl;
+         
+          //add elements to the scanline
+          for(int i = 0; i < 3; ++i) {
+            if(vertex.second[i] != countBelow) {
+              //std::cout << "insert: " << vertex.first.x() << " " << vertex.first.y() << " " << i-1 <<
+              //  " " << vertex.second[i][0] << " " << vertex.second[i][1] << std::endl;
+              iterator insertIter = scanData_.insert(scanData_.end(), 
+                                                     Scan45ElementT<CountType>(vertex.first.x(), 
+                                                                               vertex.first.y(), 
+                                                                               i - 1, vertex.second[i]));
+              findCross_(insertIter);
+              output_functor f;
+              f(output, countBelow, vertex.second[i], vertex.first, i - 1, HIGH);
+            }
+            countBelow = vertex.second[i];
+          }
+        }
+        //std::cout << "end processEvent\n";
+        return inputBegin;
+      }
+   
+      //iter1 is horizontal
+      inline void scheduleCross0_(iterator iter1, iterator iter2) {
+        //std::cout << "0, ";
+        Unit y1 = iter1->evalAtX(x_);
+        Unit y2 = iter2->evalAtX(x_);
+        LongUnit delta = (LongUnit)abs((LongUnit)y1 - (LongUnit)y2);
+        if(delta + x_ <= (std::numeric_limits<Unit>::max)())
+          crossQueue_.insert(crossQueue_.end(), Point(x_ + delta, y1));
+        //std::cout <<  Point(x_ + delta, y1);
+      }
+
+      //neither iter is horizontal
+      inline void scheduleCross1_(iterator iter1, iterator iter2) {
+        //std::cout << "1, ";
+        Unit y1 = iter1->evalAtX(x_);
+        Unit y2 = iter2->evalAtX(x_);
+        //std::cout << y1 << " " << y2 << ": ";
+        //note that half the delta cannot exceed the positive inter range
+        LongUnit delta = y1;
+        delta -= y2;
+        Unit UnitMax = (std::numeric_limits<Unit>::max)();
+        if(delta & 1) {
+          //delta is odd, division by 2 will result in integer trunctaion
+          if(delta == 1) {
+            //the cross point is not on the integer grid and cannot be represented
+            //we must throw an exception
+            std::string msg = "GTL 45 Boolean error, precision insufficient to represent edge intersection coordinate value.";
+            throw(msg);
+          } else {
+            //note that result of this subtraction is always positive because itr1 is above itr2 in scanline
+            LongUnit halfDelta2 = (LongUnit)((((LongUnit)y1) - y2)/2); 
+            //note that halfDelta2 has been truncated
+            if(halfDelta2 + x_ <= UnitMax && halfDelta2 + y2 <= UnitMax) {
+              crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta2, y2+halfDelta2));
+              crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta2, y2+halfDelta2+1));
+            }
+          }
+        } else {
+          LongUnit halfDelta = (LongUnit)((((LongUnit)y1) - y2)/2); 
+          if(halfDelta + x_ <= UnitMax && halfDelta + y2 <= UnitMax)
+            crossQueue_.insert(crossQueue_.end(), Point(x_+halfDelta, y2+halfDelta));
+          //std::cout << Point(x_+halfDelta, y2+halfDelta);
+        }
+      }
+   
+      inline void findCross_(iterator iter) {
+        //std::cout << "find cross ";
+        iterator iteratorBelow = iter;
+        iterator iteratorAbove = iter;
+        if(iter != scanData_.begin() && iter->rise < 1) {
+          --iteratorBelow;
+          if(iter->rise == 0){
+            if(iteratorBelow->rise == 1) {
+              scheduleCross0_(iter, iteratorBelow);
+            } 
+          } else {
+            //iter->rise == -1
+            if(iteratorBelow->rise == 1) {
+              scheduleCross1_(iter, iteratorBelow);
+            } else if(iteratorBelow->rise == 0) {
+              scheduleCross0_(iteratorBelow, iter);
+            }
+          }
+        }
+        ++iteratorAbove;
+        if(iteratorAbove != scanData_.end() && iter->rise > -1) {
+          if(iter->rise == 0) {
+            if(iteratorAbove->rise == -1) {
+              scheduleCross0_(iter, iteratorAbove);
+            }
+          } else {
+            //iter->rise == 1
+            if(iteratorAbove->rise == -1) {
+              scheduleCross1_(iteratorAbove, iter);
+            } else if(iteratorAbove->rise == 0) {
+              scheduleCross0_(iteratorAbove, iter);
+            }
+          }
+        } 
+        //std::cout << std::endl; 
+      } 
+   
+      inline iterator lookUp_(Unit y){
+        //if just before then we need to look from 1 not -1
+        return scanData_.lower_bound(Scan45ElementT<CountType>(x_, y, -1+2*justBefore_));
+      }
+    };
+
+    template <typename CountType>
+    static inline void print45Data(const std::set<Scan45ElementT<CountType>, 
+                                   lessScan45Element<CountType> >& data) {
+      typename std::set<Scan45ElementT<CountType>, lessScan45Element<CountType> >::const_iterator iter;
+      for(iter = data.begin(); iter != data.end(); ++iter) {
+        std::cout << iter->x << " " << iter->y << " " << iter->rise << std::endl;
+      }
+    }
+
+    static inline bool testScan45Data() {
+      Unit x = 0;
+      int justBefore = false;
+      lessScan45Element<Count2> lessElm(&x, &justBefore);
+      std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > testData(lessElm);
+      //Unit size = testData.size();
+      typedef std::set<Scan45ElementT<Count2>, lessScan45Element<Count2> > Scan45Data;
+      typename Scan45Data::iterator itr10 = testData.insert(testData.end(), Scan45Element(0, 10, 1));
+      typename Scan45Data::iterator itr20 = testData.insert(testData.end(), Scan45Element(0, 20, 1));
+      typename Scan45Data::iterator itr30 = testData.insert(testData.end(), Scan45Element(0, 30, -1));
+      typename Scan45Data::iterator itr40 = testData.insert(testData.end(), Scan45Element(0, 40, -1));
+      typename Scan45Data::iterator itrA = testData.lower_bound(Scan45Element(0, 29, -1));
+      typename Scan45Data::iterator itr1 = testData.lower_bound(Scan45Element(0, 10, -1));
+      x = 4;
+      //now at 14 24 26 36
+      typename Scan45Data::iterator itrB = testData.lower_bound(Scan45Element(4, 29, -1));
+      typename Scan45Data::iterator itr2 = testData.lower_bound(Scan45Element(4, 14, -1));
+      if(itr1 != itr2) std::cout << "test1 failed\n";
+      if(itrA == itrB) std::cout << "test2 failed\n";
+      //remove crossing elements
+      testData.erase(itr20);
+      testData.erase(itr30);
+      x = 5;
+      itr20 = testData.insert(testData.end(), Scan45Element(0, 20, 1));
+      itr30 = testData.insert(testData.end(), Scan45Element(0, 30, -1));
+      //now at 15 25 25 35
+      typename Scan45Data::iterator itr = testData.begin();
+      if(itr != itr10) std::cout << "test3 failed\n";
+      ++itr;
+      if(itr != itr30) std::cout << "test4 failed\n";
+      ++itr;
+      if(itr != itr20) std::cout << "test5 failed\n";
+      ++itr;
+      if(itr != itr40) std::cout << "test6 failed\n";
+      std::cout << "done testing Scan45Data\n";
+      return true;
+    }
+   
+    static inline bool testScan45Rect() {
+      std::cout << "testing Scan45Rect\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 8
+      // result == 0 0 0 1
+      // result == 0 0 2 1
+      // result == 0 10 2 -1
+      // result == 0 10 0 -1
+      // result == 10 0 0 -1
+      // result == 10 0 2 -1
+      // result == 10 10 2 1
+      // result == 10 10 0 1
+      std::vector<Vertex45> reference;
+      reference.push_back(Vertex45(Point(0, 0), 0, 1));
+      reference.push_back(Vertex45(Point(0, 0), 2, 1));
+      reference.push_back(Vertex45(Point(0, 10), 2, -1));
+      reference.push_back(Vertex45(Point(0, 10), 0, -1));
+      reference.push_back(Vertex45(Point(10, 0), 0, -1));
+      reference.push_back(Vertex45(Point(10, 0), 2, -1));
+      reference.push_back(Vertex45(Point(10, 10), 2, 1));
+      reference.push_back(Vertex45(Point(10, 10), 0, 1));
+      if(result != reference) {
+        std::cout << "result size == " << result.size() << std::endl;
+        for(unsigned int i = 0; i < result.size(); ++i) {
+          //std::cout << "result == " << result[i]<< std::endl;
+        }
+        std::cout << "reference size == " << reference.size() << std::endl;
+        for(unsigned int i = 0; i < reference.size(); ++i) {
+          //std::cout << "reference == " << reference[i]<< std::endl;
+        }
+        return false;
+      }
+      std::cout << "done testing Scan45Rect\n";
+      return true;
+    }
+
+    static inline bool testScan45P1() {
+      std::cout << "testing Scan45P1\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), Count2(0, 0), ncount, ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), Count2(0, 0), ncount, ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,20), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 8
+      // result == 0 0 1 1
+      // result == 0 0 2 1
+      // result == 0 10 2 -1
+      // result == 0 10 1 -1
+      // result == 10 10 1 -1
+      // result == 10 10 2 -1
+      // result == 10 20 2 1
+      // result == 10 20 1 1
+      std::vector<Vertex45> reference;
+      reference.push_back(Vertex45(Point(0, 0), 1, 1));
+      reference.push_back(Vertex45(Point(0, 0), 2, 1));
+      reference.push_back(Vertex45(Point(0, 10), 2, -1));
+      reference.push_back(Vertex45(Point(0, 10), 1, -1));
+      reference.push_back(Vertex45(Point(10, 10), 1, -1));
+      reference.push_back(Vertex45(Point(10, 10), 2, -1));
+      reference.push_back(Vertex45(Point(10, 20), 2, 1));
+      reference.push_back(Vertex45(Point(10, 20), 1, 1));
+      if(result != reference) {
+        std::cout << "result size == " << result.size() << std::endl;
+        for(unsigned int i = 0; i < result.size(); ++i) {
+          //std::cout << "result == " << result[i]<< std::endl;
+        }
+        std::cout << "reference size == " << reference.size() << std::endl;
+        for(unsigned int i = 0; i < reference.size(); ++i) {
+          //std::cout << "reference == " << reference[i]<< std::endl;
+        }
+        return false;
+      }
+      std::cout << "done testing Scan45P1\n";
+      return true;
+    }
+
+    static inline bool testScan45P2() {
+      std::cout << "testing Scan45P2\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, count, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), ncount, count, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(20,10), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 8
+      // result == 0 0 0 1
+      // result == 0 0 1 -1
+      // result == 10 0 0 -1
+      // result == 10 0 1 1
+      // result == 10 10 1 1
+      // result == 10 10 0 -1
+      // result == 20 10 1 -1
+      // result == 20 10 0 1
+      std::vector<Vertex45> reference;
+      reference.push_back(Vertex45(Point(0, 0), 0, 1));
+      reference.push_back(Vertex45(Point(0, 0), 1, -1));
+      reference.push_back(Vertex45(Point(10, 0), 0, -1));
+      reference.push_back(Vertex45(Point(10, 0), 1, 1));
+      reference.push_back(Vertex45(Point(10, 10), 1, 1));
+      reference.push_back(Vertex45(Point(10, 10), 0, -1));
+      reference.push_back(Vertex45(Point(20, 10), 1, -1));
+      reference.push_back(Vertex45(Point(20, 10), 0, 1));
+      if(result != reference) {
+        std::cout << "result size == " << result.size() << std::endl;
+        for(unsigned int i = 0; i < result.size(); ++i) {
+          //std::cout << "result == " << result[i]<< std::endl;
+        }
+        std::cout << "reference size == " << reference.size() << std::endl;
+        for(unsigned int i = 0; i < reference.size(); ++i) {
+          //std::cout << "reference == " << reference[i]<< std::endl;
+        }
+        return false;
+      }
+      std::cout << "done testing Scan45P2\n";
+      return true;
+    }
+
+    static inline bool testScan45And() {
+      std::cout << "testing Scan45And\n";
+      Scan45<Count2, boolean_op_45_output_functor<1> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      vertices.push_back(Scan45Vertex(Point(0,10), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(10,10), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(2,2), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      vertices.push_back(Scan45Vertex(Point(2,12), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(12,2), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(12,12), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      //result size == 8
+      //result == 2 2 0 1
+      //result == 2 2 2 1
+      //result == 2 10 2 -1
+      //result == 2 10 0 -1
+      //result == 10 2 0 -1
+      //result == 10 2 2 -1
+      //result == 10 10 2 1
+      //result == 10 10 0 1
+      std::vector<Vertex45> reference;
+      reference.push_back(Vertex45(Point(2, 2), 0, 1));
+      reference.push_back(Vertex45(Point(2, 2), 2, 1));
+      reference.push_back(Vertex45(Point(2, 10), 2, -1));
+      reference.push_back(Vertex45(Point(2, 10), 0, -1));
+      reference.push_back(Vertex45(Point(10, 2), 0, -1));
+      reference.push_back(Vertex45(Point(10, 2), 2, -1));
+      reference.push_back(Vertex45(Point(10, 10), 2, 1));
+      reference.push_back(Vertex45(Point(10, 10), 0, 1));
+      if(result != reference) {
+        std::cout << "result size == " << result.size() << std::endl;
+        for(unsigned int i = 0; i < result.size(); ++i) {
+          //std::cout << "result == " << result[i]<< std::endl;
+        }
+        std::cout << "reference size == " << reference.size() << std::endl;
+        for(unsigned int i = 0; i < reference.size(); ++i) {
+          //std::cout << "reference == " << reference[i]<< std::endl;
+        }
+        return false;
+      }
+      std::cout << "done testing Scan45And\n";
+      return true;
+    }
+
+    static inline bool testScan45Star1() {
+      std::cout << "testing Scan45Star1\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(8,16), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(12,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(4,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+      vertices.push_back(Scan45Vertex(Point(4,16), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 24
+      // result == 0 8 -1 1
+      // result == 0 8 1 -1
+      // result == 4 0 1 1
+      // result == 4 0 2 1
+      // result == 4 4 2 -1
+      // result == 4 4 -1 -1
+      // result == 4 12 1 1
+      // result == 4 12 2 1
+      // result == 4 16 2 -1
+      // result == 4 16 -1 -1
+      // result == 6 2 1 -1
+      // result == 6 14 -1 1
+      // result == 6 2 -1 1
+      // result == 6 14 1 -1
+      // result == 8 0 -1 -1
+      // result == 8 0 2 -1
+      // result == 8 4 2 1
+      // result == 8 4 1 1
+      // result == 8 12 -1 -1
+      // result == 8 12 2 -1
+      // result == 8 16 2 1
+      // result == 8 16 1 1
+      // result == 12 8 1 -1
+      // result == 12 8 -1 1
+      if(result.size() != 24) {
+        //std::cout << "result size == " << result.size() << std::endl;
+        //std::cout << "reference size == " << 24 << std::endl;
+        return false;
+      }
+      std::cout << "done testing Scan45Star1\n";
+      return true;
+    }
+
+    static inline bool testScan45Star2() {
+      std::cout << "testing Scan45Star2\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 24
+      // result == 0 4 0 1
+      // result == 0 4 1 -1
+      // result == 0 8 -1 1
+      // result == 0 8 0 -1
+      // result == 2 6 1 1
+      // result == 2 6 -1 -1
+      // result == 4 4 0 -1
+      // result == 4 8 0 1
+      // result == 4 4 -1 1
+      // result == 4 8 1 -1
+      // result == 8 0 -1 -1
+      // result == 8 0 1 1
+      // result == 8 12 1 1
+      // result == 8 12 -1 -1
+      // result == 12 4 1 -1
+      // result == 12 8 -1 1
+      // result == 12 4 0 1
+      // result == 12 8 0 -1
+      // result == 14 6 -1 -1
+      // result == 14 6 1 1
+      // result == 16 4 0 -1
+      // result == 16 4 -1 1
+      // result == 16 8 1 -1
+      // result == 16 8 0 1
+      if(result.size() != 24) {
+        //std::cout << "result size == " << result.size() << std::endl;
+        //std::cout << "reference size == " << 24 << std::endl;
+        return false;
+      }
+      std::cout << "done testing Scan45Star2\n";
+      return true;
+    }
+
+    static inline bool testScan45Star3() {
+      std::cout << "testing Scan45Star3\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(8,16), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+
+      vertices.push_back(Scan45Vertex(Point(6,0), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      vertices.push_back(Scan45Vertex(Point(6,14), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(12,0), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(12,14), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(12,8), Scan45Count(count, Count2(0, 0), ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(4,0), Scan45Count(Count2(0, 0), Count2(0, 0), count, count)));
+      vertices.push_back(Scan45Vertex(Point(4,16), Scan45Count(ncount, Count2(0, 0), Count2(0, 0), ncount)));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 28
+      // result == 0 8 -1 1
+      // result == 0 8 1 -1
+      // result == 4 0 1 1
+      // result == 4 0 2 1
+      // result == 4 4 2 -1
+      // result == 4 4 -1 -1
+      // result == 4 12 1 1
+      // result == 4 12 2 1
+      // result == 4 16 2 -1
+      // result == 4 16 -1 -1
+      // result == 6 2 1 -1
+      // result == 6 14 -1 1
+      // result == 6 0 0 1
+      // result == 6 0 2 1
+      // result == 6 2 2 -1
+      // result == 6 14 1 -1
+      // result == 8 0 0 -1
+      // result == 8 0 0 1
+      // result == 8 14 0 -1
+      // result == 8 14 2 -1
+      // result == 8 16 2 1
+      // result == 8 16 1 1
+      // result == 12 0 0 -1
+      // result == 12 0 2 -1
+      // result == 12 8 2 1
+      // result == 12 8 2 -1
+      // result == 12 14 2 1
+      // result == 12 14 0 1
+      if(result.size() != 28) {
+        //std::cout << "result size == " << result.size() << std::endl;
+        //std::cout << "reference size == " << 28 << std::endl;
+        return false;
+      }
+
+      std::cout << "done testing Scan45Star3\n";
+      return true;
+    }
+
+    static inline bool testScan45Star4() {
+      std::cout << "testing Scan45Star4\n";
+      Scan45<Count2, boolean_op_45_output_functor<0> > scan45;
+      std::vector<Vertex45 > result;
+      typedef std::pair<Point, Scan45Count> Scan45Vertex;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+
+      vertices.push_back(Scan45Vertex(Point(0,6), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      vertices.push_back(Scan45Vertex(Point(0,12), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(16,6), Scan45Count(Count2(0, 0), ncount, Count2(0, 0), ncount)));
+      vertices.push_back(Scan45Vertex(Point(16,12), Scan45Count(Count2(0, 0), count, Count2(0, 0), count)));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+      std::cout << "done scanning\n";
+      // result size == 28
+      // result == 0 4 0 1
+      // result == 0 4 1 -1
+      // result == 0 6 0 1
+      // result == 0 6 2 1
+      // result == 0 8 2 -1
+      // result == 0 8 2 1
+      // result == 0 12 2 -1
+      // result == 0 12 0 -1
+      // result == 2 6 1 1
+      // result == 2 6 0 -1
+      // result == 4 4 0 -1
+      // result == 4 4 -1 1
+      // result == 8 12 0 1
+      // result == 8 0 -1 -1
+      // result == 8 0 1 1
+      // result == 8 12 0 -1
+      // result == 12 4 1 -1
+      // result == 12 4 0 1
+      // result == 14 6 -1 -1
+      // result == 14 6 0 1
+      // result == 16 4 0 -1
+      // result == 16 4 -1 1
+      // result == 16 6 0 -1
+      // result == 16 6 2 -1
+      // result == 16 8 2 1
+      // result == 16 8 2 -1
+      // result == 16 12 2 1
+      // result == 16 12 0 1
+      if(result.size() != 28) {
+        //std::cout << "result size == " << result.size() << std::endl;
+        //std::cout << "reference size == " << 28 << std::endl;
+        return false;
+      }
+
+      std::cout << "done testing Scan45Star4\n";
+      return true;
+    }
+
+    static inline bool testScan45() {
+      if(!testScan45Rect()) return false;
+      if(!testScan45P1()) return false;
+      if(!testScan45P2()) return false;
+      if(!testScan45And()) return false;
+      if(!testScan45Star1()) return false;
+      if(!testScan45Star2()) return false;
+      if(!testScan45Star3()) return false;
+      if(!testScan45Star4()) return false;
+      return true;
+    }
+
+  };
+
+}
+
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/iterator_compact_to_points.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/iterator_compact_to_points.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,69 @@
+/*
+  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_ITERATOR_COMPACT_TO_POINTS_HPP
+#define BOOST_POLYGON_ITERATOR_COMPACT_TO_POINTS_HPP
+namespace boost { namespace polygon{
+template <typename iterator_type, typename point_type>
+class iterator_compact_to_points {
+private:
+  iterator_type iter_;
+  iterator_type iter_end_;
+  point_type pt_;
+  typename point_traits<point_type>::coordinate_type firstX_;
+  orientation_2d orient_;
+public:
+  typedef std::forward_iterator_tag iterator_category;
+  typedef point_type value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const point_type* pointer; //immutable
+  typedef const point_type& reference; //immutable
+
+  inline iterator_compact_to_points() : iter_(), iter_end_(), pt_(), firstX_(), orient_() {}
+  inline iterator_compact_to_points(iterator_type iter, iterator_type iter_end) : 
+    iter_(iter), iter_end_(iter_end), pt_(), firstX_(), orient_(HORIZONTAL) {
+    if(iter_ != iter_end_) {
+      firstX_ = *iter_;
+      x(pt_, firstX_);
+      ++iter_;
+      if(iter_ != iter_end_) {
+        y(pt_, *iter_);
+      }
+    }
+  }
+  //use bitwise copy and assign provided by the compiler
+  inline iterator_compact_to_points& operator++() {
+    iterator_type prev_iter = iter_;
+    ++iter_;
+    if(iter_ == iter_end_) {
+      if(x(pt_) != firstX_) {
+        iter_ = prev_iter;
+        x(pt_, firstX_);
+      }
+    } else {
+      set(pt_, orient_, *iter_);
+      orient_.turn_90();
+    }
+    return *this;
+  }
+  inline const iterator_compact_to_points operator++(int) {
+    iterator_compact_to_points tmp(*this);
+    ++(*this);
+    return tmp;
+  }
+  inline bool operator==(const iterator_compact_to_points& that) const {
+    return (iter_ == that.iter_);
+  }
+  inline bool operator!=(const iterator_compact_to_points& that) const {
+    return (iter_ != that.iter_);
+  }
+  inline reference operator*() const { return pt_; }
+};
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/iterator_geometry_to_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/iterator_geometry_to_set.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,309 @@
+/*
+  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_ITERATOR_GEOMETRY_TO_SET_HPP
+#define BOOST_POLYGON_ITERATOR_GEOMETRY_TO_SET_HPP
+namespace boost { namespace polygon{
+template <typename concept_type, typename geometry_type>
+class iterator_geometry_to_set {};
+
+template <typename rectangle_type>
+class iterator_geometry_to_set<rectangle_concept, rectangle_type> {
+public:
+  typedef typename rectangle_traits<rectangle_type>::coordinate_type coordinate_type;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const value_type* pointer; //immutable
+  typedef const value_type& reference; //immutable
+private:
+  rectangle_data<coordinate_type> rectangle_;
+  mutable value_type vertex_;
+  unsigned int corner_;
+  orientation_2d orient_;
+  bool is_hole_;
+public:
+  iterator_geometry_to_set() : rectangle_(), vertex_(), corner_(4), orient_(), is_hole_() {}
+  iterator_geometry_to_set(const rectangle_type& rectangle, direction_1d dir, 
+                           orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
+    rectangle_(), vertex_(), corner_(0), orient_(orient), is_hole_(is_hole) {
+    assign(rectangle_, rectangle);
+    if(dir == HIGH) corner_ = 4;
+  }
+  inline iterator_geometry_to_set& operator++() {
+    ++corner_;
+    return *this;
+  }
+  inline const iterator_geometry_to_set operator++(int) {
+    iterator_geometry_to_set tmp(*this);
+    ++(*this);
+    return tmp;
+  }
+  inline bool operator==(const iterator_geometry_to_set& that) const {
+    return corner_ == that.corner_;
+  }
+  inline bool operator!=(const iterator_geometry_to_set& that) const {
+    return !(*this == that);
+  }
+  inline reference operator*() const {
+    if(corner_ == 0) {
+      vertex_.first = get(get(rectangle_, orient_.get_perpendicular()), LOW);
+      vertex_.second.first = get(get(rectangle_, orient_), LOW);
+      vertex_.second.second = 1;
+      if(is_hole_) vertex_.second.second *= -1;
+    } else if(corner_ == 1) {
+      vertex_.second.first = get(get(rectangle_, orient_), HIGH);
+      vertex_.second.second = -1;
+      if(is_hole_) vertex_.second.second *= -1;
+    } else if(corner_ == 2) {
+      vertex_.first = get(get(rectangle_, orient_.get_perpendicular()), HIGH);
+      vertex_.second.first = get(get(rectangle_, orient_), LOW);
+    } else {
+      vertex_.second.first = get(get(rectangle_, orient_), HIGH);
+      vertex_.second.second = 1;
+      if(is_hole_) vertex_.second.second *= -1;
+    }
+    return vertex_; 
+  }
+};
+
+template <typename polygon_type>
+class iterator_geometry_to_set<polygon_90_concept, polygon_type> {
+public:
+  typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const value_type* pointer; //immutable
+  typedef const value_type& reference; //immutable
+  typedef typename polygon_traits<polygon_type>::iterator_type coord_iterator_type;
+private:
+  value_type vertex_;
+  typename polygon_traits<polygon_type>::iterator_type itrb, itre;
+  bool last_vertex_;
+  bool is_hole_;
+  int multiplier_;
+  point_data<coordinate_type> first_pt, second_pt, pts[3];
+  bool use_wrap;
+  orientation_2d orient_;
+  int polygon_index;
+public:
+  iterator_geometry_to_set() : vertex_(), itrb(), itre(), last_vertex_(), is_hole_(), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(), orient_(), polygon_index(-1) {}
+  iterator_geometry_to_set(const polygon_type& polygon, direction_1d dir, orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
+    vertex_(), itrb(), itre(), last_vertex_(), 
+    is_hole_(is_hole), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(), 
+    orient_(orient), polygon_index(0) {
+    itrb = begin_points(polygon);
+    itre = end_points(polygon);
+    use_wrap = false;
+    if(itrb == itre || dir == HIGH || size(polygon) < 4) {
+      polygon_index = -1;
+    } else {
+      direction_1d wdir = winding(polygon);
+      multiplier_ = wdir == LOW ? -1 : 1;
+      if(is_hole_) multiplier_ *= -1;
+      first_pt = pts[0] = *itrb;
+      ++itrb;
+      second_pt = pts[1] = *itrb;
+      ++itrb;
+      pts[2] = *itrb;
+      evaluate_();
+    }
+  }
+  iterator_geometry_to_set(const iterator_geometry_to_set& that) : 
+    vertex_(), itrb(), itre(), last_vertex_(), is_hole_(), multiplier_(), first_pt(),
+    second_pt(), pts(), use_wrap(), orient_(), polygon_index(-1) {
+    vertex_ = that.vertex_;
+    itrb = that.itrb;
+    itre = that.itre;
+    last_vertex_ = that.last_vertex_;
+    is_hole_ = that.is_hole_;
+    multiplier_ = that.multiplier_;
+    first_pt = that.first_pt;
+    second_pt = that.second_pt;
+    pts[0] = that.pts[0];
+    pts[1] = that.pts[1];
+    pts[2] = that.pts[2];
+    use_wrap = that.use_wrap;
+    orient_ = that.orient_;
+    polygon_index = that.polygon_index;
+  }
+  inline iterator_geometry_to_set& operator++() {
+    ++polygon_index;
+    if(itrb == itre) {
+      if(first_pt == pts[1]) polygon_index = -1;
+      else {
+        pts[0] = pts[1];
+        pts[1] = pts[2];
+        if(first_pt == pts[2]) {
+          pts[2] = second_pt;
+        } else {
+          pts[2] = first_pt;
+        }
+      }
+    } else {
+      ++itrb;
+      pts[0] = pts[1];
+      pts[1] = pts[2];
+      if(itrb == itre) {
+        if(first_pt == pts[2]) {
+          pts[2] = second_pt;
+        } else {
+          pts[2] = first_pt;
+        }
+      } else {
+        pts[2] = *itrb;
+      }
+    }
+    evaluate_();
+    return *this;
+  }
+  inline const iterator_geometry_to_set operator++(int) {
+    iterator_geometry_to_set tmp(*this);
+    ++(*this);
+    return tmp;
+  }
+  inline bool operator==(const iterator_geometry_to_set& that) const {
+    return polygon_index == that.polygon_index;
+  }
+  inline bool operator!=(const iterator_geometry_to_set& that) const {
+    return !(*this == that);
+  }
+  inline reference operator*() const {
+    return vertex_; 
+  }
+
+  inline void evaluate_() {
+    vertex_.first = pts[1].get(orient_.get_perpendicular());
+    vertex_.second.first =pts[1].get(orient_);
+    if(pts[1] == pts[2]) {
+      vertex_.second.second = 0;
+      return;
+    }
+    if(pts[0].get(HORIZONTAL) != pts[1].get(HORIZONTAL)) {
+      vertex_.second.second = -1; 
+    } else if(pts[0].get(VERTICAL) != pts[1].get(VERTICAL)) {
+      vertex_.second.second = 1;
+    } else {
+      vertex_.second.second = 0;
+    }
+    vertex_.second.second *= multiplier_;
+  }
+};
+
+template <typename polygon_with_holes_type>
+class iterator_geometry_to_set<polygon_90_with_holes_concept, polygon_with_holes_type> {
+public:
+  typedef typename polygon_90_traits<polygon_with_holes_type>::coordinate_type coordinate_type;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const value_type* pointer; //immutable
+  typedef const value_type& reference; //immutable
+private:
+  iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type> itrb, itre;
+  iterator_geometry_to_set<polygon_90_concept, typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type> itrhib, itrhie;
+  typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itrhb, itrhe;
+  orientation_2d orient_;
+  bool is_hole_;
+  bool started_holes;
+public:
+  iterator_geometry_to_set() : itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(), is_hole_(), started_holes() {}
+  iterator_geometry_to_set(const polygon_with_holes_type& polygon, direction_1d dir, 
+                           orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
+    itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(orient), is_hole_(is_hole), started_holes() {
+    itre = iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type>(polygon, HIGH, orient, is_hole_);
+    itrhe = end_holes(polygon);
+    if(dir == HIGH) {
+      itrb = itre;
+      itrhb = itrhe;
+      started_holes = true;
+    } else {
+      itrb = iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type>(polygon, LOW, orient, is_hole_);
+      itrhb = begin_holes(polygon);
+      started_holes = false;
+    }
+  }
+  iterator_geometry_to_set(const iterator_geometry_to_set& that) : 
+    itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(), is_hole_(), started_holes() {
+    itrb = that.itrb;
+    itre = that.itre;
+    if(that.itrhib != that.itrhie) {
+      itrhib = that.itrhib;
+      itrhie = that.itrhie;
+    }
+    itrhb = that.itrhb;
+    itrhe = that.itrhe;
+    orient_ = that.orient_;
+    is_hole_ = that.is_hole_;
+    started_holes = that.started_holes;
+  }
+  inline iterator_geometry_to_set& operator++() {
+    //this code can be folded with flow control factoring
+    if(itrb == itre) {
+      if(itrhib == itrhie) {
+        if(itrhb != itrhe) {
+          itrhib = iterator_geometry_to_set<polygon_90_concept, 
+            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
+          itrhie = iterator_geometry_to_set<polygon_90_concept, 
+            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
+          ++itrhb;
+        } else {
+          itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept, 
+            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
+        }
+      } else {
+        ++itrhib;
+        if(itrhib == itrhie) {
+          if(itrhb != itrhe) {
+            itrhib = iterator_geometry_to_set<polygon_90_concept, 
+              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
+            itrhie = iterator_geometry_to_set<polygon_90_concept, 
+              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
+            ++itrhb;
+          } else {
+            itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept, 
+              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
+          }
+        }
+      }
+    } else {
+      ++itrb;
+      if(itrb == itre) {
+        if(itrhb != itrhe) {
+          itrhib = iterator_geometry_to_set<polygon_90_concept, 
+            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
+          itrhie = iterator_geometry_to_set<polygon_90_concept, 
+            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
+          ++itrhb;
+        }
+      }
+    }
+    return *this;
+  }
+  inline const iterator_geometry_to_set operator++(int) {
+    iterator_geometry_to_set tmp(*this);
+    ++(*this);
+    return tmp;
+  }
+  inline bool operator==(const iterator_geometry_to_set& that) const {
+    return itrb == that.itrb && itrhb == that.itrhb && itrhib == that.itrhib;
+  }
+  inline bool operator!=(const iterator_geometry_to_set& that) const {
+    return !(*this == that);
+  }
+  inline reference operator*() const {
+    if(itrb != itre) return *itrb;
+    return *itrhib;
+  }
+};
+
+
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/iterator_points_to_compact.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/iterator_points_to_compact.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,60 @@
+/*
+  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_ITERATOR_POINTS_TO_COMPACT_HPP
+#define BOOST_POLYGON_ITERATOR_POINTS_TO_COMPACT_HPP
+namespace boost { namespace polygon{
+template <typename iT, typename point_type>
+class iterator_points_to_compact {
+private:
+  iT iter_, iterEnd_;
+  orientation_2d orient_;
+  mutable typename point_traits<point_type>::coordinate_type coord_;
+public:
+  typedef typename point_traits<point_type>::coordinate_type coordinate_type;
+  typedef std::forward_iterator_tag iterator_category;
+  typedef coordinate_type value_type;
+  typedef std::ptrdiff_t difference_type;
+  typedef const coordinate_type* pointer; //immutable
+  typedef const coordinate_type& reference; //immutable
+
+  inline iterator_points_to_compact() : iter_(), iterEnd_(), orient_(), coord_() {}
+  explicit inline iterator_points_to_compact(iT iter, iT iterEnd) : 
+    iter_(iter), iterEnd_(iterEnd), orient_(HORIZONTAL), coord_() {}
+  inline iterator_points_to_compact(const iterator_points_to_compact& that) : 
+    iter_(that.iter_), iterEnd_(that.iterEnd_), orient_(that.orient_), coord_(that.coord_) {}
+  //use bitwise copy and assign provided by the compiler
+  inline iterator_points_to_compact& operator++() {
+    //iT tmp = iter_;
+    ++iter_;
+    //iT tmp2 = iter_;
+    orient_.turn_90();
+    //while(tmp2 != iterEnd_ && get(*tmp2, orient_) == get(*tmp, orient_)) {
+    //  iter_ = tmp2;
+    //  ++tmp2;
+    //}
+    return *this;
+  }
+  inline const iterator_points_to_compact operator++(int) {
+    iT tmp(*this);
+    ++(*this);
+    return tmp;
+  }
+  inline bool operator==(const iterator_points_to_compact& that) const {
+    return (iter_ == that.iter_);
+  }
+  inline bool operator!=(const iterator_points_to_compact& that) const {
+    return (iter_ != that.iter_);
+  }
+  inline reference operator*() const { coord_ = get(*iter_, orient_); 
+    return coord_;
+  }
+};
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/max_cover.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/max_cover.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,278 @@
+/*
+  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_MAX_COVER_HPP
+#define BOOST_POLYGON_MAX_COVER_HPP
+namespace boost { namespace polygon{
+
+  template <typename Unit>
+  struct MaxCover {
+    typedef interval_data<Unit> Interval;
+    typedef rectangle_data<Unit> Rectangle;
+
+    class Node {
+    private:
+      std::vector<Node*> children_;
+      std::set<Interval> tracedPaths_;
+    public:
+      Rectangle rect;
+      Node() : children_(), tracedPaths_(), rect() {}
+      Node(const Rectangle rectIn) : children_(), tracedPaths_(), rect(rectIn) {}
+      typedef typename std::vector<Node*>::iterator iterator;
+      inline iterator begin() { return children_.begin(); }
+      inline iterator end() { return children_.end(); }
+      inline void add(Node* child) { children_.push_back(child); }
+      inline bool tracedPath(const Interval& ivl) const {
+        return tracedPaths_.find(ivl) != tracedPaths_.end();
+      }
+      inline void addPath(const Interval& ivl) {
+        tracedPaths_.insert(tracedPaths_.end(), ivl);
+      }
+    };
+
+    typedef std::pair<std::pair<Unit, Interval>, Node* > EdgeAssociation;
+  
+    class lessEdgeAssociation : public std::binary_function<const EdgeAssociation&, const EdgeAssociation&, bool> {
+    public:
+      inline lessEdgeAssociation() {}
+      inline bool operator () (const EdgeAssociation& elem1, const EdgeAssociation& elem2) const {
+        if(elem1.first.first < elem2.first.first) return true;
+        if(elem1.first.first > elem2.first.first) return false;
+        return elem1.first.second < elem2.first.second;
+      }
+    };
+
+    template <class cT>
+    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient) {
+      Interval rectIvl = node->rect.get(orient);
+      if(node->tracedPath(rectIvl)) {
+        return;
+      }
+      node->addPath(rectIvl);
+      if(node->begin() == node->end()) {
+        //std::cout << "WRITE OUT 3: " << node->rect << std::endl;
+        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(node->rect));
+        return;
+      }
+      bool writeOut = true;
+      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
+        getMaxCover(outputContainer, *itr, orient, node->rect); //get rectangles down path
+        Interval nodeIvl = (*itr)->rect.get(orient);
+        if(contains(nodeIvl, rectIvl, true)) writeOut = false;
+      }
+      if(writeOut) {
+        //std::cout << "WRITE OUT 2: " << node->rect << std::endl;
+        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(node->rect));
+      }
+    }
+
+    struct stack_element {
+      inline stack_element() :
+        node(), rect(), itr() {}
+      inline stack_element(Node* n,
+                           const Rectangle& r,
+                           typename Node::iterator i) :
+        node(n), rect(r), itr(i) {}
+      Node* node;
+      Rectangle rect;
+      typename Node::iterator itr;
+    };
+
+    template <class cT>
+    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient, 
+                                   Rectangle rect) {
+      //std::cout << "New Root\n";
+      std::vector<stack_element> stack;
+      typename Node::iterator itr = node->begin();
+      do {
+        //std::cout << "LOOP\n";
+        //std::cout << node->rect << std::endl;
+        Interval rectIvl = rect.get(orient);
+        Interval nodeIvl = node->rect.get(orient);
+        bool iresult = intersect(rectIvl, nodeIvl, false);
+        bool tresult = !node->tracedPath(rectIvl);
+        //std::cout << (itr != node->end()) << " " << iresult << " " << tresult << std::endl;
+        Rectangle nextRect = Rectangle(rectIvl, rectIvl);
+        Unit low = rect.get(orient.get_perpendicular()).low();
+        Unit high = node->rect.get(orient.get_perpendicular()).high();
+        nextRect.set(orient.get_perpendicular(), Interval(low, high));
+        if(iresult && tresult) {
+          node->addPath(rectIvl);
+          bool writeOut = true;
+          //check further visibility beyond this node
+          for(typename Node::iterator itr2 = node->begin(); itr2 != node->end(); ++itr2) {
+            Interval nodeIvl3 = (*itr2)->rect.get(orient);
+            //if a child of this node can contain the interval then we can extend through
+            if(contains(nodeIvl3, rectIvl, true)) writeOut = false;
+            //std::cout << "child " << (*itr2)->rect << std::endl;
+          }
+          Rectangle nextRect = Rectangle(rectIvl, rectIvl);
+          Unit low = rect.get(orient.get_perpendicular()).low();
+          Unit high = node->rect.get(orient.get_perpendicular()).high();
+          nextRect.set(orient.get_perpendicular(), Interval(low, high));
+          if(writeOut) {
+            //std::cout << "write out " << nextRect << std::endl;
+            outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
+          } else {
+            //std::cout << "supress " << nextRect << std::endl;
+          }
+        }
+        if(itr != node->end() && iresult && tresult) {
+          //std::cout << "recurse into child\n";
+          stack.push_back(stack_element(node, rect, itr));
+          rect = nextRect;
+          node = *itr;
+          itr = node->begin();
+        } else {
+          if(!stack.empty()) {
+            //std::cout << "recurse out of child\n";
+            node = stack.back().node;
+            rect = stack.back().rect;
+            itr = stack.back().itr;
+            stack.pop_back();
+          } else {
+            //std::cout << "empty stack\n";
+            //if there were no children of the root node
+//             Rectangle nextRect = Rectangle(rectIvl, rectIvl);
+//             Unit low = rect.get(orient.get_perpendicular()).low();
+//             Unit high = node->rect.get(orient.get_perpendicular()).high();
+//             nextRect.set(orient.get_perpendicular(), Interval(low, high));
+//             outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
+          }
+          //std::cout << "increment " << (itr != node->end()) << std::endl;
+          if(itr != node->end()) {
+            ++itr;
+            if(itr != node->end()) {
+              //std::cout << "recurse into next child.\n";
+              stack.push_back(stack_element(node, rect, itr));
+              Interval rectIvl2 = rect.get(orient);
+              Interval nodeIvl2 = node->rect.get(orient);
+              /*bool iresult =*/ intersect(rectIvl2, nodeIvl2, false);
+              Rectangle nextRect2 = Rectangle(rectIvl2, rectIvl2);
+              Unit low2 = rect.get(orient.get_perpendicular()).low();
+              Unit high2 = node->rect.get(orient.get_perpendicular()).high();
+              nextRect2.set(orient.get_perpendicular(), Interval(low2, high2));
+              rect = nextRect2;
+              //std::cout << "rect for next child" << rect << std::endl;
+              node = *itr;
+              itr = node->begin();
+            }
+          }
+        }
+      } while(!stack.empty() || itr != node->end());
+    }
+
+    /*  Function recursive version of getMaxCover
+        Because the code is so much simpler than the loop algorithm I retain it for clarity
+
+    template <class cT>
+    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient, 
+                                   const Rectangle& rect) {
+      Interval rectIvl = rect.get(orient);
+      Interval nodeIvl = node->rect.get(orient);
+      if(!intersect(rectIvl, nodeIvl, false)) {
+        return;
+      }
+      if(node->tracedPath(rectIvl)) {
+        return;
+      }
+      node->addPath(rectIvl);
+      Rectangle nextRect(rectIvl, rectIvl);
+      Unit low = rect.get(orient.get_perpendicular()).low();
+      Unit high = node->rect.get(orient.get_perpendicular()).high();
+      nextRect.set(orient.get_perpendicular(), Interval(low, high));
+      bool writeOut = true;
+      rectIvl = nextRect.get(orient);
+      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
+        nodeIvl = (*itr)->rect.get(orient);
+        if(contains(nodeIvl, rectIvl, true)) writeOut = false;
+      }
+      if(writeOut) {
+        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
+      }
+      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
+        getMaxCover(outputContainer, *itr, orient, nextRect);
+      }
+    }
+    */
+
+    //iterator range is assummed to be in topological order meaning all node's trailing
+    //edges are in sorted order
+    template <class iT>
+    static inline void computeDag(iT beginNode, iT endNode, orientation_2d orient,
+                           unsigned int size) {
+      std::vector<EdgeAssociation> leadingEdges; 
+      leadingEdges.reserve(size);
+      for(iT iter = beginNode; iter != endNode; ++iter) {
+        Node* nodep = &(*iter);
+        Unit leading = nodep->rect.get(orient.get_perpendicular()).low();
+        Interval rectIvl = nodep->rect.get(orient);
+        leadingEdges.push_back(EdgeAssociation(std::pair<Unit, Interval>(leading, rectIvl), nodep));
+      }
+      std::sort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation());
+      typename std::vector<EdgeAssociation>::iterator leadingBegin = leadingEdges.begin();
+      iT trailingBegin = beginNode;
+      while(leadingBegin != leadingEdges.end()) {
+        EdgeAssociation& leadingSegment = (*leadingBegin);
+        Unit trailing = (*trailingBegin).rect.get(orient.get_perpendicular()).high();
+        Interval ivl = (*trailingBegin).rect.get(orient);
+        std::pair<Unit, Interval> trailingSegment(trailing, ivl);
+        if(leadingSegment.first.first < trailingSegment.first) {
+          ++leadingBegin;
+          continue;
+        }
+        if(leadingSegment.first.first > trailingSegment.first) {
+          ++trailingBegin;
+          continue;
+        }
+        if(leadingSegment.first.second.high() <= trailingSegment.second.low()) {
+          ++leadingBegin;
+          continue;
+        }
+        if(trailingSegment.second.high() <= leadingSegment.first.second.low()) {
+          ++trailingBegin;
+          continue;
+        }
+        //leading segment intersects trailing segment
+        (*trailingBegin).add((*leadingBegin).second);
+        if(leadingSegment.first.second.high() > trailingSegment.second.high()) {
+          ++trailingBegin;
+          continue;
+        }
+        if(trailingSegment.second.high() > leadingSegment.first.second.high()) {
+          ++leadingBegin;
+          continue;
+        }
+        ++leadingBegin;
+        ++trailingBegin;
+      }
+    }
+
+    template <class cT>
+    static inline void getMaxCover(cT& outputContainer,
+                                   const std::vector<Rectangle>& rects, orientation_2d orient) {
+      if(rects.empty()) return;
+      std::vector<Node> nodes;
+      {
+        if(rects.size() == 1) {
+          outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(rects[0]));
+          return;
+        }
+        nodes.reserve(rects.size());
+        for(unsigned int i = 0; i < rects.size(); ++i) { nodes.push_back(Node(rects[i])); }
+      }
+      computeDag(nodes.begin(), nodes.end(), orient, nodes.size());
+      for(unsigned int i = 0; i < nodes.size(); ++i) {
+        getMaxCover(outputContainer, &(nodes[i]), orient);
+      }
+    }
+
+  };
+}
+}
+
+#endif
Added: sandbox/gtl/boost/polygon/detail/polygon_45_formation.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_45_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,2213 @@
+/*
+    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_POLYGON_45_FORMATION_HPP
+#define BOOST_POLYGON_POLYGON_45_FORMATION_HPP
+namespace boost { namespace polygon{
+
+  template <typename T, typename T2>
+  struct PolyLineByConcept {};
+
+  template <typename T>
+  class PolyLine45PolygonData;
+  template <typename T>
+  class PolyLine45HoleData;
+
+  //polygon45formation algorithm
+  template <typename Unit>
+  struct polygon_45_formation : public boolean_op_45<Unit> {
+    typedef point_data<Unit> Point;
+    typedef polygon_45_data<Unit> Polygon45;
+    typedef polygon_45_with_holes_data<Unit> Polygon45WithHoles;
+    typedef typename boolean_op_45<Unit>::Vertex45 Vertex45;
+    typedef typename boolean_op_45<Unit>::lessVertex45 lessVertex45;
+    typedef typename boolean_op_45<Unit>::Count2 Count2;
+    typedef typename boolean_op_45<Unit>::Scan45Count Scan45Count;
+    typedef std::pair<Point, Scan45Count> Scan45Vertex;
+    typedef typename boolean_op_45<Unit>::template
+    Scan45<Count2, typename boolean_op_45<Unit>::template boolean_op_45_output_functor<0> > Scan45;
+    
+    class PolyLine45 {
+    public:
+      typedef typename std::list<Point>::const_iterator iterator;
+
+      // default constructor of point does not initialize x and y
+      inline PolyLine45() : points() {} //do nothing default constructor
+
+      // initialize a polygon from x,y values, it is assumed that the first is an x
+      // and that the input is a well behaved polygon
+      template<class iT>
+      inline PolyLine45& set(iT inputBegin, iT inputEnd) {
+        points.clear();  //just in case there was some old data there
+        while(inputBegin != inputEnd) {
+          points.insert(points.end(), *inputBegin);
+          ++inputBegin;
+        }
+        return *this;
+      }
+
+      // copy constructor (since we have dynamic memory)
+      inline PolyLine45(const PolyLine45& that) : points(that.points) {}
+  
+      // assignment operator (since we have dynamic memory do a deep copy)
+      inline PolyLine45& operator=(const PolyLine45& that) {
+        points = that.points;
+        return *this;
+      }
+
+      // get begin iterator, returns a pointer to a const Unit
+      inline iterator begin() const { return points.begin(); }
+
+      // get end iterator, returns a pointer to a const Unit
+      inline iterator end() const { return points.end(); }
+
+      inline std::size_t size() const { return points.size(); }
+
+      //public data member
+      std::list<Point> points; 
+    };
+
+    class ActiveTail45 {
+    private:
+      //data
+      PolyLine45* tailp_; 
+      ActiveTail45 *otherTailp_;
+      std::list<ActiveTail45*> holesList_;
+      bool head_;
+    public:
+   
+      /**
+       * @brief iterator over coordinates of the figure
+       */
+      typedef typename PolyLine45::iterator iterator;
+   
+      /**
+       * @brief iterator over holes contained within the figure
+       */
+      typedef typename std::list<ActiveTail45*>::const_iterator iteratorHoles;
+   
+      //default constructor
+      inline ActiveTail45() : tailp_(0), otherTailp_(0), holesList_(), head_(0) {}
+   
+      //constructor
+      inline ActiveTail45(const Vertex45& vertex, ActiveTail45* otherTailp = 0) :
+        tailp_(0), otherTailp_(0), holesList_(), head_(0) {
+        tailp_ = new PolyLine45;
+        tailp_->points.push_back(vertex.pt);
+        bool headArray[4] = {false, true, true, true};
+        bool inverted = vertex.count == -1;
+        head_ = headArray[vertex.rise+1] ^ inverted;
+        otherTailp_ = otherTailp;
+      }
+
+      inline ActiveTail45(Point point, ActiveTail45* otherTailp, bool head = true) :
+        tailp_(0), otherTailp_(0), holesList_(), head_(0) {
+        tailp_ = new PolyLine45;
+        tailp_->points.push_back(point);
+        head_ = head;
+        otherTailp_ = otherTailp;
+      
+      }
+      inline ActiveTail45(ActiveTail45* otherTailp) :
+        tailp_(0), otherTailp_(0), holesList_(), head_(0)  {
+        tailp_ = otherTailp->tailp_;
+        otherTailp_ = otherTailp;
+      }
+
+      //copy constructor
+      inline ActiveTail45(const ActiveTail45& that) :
+        tailp_(0), otherTailp_(0), holesList_(), head_(0)  { (*this) = that; }
+
+      //destructor
+      inline ~ActiveTail45() {
+        destroyContents();
+      }
+
+      //assignment operator
+      inline ActiveTail45& operator=(const ActiveTail45& that) {
+        tailp_ = new PolyLine45(*(that.tailp_));
+        head_ = that.head_;
+        otherTailp_ = that.otherTailp_;
+        holesList_ = that.holesList_;
+        return *this;
+      }
+
+      //equivalence operator
+      inline bool operator==(const ActiveTail45& b) const {
+        return tailp_ == b.tailp_ && head_ == b.head_;
+      }
+
+      /**
+       * @brief get the pointer to the polyline that this is an active tail of
+       */
+      inline PolyLine45* getTail() const { return tailp_; }
+
+      /**
+       * @brief get the pointer to the polyline at the other end of the chain
+       */
+      inline PolyLine45* getOtherTail() const { return otherTailp_->tailp_; }
+
+      /**
+       * @brief get the pointer to the activetail at the other end of the chain
+       */
+      inline ActiveTail45* getOtherActiveTail() const { return otherTailp_; }
+   
+      /**
+       * @brief test if another active tail is the other end of the chain
+       */
+      inline bool isOtherTail(const ActiveTail45& b) const { return &b == otherTailp_; }
+
+      /**
+       * @brief update this end of chain pointer to new polyline
+       */
+      inline ActiveTail45& updateTail(PolyLine45* newTail) { tailp_ = newTail; return *this; }
+
+      inline bool join(ActiveTail45* tail) {
+        if(tail == otherTailp_) {
+          //std::cout << "joining to other tail!\n";
+          return false;
+        }
+        if(tail->head_ == head_) {
+          //std::cout << "joining head to head!\n";
+          return false;
+        }
+        if(!tailp_) {
+          //std::cout << "joining empty tail!\n";
+          return false;
+        }
+        if(!(otherTailp_->head_)) {
+          otherTailp_->copyHoles(*tail);
+          otherTailp_->copyHoles(*this);
+        } else {
+          tail->otherTailp_->copyHoles(*this);
+          tail->otherTailp_->copyHoles(*tail);
+        }
+        PolyLine45* tail1 = tailp_;
+        PolyLine45* tail2 = tail->tailp_;
+        if(head_) std::swap(tail1, tail2);
+        tail1->points.splice(tail1->points.end(), tail2->points);
+        delete tail2;
+        otherTailp_->tailp_ = tail1;
+        tail->otherTailp_->tailp_ = tail1;
+        otherTailp_->otherTailp_ = tail->otherTailp_;
+        tail->otherTailp_->otherTailp_ = otherTailp_;
+        tailp_ = 0;
+        tail->tailp_ = 0;
+        tail->otherTailp_ = 0;
+        otherTailp_ = 0;
+        return true;
+      }
+
+      /**
+       * @brief associate a hole to this active tail by the specified policy
+       */
+      inline ActiveTail45* addHole(ActiveTail45* hole) {
+        holesList_.push_back(hole);
+        copyHoles(*hole);
+        copyHoles(*(hole->otherTailp_));
+        return this;
+      }
+
+      /**
+       * @brief get the list of holes
+       */
+      inline const std::list<ActiveTail45*>& getHoles() const { return holesList_; }
+
+      /**
+       * @brief copy holes from that to this
+       */
+      inline void copyHoles(ActiveTail45& that) { holesList_.splice(holesList_.end(), that.holesList_); }
+
+      /**
+       * @brief find out if solid to right
+       */
+      inline bool solidToRight() const { return !head_; }
+      inline bool solidToLeft() const { return head_; }
+
+      /**
+       * @brief get vertex
+       */
+      inline Point getPoint() const {
+        if(head_) return tailp_->points.front();
+        return tailp_->points.back();
+      }
+
+      /**
+       * @brief add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
+       */
+      inline void pushPoint(Point point) {
+        if(head_) {
+          //if(tailp_->points.size() < 2) {
+          //   tailp_->points.push_front(point);
+          //   return;
+          //}
+          typename std::list<Point>::iterator iter = tailp_->points.begin();
+          if(iter == tailp_->points.end()) {
+            tailp_->points.push_front(point);
+            return;
+          }
+          Unit firstY = (*iter).y();
+          ++iter;
+          if(iter == tailp_->points.end()) {
+            tailp_->points.push_front(point);
+            return;
+          }
+          if(iter->y() == point.y() && firstY == point.y()) {
+            --iter;
+            *iter = point;
+          } else {
+            tailp_->points.push_front(point);
+          }
+          return;
+        }
+        //if(tailp_->points.size() < 2) {
+        //   tailp_->points.push_back(point);
+        //   return;
+        //}
+        typename std::list<Point>::reverse_iterator iter = tailp_->points.rbegin();
+        if(iter == tailp_->points.rend()) {
+          tailp_->points.push_back(point);
+          return;
+        }
+        Unit firstY = (*iter).y();
+        ++iter;
+        if(iter == tailp_->points.rend()) {
+          tailp_->points.push_back(point);
+          return;
+        }
+        if(iter->y() == point.y() && firstY == point.y()) {
+          --iter;
+          *iter = point;
+        } else {
+          tailp_->points.push_back(point);
+        }
+      }
+
+      /**
+       * @brief joins the two chains that the two active tail tails are ends of
+       * checks for closure of figure and writes out polygons appropriately
+       * returns a handle to a hole if one is closed
+       */
+
+      template <class cT>
+      static inline ActiveTail45* joinChains(Point point, ActiveTail45* at1, ActiveTail45* at2, bool solid, 
+                                             cT& output) {
+        if(at1->otherTailp_ == at2) {
+          //if(at2->otherTailp_ != at1) std::cout << "half closed error\n";
+          //we are closing a figure
+          at1->pushPoint(point);
+          at2->pushPoint(point);
+          if(solid) {
+            //we are closing a solid figure, write to output
+            //std::cout << "test1\n";
+            at1->copyHoles(*(at1->otherTailp_));
+            //std::cout << "test2\n";
+            //Polygon45WithHolesImpl<PolyLine45PolygonData> poly(polyData);
+            //std::cout << poly << std::endl;
+            //std::cout << "test3\n";
+            typedef typename cT::value_type pType;
+            output.push_back(pType());
+            typedef typename geometry_concept<pType>::type cType;
+            typename PolyLineByConcept<Unit, cType>::type polyData(at1);
+            assign(output.back(), polyData);
+            //std::cout << "test4\n";
+            //std::cout << "delete " << at1->otherTailp_ << std::endl;
+            //at1->print();
+            //at1->otherTailp_->print();
+            delete at1->otherTailp_;
+            //at1->print();
+            //at1->otherTailp_->print();
+            //std::cout << "test5\n";
+            //std::cout << "delete " << at1 << std::endl;
+            delete at1;
+            //std::cout << "test6\n";
+            return 0;
+          } else {
+            //we are closing a hole, return the tail end active tail of the figure
+            return at1;
+          }
+        }
+        //we are not closing a figure
+        at1->pushPoint(point);
+        at1->join(at2);
+        delete at1;
+        delete at2;
+        return 0;
+      }
+
+      inline void destroyContents() {
+        if(otherTailp_) {
+          //std::cout << "delete p " << tailp_ << std::endl;
+          if(tailp_) delete tailp_;
+          tailp_ = 0;
+          otherTailp_->otherTailp_ = 0;
+          otherTailp_->tailp_ = 0;
+          otherTailp_ = 0;
+        }
+        for(typename std::list<ActiveTail45*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
+          //std::cout << "delete p " << (*itr) << std::endl;
+          if(*itr) {
+            if((*itr)->otherTailp_) {
+              delete (*itr)->otherTailp_;
+              (*itr)->otherTailp_ = 0;
+            }
+            delete (*itr);
+          }
+          (*itr) = 0;
+        }
+        holesList_.clear();
+      }
+
+      inline void print() {
+        std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
+      }
+
+      static inline std::pair<ActiveTail45*, ActiveTail45*> createActiveTail45sAsPair(Point point, bool solid, 
+                                                                                      ActiveTail45* phole, bool fractureHoles) {
+        ActiveTail45* at1 = 0;
+        ActiveTail45* at2 = 0;
+        if(phole && fractureHoles) {
+          //std::cout << "adding hole\n";
+          at1 = phole;
+          //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
+          at2 = at1->getOtherActiveTail();
+          at2->pushPoint(point);
+          at1->pushPoint(point);
+        } else {
+          at1 = new ActiveTail45(point, at2, solid);
+          at2 = new ActiveTail45(at1);
+          at1->otherTailp_ = at2;
+          at2->head_ = !solid;
+          if(phole) 
+            at2->addHole(phole); //assert fractureHoles == false
+        }
+        return std::pair<ActiveTail45*, ActiveTail45*>(at1, at2);
+      }
+
+    };
+
+    template <typename ct>
+    class Vertex45CountT {
+    public:
+      typedef ct count_type;
+      inline Vertex45CountT() : counts() { counts[0] = counts[1] = counts[2] = counts[3] = 0; }
+      //inline Vertex45CountT(ct count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
+      inline Vertex45CountT(const ct& count1, const ct& count2, const ct& count3, 
+                           const ct& count4) : counts() { 
+        counts[0] = count1; 
+        counts[1] = count2; 
+        counts[2] = count3;
+        counts[3] = count4; 
+      }
+      inline Vertex45CountT(const Vertex45& vertex) : counts() { 
+        counts[0] = counts[1] = counts[2] = counts[3] = 0;
+        (*this) += vertex;
+      }
+      inline Vertex45CountT(const Vertex45CountT& count) : counts() { 
+        (*this) = count;
+      }
+      inline bool operator==(const Vertex45CountT& count) const { 
+        for(unsigned int i = 0; i < 4; ++i) {
+          if(counts[i] != count.counts[i]) return false; 
+        }
+        return true;
+      }
+      inline bool operator!=(const Vertex45CountT& count) const { return !((*this) == count); }
+      inline Vertex45CountT& operator=(ct count) { 
+        counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
+      inline Vertex45CountT& operator=(const Vertex45CountT& count) {
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] = count.counts[i]; 
+        }
+        return *this; 
+      }
+      inline ct& operator[](int index) { return counts[index]; }
+      inline ct operator[](int index) const {return counts[index]; }
+      inline Vertex45CountT& operator+=(const Vertex45CountT& count){
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] += count.counts[i]; 
+        }
+        return *this;
+      }
+      inline Vertex45CountT& operator-=(const Vertex45CountT& count){
+        for(unsigned int i = 0; i < 4; ++i) {
+          counts[i] -= count.counts[i]; 
+        }
+        return *this;
+      }
+      inline Vertex45CountT operator+(const Vertex45CountT& count) const {
+        return Vertex45CountT(*this)+=count;
+      }
+      inline Vertex45CountT operator-(const Vertex45CountT& count) const {
+        return Vertex45CountT(*this)-=count;
+      }
+      inline Vertex45CountT invert() const {
+        return Vertex45CountT()-=(*this);
+      }
+      inline Vertex45CountT& operator+=(const Vertex45& element){
+        counts[element.rise+1] += element.count; return *this;
+      }
+      inline bool is_45() const {
+        return counts[0] != 0 || counts[2] != 0;
+      }
+    private:
+      ct counts[4];
+    };
+
+    typedef Vertex45CountT<int> Vertex45Count;
+
+//     inline std::ostream& operator<< (std::ostream& o, const Vertex45Count& c) {
+//       o << c[0] << ", " << c[1] << ", ";
+//       o << c[2] << ", " << c[3];
+//       return o;
+//     }
+
+    template <typename ct>
+    class Vertex45CompactT {
+    public:
+      Point pt;
+      ct count;
+      typedef typename boolean_op_45<Unit>::template Vertex45T<typename ct::count_type> Vertex45T;
+      inline Vertex45CompactT() : pt(), count() {}
+      inline Vertex45CompactT(const Point& point, int riseIn, int countIn) : pt(point), count() {
+        count[riseIn+1] = countIn;
+      }
+      inline Vertex45CompactT(const Vertex45T& vertex) : pt(vertex.pt), count() {
+        count[vertex.rise+1] = vertex.count;
+      }
+      inline Vertex45CompactT(const Vertex45CompactT& vertex) : pt(vertex.pt), count(vertex.count) {}
+      inline Vertex45CompactT& operator=(const Vertex45CompactT& vertex){ 
+        pt = vertex.pt; count = vertex.count; return *this; }
+      inline bool operator==(const Vertex45CompactT& vertex) const {
+        return pt == vertex.pt && count == vertex.count; }
+      inline bool operator!=(const Vertex45CompactT& vertex) const { return !((*this) == vertex); }
+      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
+      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
+      inline bool operator<(const Vertex45CompactT& vertex) const {
+        if(pt.x() < vertex.pt.x()) return true;
+        if(pt.x() == vertex.pt.x()) {
+          return pt.y() < vertex.pt.y();
+        }
+        return false;
+      }
+      inline bool operator>(const Vertex45CompactT& vertex) const { return vertex < (*this); }
+      inline bool operator<=(const Vertex45CompactT& vertex) const { return !((*this) > vertex); }
+      inline bool operator>=(const Vertex45CompactT& vertex) const { return !((*this) < vertex); }
+      inline bool haveVertex45(int index) const { return count[index]; }
+      inline Vertex45T operator[](int index) const {
+        return Vertex45T(pt, index-1, count[index]); }
+    };
+
+    typedef Vertex45CompactT<Vertex45Count> Vertex45Compact;
+
+//     inline std::ostream& operator<< (std::ostream& o, const Vertex45Compact& c) {
+//       o << c.pt << ", " << c.count;
+//       return o;
+//     }
+
+    class Polygon45Formation {
+    private:
+      //definitions
+      typedef std::map<Vertex45, ActiveTail45*, lessVertex45> Polygon45FormationData;
+      typedef typename Polygon45FormationData::iterator iterator;
+      typedef typename Polygon45FormationData::const_iterator const_iterator;
+   
+      //data
+      Polygon45FormationData scanData_;
+      Unit x_;
+      int justBefore_;
+      int fractureHoles_; 
+    public:
+      inline Polygon45Formation() : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) {
+        lessVertex45 lessElm(&x_, &justBefore_);
+        scanData_ = Polygon45FormationData(lessElm);
+      }
+      inline Polygon45Formation(bool fractureHoles) : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(fractureHoles) {
+        lessVertex45 lessElm(&x_, &justBefore_);
+        scanData_ = Polygon45FormationData(lessElm);
+      }
+      inline Polygon45Formation(const Polygon45Formation& that) :
+        scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) { (*this) = that; }
+      inline Polygon45Formation& operator=(const Polygon45Formation& that) {
+        x_ = that.x_;
+        justBefore_ = that.justBefore_;
+        fractureHoles_ = that.fractureHoles_;
+        lessVertex45 lessElm(&x_, &justBefore_);
+        scanData_ = Polygon45FormationData(lessElm);
+        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
+          scanData_.insert(scanData_.end(), *itr);
+        }
+        return *this;
+      }
+   
+      //cT is an output container of Polygon45 or Polygon45WithHoles
+      //iT is an iterator over Vertex45 elements
+      //inputBegin - inputEnd is a range of sorted iT that represents
+      //one or more scanline stops worth of data
+      template <class cT, class iT>
+      void scan(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "1\n";
+        while(inputBegin != inputEnd) {
+          //std::cout << "2\n";
+          x_ = (*inputBegin).pt.x();
+          //std::cout << "SCAN FORMATION " << x_ << std::endl;
+          //std::cout << "x_ = " << x_ << std::endl;
+          //std::cout << "scan line size: " << scanData_.size() << std::endl;
+          inputBegin = processEvent_(output, inputBegin, inputEnd);
+        }
+      }
+
+    private:
+      //functions
+      template <class cT, class cT2>
+      inline std::pair<int, ActiveTail45*> processPoint_(cT& output, cT2& elements, Point point, 
+                                                         Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) { 
+        //std::cout << point << std::endl;
+        //std::cout << counts[0] << " ";
+        //std::cout << counts[1] << " ";
+        //std::cout << counts[2] << " ";
+        //std::cout << counts[3] << "\n";
+        //std::cout << incoming[0] << " ";
+        //std::cout << incoming[1] << " ";
+        //std::cout << incoming[2] << " ";
+        //std::cout << incoming[3] << "\n";
+        //join any closing solid corners
+        ActiveTail45* returnValue = 0;
+        int returnCount = 0;
+        for(int i = 0; i < 3; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] == -1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < 4; ++j) {
+              //std::cout << j << std::endl;
+              if(counts[j]) {
+                if(counts[j] == 1) {
+                  //std::cout << "case1: " << i << " " << j << std::endl;
+                  //if a figure is closed it will be written out by this function to output
+                  ActiveTail45::joinChains(point, tails[i], tails[j], true, output); 
+                  counts[i] = 0;
+                  counts[j] = 0;
+                  tails[i] = 0;
+                  tails[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+        //find any pairs of incoming edges that need to create pair for leading solid
+        //std::cout << "checking case2\n";
+        for(int i = 0; i < 3; ++i) {
+          //std::cout << i << std::endl;
+          if(incoming[i] == 1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < 4; ++j) {
+              //std::cout << j << std::endl;
+              if(incoming[j]) {
+                if(incoming[j] == -1) {
+                  //std::cout << "case2: " << i << " " << j << std::endl;
+                  //std::cout << "creating active tail pair\n";
+                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, fractureHoles_);
+                  //tailPair.first->print();
+                  //tailPair.second->print();
+                  if(j == 3) {
+                    //vertical active tail becomes return value
+                    returnValue = tailPair.first;
+                    returnCount = 1;
+                  } else {
+                    Vertex45 vertex(point, i -1, incoming[i]);
+                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
+                    elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
+                  }
+                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
+                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
+                  incoming[i] = 0;
+                  incoming[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+
+        //find any active tail that needs to pass through to an incoming edge
+        //we expect to find no more than two pass through
+
+        //find pass through with solid on top
+        //std::cout << "checking case 3\n";
+        for(int i = 0; i < 4; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] != 0) {
+            if(counts[i] == 1) {
+              //std::cout << "fixed i\n";
+              for(int j = 3; j >= 0; --j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == 1) {
+                    //std::cout << "case3: " << i << " " << j << std::endl;
+                    //tails[i]->print();
+                    //pass through solid on top
+                    tails[i]->pushPoint(point);
+                    //std::cout << "after push\n";
+                    if(j == 3) {
+                      returnValue = tails[i];
+                      returnCount = -1;
+                    } else {
+                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+        //std::cout << "checking case 4\n";
+        //find pass through with solid on bottom
+        for(int i = 3; i >= 0; --i) {
+          if(counts[i] != 0) {
+            if(counts[i] == -1) {
+              for(int j = 0; j < 4; ++j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == -1) {
+                    //std::cout << "case4: " << i << " " << j << std::endl;
+                    //pass through solid on bottom
+                    tails[i]->pushPoint(point);
+                    if(j == 3) {
+                      returnValue = tails[i];
+                      returnCount = 1;
+                    } else {
+                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+
+        //find the end of a hole or the beginning of a hole
+
+        //find end of a hole
+        for(int i = 0; i < 3; ++i) {
+          if(counts[i] != 0) {
+            for(int j = i+1; j < 4; ++j) {
+              if(counts[j] != 0) {
+                //std::cout << "case5: " << i << " " << j << std::endl;
+                //we are ending a hole and may potentially close a figure and have to handle the hole
+                returnValue = ActiveTail45::joinChains(point, tails[i], tails[j], false, output);
+                tails[i] = 0;
+                tails[j] = 0;
+                counts[i] = 0;
+                counts[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        } 
+        //find beginning of a hole
+        for(int i = 0; i < 3; ++i) {
+          if(incoming[i] != 0) {
+            for(int j = i+1; j < 4; ++j) {
+              if(incoming[j] != 0) {
+                //std::cout << "case6: " << i << " " << j << std::endl;
+                //we are beginning a empty space
+                ActiveTail45* holep = 0;
+                if(counts[3] == 0) holep = tails[3];
+                std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+                  ActiveTail45::createActiveTail45sAsPair(point, false, holep, fractureHoles_);
+                if(j == 3) {
+                  returnValue = tailPair.first;
+                  returnCount = -1;
+                } else {
+                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.first));
+                }
+                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
+                elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), tailPair.second));
+                incoming[i] = 0;
+                incoming[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        }
+        //assert that tails, counts and incoming are all null
+        return std::pair<int, ActiveTail45*>(returnCount, returnValue);
+      }
+
+      template <class cT, class iT>
+      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "processEvent_\n";
+        justBefore_ = true;
+        //collect up all elements from the tree that are at the y
+        //values of events in the input queue
+        //create vector of new elements to add into tree
+        ActiveTail45* verticalTail = 0;
+        int verticalCount = 0;
+        iT currentIter = inputBegin;
+        std::vector<iterator> elementIters;
+        std::vector<std::pair<Vertex45, ActiveTail45*> > elements;
+        while(currentIter != inputEnd && currentIter->pt.x() == x_) {
+          //std::cout << "loop\n";
+          Unit currentY = (*currentIter).pt.y();
+          iterator iter = lookUp_(currentY);
+          //int counts[4] = {0, 0, 0, 0};
+          Vertex45Count counts;
+          ActiveTail45* tails[4] = {0, 0, 0, verticalTail};
+          //std::cout << "finding elements in tree\n";
+          while(iter != scanData_.end() &&
+                iter->first.evalAtX(x_) == currentY) {
+            //std::cout << "loop2\n";
+            elementIters.push_back(iter);
+            int index = iter->first.rise + 1;
+            //std::cout << index << " " << iter->first.count << std::endl;
+            counts[index] = iter->first.count;
+            tails[index] = iter->second;
+            ++iter;
+          }
+          //int incoming[4] = {0, 0, 0, 0};
+          Vertex45Count incoming;
+          //std::cout << "aggregating\n";
+          do {
+            //std::cout << "loop3\n";
+            Vertex45Compact currentVertex(*currentIter);
+            incoming += currentVertex.count;
+            ++currentIter;
+          } while(currentIter != inputEnd && currentIter->pt.y() == currentY &&
+                  currentIter->pt.x() == x_);
+          //now counts and tails have the data from the left and
+          //incoming has the data from the right at this point
+          //cancel out any end points
+          //std::cout << counts[0] << " ";
+          //std::cout << counts[1] << " ";
+          //std::cout << counts[2] << " ";
+          //std::cout << counts[3] << "\n";
+          //std::cout << incoming[0] << " ";
+          //std::cout << incoming[1] << " ";
+          //std::cout << incoming[2] << " ";
+          //std::cout << incoming[3] << "\n";
+          if(verticalTail) {
+            counts[3] = -verticalCount;
+          }
+          incoming[3] *= -1;
+          for(unsigned int i = 0; i < 4; ++i) incoming[i] += counts[i];
+          //std::cout << "calling processPoint_\n";
+          std::pair<int, ActiveTail45*> result = processPoint_(output, elements, Point(x_, currentY), counts, tails, incoming);
+          verticalCount = result.first;
+          verticalTail = result.second;
+          //if(verticalTail) std::cout << "have vertical tail\n";
+          //std::cout << "verticalCount: " << verticalCount << std::endl;
+          if(verticalTail && !verticalCount) {
+            //we got a hole out of the point we just processed
+            //iter is still at the next y element above the current y value in the tree
+            //std::cout << "checking whether ot handle hole\n";
+            if(currentIter == inputEnd || 
+               currentIter->pt.x() != x_ ||
+               currentIter->pt.y() >= iter->first.evalAtX(x_)) {
+              //std::cout << "handle hole here\n";
+              if(fractureHoles_) {
+                //std::cout << "fracture hole here\n";
+                //we need to handle the hole now and not at the next input vertex
+                ActiveTail45* at = iter->second;
+                Point point(x_, iter->first.evalAtX(x_));
+                verticalTail->getOtherActiveTail()->pushPoint(point);
+                iter->second = verticalTail->getOtherActiveTail();
+                at->pushPoint(point);
+                verticalTail->join(at);
+                delete at;
+                delete verticalTail;
+                verticalTail = 0;
+              } else {
+                //std::cout << "push hole onto list\n";
+                iter->second->addHole(verticalTail);
+                verticalTail = 0;
+              }
+            }
+          }
+        }
+        //std::cout << "erasing\n";
+        //erase all elements from the tree
+        for(typename std::vector<iterator>::iterator iter = elementIters.begin();
+            iter != elementIters.end(); ++iter) {
+          //std::cout << "erasing loop\n";
+          scanData_.erase(*iter);
+        }
+        //switch comparison tie breaking policy
+        justBefore_ = false;
+        //add new elements into tree
+        //std::cout << "inserting\n";
+        for(typename std::vector<std::pair<Vertex45, ActiveTail45*> >::iterator iter = elements.begin();
+            iter != elements.end(); ++iter) {
+          //std::cout << "inserting loop\n";
+          scanData_.insert(scanData_.end(), *iter);
+        }
+        //std::cout << "end processEvent\n";
+        return currentIter;
+      }
+   
+      inline iterator lookUp_(Unit y){
+        //if just before then we need to look from 1 not -1
+        return scanData_.lower_bound(Vertex45(Point(x_, y), -1+2*justBefore_, 0));
+      }
+   
+    };
+
+    static inline bool testPolygon45FormationRect() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygon45FormationP1() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 1, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 1, -1));
+      data.push_back(Vertex45(Point(10, 10), 1, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, -1));
+      data.push_back(Vertex45(Point(10, 20), 2, 1));
+      data.push_back(Vertex45(Point(10, 20), 1, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+    //polygon45set class
+
+    static inline bool testPolygon45FormationP2() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 1, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 1, 1));
+      data.push_back(Vertex45(Point(10, 10), 1, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, -1));
+      data.push_back(Vertex45(Point(20, 10), 1, -1));
+      data.push_back(Vertex45(Point(20, 10), 0, 1)); 
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+    //polygon45set class
+
+    static inline bool testPolygon45FormationStar1() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45FormationStar2() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      Scan45 scan45;
+      std::vector<Vertex45 > result;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+   
+      std::sort(result.begin(), result.end());
+      pf.scan(polys, result.begin(), result.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45FormationStarHole1() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(true);
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+
+      data.push_back(Vertex45(Point(6, 4), 1, -1));
+      data.push_back(Vertex45(Point(6, 4), 2, -1));
+      data.push_back(Vertex45(Point(6, 8), -1, 1));
+      data.push_back(Vertex45(Point(6, 8), 2, 1));
+      data.push_back(Vertex45(Point(8, 6), -1, -1));
+      data.push_back(Vertex45(Point(8, 6), 1, 1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45FormationStarHole2() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(false);
+      std::vector<Polygon45WithHoles> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+
+      data.push_back(Vertex45(Point(6, 4), 1, -1));
+      data.push_back(Vertex45(Point(6, 4), 2, -1));
+      data.push_back(Vertex45(Point(6, 12), -1, 1));
+      data.push_back(Vertex45(Point(6, 12), 2, 1));
+      data.push_back(Vertex45(Point(10, 8), -1, -1));
+      data.push_back(Vertex45(Point(10, 8), 1, 1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45Formation() {
+      std::cout << "testing polygon formation\n";
+      Polygon45Formation pf(false);
+      std::vector<Polygon45WithHoles> polys;
+      std::vector<Vertex45> data;
+   
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 100), 2, -1));
+      data.push_back(Vertex45(Point(0, 100), 0, -1));
+      data.push_back(Vertex45(Point(100, 0), 0, -1));
+      data.push_back(Vertex45(Point(100, 0), 2, -1));
+      data.push_back(Vertex45(Point(100, 100), 2, 1));
+      data.push_back(Vertex45(Point(100, 100), 0, 1));
+
+      data.push_back(Vertex45(Point(2, 2), 0, -1));
+      data.push_back(Vertex45(Point(2, 2), 2, -1));
+      data.push_back(Vertex45(Point(2, 10), 2, 1));
+      data.push_back(Vertex45(Point(2, 10), 0, 1));
+      data.push_back(Vertex45(Point(10, 2), 0, 1));
+      data.push_back(Vertex45(Point(10, 2), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 0, -1));
+
+      data.push_back(Vertex45(Point(2, 12), 0, -1));
+      data.push_back(Vertex45(Point(2, 12), 2, -1));
+      data.push_back(Vertex45(Point(2, 22), 2, 1));
+      data.push_back(Vertex45(Point(2, 22), 0, 1));
+      data.push_back(Vertex45(Point(10, 12), 0, 1));
+      data.push_back(Vertex45(Point(10, 12), 2, 1));
+      data.push_back(Vertex45(Point(10, 22), 2, -1));
+      data.push_back(Vertex45(Point(10, 22), 0, -1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true; 
+    }
+
+
+    class Polygon45Tiling {
+    private:
+      //definitions
+      typedef std::map<Vertex45, ActiveTail45*, lessVertex45> Polygon45FormationData;
+      typedef typename Polygon45FormationData::iterator iterator;
+      typedef typename Polygon45FormationData::const_iterator const_iterator;
+   
+      //data
+      Polygon45FormationData scanData_;
+      Unit x_;
+      int justBefore_;
+    public:
+      inline Polygon45Tiling() : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
+        lessVertex45 lessElm(&x_, &justBefore_);
+        scanData_ = Polygon45FormationData(lessElm);
+      }
+      inline Polygon45Tiling(const Polygon45Tiling& that) : 
+        scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false) { (*this) = that; }
+      inline Polygon45Tiling& operator=(const Polygon45Tiling& that) {
+        x_ = that.x_;
+        justBefore_ = that.justBefore_;
+        lessVertex45 lessElm(&x_, &justBefore_);
+        scanData_ = Polygon45FormationData(lessElm);
+        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
+          scanData_.insert(scanData_.end(), *itr);
+        }
+        return *this;
+      }
+   
+      //cT is an output container of Polygon45 or Polygon45WithHoles
+      //iT is an iterator over Vertex45 elements
+      //inputBegin - inputEnd is a range of sorted iT that represents
+      //one or more scanline stops worth of data
+      template <class cT, class iT>
+      void scan(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "1\n";
+        while(inputBegin != inputEnd) {
+          //std::cout << "2\n";
+          x_ = (*inputBegin).pt.x();
+          //std::cout << "SCAN FORMATION " << x_ << std::endl;
+          //std::cout << "x_ = " << x_ << std::endl;
+          //std::cout << "scan line size: " << scanData_.size() << std::endl;
+          inputBegin = processEvent_(output, inputBegin, inputEnd);
+        }
+      }
+
+    private:
+      //functions
+  
+      inline void getVerticalPair_(std::pair<ActiveTail45*, ActiveTail45*>& verticalPair, 
+                                   iterator previter) {
+        ActiveTail45* iterTail = (*previter).second;
+        Point prevPoint(x_, previter->first.evalAtX(x_));
+        iterTail->pushPoint(prevPoint);
+        std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+          ActiveTail45::createActiveTail45sAsPair(prevPoint, true, 0, false);
+        verticalPair.first = iterTail;
+        verticalPair.second = tailPair.first;
+        (*previter).second = tailPair.second;
+      }
+
+      template <class cT, class cT2>
+      inline std::pair<int, ActiveTail45*> processPoint_(cT& output, cT2& elements, 
+                                                         std::pair<ActiveTail45*, ActiveTail45*>& verticalPair, 
+                                                         iterator previter, Point point, 
+                                                         Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) { 
+        //std::cout << point << std::endl;
+        //std::cout << counts[0] << " ";
+        //std::cout << counts[1] << " ";
+        //std::cout << counts[2] << " ";
+        //std::cout << counts[3] << "\n";
+        //std::cout << incoming[0] << " ";
+        //std::cout << incoming[1] << " ";
+        //std::cout << incoming[2] << " ";
+        //std::cout << incoming[3] << "\n";
+        //join any closing solid corners
+        ActiveTail45* returnValue = 0;
+        std::pair<ActiveTail45*, ActiveTail45*> verticalPairOut;
+        verticalPairOut.first = 0;
+        verticalPairOut.second = 0;
+        int returnCount = 0;
+        for(int i = 0; i < 3; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] == -1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < 4; ++j) {
+              //std::cout << j << std::endl;
+              if(counts[j]) {
+                if(counts[j] == 1) {
+                  //std::cout << "case1: " << i << " " << j << std::endl;
+                  //if a figure is closed it will be written out by this function to output
+                  ActiveTail45::joinChains(point, tails[i], tails[j], true, output); 
+                  counts[i] = 0;
+                  counts[j] = 0;
+                  tails[i] = 0;
+                  tails[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+        //find any pairs of incoming edges that need to create pair for leading solid
+        //std::cout << "checking case2\n";
+        for(int i = 0; i < 3; ++i) {
+          //std::cout << i << std::endl;
+          if(incoming[i] == 1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < 4; ++j) {
+              //std::cout << j << std::endl;
+              if(incoming[j]) {
+                if(incoming[j] == -1) {
+                  //std::cout << "case2: " << i << " " << j << std::endl;
+                  //std::cout << "creating active tail pair\n";
+                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
+                  //tailPair.first->print();
+                  //tailPair.second->print();
+                  if(j == 3) {
+                    //vertical active tail becomes return value
+                    returnValue = tailPair.first;
+                    returnCount = 1;
+                  } else {
+                    Vertex45 vertex(point, i -1, incoming[i]);
+                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
+                    elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
+                  }
+                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
+                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
+                  incoming[i] = 0;
+                  incoming[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+
+        //find any active tail that needs to pass through to an incoming edge
+        //we expect to find no more than two pass through
+
+        //find pass through with solid on top
+        //std::cout << "checking case 3\n";
+        for(int i = 0; i < 4; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] != 0) {
+            if(counts[i] == 1) {
+              //std::cout << "fixed i\n";
+              for(int j = 3; j >= 0; --j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == 1) {
+                    //std::cout << "case3: " << i << " " << j << std::endl;
+                    //tails[i]->print();
+                    //pass through solid on top
+                    if(i != 3)
+                      tails[i]->pushPoint(point);
+                    //std::cout << "after push\n";
+                    if(j == 3) {
+                      returnValue = tails[i];
+                      returnCount = -1;
+                    } else {
+                      verticalPairOut.first = tails[i];
+                      std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+                        ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
+                      verticalPairOut.second = tailPair.first;
+                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), 
+                                                                            tailPair.second));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+        //std::cout << "checking case 4\n";
+        //find pass through with solid on bottom
+        for(int i = 3; i >= 0; --i) {
+          if(counts[i] != 0) {
+            if(counts[i] == -1) {
+              for(int j = 0; j < 4; ++j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == -1) {
+                    //std::cout << "case4: " << i << " " << j << std::endl;
+                    //pass through solid on bottom
+                    if(i == 3) {
+                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                      if(j == 3) {
+                        returnValue = tails[i];
+                        returnCount = 1;
+                      } else {
+                        tails[i]->pushPoint(point);
+                        elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
+                      }
+                    } else if(j == 3) {
+                      if(verticalPair.first == 0) {
+                        getVerticalPair_(verticalPair, previter);
+                      }
+                      ActiveTail45::joinChains(point, tails[i], verticalPair.first, true, output); 
+                      returnValue = verticalPair.second;
+                      returnCount = 1;
+                    } else {
+                      if(verticalPair.first == 0) {
+                        getVerticalPair_(verticalPair, previter);
+                      }
+                      ActiveTail45::joinChains(point, tails[i], verticalPair.first, true, output); 
+                      verticalPair.second->pushPoint(point);
+                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), 
+                                                                            verticalPair.second));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+
+        //find the end of a hole or the beginning of a hole
+
+        //find end of a hole
+        for(int i = 0; i < 3; ++i) {
+          if(counts[i] != 0) {
+            for(int j = i+1; j < 4; ++j) {
+              if(counts[j] != 0) {
+                //std::cout << "case5: " << i << " " << j << std::endl;
+                //we are ending a hole and may potentially close a figure and have to handle the hole
+                tails[i]->pushPoint(point);
+                verticalPairOut.first = tails[i];
+                if(j == 3) {
+                  verticalPairOut.second = tails[j];
+                } else {
+                  if(verticalPair.first == 0) {
+                    getVerticalPair_(verticalPair, previter);
+                  }
+                  ActiveTail45::joinChains(point, tails[j], verticalPair.first, true, output); 
+                  verticalPairOut.second = verticalPair.second;
+                }
+                tails[i] = 0;
+                tails[j] = 0;
+                counts[i] = 0;
+                counts[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        } 
+        //find beginning of a hole
+        for(int i = 0; i < 3; ++i) {
+          if(incoming[i] != 0) {
+            for(int j = i+1; j < 4; ++j) {
+              if(incoming[j] != 0) {
+                //std::cout << "case6: " << i << " " << j << std::endl;
+                //we are beginning a empty space
+                if(verticalPair.first == 0) {
+                  getVerticalPair_(verticalPair, previter);
+                }
+                verticalPair.second->pushPoint(point);
+                if(j == 3) {
+                  returnValue = verticalPair.first;
+                  returnCount = -1;
+                } else {
+                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
+                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
+                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.second));
+                  verticalPairOut.second = tailPair.first;
+                  verticalPairOut.first = verticalPair.first;
+                }
+                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
+                elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), verticalPair.second));
+                incoming[i] = 0;
+                incoming[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        }
+        verticalPair = verticalPairOut;
+        //assert that verticalPair is either both null, or neither null
+        //assert that returnValue is null if verticalPair is not null
+        //assert that tails, counts and incoming are all null
+        return std::pair<int, ActiveTail45*>(returnCount, returnValue);
+      }
+
+      template <class cT, class iT>
+      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
+        //std::cout << "processEvent_\n";
+        justBefore_ = true;
+        //collect up all elements from the tree that are at the y
+        //values of events in the input queue
+        //create vector of new elements to add into tree
+        ActiveTail45* verticalTail = 0;
+        std::pair<ActiveTail45*, ActiveTail45*> verticalPair;
+        verticalPair.first = 0;
+        verticalPair.second = 0;
+        int verticalCount = 0;
+        iT currentIter = inputBegin;
+        std::vector<iterator> elementIters;
+        std::vector<std::pair<Vertex45, ActiveTail45*> > elements;
+        while(currentIter != inputEnd && currentIter->pt.x() == x_) {
+          //std::cout << "loop\n";
+          Unit currentY = (*currentIter).pt.y();
+          iterator iter = lookUp_(currentY);
+          //int counts[4] = {0, 0, 0, 0};
+          Vertex45Count counts;
+          ActiveTail45* tails[4] = {0, 0, 0, verticalTail};
+          //std::cout << "finding elements in tree\n";
+          iterator previter = iter;
+          if(previter != scanData_.end() &&
+             previter->first.evalAtX(x_) >= currentY &&
+             previter != scanData_.begin())
+            --previter;
+          while(iter != scanData_.end() &&
+                iter->first.evalAtX(x_) == currentY) {
+            //std::cout << "loop2\n";
+            elementIters.push_back(iter);
+            int index = iter->first.rise + 1;
+            //std::cout << index << " " << iter->first.count << std::endl;
+            counts[index] = iter->first.count;
+            tails[index] = iter->second;
+            ++iter;
+          }
+          //int incoming[4] = {0, 0, 0, 0};
+          Vertex45Count incoming;
+          //std::cout << "aggregating\n";
+          do {
+            //std::cout << "loop3\n";
+            Vertex45Compact currentVertex(*currentIter);
+            incoming += currentVertex.count;
+            ++currentIter;
+          } while(currentIter != inputEnd && currentIter->pt.y() == currentY &&
+                  currentIter->pt.x() == x_);
+          //now counts and tails have the data from the left and
+          //incoming has the data from the right at this point
+          //cancel out any end points
+          //std::cout << counts[0] << " ";
+          //std::cout << counts[1] << " ";
+          //std::cout << counts[2] << " ";
+          //std::cout << counts[3] << "\n";
+          //std::cout << incoming[0] << " ";
+          //std::cout << incoming[1] << " ";
+          //std::cout << incoming[2] << " ";
+          //std::cout << incoming[3] << "\n";
+          if(verticalTail) {
+            counts[3] = -verticalCount;
+          }
+          incoming[3] *= -1;
+          for(unsigned int i = 0; i < 4; ++i) incoming[i] += counts[i];
+          //std::cout << "calling processPoint_\n";
+          std::pair<int, ActiveTail45*> result = processPoint_(output, elements, verticalPair, previter,
+                                                               Point(x_, currentY), counts, tails, incoming);
+          verticalCount = result.first;
+          verticalTail = result.second;
+          if(verticalPair.first != 0 && iter != scanData_.end() &&
+             (currentIter == inputEnd || currentIter->pt.x() != x_ ||
+              currentIter->pt.y() > (*iter).first.evalAtX(x_))) {
+            //splice vertical pair into edge above
+            ActiveTail45* tailabove = (*iter).second;
+            Point point(x_, (*iter).first.evalAtX(x_));
+            verticalPair.second->pushPoint(point);
+            ActiveTail45::joinChains(point, tailabove, verticalPair.first, true, output);
+            (*iter).second = verticalPair.second;
+            verticalPair.first = 0;
+            verticalPair.second = 0;
+          }
+        }
+        //std::cout << "erasing\n";
+        //erase all elements from the tree
+        for(typename std::vector<iterator>::iterator iter = elementIters.begin();
+            iter != elementIters.end(); ++iter) {
+          //std::cout << "erasing loop\n";
+          scanData_.erase(*iter);
+        }
+        //switch comparison tie breaking policy
+        justBefore_ = false;
+        //add new elements into tree
+        //std::cout << "inserting\n";
+        for(typename std::vector<std::pair<Vertex45, ActiveTail45*> >::iterator iter = elements.begin();
+            iter != elements.end(); ++iter) {
+          //std::cout << "inserting loop\n";
+          scanData_.insert(scanData_.end(), *iter);
+        }
+        //std::cout << "end processEvent\n";
+        return currentIter;
+      }
+   
+      inline iterator lookUp_(Unit y){
+        //if just before then we need to look from 1 not -1
+        return scanData_.lower_bound(Vertex45(Point(x_, y), -1+2*justBefore_, 0));
+      }
+   
+    };
+
+    static inline bool testPolygon45TilingRect() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true;
+    }
+
+    static inline bool testPolygon45TilingP1() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 1, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 1, -1));
+      data.push_back(Vertex45(Point(10, 10), 1, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, -1));
+      data.push_back(Vertex45(Point(10, 20), 2, 1));
+      data.push_back(Vertex45(Point(10, 20), 1, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingP2() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 1, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 1, 1));
+      data.push_back(Vertex45(Point(10, 10), 1, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, -1));
+      data.push_back(Vertex45(Point(20, 10), 1, -1));
+      data.push_back(Vertex45(Point(20, 10), 0, 1)); 
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingP3() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(20, 0), 0, -1));
+      data.push_back(Vertex45(Point(20, 0), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 1, -1));
+      data.push_back(Vertex45(Point(10, 10), 0, 1));
+      data.push_back(Vertex45(Point(20, 20), 1, 1));
+      data.push_back(Vertex45(Point(20, 20), 2, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingP4() {
+      std::cout << "testing polygon tiling p4\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), -1, 1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(20, 10), 2, 1));
+      data.push_back(Vertex45(Point(20, 10), 0, 1));
+      data.push_back(Vertex45(Point(20, -10), -1, -1));
+      data.push_back(Vertex45(Point(20, -10), 2, -1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingP5() {
+      std::cout << "testing polygon tiling P5\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, 1));
+
+      data.push_back(Vertex45(Point(1, 1), 0, -1));
+      data.push_back(Vertex45(Point(1, 1), 1, 1));
+      data.push_back(Vertex45(Point(2, 1), 0, 1));
+      data.push_back(Vertex45(Point(2, 1), 1, -1));
+      data.push_back(Vertex45(Point(2, 2), 1, -1));
+      data.push_back(Vertex45(Point(2, 2), 0, 1));
+      data.push_back(Vertex45(Point(3, 2), 1, 1));
+      data.push_back(Vertex45(Point(3, 2), 0, -1)); 
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true;
+    }
+
+    static inline bool testPolygon45TilingP6() {
+      std::cout << "testing polygon tiling P6\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 10), 2, -1));
+      data.push_back(Vertex45(Point(0, 10), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 0, -1));
+      data.push_back(Vertex45(Point(10, 0), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 0, 1));
+
+      data.push_back(Vertex45(Point(1, 1), 0, -1));
+      data.push_back(Vertex45(Point(1, 1), 2, -1));
+      data.push_back(Vertex45(Point(1, 2), 2, 1));
+      data.push_back(Vertex45(Point(1, 2), 0, 1));
+      data.push_back(Vertex45(Point(2, 1), 0, 1));
+      data.push_back(Vertex45(Point(2, 1), 2, 1));
+      data.push_back(Vertex45(Point(2, 2), 2, -1));
+      data.push_back(Vertex45(Point(2, 2), 0, -1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true;
+    }
+
+    static inline bool testPolygon45TilingStar1() {
+      std::cout << "testing polygon tiling star1\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingStar2() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+
+      Scan45 scan45;
+      std::vector<Vertex45 > result;
+      std::vector<Scan45Vertex> vertices;
+      //is a Rectnagle(0, 0, 10, 10);
+      Count2 count(1, 0);
+      Count2 ncount(-1, 0);
+      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      count = Count2(0, 1);
+      ncount = count.invert();
+      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
+      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
+      sortScan45Vector(vertices);
+      std::cout << "scanning\n";
+      scan45.scan(result, vertices.begin(), vertices.end());
+   
+      std::sort(result.begin(), result.end());
+      pf.scan(polys, result.begin(), result.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingStarHole1() {
+      std::cout << "testing polygon tiling star hole 1\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+
+      data.push_back(Vertex45(Point(6, 4), 1, -1));
+      data.push_back(Vertex45(Point(6, 4), 2, -1));
+      data.push_back(Vertex45(Point(6, 8), -1, 1));
+      data.push_back(Vertex45(Point(6, 8), 2, 1));
+      data.push_back(Vertex45(Point(8, 6), -1, -1));
+      data.push_back(Vertex45(Point(8, 6), 1, 1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45TilingStarHole2() {
+      std::cout << "testing polygon tiling star hole 2\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45WithHoles> polys;
+      std::vector<Vertex45> data;
+      // result == 0 8 -1 1
+      data.push_back(Vertex45(Point(0, 8), -1, 1));
+      // result == 0 8 1 -1
+      data.push_back(Vertex45(Point(0, 8), 1, -1));
+      // result == 4 0 1 1
+      data.push_back(Vertex45(Point(4, 0), 1, 1));
+      // result == 4 0 2 1
+      data.push_back(Vertex45(Point(4, 0), 2, 1));
+      // result == 4 4 2 -1
+      data.push_back(Vertex45(Point(4, 4), 2, -1));
+      // result == 4 4 -1 -1
+      data.push_back(Vertex45(Point(4, 4), -1, -1));
+      // result == 4 12 1 1
+      data.push_back(Vertex45(Point(4, 12), 1, 1));
+      // result == 4 12 2 1
+      data.push_back(Vertex45(Point(4, 12), 2, 1));
+      // result == 4 16 2 -1
+      data.push_back(Vertex45(Point(4, 16), 2, 1));
+      // result == 4 16 -1 -1
+      data.push_back(Vertex45(Point(4, 16), -1, -1));
+      // result == 6 2 1 -1
+      data.push_back(Vertex45(Point(6, 2), 1, -1));
+      // result == 6 14 -1 1
+      data.push_back(Vertex45(Point(6, 14), -1, 1));
+      // result == 6 2 -1 1
+      data.push_back(Vertex45(Point(6, 2), -1, 1));
+      // result == 6 14 1 -1
+      data.push_back(Vertex45(Point(6, 14), 1, -1));
+      // result == 8 0 -1 -1
+      data.push_back(Vertex45(Point(8, 0), -1, -1));
+      // result == 8 0 2 -1
+      data.push_back(Vertex45(Point(8, 0), 2, -1));
+      // result == 8 4 2 1
+      data.push_back(Vertex45(Point(8, 4), 2, 1));
+      // result == 8 4 1 1
+      data.push_back(Vertex45(Point(8, 4), 1, 1));
+      // result == 8 12 -1 -1
+      data.push_back(Vertex45(Point(8, 12), -1, -1));
+      // result == 8 12 2 -1
+      data.push_back(Vertex45(Point(8, 12), 2, -1));
+      // result == 8 16 2 1
+      data.push_back(Vertex45(Point(8, 16), 2, 1));
+      // result == 8 16 1 1
+      data.push_back(Vertex45(Point(8, 16), 1, 1));
+      // result == 12 8 1 -1
+      data.push_back(Vertex45(Point(12, 8), 1, -1));
+      // result == 12 8 -1 1
+      data.push_back(Vertex45(Point(12, 8), -1, 1));
+
+      data.push_back(Vertex45(Point(6, 4), 1, -1));
+      data.push_back(Vertex45(Point(6, 4), 2, -1));
+      data.push_back(Vertex45(Point(6, 12), -1, 1));
+      data.push_back(Vertex45(Point(6, 12), 2, 1));
+      data.push_back(Vertex45(Point(10, 8), -1, -1));
+      data.push_back(Vertex45(Point(10, 8), 1, 1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+
+    static inline bool testPolygon45Tiling() {
+      std::cout << "testing polygon tiling\n";
+      Polygon45Tiling pf;
+      std::vector<Polygon45WithHoles> polys;
+      std::vector<Vertex45> data;
+   
+      data.push_back(Vertex45(Point(0, 0), 0, 1));
+      data.push_back(Vertex45(Point(0, 0), 2, 1));
+      data.push_back(Vertex45(Point(0, 100), 2, -1));
+      data.push_back(Vertex45(Point(0, 100), 0, -1));
+      data.push_back(Vertex45(Point(100, 0), 0, -1));
+      data.push_back(Vertex45(Point(100, 0), 2, -1));
+      data.push_back(Vertex45(Point(100, 100), 2, 1));
+      data.push_back(Vertex45(Point(100, 100), 0, 1));
+
+      data.push_back(Vertex45(Point(2, 2), 0, -1));
+      data.push_back(Vertex45(Point(2, 2), 2, -1));
+      data.push_back(Vertex45(Point(2, 10), 2, 1));
+      data.push_back(Vertex45(Point(2, 10), 0, 1));
+      data.push_back(Vertex45(Point(10, 2), 0, 1));
+      data.push_back(Vertex45(Point(10, 2), 2, 1));
+      data.push_back(Vertex45(Point(10, 10), 2, -1));
+      data.push_back(Vertex45(Point(10, 10), 0, -1));
+
+      data.push_back(Vertex45(Point(2, 12), 0, -1));
+      data.push_back(Vertex45(Point(2, 12), 2, -1));
+      data.push_back(Vertex45(Point(2, 22), 2, 1));
+      data.push_back(Vertex45(Point(2, 22), 0, 1));
+      data.push_back(Vertex45(Point(10, 12), 0, 1));
+      data.push_back(Vertex45(Point(10, 12), 2, 1));
+      data.push_back(Vertex45(Point(10, 22), 2, -1));
+      data.push_back(Vertex45(Point(10, 22), 0, -1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon tiling\n";
+      return true; 
+    }
+  };
+
+  template <typename Unit>
+  class PolyLine45HoleData {
+  public:
+    typedef typename polygon_45_formation<Unit>::ActiveTail45 ActiveTail45;
+    typedef typename ActiveTail45::iterator iterator;
+    
+    typedef polygon_45_concept geometry_type;
+    typedef Unit coordinate_type;
+    typedef point_data<Unit> Point;
+    typedef Point point_type;
+    //    typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
+    typedef iterator iterator_type;
+    typedef typename coordinate_traits<Unit>::area_type area_type;
+    
+    inline PolyLine45HoleData() : p_(0) {}
+    inline PolyLine45HoleData(ActiveTail45* p) : p_(p) {}
+    //use default copy and assign
+    inline iterator begin() const { return p_->getTail()->begin(); }
+    inline iterator end() const { return p_->getTail()->end(); }
+    inline unsigned int size() const { return 0; }
+    template<class iT>
+    inline PolyLine45HoleData& set(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+  private:
+    ActiveTail45* p_;
+  };
+
+  template <typename Unit>
+  class PolyLine45PolygonData {
+  public:
+    typedef typename polygon_45_formation<Unit>::ActiveTail45 ActiveTail45;
+    typedef typename ActiveTail45::iterator iterator;
+    typedef PolyLine45HoleData<Unit> holeType;
+    
+    typedef polygon_45_with_holes_concept geometry_type;
+    typedef Unit coordinate_type;
+    typedef point_data<Unit> Point;
+    typedef Point point_type;
+    //    typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
+    typedef iterator iterator_type;
+    typedef holeType hole_type;
+    typedef typename coordinate_traits<Unit>::area_type area_type;
+    class iteratorHoles {
+    private:
+      typename ActiveTail45::iteratorHoles itr_;
+    public:
+      typedef PolyLine45HoleData<Unit> holeType;
+      typedef holeType value_type;
+      typedef std::forward_iterator_tag iterator_category;
+      typedef std::ptrdiff_t difference_type;
+      typedef const value_type* pointer; //immutable
+      typedef const value_type& reference; //immutable
+      inline iteratorHoles() : itr_() {}
+      inline iteratorHoles(typename ActiveTail45::iteratorHoles itr) : itr_(itr) {}
+      inline iteratorHoles(const iteratorHoles& that) : itr_(that.itr_) {} 
+      inline iteratorHoles& operator=(const iteratorHoles& that) {
+        itr_ = that.itr_;
+        return *this;
+      }
+      inline bool operator==(const iteratorHoles& that) { return itr_ == that.itr_; }
+      inline bool operator!=(const iteratorHoles& that) { return itr_ != that.itr_; }
+      inline iteratorHoles& operator++() {
+        ++itr_;
+        return *this;
+      }
+      inline const iteratorHoles operator++(int) {
+        iteratorHoles tmp = *this;
+        ++(*this);
+        return tmp;
+      }
+      inline holeType operator*() {
+        return *itr_;
+      }
+    };
+    typedef iteratorHoles iterator_holes_type;
+    
+    
+    inline PolyLine45PolygonData() : p_(0) {}
+    inline PolyLine45PolygonData(ActiveTail45* p) : p_(p) {}
+    //use default copy and assign
+    inline iterator begin() const { return p_->getTail()->begin(); }
+    inline iterator end() const { return p_->getTail()->end(); }
+    inline iteratorHoles begin_holes() const { return iteratorHoles(p_->getHoles().begin()); }
+    inline iteratorHoles end_holes() const { return iteratorHoles(p_->getHoles().end()); }
+    inline ActiveTail45* yield() { return p_; }
+    //stub out these four required functions that will not be used but are needed for the interface
+    inline unsigned int size_holes() const { return 0; }
+    inline unsigned int size() const { return 0; }
+    template<class iT>
+    inline PolyLine45PolygonData& set(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+    
+    // initialize a polygon from x,y values, it is assumed that the first is an x
+    // and that the input is a well behaved polygon
+    template<class iT>
+    inline PolyLine45PolygonData& set_holes(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+  private:
+    ActiveTail45* p_;
+  };
+
+  template <typename T>
+  struct PolyLineByConcept<T, polygon_45_with_holes_concept> { typedef PolyLine45PolygonData<T> type; };
+  template <typename T>
+  struct PolyLineByConcept<T, polygon_with_holes_concept> { typedef PolyLine45PolygonData<T> type; };
+  template <typename T>
+  struct PolyLineByConcept<T, polygon_45_concept> { typedef PolyLine45HoleData<T> type; };
+  template <typename T>
+  struct PolyLineByConcept<T, polygon_concept> { typedef PolyLine45HoleData<T> type; };
+
+  template <typename T>
+  struct geometry_concept<PolyLine45PolygonData<T> > { typedef polygon_45_with_holes_concept type; };
+  template <typename T>
+  struct geometry_concept<PolyLine45HoleData<T> > { typedef polygon_45_concept type; };
+}
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/polygon_45_set_view.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_45_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,342 @@
+/*
+  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_POLYGON_45_SET_VIEW_HPP
+#define BOOST_POLYGON_POLYGON_45_SET_VIEW_HPP
+namespace boost { namespace polygon{
+
+  template <typename ltype, typename rtype, int op_type>
+  class polygon_45_set_view;
+
+  template <typename ltype, typename rtype, int op_type>
+  struct polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> > {
+    typedef typename polygon_45_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
+    typedef typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
+    typedef typename polygon_45_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
+
+    static inline iterator_type begin(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set); 
+    static inline iterator_type end(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set);
+
+    template <typename input_iterator_type>
+    static inline void set(polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set, 
+                           input_iterator_type input_begin, input_iterator_type input_end);
+
+    static inline bool clean(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set);
+
+  };
+
+  template <typename value_type, typename ltype, typename rtype, int op_type>
+  struct compute_45_set_value {
+    static
+    void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_) {
+      output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
+                  polygon_45_set_traits<ltype>::end(lvalue_));
+      value_type rinput_;
+      rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
+                  polygon_45_set_traits<rtype>::end(rvalue_));
+      if(op_type == 0)
+        output_ |= rinput_;
+      else if(op_type == 1)
+        output_ &= rinput_;
+      else if(op_type == 2)
+        output_ ^= rinput_;
+      else
+        output_ -= rinput_;
+    }
+  };
+
+  template <typename value_type, typename ltype, typename rcoord, int op_type>
+  struct compute_45_set_value<value_type, ltype, polygon_45_set_data<rcoord>, op_type> {
+    static
+    void value(value_type& output_, const ltype& lvalue_, const polygon_45_set_data<rcoord>& rvalue_) {
+      output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
+                  polygon_45_set_traits<ltype>::end(lvalue_));
+      if(op_type == 0)
+        output_ |= rvalue_;
+      else if(op_type == 1)
+        output_ &= rvalue_;
+      else if(op_type == 2)
+        output_ ^= rvalue_;
+      else
+        output_ -= rvalue_;
+    }
+  };
+
+  template <typename ltype, typename rtype, int op_type>
+  class polygon_45_set_view {
+  public:
+    typedef typename polygon_45_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_45_set_data<coordinate_type> value_type;
+    typedef typename value_type::iterator_type iterator_type;
+    typedef polygon_45_set_view operator_arg_type;
+  private:
+    const ltype& lvalue_;
+    const rtype& rvalue_;
+    mutable value_type output_;
+    mutable bool evaluated_;
+  public:
+    polygon_45_set_view(const ltype& lvalue,
+                        const rtype& rvalue ) :
+      lvalue_(lvalue), rvalue_(rvalue), output_(), evaluated_(false) {}
+
+    // get iterator to begin vertex data
+  public:
+    const value_type& value() const {
+      if(!evaluated_) {
+        evaluated_ = true;
+        compute_45_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_);
+      }
+      return output_;
+    }
+  public:
+    iterator_type begin() const { return value().begin(); }
+    iterator_type end() const { return value().end(); }
+
+    bool dirty() const { return value().dirty(); } //result of a boolean is clean
+    bool sorted() const { return value().sorted(); } //result of a boolean is sorted
+
+    //     template <typename input_iterator_type>
+    //     void set(input_iterator_type input_begin, input_iterator_type input_end, 
+    //              orientation_2d orient) const {
+    //       orient_ = orient;
+    //       output_.clear();
+    //       output_.insert(output_.end(), input_begin, input_end);
+    //       std::sort(output_.begin(), output_.end());
+    //     }
+  };
+
+  template <typename ltype, typename rtype, int op_type>
+  typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
+  begin(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
+    return polygon_45_set.begin();
+  }
+  template <typename ltype, typename rtype, int op_type>
+  typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
+  end(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
+    return polygon_45_set.end();
+  }
+  template <typename ltype, typename rtype, int op_type>
+  bool polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
+  clean(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) { 
+    return polygon_45_set.value().clean(); }
+
+  template <typename geometry_type_1, typename geometry_type_2, int op_type>
+  geometry_type_1& self_assignment_boolean_op_45(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
+    typedef geometry_type_1 ltype;
+    typedef geometry_type_2 rtype;
+    typedef typename polygon_45_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_45_set_data<coordinate_type> value_type;
+    value_type output_;
+    value_type rinput_;
+    output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
+                polygon_45_set_traits<ltype>::end(lvalue_));
+    rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
+                polygon_45_set_traits<rtype>::end(rvalue_));
+    if(op_type == 0)
+      output_ |= rinput_;
+    else if(op_type == 1)
+      output_ &= rinput_;
+    else if(op_type == 2)
+      output_ ^= rinput_;
+    else
+      output_ -= rinput_;
+    polygon_45_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end());
+    return lvalue_;
+  }
+
+  template <typename concept_type>
+  struct fracture_holes_option_by_type {
+    static const bool value = true;
+  };
+  template <>
+  struct fracture_holes_option_by_type<polygon_45_with_holes_concept> {
+    static const bool value = false;
+  };
+  template <>
+  struct fracture_holes_option_by_type<polygon_with_holes_concept> {
+    static const bool value = false;
+  };
+
+  template <typename ltype, typename rtype, int op_type>
+  struct geometry_concept<polygon_45_set_view<ltype, rtype, op_type> > { typedef polygon_45_set_concept type; };
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and_3< 
+    typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+    typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+    typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+                       polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type 
+  operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
+      (lvalue, rvalue);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+      ::type
+#endif
+  ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type 
+  operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
+      (lvalue, rvalue);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+                                           typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+                                           typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+                       polygon_45_set_view<geometry_type_1, geometry_type_2, 1> >::type 
+  operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_45_set_view<geometry_type_1, geometry_type_2, 1>
+      (lvalue, rvalue);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
+                                           typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
+                                           typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
+                       polygon_45_set_view<geometry_type_1, geometry_type_2, 2> >::type 
+  operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_45_set_view<geometry_type_1, geometry_type_2, 2>
+      (lvalue, rvalue);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+      ::type
+#endif
+  ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 3> >::type 
+  operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_45_set_view<geometry_type_1, geometry_type_2, 3>
+      (lvalue, rvalue);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< 
+    typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+    typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< 
+    typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                      typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+    geometry_type_1>::type &
+  operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 2>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 3>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
+                                         typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
+                                                                coordinate_concept>::type>::type,
+                       geometry_type_1>::type &
+  operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    return resize(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type, 
+                                         typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
+                                                                coordinate_concept>::type>::type,
+                       geometry_type_1>::type &
+  operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    return resize(lvalue, -rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
+                                 coordinate_concept>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, geometry_type_1>::type
+  operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    geometry_type_1 retval(lvalue);
+    retval += rvalue;
+    return retval;
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
+                                 coordinate_concept>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type, geometry_type_1>::type
+  operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    geometry_type_1 retval(lvalue);
+    retval -= rvalue;
+    return retval;
+  }
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/polygon_45_touch.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_45_touch.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,275 @@
+/*
+  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_POLYGON_45_TOUCH_HPP
+#define BOOST_POLYGON_POLYGON_45_TOUCH_HPP
+namespace boost { namespace polygon{
+
+  template <typename Unit>
+  struct polygon_45_touch {
+
+    typedef point_data<Unit> Point;
+    typedef typename coordinate_traits<Unit>::manhattan_area_type LongUnit;
+
+    template <typename property_map>
+    static inline void merge_property_maps(property_map& mp, const property_map& mp2, bool subtract = false) {
+      property_map newmp;
+      newmp.reserve(mp.size() + mp2.size());
+      unsigned int i = 0;
+      unsigned int j = 0;
+      while(i != mp.size() && j != mp2.size()) {
+        if(mp[i].first < mp2[j].first) {
+          newmp.push_back(mp[i]);
+          ++i;
+        } else if(mp[i].first > mp2[j].first) {
+          newmp.push_back(mp2[j]);
+          if(subtract) newmp.back().second *= -1;
+          ++j;
+        } else {
+          int count = mp[i].second;
+          if(subtract) count -= mp2[j].second;
+          else count += mp2[j].second; 
+          if(count) {
+            newmp.push_back(mp[i]);
+            newmp.back().second = count;
+          }
+          ++i;
+          ++j;
+        }
+      }
+      while(i != mp.size()) {
+        newmp.push_back(mp[i]);
+        ++i;
+      }
+      while(j != mp2.size()) {
+        newmp.push_back(mp2[j]);
+        if(subtract) newmp.back().second *= -1;
+        ++j;
+      }
+      mp.swap(newmp);
+    }
+
+    class CountTouch {
+    public:
+      inline CountTouch() : counts() {}
+      //inline CountTouch(int count) { counts[0] = counts[1] = count; }
+      //inline CountTouch(int count1, int count2) { counts[0] = count1; counts[1] = count2; }
+      inline CountTouch(const CountTouch& count) : counts(count.counts) {}
+      inline bool operator==(const CountTouch& count) const { return counts == count.counts; }
+      inline bool operator!=(const CountTouch& count) const { return !((*this) == count); }
+      //inline CountTouch& operator=(int count) { counts[0] = counts[1] = count; return *this; }
+      inline CountTouch& operator=(const CountTouch& count) { counts = count.counts; return *this; }
+      inline int& operator[](int index) { 
+        std::vector<std::pair<int, int> >::iterator itr = lower_bound(counts.begin(), counts.end(), std::make_pair(index, int(0)));
+        if(itr != counts.end() && itr->first == index) {
+            return itr->second;
+        }
+        itr = counts.insert(itr, std::make_pair(index, int(0)));
+        return itr->second;
+      }
+//       inline int operator[](int index) const {
+//         std::vector<std::pair<int, int> >::const_iterator itr = counts.begin();
+//         for( ; itr != counts.end() && itr->first <= index; ++itr) {
+//           if(itr->first == index) {
+//             return itr->second;
+//           }
+//         }
+//         return 0;
+//       }
+      inline CountTouch& operator+=(const CountTouch& count){
+        merge_property_maps(counts, count.counts, false);
+        return *this;
+      }
+      inline CountTouch& operator-=(const CountTouch& count){
+        merge_property_maps(counts, count.counts, true);
+        return *this;
+      }
+      inline CountTouch operator+(const CountTouch& count) const {
+        return CountTouch(*this)+=count;
+      }
+      inline CountTouch operator-(const CountTouch& count) const {
+        return CountTouch(*this)-=count;
+      }
+      inline CountTouch invert() const {
+        CountTouch retval;
+        retval -= *this;
+        return retval;
+      }
+      std::vector<std::pair<int, int> > counts;
+    };
+
+    typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::map<int, std::set<int> > > map_graph_o; 
+    typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::vector<std::set<int> > > vector_graph_o; 
+
+    template <typename cT>
+    static void process_previous_x(cT& output) {
+      std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
+      for(typename std::map<Unit, std::set<int> >::iterator itr = y_prop_map.begin();
+          itr != y_prop_map.end(); ++itr) {
+        for(std::set<int>::iterator inner_itr = itr->second.begin();
+            inner_itr != itr->second.end(); ++inner_itr) {
+          std::set<int>& output_edges = (*(output.second))[*inner_itr];
+          std::set<int>::iterator inner_inner_itr = inner_itr;
+          ++inner_inner_itr;
+          for( ; inner_inner_itr != itr->second.end(); ++inner_inner_itr) {
+            output_edges.insert(output_edges.end(), *inner_inner_itr);
+            std::set<int>& output_edges_2 = (*(output.second))[*inner_inner_itr];
+            output_edges_2.insert(output_edges_2.end(), *inner_itr);
+          }
+        }
+      }
+      y_prop_map.clear();
+    }
+    
+    struct touch_45_output_functor {
+      template <typename cT>
+      void operator()(cT& output, const CountTouch& count1, const CountTouch& count2, 
+                      const Point& pt, int rise, direction_1d end) {
+        Unit& x = output.first.first;
+        std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
+        if(pt.x() != x) process_previous_x(output);
+        x = pt.x();
+        std::set<int>& output_set = y_prop_map[pt.y()];
+        for(std::vector<std::pair<int, int> >::const_iterator itr1 = count1.counts.begin();
+            itr1 != count1.counts.end(); ++itr1) {
+          if(itr1->second > 0) {
+            output_set.insert(output_set.end(), itr1->first);
+          } 
+        }
+        for(std::vector<std::pair<int, int> >::const_iterator itr2 = count2.counts.begin();
+            itr2 != count2.counts.end(); ++itr2) {
+          if(itr2->second > 0) {
+            output_set.insert(output_set.end(), itr2->first);
+          }
+        }
+      }
+    };
+    typedef typename std::pair<Point, 
+                               typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > Vertex45Compact;
+    typedef std::vector<Vertex45Compact> TouchSetData;
+    
+    struct lessVertex45Compact {
+      bool operator()(const Vertex45Compact& l, const Vertex45Compact& r) {
+        return l.first < r.first;
+      }
+    };
+    
+    template <typename TSD>
+    static void print_tsd(TSD& tsd) {
+      for(unsigned int i = 0; i < tsd.size(); ++i) {
+        std::cout << tsd[i].first << ": ";
+        for(unsigned int r = 0; r < 4; ++r) {
+          std::cout << r << " { ";
+          for(std::vector<std::pair<int, int> >::iterator itr = tsd[i].second[r].counts.begin();
+              itr != tsd[i].second[r].counts.end(); ++itr) {
+            std::cout << itr->first << "," << itr->second << " ";
+          } std::cout << "} ";
+        }
+      } std::cout << std::endl;
+    }
+
+    template <typename T>
+    static void print_scanline(T& t) {
+      for(typename T::iterator itr = t.begin(); itr != t.end(); ++itr) {
+        std::cout << itr->x << "," << itr->y << " " << itr->rise << " ";
+        for(std::vector<std::pair<int, int> >::iterator itr2 = itr->count.counts.begin();
+            itr2 != itr->count.counts.end(); ++itr2) {
+          std::cout << itr2->first << ":" << itr2->second << " ";
+        } std::cout << std::endl;
+      }
+    }
+
+    template <typename graph_type>
+    static void performTouch(graph_type& graph, TouchSetData& tsd) {
+      
+      std::sort(tsd.begin(), tsd.end(), lessVertex45Compact());
+      typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > > TSD;
+      TSD tsd_;
+      tsd_.reserve(tsd.size());
+      for(typename TouchSetData::iterator itr = tsd.begin(); itr != tsd.end(); ) {
+        typename TouchSetData::iterator itr2 = itr;
+        ++itr2;
+        for(; itr2 != tsd.end() && itr2->first == itr->first; ++itr2) {
+          (itr->second) += (itr2->second); //accumulate
+        }
+        tsd_.push_back(std::make_pair(itr->first, itr->second));
+        itr = itr2;
+      }
+      std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, graph_type*> output
+        (std::make_pair(std::make_pair((std::numeric_limits<Unit>::max)(), std::map<Unit, std::set<int> >()), &graph));
+      typename boolean_op_45<Unit>::template Scan45<CountTouch, touch_45_output_functor> scanline;
+      for(typename TSD::iterator itr = tsd_.begin(); itr != tsd_.end(); ) {
+        typename TSD::iterator itr2 = itr;
+        ++itr2;
+        while(itr2 != tsd_.end() && itr2->first.x() == itr->first.x()) {
+          ++itr2;
+        }
+        scanline.scan(output, itr, itr2);
+        itr = itr2;
+      }
+      process_previous_x(output);
+    }
+
+    template <typename iT>
+    static void populateTouchSetData(TouchSetData& tsd, iT begin, iT end, int nodeCount) {
+      for( ; begin != end; ++begin) {
+        Vertex45Compact vertex;
+        vertex.first = typename Vertex45Compact::first_type(begin->pt.x() * 2, begin->pt.y() * 2);
+        tsd.push_back(vertex);
+        for(unsigned int i = 0; i < 4; ++i) {
+          if(begin->count[i]) {
+            tsd.back().second[i][nodeCount] += begin->count[i];
+          }
+        }
+      }
+    }
+    
+  };
+
+  //ConnectivityExtraction computes the graph of connectivity between rectangle, polygon and
+  //polygon set graph nodes where an edge is created whenever the geometry in two nodes overlap
+  template <typename coordinate_type>
+  class connectivity_extraction_45 {
+  private:
+    typedef typename coordinate_traits<coordinate_type>::manhattan_area_type big_coord;
+    typedef typename polygon_45_touch<big_coord>::TouchSetData tsd;
+    tsd tsd_;
+    unsigned int nodeCount_;
+  public:
+    inline connectivity_extraction_45() : tsd_(), nodeCount_(0) {}
+    inline connectivity_extraction_45(const connectivity_extraction_45& that) : tsd_(that.tsd_),
+                                                                          nodeCount_(that.nodeCount_) {}
+    inline connectivity_extraction_45& operator=(const connectivity_extraction_45& that) { 
+      tsd_ = that.tsd_; 
+      nodeCount_ = that.nodeCount_; {}
+      return *this;
+    }
+    
+    //insert a polygon set graph node, the value returned is the id of the graph node
+    inline unsigned int insert(const polygon_45_set_data<coordinate_type>& ps) {
+      ps.clean();
+      polygon_45_touch<big_coord>::populateTouchSetData(tsd_, ps.begin(), ps.end(), nodeCount_);
+      return nodeCount_++;
+    }
+    template <class GeoObjT>
+    inline unsigned int insert(const GeoObjT& geoObj) {
+      polygon_45_set_data<coordinate_type> ps;
+      ps.insert(geoObj);
+      return insert(ps);
+    }
+    
+    //extract connectivity and store the edges in the graph
+    //graph must be indexable by graph node id and the indexed value must be a std::set of
+    //graph node id
+    template <class GraphT>
+    inline void extract(GraphT& graph) {
+      polygon_45_touch<big_coord>::performTouch(graph, tsd_);
+    }
+  };
+}
+}
+#endif 
Added: sandbox/gtl/boost/polygon/detail/polygon_90_set_view.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_90_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,438 @@
+/*
+  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_POLYGON_90_SET_VIEW_HPP
+#define BOOST_POLYGON_POLYGON_90_SET_VIEW_HPP
+namespace boost { namespace polygon{
+  struct operator_provides_storage {};
+  struct operator_requires_copy {};
+
+  template <typename value_type, typename arg_type>
+  inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient);
+
+  template <typename ltype, typename rtype, typename op_type>
+  class polygon_90_set_view;
+
+  template <typename ltype, typename rtype, typename op_type>
+  struct polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> > {
+    typedef typename polygon_90_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
+    typedef typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
+    typedef typename polygon_90_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
+
+    static inline iterator_type begin(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set); 
+    static inline iterator_type end(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
+
+    static inline orientation_2d orient(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
+
+    static inline bool clean(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
+
+    static inline bool sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
+  };
+
+  template <typename value_type, typename ltype, typename rtype, typename op_type>
+  struct compute_90_set_value {
+    static
+    void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_, orientation_2d orient_) {
+      value_type linput_(orient_);
+      value_type rinput_(orient_);
+      insert_into_view_arg(linput_, lvalue_, orient_);
+      insert_into_view_arg(rinput_, rvalue_, orient_);
+      output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+                                   rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
+    }
+  };
+
+  template <typename value_type, typename lcoord, typename rcoord, typename op_type>
+  struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, polygon_90_set_data<rcoord>, op_type> {
+    static
+    void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
+               const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
+      lvalue_.sort();
+      rvalue_.sort();
+      output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+                                   rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); 
+    }
+  };
+
+  template <typename value_type, typename lcoord, typename rtype, typename op_type>
+  struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, rtype, op_type> {
+    static
+    void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
+               const rtype& rvalue_, orientation_2d orient_) {
+      value_type rinput_(orient_);
+      lvalue_.sort();
+      insert_into_view_arg(rinput_, rvalue_, orient_);
+      output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+                                   rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
+    }
+  };
+
+  template <typename value_type, typename ltype, typename rcoord, typename op_type>
+  struct compute_90_set_value<value_type, ltype, polygon_90_set_data<rcoord>, op_type> {
+    static
+    void value(value_type& output_, const ltype& lvalue_,
+               const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
+      value_type linput_(orient_);
+      insert_into_view_arg(linput_, lvalue_, orient_);
+      rvalue_.sort();
+      output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+                                   rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); 
+    }
+  };
+
+  template <typename ltype, typename rtype, typename op_type>
+  class polygon_90_set_view {
+  public:
+    typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_90_set_data<coordinate_type> value_type;
+    typedef typename value_type::iterator_type iterator_type;
+    typedef polygon_90_set_view operator_arg_type;
+  private:
+    const ltype& lvalue_;
+    const rtype& rvalue_;
+    orientation_2d orient_;
+    op_type op_;
+    mutable value_type output_;
+    mutable bool evaluated_;
+  public:
+    polygon_90_set_view(const ltype& lvalue,
+                     const rtype& rvalue,
+                     orientation_2d orient,
+                     op_type op) :
+      lvalue_(lvalue), rvalue_(rvalue), orient_(orient), op_(op), output_(orient), evaluated_(false) {}
+
+    // get iterator to begin vertex data
+  private:
+    const value_type& value() const {
+      if(!evaluated_) {
+        evaluated_ = true;
+        compute_90_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_, orient_);
+      }
+      return output_;
+    }
+  public:
+    iterator_type begin() const { return value().begin(); }
+    iterator_type end() const { return value().end(); }
+
+    orientation_2d orient() const { return orient_; }
+    bool dirty() const { return false; } //result of a boolean is clean
+    bool sorted() const { return true; } //result of a boolean is sorted
+
+//     template <typename input_iterator_type>
+//     void set(input_iterator_type input_begin, input_iterator_type input_end, 
+//              orientation_2d orient) const {
+//       orient_ = orient;
+//       output_.clear();
+//       output_.insert(output_.end(), input_begin, input_end);
+//       std::sort(output_.begin(), output_.end());
+//     }
+    void sort() const {} //is always sorted
+  };
+
+  template <typename ltype, typename rtype, typename op_type>
+  struct geometry_concept<polygon_90_set_view<ltype, rtype, op_type> > {
+    typedef polygon_90_set_concept type;
+  };
+
+  template <typename ltype, typename rtype, typename op_type>
+  typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+  begin(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
+    return polygon_set.begin();
+  }
+  template <typename ltype, typename rtype, typename op_type>
+  typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+  end(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
+    return polygon_set.end();
+  }
+//   template <typename ltype, typename rtype, typename op_type>
+//   template <typename input_iterator_type>
+//   void polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+//   set(polygon_90_set_view<ltype, rtype, op_type>& polygon_set, 
+//       input_iterator_type input_begin, input_iterator_type input_end,
+//       orientation_2d orient) {
+//     polygon_set.set(input_begin, input_end, orient);
+//   }
+  template <typename ltype, typename rtype, typename op_type>
+  orientation_2d polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+  orient(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
+    return polygon_set.orient(); }
+  template <typename ltype, typename rtype, typename op_type>
+  bool polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+  clean(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
+    return true; }
+  template <typename ltype, typename rtype, typename op_type>
+  bool polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
+  sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
+    return true; }
+
+  template <typename value_type, typename arg_type>
+  inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient) {
+    typedef typename polygon_90_set_traits<arg_type>::iterator_type literator;
+    literator itr1, itr2;
+    itr1 = polygon_90_set_traits<arg_type>::begin(arg);
+    itr2 = polygon_90_set_traits<arg_type>::end(arg);
+    dest.insert(itr1, itr2, orient);
+    dest.sort();
+  }
+  
+  template <typename T>
+  template <typename ltype, typename rtype, typename op_type>
+  inline polygon_90_set_data<T>& polygon_90_set_data<T>::operator=(const polygon_90_set_view<ltype, rtype, op_type>& that) {
+    set(that.begin(), that.end(), that.orient());
+    dirty_ = false;
+    unsorted_ = false;
+    return *this;
+  }
+  
+  template <typename T>
+  template <typename ltype, typename rtype, typename op_type>
+  inline polygon_90_set_data<T>::polygon_90_set_data(const polygon_90_set_view<ltype, rtype, op_type>& that) :
+    orient_(that.orient()), data_(that.begin(), that.end()), dirty_(false), unsorted_(false) {}
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  struct self_assign_operator_lvalue {
+    typedef geometry_type_1& type;
+  };
+    
+  template <typename type_1, typename type_2>
+  struct by_value_binary_operator {
+    typedef type_1 type;
+  };
+    
+  template <typename geometry_type_1, typename geometry_type_2, typename op_type>
+  geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
+    typedef geometry_type_1 ltype;
+    typedef geometry_type_2 rtype;
+    typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_90_set_data<coordinate_type> value_type;
+    orientation_2d orient_ = polygon_90_set_traits<ltype>::orient(lvalue_);
+    value_type linput_(orient_);
+    value_type rinput_(orient_);
+    value_type output_(orient_);
+    insert_into_view_arg(linput_, lvalue_, orient_);
+    insert_into_view_arg(rinput_, rvalue_, orient_);
+    output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+                                 rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
+    polygon_90_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end(), orient_);
+    return lvalue_;
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< 
+    typename is_polygon_90_set_type<geometry_type_1>::type,
+    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
+  operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryOr());
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< 
+    typename gtl_and< 
+      typename is_polygon_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+      ::type
+#endif
+      ::type,
+      typename is_polygon_90_set_type<geometry_type_2>::type>
+#ifdef BOOST_POLYGON_ICC 
+    ::type
+#endif
+    ::type,
+    polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
+  operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryOr());
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< 
+    typename is_polygon_90_set_type<geometry_type_1>::type,
+    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
+  operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryAnd());
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_if<typename gtl_and< 
+    typename is_polygon_90_set_type<geometry_type_1>::type,
+    typename is_polygon_90_set_type<geometry_type_2>::type>::type>::type,
+                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
+  operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryAnd());
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< 
+    typename is_polygon_90_set_type<geometry_type_1>::type,
+    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
+                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor> >::type
+  operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryXor());
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< 
+    typename is_polygon_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+::type,
+    typename is_polygon_90_set_type<geometry_type_2>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+::type,
+                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot> >::type
+  operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot> 
+      (lvalue, rvalue, 
+       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
+       boolean_op::BinaryNot());
+  }
+  
+  template <typename coordinate_type_1, typename geometry_type_2>
+  typename enable_if< typename is_polygon_90_set_type<geometry_type_2>::type,
+                       polygon_90_set_data<coordinate_type_1> >::type &
+  operator+=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
+    lvalue.insert(polygon_90_set_traits<geometry_type_2>::begin(rvalue), polygon_90_set_traits<geometry_type_2>::end(rvalue),
+                  polygon_90_set_traits<geometry_type_2>::orient(rvalue));
+    return lvalue;
+  }
+  
+  //
+  template <typename coordinate_type_1, typename geometry_type_2>
+  typename enable_if< typename is_polygon_90_set_type<geometry_type_2>::type, 
+                       polygon_90_set_data<coordinate_type_1> >::type &
+  operator|=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
+    return lvalue += rvalue;
+  }
+
+  //normal self assignment boolean operations
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
+  }
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryXor>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename geometry_type_2>
+  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
+                       geometry_type_1>::type &
+  operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryNot>(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and<
+    typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
+                       geometry_type_1>::type &
+  operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    return resize(lvalue, rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and<
+    typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
+    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
+                       geometry_type_1>::type &
+  operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    return resize(lvalue, -rvalue);
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and<
+    typename is_mutable_polygon_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+::type, 
+    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type,
+                       geometry_type_1>::type
+  operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    geometry_type_1 retval(lvalue);
+    retval += rvalue;
+    return retval;
+  }
+
+  template <typename geometry_type_1, typename coordinate_type_1>
+  typename enable_if< typename gtl_and<
+    typename is_mutable_polygon_90_set_type<geometry_type_1>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+::type, 
+    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
+#ifdef BOOST_POLYGON_ICC 
+  ::type
+#endif
+  ::type,
+                       geometry_type_1>::type
+  operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
+    geometry_type_1 retval(lvalue);
+    retval -= rvalue;
+    return retval;
+  }
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/polygon_90_touch.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_90_touch.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,418 @@
+/*
+  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_POLYGON_90_TOUCH_HPP
+#define BOOST_POLYGON_POLYGON_90_TOUCH_HPP
+namespace boost { namespace polygon{
+
+  template <typename Unit>
+  struct touch_90_operation {
+    typedef interval_data<Unit> Interval;
+
+    class TouchScanEvent {
+    private:
+      typedef std::map<Unit, std::set<int> > EventData;
+      EventData eventData_;
+    public:
+
+      // The TouchScanEvent::iterator is a lazy algorithm that accumulates
+      // polygon ids in a set as it is incremented through the
+      // scan event data structure.
+      // The iterator provides a forward iterator semantic only.
+      class iterator {
+      private:
+        typename EventData::const_iterator itr_;
+        std::pair<Interval, std::set<int> > ivlIds_;
+        bool incremented_;
+      public:
+        inline iterator() : itr_(), ivlIds_(), incremented_(false) {}
+        inline iterator(typename EventData::const_iterator itr, 
+                        Unit prevPos, Unit curPos, const std::set<int>& ivlIds) : itr_(itr), ivlIds_(), incremented_(false) {
+          ivlIds_.second = ivlIds;
+          ivlIds_.first = Interval(prevPos, curPos);
+        }
+        inline iterator(const iterator& that) : itr_(), ivlIds_(), incremented_(false) { (*this) = that; }
+        inline iterator& operator=(const iterator& that) {
+          itr_ = that.itr_;
+          ivlIds_.first = that.ivlIds_.first;
+          ivlIds_.second = that.ivlIds_.second;
+          incremented_ = that.incremented_;
+          return *this;
+        };
+        inline bool operator==(const iterator& that) { return itr_ == that.itr_; }
+        inline bool operator!=(const iterator& that) { return itr_ != that.itr_; }
+        inline iterator& operator++() {
+          //std::cout << "increment\n";
+          //std::cout << "state\n";
+          //for(std::set<int>::iterator itr = ivlIds_.second.begin(); itr != ivlIds_.second.end(); ++itr) {
+          //   std::cout << (*itr) << " ";
+          //} std::cout << std::endl;
+          //std::cout << "update\n";
+          for(std::set<int>::const_iterator itr = (*itr_).second.begin();
+              itr != (*itr_).second.end(); ++itr) {
+            //std::cout << (*itr) <<  " ";
+            std::set<int>::iterator lb = ivlIds_.second.find(*itr);
+            if(lb != ivlIds_.second.end()) {
+              ivlIds_.second.erase(lb);
+            } else {
+              ivlIds_.second.insert(*itr);
+            }
+          } 
+          //std::cout << std::endl;
+          //std::cout << "new state\n";
+          //for(std::set<int>::iterator itr = ivlIds_.second.begin(); itr != ivlIds_.second.end(); ++itr) {
+          //   std::cout << (*itr) << " ";
+          //} std::cout << std::endl;
+          ++itr_;
+          //ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
+          incremented_ = true;
+          return *this;
+        }
+        inline const iterator operator++(int){
+          iterator tmpItr(*this);
+          ++(*this);
+          return tmpItr;
+        }
+        inline std::pair<Interval, std::set<int> >& operator*() { 
+          if(incremented_) ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
+          incremented_ = false;
+          if(ivlIds_.second.empty())(++(*this));
+          if(incremented_) ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
+          incremented_ = false;
+          return ivlIds_; }
+      };
+
+      inline TouchScanEvent() : eventData_() {}
+      template<class iT>
+      inline TouchScanEvent(iT begin, iT end) : eventData_() {
+        for( ; begin != end; ++begin){
+          insert(*begin);
+        }
+      }
+      inline TouchScanEvent(const TouchScanEvent& that) : eventData_(that.eventData_) {}
+      inline TouchScanEvent& operator=(const TouchScanEvent& that){
+        eventData_ = that.eventData_;
+        return *this;
+      }
+   
+      //Insert an interval polygon id into the EventData
+      inline void insert(const std::pair<Interval, int>& intervalId){
+        insert(intervalId.first.low(), intervalId.second);
+        insert(intervalId.first.high(), intervalId.second);
+      }
+   
+      //Insert an position and polygon id into EventData
+      inline void insert(Unit pos, int id) {
+        typename EventData::iterator lb = eventData_.lower_bound(pos);
+        if(lb != eventData_.end() && lb->first == pos) {
+          std::set<int>& mr (lb->second);
+          std::set<int>::iterator mri = mr.find(id);
+          if(mri == mr.end()) {
+            mr.insert(id);
+          } else {
+            mr.erase(id);
+          }
+        } else {
+          lb = eventData_.insert(lb, std::pair<Unit, std::set<int> >(pos, std::set<int>()));
+          (*lb).second.insert(id);
+        }
+      }
+   
+      //merge this scan event with that by inserting its data
+      inline void insert(const TouchScanEvent& that){
+        typename EventData::const_iterator itr;
+        for(itr = that.eventData_.begin(); itr != that.eventData_.end(); ++itr) {
+          eventData_[(*itr).first].insert(itr->second.begin(), itr->second.end());
+        }
+      }
+   
+      //Get the begin iterator over event data
+      inline iterator begin() const { 
+        //std::cout << "begin\n";
+        if(eventData_.empty()) return end();
+        typename EventData::const_iterator itr = eventData_.begin();
+        Unit pos = itr->first;
+        const std::set<int>& idr = itr->second;
+        ++itr;
+        return iterator(itr, pos, itr->first, idr);
+      }
+   
+      //Get the end iterator over event data
+      inline iterator end() const { return iterator(eventData_.end(), 0, 0, std::set<int>()); }
+   
+      inline void clear() { eventData_.clear(); }
+   
+      inline Interval extents() const { 
+        if(eventData_.empty()) return Interval();
+        return Interval((*(eventData_.begin())).first, (*(eventData_.rbegin())).first);
+      }
+    };
+   
+    //declaration of a map of scan events by coordinate value used to store all the
+    //polygon data for a single layer input into the scanline algorithm
+    typedef std::pair<std::map<Unit, TouchScanEvent>, std::map<Unit, TouchScanEvent> > TouchSetData;
+
+    class TouchOp {
+    public:
+      typedef std::map<Unit, std::set<int> > ScanData;
+      typedef std::pair<Unit, std::set<int> > ElementType;
+    protected:
+      ScanData scanData_;
+      typename ScanData::iterator nextItr_;
+    public:
+      inline TouchOp () : scanData_(), nextItr_() { nextItr_ = scanData_.end(); }
+      inline TouchOp (const TouchOp& that) : scanData_(that.scanData_), nextItr_() { nextItr_ = scanData_.begin(); }
+      inline TouchOp& operator=(const TouchOp& that); 
+   
+      //moves scanline forward
+      inline void advanceScan() { nextItr_ = scanData_.begin(); }
+
+      //proceses the given interval and std::set<int> data
+      //the output data structre is a graph, the indicies in the vector correspond to graph nodes,
+      //the integers in the set are vector indicies and are the nodes with which that node shares an edge
+      template <typename graphT>
+      inline void processInterval(graphT& outputContainer, Interval ivl, const std::set<int>& ids, bool leadingEdge) {
+        //print();
+        typename ScanData::iterator lowItr = lookup_(ivl.low());
+        typename ScanData::iterator highItr = lookup_(ivl.high());
+        //std::cout << "Interval: " << ivl << std::endl;
+        //for(std::set<int>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
+        //   std::cout << (*itr) << " ";
+        //std::cout << std::endl;
+        //add interval to scan data if it is past the end
+        if(lowItr == scanData_.end()) {
+          //std::cout << "case0" << std::endl;
+          lowItr = insert_(ivl.low(), ids);
+          evaluateBorder_(outputContainer, ids, ids);
+          highItr = insert_(ivl.high(), std::set<int>());
+          return;
+        }
+        //ensure that highItr points to the end of the ivl
+        if(highItr == scanData_.end() || (*highItr).first > ivl.high()) {
+          //std::cout << "case1" << std::endl;
+          //std::cout << highItr->first << std::endl;
+          std::set<int> value = std::set<int>();
+          if(highItr != scanData_.begin()) {
+            --highItr;
+            //std::cout << highItr->first << std::endl;
+            //std::cout << "high set size " << highItr->second.size() << std::endl;
+            value = highItr->second;
+          }
+          nextItr_ = highItr;
+          highItr = insert_(ivl.high(), value);
+        } else {
+          //evaluate border with next higher interval
+          //std::cout << "case1a" << std::endl;
+          if(leadingEdge)evaluateBorder_(outputContainer, highItr->second, ids);
+        }
+        //split the low interval if needed
+        if(lowItr->first > ivl.low()) {
+          //std::cout << "case2" << std::endl;
+          if(lowItr != scanData_.begin()) {
+            //std::cout << "case3" << std::endl;
+            --lowItr;
+            nextItr_ = lowItr;
+            //std::cout << lowItr->first << " " << lowItr->second.size() << std::endl;
+            lowItr = insert_(ivl.low(), lowItr->second);
+          } else {
+            //std::cout << "case4" << std::endl;
+            nextItr_ = lowItr;
+            lowItr = insert_(ivl.low(), std::set<int>());
+          }
+        } else {
+          //evaluate border with next higher interval
+          //std::cout << "case2a" << std::endl;
+          typename ScanData::iterator nextLowerItr = lowItr;
+          if(leadingEdge && nextLowerItr != scanData_.begin()){
+            --nextLowerItr;
+            evaluateBorder_(outputContainer, nextLowerItr->second, ids);
+          }
+        }
+        //std::cout << "low: " << lowItr->first << " high: " << highItr->first << std::endl;
+        //print();
+        //process scan data intersecting interval
+        for(typename ScanData::iterator itr = lowItr; itr != highItr; ){
+          //std::cout << "case5" << std::endl;
+          //std::cout << itr->first << std::endl;
+          std::set<int>& beforeIds = itr->second;
+          ++itr;
+          evaluateInterval_(outputContainer, beforeIds, ids, leadingEdge);
+        }
+        //print();
+        //merge the bottom interval with the one below if they have the same count
+        if(lowItr != scanData_.begin()){
+          //std::cout << "case6" << std::endl;
+          typename ScanData::iterator belowLowItr = lowItr;
+          --belowLowItr;
+          if(belowLowItr->second == lowItr->second) {
+            //std::cout << "case7" << std::endl;
+            scanData_.erase(lowItr);
+          }
+        } 
+        //merge the top interval with the one above if they have the same count
+        if(highItr != scanData_.begin()) {
+          //std::cout << "case8" << std::endl;
+          typename ScanData::iterator beforeHighItr = highItr;
+          --beforeHighItr;
+          if(beforeHighItr->second == highItr->second) {
+            //std::cout << "case9" << std::endl;
+            scanData_.erase(highItr);
+            highItr = beforeHighItr;
+            ++highItr;
+          }
+        }
+        //print();
+        nextItr_ = highItr;
+      }
+
+      inline void print() const {
+        for(typename ScanData::const_iterator itr = scanData_.begin(); itr != scanData_.end(); ++itr) {
+          std::cout << itr->first << ": ";
+          for(std::set<int>::const_iterator sitr = itr->second.begin();
+              sitr != itr->second.end(); ++sitr){
+            std::cout << *sitr << " ";
+          }
+          std::cout << std::endl;
+        }
+      }
+   
+    private:
+      inline typename ScanData::iterator lookup_(Unit pos){
+        if(nextItr_ != scanData_.end() && nextItr_->first >= pos) {
+          return nextItr_;
+        }
+        return nextItr_ = scanData_.lower_bound(pos);
+      }
+
+      inline typename ScanData::iterator insert_(Unit pos, const std::set<int>& ids){
+        //std::cout << "inserting " << ids.size() << " ids at: " << pos << std::endl;
+        return nextItr_ = scanData_.insert(nextItr_, std::pair<Unit, std::set<int> >(pos, ids));
+      }
+
+      template <typename graphT>
+      inline void evaluateInterval_(graphT& outputContainer, std::set<int>& ids, 
+                                    const std::set<int>& changingIds, bool leadingEdge) {
+        for(std::set<int>::const_iterator ciditr = changingIds.begin(); ciditr != changingIds.end(); ++ciditr){
+          //std::cout << "evaluateInterval " << (*ciditr) << std::endl;
+          evaluateId_(outputContainer, ids, *ciditr, leadingEdge);
+        }
+      }
+      template <typename graphT>
+      inline void evaluateBorder_(graphT& outputContainer, const std::set<int>& ids, const std::set<int>& changingIds) {
+        for(std::set<int>::const_iterator ciditr = changingIds.begin(); ciditr != changingIds.end(); ++ciditr){
+          //std::cout << "evaluateBorder " << (*ciditr) << std::endl;
+          evaluateBorderId_(outputContainer, ids, *ciditr);
+        }
+      }
+      template <typename graphT>
+      inline void evaluateBorderId_(graphT& outputContainer, const std::set<int>& ids, int changingId) {
+        for(std::set<int>::const_iterator scanItr = ids.begin(); scanItr != ids.end(); ++scanItr) {
+          //std::cout << "create edge: " << changingId << " " << *scanItr << std::endl;
+          if(changingId != *scanItr){
+            outputContainer[changingId].insert(*scanItr);
+            outputContainer[*scanItr].insert(changingId);
+          }
+        }
+      }
+      template <typename graphT>
+      inline void evaluateId_(graphT& outputContainer, std::set<int>& ids, int changingId, bool leadingEdge) {
+        //std::cout << "changingId: " << changingId << std::endl;
+        //for( std::set<int>::iterator itr = ids.begin(); itr != ids.end(); ++itr){
+        //   std::cout << *itr << " ";
+        //}std::cout << std::endl;
+        std::set<int>::iterator lb = ids.lower_bound(changingId);
+        if(lb == ids.end() || (*lb) != changingId) {
+          if(leadingEdge) {
+            //std::cout << "insert\n";
+            //insert and add to output
+            for(std::set<int>::iterator scanItr = ids.begin(); scanItr != ids.end(); ++scanItr) {
+              //std::cout << "create edge: " << changingId << " " << *scanItr << std::endl;
+              if(changingId != *scanItr){
+                outputContainer[changingId].insert(*scanItr);
+                outputContainer[*scanItr].insert(changingId);
+              }
+            }
+            ids.insert(changingId);
+          }
+        } else {
+          if(!leadingEdge){
+            //std::cout << "erase\n";
+            ids.erase(lb);
+          }
+        }
+      }
+    };
+
+    template <typename graphT>
+    static inline void processEvent(graphT& outputContainer, TouchOp& op, const TouchScanEvent& data, bool leadingEdge) {
+      for(typename TouchScanEvent::iterator itr = data.begin(); itr != data.end(); ++itr) {
+        //std::cout << "processInterval" << std::endl;
+        op.processInterval(outputContainer, (*itr).first, (*itr).second, leadingEdge);
+      }
+    }
+
+    template <typename graphT>
+    static inline void performTouch(graphT& outputContainer, const TouchSetData& data) {
+      typename std::map<Unit, TouchScanEvent>::const_iterator leftItr = data.first.begin();
+      typename std::map<Unit, TouchScanEvent>::const_iterator rightItr = data.second.begin();
+      typename std::map<Unit, TouchScanEvent>::const_iterator leftEnd = data.first.end();
+      typename std::map<Unit, TouchScanEvent>::const_iterator rightEnd = data.second.end();
+      TouchOp op;
+      while(leftItr != leftEnd || rightItr != rightEnd) {
+        //std::cout << "loop" << std::endl;
+        op.advanceScan();
+        //rightItr cannont be at end if leftItr is not at end
+        if(leftItr != leftEnd && rightItr != rightEnd &&
+           leftItr->first <= rightItr->first) {
+          //std::cout << "case1" << std::endl;
+          //std::cout << leftItr ->first << std::endl;
+          processEvent(outputContainer, op, leftItr->second, true);
+          ++leftItr;
+        } else {
+          //std::cout << "case2" << std::endl;
+          //std::cout << rightItr ->first << std::endl;
+          processEvent(outputContainer, op, rightItr->second, false);
+          ++rightItr;
+        }
+      }
+    }
+
+    template <class iT>
+    static inline void populateTouchSetData(TouchSetData& data, iT beginData, iT endData, int id) {
+      Unit prevPos = ((std::numeric_limits<Unit>::max)());
+      Unit prevY = prevPos;
+      int count = 0;
+      for(iT itr = beginData; itr != endData; ++itr) {
+        Unit pos = (*itr).first;
+        if(pos != prevPos) {
+          prevPos = pos;
+          prevY = (*itr).second.first;
+          count = (*itr).second.second;
+          continue;
+        }
+        Unit y = (*itr).second.first;
+        if(count != 0 && y != prevY) {
+          std::pair<Interval, int> element(Interval(prevY, y), id);
+          if(count > 0) {
+            data.first[pos].insert(element);
+          } else {
+            data.second[pos].insert(element);
+          }
+        }
+        prevY = y;
+        count += (*itr).second.second;
+      }
+    }
+
+    static inline void populateTouchSetData(TouchSetData& data, const std::vector<std::pair<Unit, std::pair<Unit, int> > >& inputData, int id) {
+      populateTouchSetData(data, inputData.begin(), inputData.end(), id);
+    }
+
+  };
+}
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/polygon_arbitrary_formation.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_arbitrary_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,1937 @@
+/*
+    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_POLYGON_ARBITRARY_FORMATION_HPP
+#define BOOST_POLYGON_POLYGON_ARBITRARY_FORMATION_HPP
+namespace boost { namespace polygon{
+  template <typename T, typename T2>
+  struct PolyLineArbitraryByConcept {};
+
+  template <typename T>
+  class poly_line_arbitrary_polygon_data;
+  template <typename T>
+  class poly_line_arbitrary_hole_data;
+
+  template <typename Unit>
+  struct scanline_base {
+
+    typedef point_data<Unit> Point;
+    typedef std::pair<Point, Point> half_edge;
+
+    class less_point : public std::binary_function<Point, Point, bool> {
+    public:
+      inline less_point() {}
+      inline bool operator () (const Point& pt1, const Point& pt2) const {
+        if(pt1.get(HORIZONTAL) < pt2.get(HORIZONTAL)) return true;
+        if(pt1.get(HORIZONTAL) == pt2.get(HORIZONTAL)) {
+          if(pt1.get(VERTICAL) < pt2.get(VERTICAL)) return true;
+        }
+        return false;
+      }
+    };
+
+    static inline bool 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 area_type>
+    static inline Unit compute_intercept(const area_type& dy2,
+                                         const area_type& dx1,
+                                         const area_type& dx2) {
+      //intercept = dy2 * dx1 / dx2
+      //return (Unit)(((area_type)dy2 * (area_type)dx1) / (area_type)dx2);
+      area_type dx1_q = dx1 / dx2;
+      area_type dx1_r = dx1 % dx2;
+      return dx1_q * dy2 + (dy2 * dx1_r)/dx2;
+    }
+
+    template <typename area_type>
+    static inline bool equal_slope(area_type dx1, area_type dy1, area_type dx2, area_type dy2) {
+      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
+      unsigned_product_type cross_1 = (unsigned_product_type)(dx2 < 0 ? -dx2 :dx2) * (unsigned_product_type)(dy1 < 0 ? -dy1 : dy1);
+      unsigned_product_type cross_2 = (unsigned_product_type)(dx1 < 0 ? -dx1 :dx1) * (unsigned_product_type)(dy2 < 0 ? -dy2 : dy2);
+      int dx1_sign = dx1 < 0 ? -1 : 1;
+      int dx2_sign = dx2 < 0 ? -1 : 1;
+      int dy1_sign = dy1 < 0 ? -1 : 1;
+      int dy2_sign = dy2 < 0 ? -1 : 1;
+      int cross_1_sign = dx2_sign * dy1_sign;
+      int cross_2_sign = dx1_sign * dy2_sign;
+      return cross_1 == cross_2 && (cross_1_sign == cross_2_sign || cross_1 == 0);
+    }
+
+    static inline bool equal_slope(const Unit& x, const Unit& y,
+                                   const Point& pt1, const Point& pt2) {
+      const Point* pts[2] = {&pt1, &pt2};
+      typedef typename coordinate_traits<Unit>::manhattan_area_type at;
+      at dy2 = (at)pts[1]->get(VERTICAL) - (at)y;
+      at dy1 = (at)pts[0]->get(VERTICAL) - (at)y;
+      at dx2 = (at)pts[1]->get(HORIZONTAL) - (at)x;
+      at dx1 = (at)pts[0]->get(HORIZONTAL) - (at)x;
+      return equal_slope(dx1, dy1, dx2, dy2);
+    }
+
+    template <typename area_type>
+    static inline bool less_slope(area_type dx1, area_type dy1, area_type dx2, area_type dy2) {
+      //reflext x and y slopes to right hand side half plane
+      if(dx1 < 0) {
+        dy1 *= -1;
+        dx1 *= -1;
+      } else if(dx1 == 0) {
+        //if the first slope is vertical the first cannot be less
+        return false;
+      }
+      if(dx2 < 0) {
+        dy2 *= -1;
+        dx2 *= -1;
+      } else if(dx2 == 0) {
+        //if the second slope is vertical the first is always less unless it is also vertical, in which case they are equal 
+        return dx1 != 0;
+      }
+      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
+      unsigned_product_type cross_1 = (unsigned_product_type)(dx2 < 0 ? -dx2 :dx2) * (unsigned_product_type)(dy1 < 0 ? -dy1 : dy1);
+      unsigned_product_type cross_2 = (unsigned_product_type)(dx1 < 0 ? -dx1 :dx1) * (unsigned_product_type)(dy2 < 0 ? -dy2 : dy2);
+      int dx1_sign = dx1 < 0 ? -1 : 1;
+      int dx2_sign = dx2 < 0 ? -1 : 1;
+      int dy1_sign = dy1 < 0 ? -1 : 1;
+      int dy2_sign = dy2 < 0 ? -1 : 1;
+      int cross_1_sign = dx2_sign * dy1_sign;
+      int cross_2_sign = dx1_sign * dy2_sign;
+      if(cross_1_sign < cross_2_sign) return true;
+      if(cross_2_sign < cross_1_sign) return false;
+      if(cross_1_sign == -1) return cross_2 < cross_1;
+      return cross_1 < cross_2;
+    }
+
+    static inline bool less_slope(const Unit& x, const Unit& y,
+                                  const Point& pt1, const Point& pt2) {
+      const Point* pts[2] = {&pt1, &pt2};
+      //compute y value on edge from pt_ to pts[1] at the x value of pts[0]
+      typedef typename coordinate_traits<Unit>::manhattan_area_type at;
+      at dy2 = (at)pts[1]->get(VERTICAL) - (at)y;
+      at dy1 = (at)pts[0]->get(VERTICAL) - (at)y;
+      at dx2 = (at)pts[1]->get(HORIZONTAL) - (at)x;
+      at dx1 = (at)pts[0]->get(HORIZONTAL) - (at)x;
+      return less_slope(dx1, dy1, dx2, dy2);
+    }
+
+    //return -1 below, 0 on and 1 above line
+    //assumes point is on x interval of segment
+    static inline int on_above_or_below(Point pt, const half_edge& he) {
+      if(pt == he.first || pt == he.second) return 0;
+      if(equal_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), he.first, he.second)) return 0;
+      bool less_result = less_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), he.first, he.second);
+      int retval = less_result ? -1 : 1;
+      less_point lp;
+      if(lp(he.second, he.first)) retval *= -1;
+      if(!between(pt, he.first, he.second)) retval *= -1;
+      return retval;
+    }
+
+    //returns true is the segment intersects the integer grid square with lower
+    //left corner at point
+    static inline bool intersects_grid(Point pt, const half_edge& he) {
+      if(pt == he.second) return true;
+      if(pt == he.first) return true;
+      rectangle_data<Unit> rect1;
+      set_points(rect1, he.first, he.second);
+      if(contains(rect1, pt, true)) {
+        if(is_vertical(he) || is_horizontal(he)) return true;
+      } else {
+        return false; //can't intersect a grid not within bounding box
+      }
+      Unit x = pt.get(HORIZONTAL);
+      Unit y = pt.get(VERTICAL);
+      if(equal_slope(x, y, he.first, he.second) &&
+         between(pt, he.first, he.second)) return true;
+      Point pt01(pt.get(HORIZONTAL), pt.get(VERTICAL) + 1);
+      Point pt10(pt.get(HORIZONTAL) + 1, pt.get(VERTICAL));
+      Point pt11(pt.get(HORIZONTAL) + 1, pt.get(VERTICAL) + 1);
+//       if(pt01 == he.first) return true;
+//       if(pt10 == he.first) return true;
+//       if(pt11 == he.first) return true;
+//       if(pt01 == he.second) return true;
+//       if(pt10 == he.second) return true;
+//       if(pt11 == he.second) return true;
+      //check non-integer intersections
+      half_edge widget1(pt, pt11);
+      //intersects but not just at pt11
+      if(intersects(widget1, he) && on_above_or_below(pt11, he)) return true;
+      half_edge widget2(pt01, pt10);
+      //intersects but not just at pt01 or 10
+      if(intersects(widget2, he) && on_above_or_below(pt01, he) && on_above_or_below(pt10, he)) return true;
+      return false;
+    }
+
+    static inline typename high_precision_type<Unit>::type evalAtXforY(Unit xIn, Point pt, Point other_pt) { 
+      //y = (x - x1)dy/dx + y1
+      //y = (xIn - pt.x)*(other_pt.y-pt.y)/(other_pt.x-pt.x) + pt.y
+      //assert pt.x != other_pt.x
+      Unit x1 = pt.get(HORIZONTAL);
+      Unit y1 = pt.get(VERTICAL);
+      typedef typename high_precision_type<Unit>::type high_precision;
+      high_precision dx1 = (high_precision)xIn - (high_precision)pt.get(HORIZONTAL);
+      if(dx1 == high_precision(0)) return (high_precision)(pt.get(VERTICAL)); 
+      high_precision dx = (high_precision)(other_pt.get(HORIZONTAL)) - (high_precision)x1;
+      high_precision dy = (high_precision)(other_pt.get(VERTICAL)) - (high_precision)y1;
+      high_precision y = (((high_precision)dx1) * (high_precision)dy / (high_precision)dx + (high_precision)y1);
+      return y;
+    }
+  
+
+    static inline bool is_vertical(const half_edge& he) {
+      return he.first.get(HORIZONTAL) == he.second.get(HORIZONTAL);
+    }
+      
+    static inline bool is_horizontal(const half_edge& he) {
+      return he.first.get(VERTICAL) == he.second.get(VERTICAL);
+    }
+
+    static inline bool is_45_degree(const half_edge& he) {
+      return euclidean_distance(he.first, he.second, HORIZONTAL) == euclidean_distance(he.first, he.second, VERTICAL);
+    }
+
+    //scanline comparator functor
+    class less_half_edge : public std::binary_function<half_edge, half_edge, bool> {
+    private:
+      Unit *x_; //x value at which to apply comparison
+      int *justBefore_;
+    public:
+      inline less_half_edge() : x_(0), justBefore_(0) {}
+      inline less_half_edge(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
+      inline less_half_edge(const less_half_edge& that) : x_(that.x_), justBefore_(that.justBefore_) {}
+      inline less_half_edge& operator=(const less_half_edge& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
+      inline bool operator () (const half_edge& elm1, const half_edge& elm2) const {
+        //Unit y1 = evalAtXforY(*x_ + !*justBefore_, elm1.first, elm1.second);
+        //Unit y2 = evalAtXforY(*x_ + !*justBefore_, elm2.first, elm2.second);
+        typedef typename high_precision_type<Unit>::type high_precision;
+        high_precision y1 = evalAtXforY(*x_, elm1.first, elm1.second);
+        high_precision y2 = evalAtXforY(*x_, elm2.first, elm2.second);
+        if(y1 < y2) return true;
+        if(y1 == y2) {
+          //if justBefore is true we invert the result of the comparison of slopes
+          bool result = less_slope(elm1.second.get(HORIZONTAL) - elm1.first.get(HORIZONTAL),
+                                   elm1.second.get(VERTICAL) - elm1.first.get(VERTICAL),
+                                   elm2.second.get(HORIZONTAL) - elm2.first.get(HORIZONTAL),
+                                   elm2.second.get(VERTICAL) - elm2.first.get(VERTICAL));
+          return (*justBefore_) ^ result;
+        }
+        return false;
+      }
+    };
+
+    template <typename unsigned_product_type>
+    static inline void unsigned_mod(unsigned_product_type& result, int& result_sign, unsigned_product_type a, int a_sign, unsigned_product_type b, int b_sign) {
+      result = a % b;
+      result_sign = a_sign;
+    }
+
+    template <typename unsigned_product_type>
+    static inline void unsigned_add(unsigned_product_type& result, int& result_sign, unsigned_product_type a, int a_sign, unsigned_product_type b, int b_sign) {
+      int switcher = 0;
+      if(a_sign < 0) switcher += 1; 
+      if(b_sign < 0) switcher += 2; 
+      if(a < b) switcher += 4;
+      switch (switcher) {
+      case 0: //both positive
+        result = a + b;
+        result_sign = 1;
+        break;
+      case 1: //a is negative
+        result = a - b;
+        result_sign = -1;
+        break;
+      case 2: //b is negative
+        result = a - b;
+        result_sign = 1;
+        break;
+      case 3: //both negative
+        result = a + b;
+        result_sign = -1;
+        break;
+      case 4: //both positive
+        result = a + b;
+        result_sign = 1;
+        break;
+      case 5: //a is negative
+        result = b - a;
+        result_sign = 1;
+        break;
+      case 6: //b is negative
+        result = b - a;
+        result_sign = -1;
+        break;
+      case 7: //both negative
+        result = b + a;
+        result_sign = -1;
+        break;
+      };
+    }
+
+    //slower but more overflow protected way to compute coordinate of intersection
+    template <typename product_type>
+    static inline Unit compute_x_intercept(product_type x11,
+                                           product_type x21,
+                                           product_type y11,
+                                           product_type y21,
+                                           product_type dy1,
+                                           product_type dy2,
+                                           product_type dx1,
+                                           product_type dx2) {
+      // x = (x11 * dy1 * dx2 - x21 * dy2 * dx1 + y21 * dx1 * dx2 - y11 * dx1 * dx2) / (dy1 * dx2 - dy2 * dx1);
+      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
+      unsigned_product_type udy1 = dy1 < 0 ? -dy1 : dy1;
+      int dy1sign = dy1 < 0 ? -1 : 1;
+      unsigned_product_type udy2 = dy2 < 0 ? -dy2 : dy2;
+      int dy2sign = dy2 < 0 ? -1 : 1;
+      unsigned_product_type udx1 = dx1 < 0 ? -dx1 : dx1;
+      int dx1sign = dx1 < 0 ? -1 : 1;
+      unsigned_product_type udx2 = dx2 < 0 ? -dx2 : dx2;
+      int dx2sign = dx2 < 0 ? -1 : 1;
+      unsigned_product_type u_dy1dx2 = udy1 * udx2;
+      unsigned_product_type u_dy2dx1 = udy2 * udx1;
+      unsigned_product_type u_dx1dx2 = udx1 * udx2;
+      int dy1dx2sign = dy1sign * dx2sign;
+      int dy2dx1sign = dy2sign * dx1sign;
+      int dx1dx2sign = dx1sign * dx2sign;
+      unsigned_product_type u_den = 0;;
+      int den_sign = 0;;
+      unsigned_add(u_den, den_sign, u_dy1dx2, dy1dx2sign, u_dy2dx1, -dy2dx1sign);
+      product_type dy1dx2_q = u_dy1dx2 / u_den;
+      product_type dy2dx1_q = u_dy2dx1 / u_den;
+      product_type dx1dx2_q = u_dx1dx2 / u_den;
+      dy1dx2_q *= dy1dx2sign * den_sign;
+      dy2dx1_q *= dy2dx1sign * den_sign;
+      dx1dx2_q *= dx1dx2sign * den_sign;
+      unsigned_product_type u_dy1dx2_r = 0;;
+      unsigned_product_type u_dy2dx1_r = 0;;
+      unsigned_product_type u_dx1dx2_r = 0;;
+      int dy1dx2_r_sign = 0;
+      int dy2dx1_r_sign = 0;
+      int dx1dx2_r_sign = 0;
+      unsigned_mod(u_dy1dx2_r, dy1dx2_r_sign, u_dy1dx2, dy1dx2sign, u_den, den_sign);
+      unsigned_mod(u_dy2dx1_r, dy2dx1_r_sign, u_dy2dx1, dy2dx1sign, u_den, den_sign);
+      unsigned_mod(u_dx1dx2_r, dx1dx2_r_sign, u_dx1dx2, dx1dx2sign, u_den, den_sign);
+      product_type dy1dx2_r = u_dy1dx2_r;
+      product_type dy2dx1_r = u_dy2dx1_r;
+      product_type dx1dx2_r = u_dx1dx2_r;
+      dy1dx2_r *= dy1dx2_r_sign;
+      dy2dx1_r *= dy2dx1_r_sign;
+      dx1dx2_r *= dx1dx2_r_sign;
+      product_type q = x11 * dy1dx2_q - x21 * dy2dx1_q + (y21 - y11) * dx1dx2_q;
+      product_type r = x11 * dy1dx2_r - x21 * dy2dx1_r + (y21 - y11) * dx1dx2_r;
+      unsigned_product_type ur = 0;
+      int rsign = 0;;
+      if(r < 0) { ur = -r; rsign = -1; } else { ur = r; rsign = 1; }
+      //this operation performs only one truncation
+      ur /= u_den;
+      rsign *= den_sign;
+      r = ur;
+      r *= rsign;
+      return q + r;
+    }
+
+    static inline bool compute_intersection(Point& intersection, const half_edge& he1, const half_edge& he2) {
+      typedef typename high_precision_type<Unit>::type high_precision;
+      typedef rectangle_data<Unit> Rectangle;
+      Rectangle rect1, rect2;
+      set_points(rect1, he1.first, he1.second);
+      set_points(rect2, he2.first, he2.second);
+      if(!::boost::polygon::intersects(rect1, rect2, true)) return false;
+      if(is_vertical(he1)) {
+        if(is_vertical(he2)) return false;
+        high_precision y_high = evalAtXforY(he1.first.get(HORIZONTAL), he2.first, he2.second);
+        Unit y = (Unit)y_high;
+        if(y_high < (high_precision)y) --y;
+        if(contains(rect1.get(VERTICAL), y, true)) {
+          intersection = Point(he1.first.get(HORIZONTAL), y);
+          return true;
+        } else {
+          return false;
+        }
+      } else if(is_vertical(he2)) {
+        high_precision y_high = evalAtXforY(he2.first.get(HORIZONTAL), he1.first, he1.second);
+        Unit y = (Unit)y_high;
+        if(y_high < (high_precision)y) --y;
+        if(contains(rect2.get(VERTICAL), y, true)) {
+          intersection = Point(he2.first.get(HORIZONTAL), y);
+          return true;
+        } else {
+          return false;
+        }
+      }
+      //the bounding boxes of the two line segments intersect, so we check closer to find the intersection point
+      high_precision dy2 = (high_precision)(he2.second.get(VERTICAL)) - 
+        (high_precision)(he2.first.get(VERTICAL));
+      high_precision dy1 = (high_precision)(he1.second.get(VERTICAL)) - 
+        (high_precision)(he1.first.get(VERTICAL));
+      high_precision dx2 = (high_precision)(he2.second.get(HORIZONTAL)) - 
+        (high_precision)(he2.first.get(HORIZONTAL));
+      high_precision dx1 = (high_precision)(he1.second.get(HORIZONTAL)) - 
+        (high_precision)(he1.first.get(HORIZONTAL));
+      if(equal_slope(dx1, dy1, dx2, dy2)) return false;
+      //the line segments have different slopes
+      //we can assume that the line segments are not vertical because such an intersection is handled elsewhere
+      high_precision x11 = (high_precision)(he1.first.get(HORIZONTAL));
+      high_precision x21 = (high_precision)(he2.first.get(HORIZONTAL));
+      high_precision y11 = (high_precision)(he1.first.get(VERTICAL));
+      high_precision y21 = (high_precision)(he2.first.get(VERTICAL));
+      //Unit exp_x = ((at)x11 * (at)dy1 * (at)dx2 - (at)x21 * (at)dy2 * (at)dx1 + (at)y21 * (at)dx1 * (at)dx2 - (at)y11 * (at)dx1 * (at)dx2) / ((at)dy1 * (at)dx2 - (at)dy2 * (at)dx1);
+      //Unit exp_y = ((at)y11 * (at)dx1 * (at)dy2 - (at)y21 * (at)dx2 * (at)dy1 + (at)x21 * (at)dy1 * (at)dy2 - (at)x11 * (at)dy1 * (at)dy2) / ((at)dx1 * (at)dy2 - (at)dx2 * (at)dy1);
+      high_precision x_num = (x11 * dy1 * dx2 - x21 * dy2 * dx1 + y21 * dx1 * dx2 - y11 * dx1 * dx2); 
+      high_precision x_den = (dy1 * dx2 - dy2 * dx1);
+      high_precision y_num = (y11 * dx1 * dy2 - y21 * dx2 * dy1 + x21 * dy1 * dy2 - x11 * dy1 * dy2);
+      high_precision y_den = (dx1 * dy2 - dx2 * dy1);
+      high_precision x = x_num / x_den;
+      high_precision y = y_num / y_den;
+      //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << std::endl;
+      //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << std::endl;
+      //Unit exp_x = compute_x_intercept<at>(x11, x21, y11, y21, dy1, dy2, dx1, dx2);
+      //Unit exp_y = compute_x_intercept<at>(y11, y21, x11, x21, dx1, dx2, dy1, dy2);
+      Unit x_unit = (Unit)x;
+      Unit y_unit = (Unit)y;
+      //truncate downward if it went up due to negative number
+      if(x < (high_precision)x_unit) --x_unit;
+      if(y < (high_precision)y_unit) --y_unit;
+      //if(x != exp_x || y != exp_y)
+      //  std::cout << exp_x << " " << exp_y << " " << x << " " << y << std::endl;
+      //Unit y1 = evalAtXforY(exp_x, he1.first, he1.second);
+      //Unit y2 = evalAtXforY(exp_x, he2.first, he2.second);
+      //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << std::endl;
+      Point result(x_unit, y_unit);
+      if(!contains(rect1, result, true)) return false;
+      if(!contains(rect2, result, true)) return false;
+      intersection = result;
+      return true;
+    }
+
+    static inline bool intersects(const half_edge& he1, const half_edge& he2) {
+      typedef rectangle_data<Unit> Rectangle;
+      Rectangle rect1, rect2;
+      set_points(rect1, he1.first, he1.second);
+      set_points(rect2, he2.first, he2.second);
+      if(::boost::polygon::intersects(rect1, rect2, false)) {
+        if(he1.first == he2.first) {
+          if(he1.second != he2.second && equal_slope(he1.first.get(HORIZONTAL), he1.first.get(VERTICAL),
+                                                     he1.second, he2.second)) {
+            return true;
+          } else {
+            return false;
+          }
+        }
+        if(he1.first == he2.second) {
+          if(he1.second != he2.first && equal_slope(he1.first.get(HORIZONTAL), he1.first.get(VERTICAL),
+                                                    he1.second, he2.first)) {
+            return true;
+          } else {
+            return false;
+          }
+        }
+        if(he1.second == he2.first) {
+          if(he1.first != he2.second && equal_slope(he1.second.get(HORIZONTAL), he1.second.get(VERTICAL),
+                                                    he1.first, he2.second)) {
+            return true;
+          } else {
+            return false;
+          }
+        }
+        if(he1.second == he2.second) {
+          if(he1.first != he2.first && equal_slope(he1.second.get(HORIZONTAL), he1.second.get(VERTICAL),
+                                                   he1.first, he2.first)) {
+            return true;
+          } else {
+            return false;
+          }
+        }
+        int oab1 = on_above_or_below(he1.first, he2);
+        if(oab1 == 0 && between(he1.first, he2.first, he2.second)) return true; 
+        int oab2 = on_above_or_below(he1.second, he2);
+        if(oab2 == 0 && between(he1.second, he2.first, he2.second)) return true; 
+        if(oab1 == oab2 && oab1 != 0) return false; //both points of he1 are on same side of he2
+        int oab3 = on_above_or_below(he2.first, he1);
+        if(oab3 == 0 && between(he2.first, he1.first, he1.second)) return true; 
+        int oab4 = on_above_or_below(he2.second, he1);
+        if(oab4 == 0 && between(he2.second, he1.first, he1.second)) return true; 
+        if(oab3 == oab4) return false; //both points of he2 are on same side of he1
+        return true; //they must cross
+      }
+      if(is_vertical(he1) && is_vertical(he2) && he1.first.get(HORIZONTAL) == he2.first.get(HORIZONTAL))
+        return ::boost::polygon::intersects(rect1.get(VERTICAL), rect2.get(VERTICAL), false) &&
+          rect1.get(VERTICAL) != rect2.get(VERTICAL);
+      if(is_horizontal(he1) && is_horizontal(he2) && he1.first.get(VERTICAL) == he2.first.get(VERTICAL))
+        return ::boost::polygon::intersects(rect1.get(HORIZONTAL), rect2.get(HORIZONTAL), false) &&
+          rect1.get(HORIZONTAL) != rect2.get(HORIZONTAL);
+      return false;
+    }
+
+    class vertex_half_edge {
+    public:
+      typedef typename high_precision_type<Unit>::type high_precision;
+      Point pt;
+      Point other_pt; // 1, 0 or -1
+      int count; //dxdydTheta
+      inline vertex_half_edge() {}
+      inline vertex_half_edge(const Point& point, const Point& other_point, int countIn) : pt(point), other_pt(other_point), count(countIn) {}
+      inline vertex_half_edge(const vertex_half_edge& vertex) : pt(vertex.pt), other_pt(vertex.other_pt), count(vertex.count) {}
+      inline vertex_half_edge& operator=(const vertex_half_edge& vertex){ 
+        pt = vertex.pt; other_pt = vertex.other_pt; count = vertex.count; return *this; }
+      inline vertex_half_edge(const std::pair<Point, Point>& vertex) {}
+      inline vertex_half_edge& operator=(const std::pair<Point, Point>& vertex){ return *this; }
+      inline bool operator==(const vertex_half_edge& vertex) const {
+        return pt == vertex.pt && other_pt == vertex.other_pt && count == vertex.count; }
+      inline bool operator!=(const vertex_half_edge& vertex) const { return !((*this) == vertex); }
+      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
+      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
+      inline bool operator<(const vertex_half_edge& vertex) const {
+        if(pt.get(HORIZONTAL) < vertex.pt.get(HORIZONTAL)) return true;
+        if(pt.get(HORIZONTAL) == vertex.pt.get(HORIZONTAL)) {
+          if(pt.get(VERTICAL) < vertex.pt.get(VERTICAL)) return true;
+          if(pt.get(VERTICAL) == vertex.pt.get(VERTICAL)) { return less_slope(pt.get(HORIZONTAL), pt.get(VERTICAL),
+                                                                              other_pt, vertex.other_pt);
+          }
+        }
+        return false;
+      }
+      inline bool operator>(const vertex_half_edge& vertex) const { return vertex < (*this); }
+      inline bool operator<=(const vertex_half_edge& vertex) const { return !((*this) > vertex); }
+      inline bool operator>=(const vertex_half_edge& vertex) const { return !((*this) < vertex); }
+      inline high_precision evalAtX(Unit xIn) const { return evalAtXforY(xIn, pt, other_pt); }
+      inline bool is_vertical() const {
+        return pt.get(HORIZONTAL) == other_pt.get(HORIZONTAL);
+      }
+      inline bool is_begin() const {
+        return pt.get(HORIZONTAL) < other_pt.get(HORIZONTAL) ||
+          (pt.get(HORIZONTAL) == other_pt.get(HORIZONTAL) &&
+           (pt.get(VERTICAL) < other_pt.get(VERTICAL)));
+      }
+    };
+
+    //when scanning Vertex45 for polygon formation we need a scanline comparator functor
+    class less_vertex_half_edge : public std::binary_function<vertex_half_edge, vertex_half_edge, bool> {
+    private:
+      Unit *x_; //x value at which to apply comparison
+      int *justBefore_;
+    public:
+      inline less_vertex_half_edge() : x_(0), justBefore_(0) {}
+      inline less_vertex_half_edge(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
+      inline less_vertex_half_edge(const less_vertex_half_edge& that) : x_(that.x_), justBefore_(that.justBefore_) {}
+      inline less_vertex_half_edge& operator=(const less_vertex_half_edge& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
+      inline bool operator () (const vertex_half_edge& elm1, const vertex_half_edge& elm2) const {
+        typedef typename high_precision_type<Unit>::type high_precision;
+        high_precision y1 = elm1.evalAtX(*x_);
+        high_precision y2 = elm2.evalAtX(*x_);
+        if(y1 < y2) return true;
+        if(y1 == y2) {
+          //if justBefore is true we invert the result of the comparison of slopes
+          bool result = less_slope(elm1.other_pt.get(HORIZONTAL) - elm1.pt.get(HORIZONTAL),
+                                   elm1.other_pt.get(VERTICAL) - elm1.pt.get(VERTICAL),
+                                   elm2.other_pt.get(HORIZONTAL) - elm2.pt.get(HORIZONTAL),
+                                   elm2.other_pt.get(VERTICAL) - elm2.pt.get(VERTICAL));
+          return (*justBefore_) ^ result;
+        }
+        return false;
+      }
+    };
+
+  };
+
+  template <typename Unit>
+  class polygon_arbitrary_formation : public scanline_base<Unit> {
+  public:
+    typedef typename scanline_base<Unit>::Point Point;
+    typedef typename scanline_base<Unit>::half_edge half_edge;
+    typedef typename scanline_base<Unit>::vertex_half_edge vertex_half_edge;
+    typedef typename scanline_base<Unit>::less_vertex_half_edge less_vertex_half_edge;
+    
+    class poly_line_arbitrary {
+    public:
+      typedef typename std::list<Point>::const_iterator iterator;
+
+      // default constructor of point does not initialize x and y
+      inline poly_line_arbitrary() : points() {} //do nothing default constructor
+
+      // initialize a polygon from x,y values, it is assumed that the first is an x
+      // and that the input is a well behaved polygon
+      template<class iT>
+      inline poly_line_arbitrary& set(iT inputBegin, iT inputEnd) {
+        points.clear();  //just in case there was some old data there
+        while(inputBegin != inputEnd) {
+          points.insert(points.end(), *inputBegin);
+          ++inputBegin;
+        }
+        return *this;
+      }
+
+      // copy constructor (since we have dynamic memory)
+      inline poly_line_arbitrary(const poly_line_arbitrary& that) : points(that.points) {}
+  
+      // assignment operator (since we have dynamic memory do a deep copy)
+      inline poly_line_arbitrary& operator=(const poly_line_arbitrary& that) {
+        points = that.points;
+        return *this;
+      }
+
+      // get begin iterator, returns a pointer to a const Unit
+      inline iterator begin() const { return points.begin(); }
+
+      // get end iterator, returns a pointer to a const Unit
+      inline iterator end() const { return points.end(); }
+
+      inline std::size_t size() const { return points.size(); }
+
+      //public data member
+      std::list<Point> points; 
+    };
+
+    class active_tail_arbitrary {
+    private:
+      //data
+      poly_line_arbitrary* tailp_; 
+      active_tail_arbitrary *otherTailp_;
+      std::list<active_tail_arbitrary*> holesList_;
+      bool head_;
+    public:
+   
+      /**
+       * @brief iterator over coordinates of the figure
+       */
+      typedef typename poly_line_arbitrary::iterator iterator;
+   
+      /**
+       * @brief iterator over holes contained within the figure
+       */
+      typedef typename std::list<active_tail_arbitrary*>::const_iterator iteratorHoles;
+   
+      //default constructor
+      inline active_tail_arbitrary() : tailp_(), otherTailp_(), holesList_(), head_() {}
+   
+      //constructor
+      inline active_tail_arbitrary(const vertex_half_edge& vertex, active_tail_arbitrary* otherTailp = 0) : tailp_(), otherTailp_(), holesList_(), head_() {
+        tailp_ = new poly_line_arbitrary;
+        tailp_->points.push_back(vertex.pt);
+        bool headArray[4] = {false, true, true, true};
+        bool inverted = vertex.count == -1;
+        head_ = (!vertex.is_vertical) ^ inverted;
+        otherTailp_ = otherTailp;
+      }
+
+      inline active_tail_arbitrary(Point point, active_tail_arbitrary* otherTailp, bool head = true) :
+        tailp_(), otherTailp_(), holesList_(), head_() {
+        tailp_ = new poly_line_arbitrary;
+        tailp_->points.push_back(point);
+        head_ = head;
+        otherTailp_ = otherTailp;
+      
+      }
+      inline active_tail_arbitrary(active_tail_arbitrary* otherTailp) :
+        tailp_(), otherTailp_(), holesList_(), head_() {
+        tailp_ = otherTailp->tailp_;
+        otherTailp_ = otherTailp;
+      }
+
+      //copy constructor
+      inline active_tail_arbitrary(const active_tail_arbitrary& that) :
+        tailp_(), otherTailp_(), holesList_(), head_() { (*this) = that; }
+
+      //destructor
+      inline ~active_tail_arbitrary() {
+        destroyContents();
+      }
+
+      //assignment operator
+      inline active_tail_arbitrary& operator=(const active_tail_arbitrary& that) {
+        tailp_ = new poly_line_arbitrary(*(that.tailp_));
+        head_ = that.head_;
+        otherTailp_ = that.otherTailp_;
+        holesList_ = that.holesList_;
+        return *this;
+      }
+
+      //equivalence operator
+      inline bool operator==(const active_tail_arbitrary& b) const {
+        return tailp_ == b.tailp_ && head_ == b.head_;
+      }
+
+      /**
+       * @brief get the pointer to the polyline that this is an active tail of
+       */
+      inline poly_line_arbitrary* getTail() const { return tailp_; }
+
+      /**
+       * @brief get the pointer to the polyline at the other end of the chain
+       */
+      inline poly_line_arbitrary* getOtherTail() const { return otherTailp_->tailp_; }
+
+      /**
+       * @brief get the pointer to the activetail at the other end of the chain
+       */
+      inline active_tail_arbitrary* getOtherActiveTail() const { return otherTailp_; }
+   
+      /**
+       * @brief test if another active tail is the other end of the chain
+       */
+      inline bool isOtherTail(const active_tail_arbitrary& b) const { return &b == otherTailp_; }
+
+      /**
+       * @brief update this end of chain pointer to new polyline
+       */
+      inline active_tail_arbitrary& updateTail(poly_line_arbitrary* newTail) { tailp_ = newTail; return *this; }
+
+      inline bool join(active_tail_arbitrary* tail) {
+        if(tail == otherTailp_) {
+          //std::cout << "joining to other tail!\n";
+          return false;
+        }
+        if(tail->head_ == head_) {
+          //std::cout << "joining head to head!\n";
+          return false;
+        }
+        if(!tailp_) {
+          //std::cout << "joining empty tail!\n";
+          return false;
+        }
+        if(!(otherTailp_->head_)) {
+          otherTailp_->copyHoles(*tail);
+          otherTailp_->copyHoles(*this);
+        } else {
+          tail->otherTailp_->copyHoles(*this);
+          tail->otherTailp_->copyHoles(*tail);
+        }
+        poly_line_arbitrary* tail1 = tailp_;
+        poly_line_arbitrary* tail2 = tail->tailp_;
+        if(head_) std::swap(tail1, tail2);
+        typename std::list<point_data<Unit> >::reverse_iterator riter = tail1->points.rbegin();
+        typename std::list<point_data<Unit> >::iterator iter = tail2->points.begin();
+        if(*riter == *iter) {
+          tail1->points.pop_back(); //remove duplicate point
+        }
+        tail1->points.splice(tail1->points.end(), tail2->points);
+        delete tail2;
+        otherTailp_->tailp_ = tail1;
+        tail->otherTailp_->tailp_ = tail1;
+        otherTailp_->otherTailp_ = tail->otherTailp_;
+        tail->otherTailp_->otherTailp_ = otherTailp_;
+        tailp_ = 0;
+        tail->tailp_ = 0;
+        tail->otherTailp_ = 0;
+        otherTailp_ = 0;
+        return true;
+      }
+
+      /**
+       * @brief associate a hole to this active tail by the specified policy
+       */
+      inline active_tail_arbitrary* addHole(active_tail_arbitrary* hole) {
+        holesList_.push_back(hole);
+        copyHoles(*hole);
+        copyHoles(*(hole->otherTailp_));
+        return this;
+      }
+
+      /**
+       * @brief get the list of holes
+       */
+      inline const std::list<active_tail_arbitrary*>& getHoles() const { return holesList_; }
+
+      /**
+       * @brief copy holes from that to this
+       */
+      inline void copyHoles(active_tail_arbitrary& that) { holesList_.splice(holesList_.end(), that.holesList_); }
+
+      /**
+       * @brief find out if solid to right
+       */
+      inline bool solidToRight() const { return !head_; }
+      inline bool solidToLeft() const { return head_; }
+
+      /**
+       * @brief get vertex
+       */
+      inline Point getPoint() const {
+        if(head_) return tailp_->points.front();
+        return tailp_->points.back();
+      }
+
+      /**
+       * @brief add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
+       */
+      inline void pushPoint(Point point) {
+        if(head_) {
+          //if(tailp_->points.size() < 2) {
+          //   tailp_->points.push_front(point);
+          //   return;
+          //}
+          typename std::list<Point>::iterator iter = tailp_->points.begin();
+          if(iter == tailp_->points.end()) {
+            tailp_->points.push_front(point);
+            return;
+          }
+          ++iter;
+          if(iter == tailp_->points.end()) {
+            tailp_->points.push_front(point);
+            return;
+          }
+          --iter;
+          if(*iter != point) {
+            tailp_->points.push_front(point);
+          }
+          return;
+        }
+        //if(tailp_->points.size() < 2) {
+        //   tailp_->points.push_back(point);
+        //   return;
+        //}
+        typename std::list<Point>::reverse_iterator iter = tailp_->points.rbegin();
+        if(iter == tailp_->points.rend()) {
+          tailp_->points.push_back(point);
+          return;
+        }
+        ++iter;
+        if(iter == tailp_->points.rend()) {
+          tailp_->points.push_back(point);
+          return;
+        }
+        --iter;
+        if(*iter != point) {
+          tailp_->points.push_back(point);
+        }
+      }
+
+      /**
+       * @brief joins the two chains that the two active tail tails are ends of
+       * checks for closure of figure and writes out polygons appropriately
+       * returns a handle to a hole if one is closed
+       */
+      template <class cT>
+      static inline active_tail_arbitrary* joinChains(Point point, active_tail_arbitrary* at1, active_tail_arbitrary* at2, bool solid, 
+                                                      cT& output) {
+        if(at1->otherTailp_ == at2) {
+          //if(at2->otherTailp_ != at1) std::cout << "half closed error\n";
+          //we are closing a figure
+          at1->pushPoint(point);
+          at2->pushPoint(point);
+          if(solid) {
+            //we are closing a solid figure, write to output
+            //std::cout << "test1\n";
+            at1->copyHoles(*(at1->otherTailp_));
+            typename PolyLineArbitraryByConcept<Unit, typename geometry_concept<typename cT::value_type>::type>::type polyData(at1);
+            //poly_line_arbitrary_polygon_data polyData(at1);
+            //std::cout << "test2\n";
+            //std::cout << poly << std::endl;
+            //std::cout << "test3\n";
+            typedef typename cT::value_type result_type;
+            typedef typename geometry_concept<result_type>::type result_concept;
+            output.push_back(result_type());
+            assign(output.back(), polyData);
+            //std::cout << "test4\n";
+            //std::cout << "delete " << at1->otherTailp_ << std::endl;
+            //at1->print();
+            //at1->otherTailp_->print();
+            delete at1->otherTailp_;
+            //at1->print();
+            //at1->otherTailp_->print();
+            //std::cout << "test5\n";
+            //std::cout << "delete " << at1 << std::endl;
+            delete at1;
+            //std::cout << "test6\n";
+            return 0;
+          } else {
+            //we are closing a hole, return the tail end active tail of the figure
+            return at1;
+          }
+        }
+        //we are not closing a figure
+        at1->pushPoint(point);
+        at1->join(at2);
+        delete at1;
+        delete at2;
+        return 0;
+      }
+
+      inline void destroyContents() {
+        if(otherTailp_) {
+          //std::cout << "delete p " << tailp_ << std::endl;
+          if(tailp_) delete tailp_;
+          tailp_ = 0;
+          otherTailp_->otherTailp_ = 0;
+          otherTailp_->tailp_ = 0;
+          otherTailp_ = 0;
+        }
+        for(typename std::list<active_tail_arbitrary*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
+          //std::cout << "delete p " << (*itr) << std::endl;
+          if(*itr) {
+            if((*itr)->otherTailp_) {
+              delete (*itr)->otherTailp_;
+              (*itr)->otherTailp_ = 0;
+            }
+            delete (*itr);
+          }
+          (*itr) = 0;
+        }
+        holesList_.clear();
+      }
+
+      inline void print() {
+        std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
+      }
+
+      static inline std::pair<active_tail_arbitrary*, active_tail_arbitrary*> createActiveTailsAsPair(Point point, bool solid, 
+                                                                                                      active_tail_arbitrary* phole, bool fractureHoles) {
+        active_tail_arbitrary* at1 = 0;
+        active_tail_arbitrary* at2 = 0;
+        if(phole && fractureHoles) {
+          //std::cout << "adding hole\n";
+          at1 = phole;
+          //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
+          at2 = at1->getOtherActiveTail();
+          at2->pushPoint(point);
+          at1->pushPoint(point);
+        } else {
+          at1 = new active_tail_arbitrary(point, at2, solid);
+          at2 = new active_tail_arbitrary(at1);
+          at1->otherTailp_ = at2;
+          at2->head_ = !solid;
+          if(phole) 
+            at2->addHole(phole); //assert fractureHoles == false
+        }
+        return std::pair<active_tail_arbitrary*, active_tail_arbitrary*>(at1, at2);
+      }
+
+    };
+
+
+    typedef std::vector<std::pair<Point, int> > vertex_arbitrary_count;
+
+    class less_half_edge_count : public std::binary_function<vertex_half_edge, vertex_half_edge, bool> {
+    private:
+      Point pt_;
+    public:
+      inline less_half_edge_count() : pt_() {}
+      inline less_half_edge_count(Point point) : pt_(point) {}
+      inline bool operator () (const std::pair<Point, int>& elm1, const std::pair<Point, int>& elm2) const {
+        return less_slope(pt_.get(HORIZONTAL), pt_.get(VERTICAL), elm1.first, elm2.first);
+      }
+    };
+
+    static inline void sort_vertex_arbitrary_count(vertex_arbitrary_count& count, const Point& pt) {
+      less_half_edge_count lfec(pt);
+      std::sort(count.begin(), count.end(), lfec);
+    }
+
+    typedef std::vector<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*> > incoming_count;
+
+    class less_incoming_count : public std::binary_function<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>, 
+                                                            std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>, bool> {
+    private:
+      Point pt_;
+    public:
+      inline less_incoming_count() : pt_() {}
+      inline less_incoming_count(Point point) : pt_(point) {}
+      inline bool operator () (const std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>& elm1, 
+                               const std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>& elm2) const {
+        Unit dx1 = elm1.first.first.first.get(HORIZONTAL) - elm1.first.first.second.get(HORIZONTAL);
+        Unit dx2 = elm2.first.first.first.get(HORIZONTAL) - elm2.first.first.second.get(HORIZONTAL);
+        Unit dy1 = elm1.first.first.first.get(VERTICAL) - elm1.first.first.second.get(VERTICAL);
+        Unit dy2 = elm2.first.first.first.get(VERTICAL) - elm2.first.first.second.get(VERTICAL);
+        return less_slope(dx1, dy1, dx2, dy2);
+      }
+    };
+
+    static inline void sort_incoming_count(incoming_count& count, const Point& pt) {
+      less_incoming_count lfec(pt);
+      std::sort(count.begin(), count.end(), lfec);
+    }
+
+    static inline void compact_vertex_arbitrary_count(const Point& pt, vertex_arbitrary_count &count) {
+      if(count.empty()) return;
+      vertex_arbitrary_count tmp;
+      tmp.reserve(count.size());
+      tmp.push_back(count[0]);
+      //merge duplicates
+      for(unsigned int i = 1; i < count.size(); ++i) {
+        if(!equal_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), tmp[i-1].first, count[i].first)) {
+          tmp.push_back(count[i]);
+        } else {
+          tmp.back().second += count[i].second;
+        }
+      }
+      count.clear();
+      count.swap(tmp);
+    }
+
+    // inline std::ostream& operator<< (std::ostream& o, const vertex_arbitrary_count& c) {
+//       for(unsinged int i = 0; i < c.size(); ++i) {
+//         o << c[i].first << " " << c[i].second << " ";
+//       }
+//       return o;
+//     }
+
+    class vertex_arbitrary_compact {
+    public:
+      Point pt;
+      vertex_arbitrary_count count;
+      inline vertex_arbitrary_compact() : pt(), count() {}
+      inline vertex_arbitrary_compact(const Point& point, const Point& other_point, int countIn) : pt(point), count() {
+        count.push_back(std::pair<Point, int>(other_point, countIn));
+      }
+      inline vertex_arbitrary_compact(const vertex_half_edge& vertex) : pt(vertex.pt), count() {
+        count.push_back(std::pair<Point, int>(vertex.other_pt, vertex.count));
+      }
+      inline vertex_arbitrary_compact(const vertex_arbitrary_compact& vertex) : pt(vertex.pt), count(vertex.count) {}
+      inline vertex_arbitrary_compact& operator=(const vertex_arbitrary_compact& vertex){ 
+        pt = vertex.pt; count = vertex.count; return *this; }
+      //inline vertex_arbitrary_compact(const std::pair<Point, Point>& vertex) {}
+      inline vertex_arbitrary_compact& operator=(const std::pair<Point, Point>& vertex){ return *this; }
+      inline bool operator==(const vertex_arbitrary_compact& vertex) const {
+        return pt == vertex.pt && count == vertex.count; }
+      inline bool operator!=(const vertex_arbitrary_compact& vertex) const { return !((*this) == vertex); }
+      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
+      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
+      inline bool operator<(const vertex_arbitrary_compact& vertex) const {
+        if(pt.get(HORIZONTAL) < vertex.pt.get(HORIZONTAL)) return true;
+        if(pt.get(HORIZONTAL) == vertex.pt.get(HORIZONTAL)) {
+          return pt.get(VERTICAL) < vertex.pt.get(VERTICAL);
+        }
+        return false;
+      }
+      inline bool operator>(const vertex_arbitrary_compact& vertex) const { return vertex < (*this); }
+      inline bool operator<=(const vertex_arbitrary_compact& vertex) const { return !((*this) > vertex); }
+      inline bool operator>=(const vertex_arbitrary_compact& vertex) const { return !((*this) < vertex); }
+      inline bool have_vertex_half_edge(int index) const { return count[index]; }
+      inline vertex_half_edge operator[](int index) const { return vertex_half_edge(pt, count[index]); }
+      };
+
+//     inline std::ostream& operator<< (std::ostream& o, const vertex_arbitrary_compact& c) {
+//       o << c.pt << ", " << c.count;
+//       return o;
+//     }
+
+  private:
+    //definitions
+    typedef std::map<vertex_half_edge, active_tail_arbitrary*, less_vertex_half_edge> scanline_data;
+    typedef typename scanline_data::iterator iterator;
+    typedef typename scanline_data::const_iterator const_iterator;
+   
+    //data
+    scanline_data scanData_;
+    Unit x_;
+    int justBefore_;
+    int fractureHoles_; 
+  public:
+    inline polygon_arbitrary_formation() : 
+      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) {
+      less_vertex_half_edge lessElm(&x_, &justBefore_);
+      scanData_ = scanline_data(lessElm);
+    }
+    inline polygon_arbitrary_formation(bool fractureHoles = false) : 
+      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(fractureHoles) {
+      less_vertex_half_edge lessElm(&x_, &justBefore_);
+      scanData_ = scanline_data(lessElm);
+    }
+    inline polygon_arbitrary_formation(const polygon_arbitrary_formation& that) : 
+      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) { (*this) = that; }
+    inline polygon_arbitrary_formation& operator=(const polygon_arbitrary_formation& that) {
+      x_ = that.x_;
+      justBefore_ = that.justBefore_;
+      fractureHoles_ = that.fractureHoles_;
+      less_vertex_half_edge lessElm(&x_, &justBefore_);
+      scanData_ = scanline_data(lessElm);
+      for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
+        scanData_.insert(scanData_.end(), *itr);
+      }
+      return *this;
+    }
+   
+    //cT is an output container of Polygon45 or Polygon45WithHoles
+    //iT is an iterator over vertex_half_edge elements
+    //inputBegin - inputEnd is a range of sorted iT that represents
+    //one or more scanline stops worth of data
+    template <class cT, class iT>
+    void scan(cT& output, iT inputBegin, iT inputEnd) {
+      //std::cout << "1\n";
+      while(inputBegin != inputEnd) {
+        //std::cout << "2\n";
+        x_ = (*inputBegin).pt.get(HORIZONTAL);
+        //std::cout << "SCAN FORMATION " << x_ << std::endl;
+        //std::cout << "x_ = " << x_ << std::endl;
+        //std::cout << "scan line size: " << scanData_.size() << std::endl;
+        inputBegin = processEvent_(output, inputBegin, inputEnd);
+      }
+      //std::cout << "scan line size: " << scanData_.size() << std::endl;
+    }
+
+  private:
+    //functions
+    template <class cT, class cT2>
+    inline std::pair<std::pair<Point, int>, active_tail_arbitrary*> processPoint_(cT& output, cT2& elements, Point point, 
+                                                                                  incoming_count& counts_from_scanline, vertex_arbitrary_count& incoming_count) { 
+      //std::cout << "\nAT POINT: " <<  point << std::endl;
+      //join any closing solid corners
+      std::vector<int> counts;
+      std::vector<int> incoming;
+      std::vector<active_tail_arbitrary*> tails;
+      counts.reserve(counts_from_scanline.size());
+      tails.reserve(counts_from_scanline.size());
+      incoming.reserve(incoming_count.size());
+      for(unsigned int i = 0; i < counts_from_scanline.size(); ++i) {
+        counts.push_back(counts_from_scanline[i].first.second);
+        tails.push_back(counts_from_scanline[i].second);
+      }
+      for(unsigned int i = 0; i < incoming_count.size(); ++i) {
+        incoming.push_back(incoming_count[i].second);
+        if(incoming_count[i].first < point) {
+          incoming.back() = 0;
+        }
+      }
+        
+      active_tail_arbitrary* returnValue = 0;
+      std::pair<Point, int> returnCount(Point(0, 0), 0);
+      int i_size_less_1 = (int)(incoming.size()) -1;
+      int c_size_less_1 = (int)(counts.size()) -1;
+      int i_size = incoming.size();
+      int c_size = counts.size();
+
+      bool have_vertical_tail_from_below = false;
+      if(c_size &&
+         is_vertical(counts_from_scanline.back().first.first)) {
+        have_vertical_tail_from_below = true;
+      }
+      //assert size = size_less_1 + 1
+      //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << std::endl;
+      //         for(unsigned int i = 0; i < counts.size(); ++i) {
+      //           std::cout << counts_from_scanline[i].first.first.first.get(HORIZONTAL) << ",";
+      //           std::cout << counts_from_scanline[i].first.first.first.get(VERTICAL) << " ";
+      //           std::cout << counts_from_scanline[i].first.first.second.get(HORIZONTAL) << ",";
+      //           std::cout << counts_from_scanline[i].first.first.second.get(VERTICAL) << ":";
+      //           std::cout << counts_from_scanline[i].first.second << " ";
+      //         } std::cout << std::endl;
+      //         print(incoming_count);
+      {
+        for(int i = 0; i < c_size_less_1; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] == -1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < c_size; ++j) {
+              //std::cout << j << std::endl;
+              if(counts[j]) {
+                if(counts[j] == 1) {
+                  //std::cout << "case1: " << i << " " << j << std::endl;
+                  //if a figure is closed it will be written out by this function to output
+                  active_tail_arbitrary::joinChains(point, tails[i], tails[j], true, output); 
+                  counts[i] = 0;
+                  counts[j] = 0;
+                  tails[i] = 0;
+                  tails[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+      }
+      //find any pairs of incoming edges that need to create pair for leading solid
+      //std::cout << "checking case2\n";
+      {
+        for(int i = 0; i < i_size_less_1; ++i) {
+          //std::cout << i << std::endl;
+          if(incoming[i] == 1) {
+            //std::cout << "fixed i\n";
+            for(int j = i + 1; j < i_size; ++j) {
+              //std::cout << j << std::endl;
+              if(incoming[j]) {
+                //std::cout << incoming[j] << std::endl;
+                if(incoming[j] == -1) {
+                  //std::cout << "case2: " << i << " " << j << std::endl;
+                  //std::cout << "creating active tail pair\n";
+                  std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair = 
+                    active_tail_arbitrary::createActiveTailsAsPair(point, true, 0, fractureHoles_);
+                  //tailPair.first->print();
+                  //tailPair.second->print();
+                  if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
+                    //vertical active tail becomes return value
+                    returnValue = tailPair.first;
+                    returnCount.first = point;
+                    returnCount.second = 1;
+                  } else {
+                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
+                    //std::cout << point << " " <<  incoming_count[j].first << std::endl;
+                    elements.push_back(std::pair<vertex_half_edge, 
+                                       active_tail_arbitrary*>(vertex_half_edge(point,
+                                                                                incoming_count[j].first, -1), tailPair.first));
+                  }
+                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
+                  //std::cout << point << " " <<  incoming_count[i].first << std::endl;
+                  elements.push_back(std::pair<vertex_half_edge, 
+                                     active_tail_arbitrary*>(vertex_half_edge(point,
+                                                                              incoming_count[i].first, 1), tailPair.second));
+                  incoming[i] = 0;
+                  incoming[j] = 0;
+                }
+                break;
+              }
+            }
+          }
+        }
+      }
+      //find any active tail that needs to pass through to an incoming edge
+      //we expect to find no more than two pass through
+
+      //find pass through with solid on top
+      {
+        //std::cout << "checking case 3\n";
+        for(int i = 0; i < c_size; ++i) {
+          //std::cout << i << std::endl;
+          if(counts[i] != 0) {
+            if(counts[i] == 1) {
+              //std::cout << "fixed i\n";
+              for(int j = i_size_less_1; j >= 0; --j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == 1) {
+                    //std::cout << "case3: " << i << " " << j << std::endl;
+                    //tails[i]->print();
+                    //pass through solid on top
+                    tails[i]->pushPoint(point);
+                    //std::cout << "after push\n";
+                    if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
+                      returnValue = tails[i];
+                      returnCount.first = point;
+                      returnCount.second = -1;
+                    } else {
+                      elements.push_back(std::pair<vertex_half_edge, 
+                                         active_tail_arbitrary*>(vertex_half_edge(point, 
+                                                                                  incoming_count[j].first, incoming[j]), tails[i]));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+      }
+      //std::cout << "checking case 4\n";
+      //find pass through with solid on bottom
+      {
+        for(int i = c_size_less_1; i >= 0; --i) {
+          //std::cout << "i = " << i << " with count " << counts[i] << std::endl;
+          if(counts[i] != 0) {
+            if(counts[i] == -1) {
+              for(int j = 0; j < i_size; ++j) {
+                if(incoming[j] != 0) {
+                  if(incoming[j] == -1) {
+                    //std::cout << "case4: " << i << " " << j << std::endl;
+                    //pass through solid on bottom
+                    tails[i]->pushPoint(point);
+                    if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
+                      returnValue = tails[i];
+                      returnCount.first = point;
+                      returnCount.second = 1;
+                    } else {
+                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                      //std::cout << point << " " <<  incoming_count[j].first << std::endl;
+                      elements.push_back(std::pair<vertex_half_edge,
+                                         active_tail_arbitrary*>(vertex_half_edge(point,
+                                                                                  incoming_count[j].first, incoming[j]), tails[i]));
+                    }
+                    tails[i] = 0;
+                    counts[i] = 0;
+                    incoming[j] = 0;
+                  }
+                  break;
+                }
+              }
+            }
+            break;
+          }
+        }
+      }
+      //find the end of a hole or the beginning of a hole
+
+      //find end of a hole
+      {
+        for(int i = 0; i < c_size_less_1; ++i) {
+          if(counts[i] != 0) {
+            for(int j = i+1; j < c_size; ++j) {
+              if(counts[j] != 0) {
+                //std::cout << "case5: " << i << " " << j << std::endl;
+                //we are ending a hole and may potentially close a figure and have to handle the hole
+                returnValue = active_tail_arbitrary::joinChains(point, tails[i], tails[j], false, output);
+                if(returnValue) returnCount.first = point;
+                //std::cout << returnValue << std::endl;
+                tails[i] = 0;
+                tails[j] = 0;
+                counts[i] = 0;
+                counts[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        } 
+      }
+      //find beginning of a hole
+      {
+        for(int i = 0; i < i_size_less_1; ++i) {
+          if(incoming[i] != 0) {
+            for(int j = i+1; j < i_size; ++j) {
+              if(incoming[j] != 0) {
+                //std::cout << "case6: " << i << " " << j << std::endl;
+                //we are beginning a empty space
+                active_tail_arbitrary* holep = 0;
+                //if(c_size && counts[c_size_less_1] == 0 && 
+                //   counts_from_scanline[c_size_less_1].first.first.first.get(HORIZONTAL) == point.get(HORIZONTAL)) 
+                if(have_vertical_tail_from_below) {
+                  holep = tails[c_size_less_1];
+                  tails[c_size_less_1] = 0;
+                  have_vertical_tail_from_below = false;
+                }
+                std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair = 
+                  active_tail_arbitrary::createActiveTailsAsPair(point, false, holep, fractureHoles_);
+                if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
+                  //std::cout << "vertical element " << point << std::endl;
+                  returnValue = tailPair.first;
+                  returnCount.first = point;
+                  //returnCount = incoming_count[j];
+                  returnCount.second = -1;
+                } else {
+                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
+                  //std::cout << point << " " <<  incoming_count[j].first << std::endl;
+                  elements.push_back(std::pair<vertex_half_edge, 
+                                     active_tail_arbitrary*>(vertex_half_edge(point,
+                                                                              incoming_count[j].first, incoming[j]), tailPair.first));
+                }
+                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
+                //std::cout << point << " " <<  incoming_count[i].first << std::endl;
+                elements.push_back(std::pair<vertex_half_edge, 
+                                   active_tail_arbitrary*>(vertex_half_edge(point,
+                                                                            incoming_count[i].first, incoming[i]), tailPair.second));
+                incoming[i] = 0;
+                incoming[j] = 0;
+                break;
+              }
+            }
+            break;
+          }
+        }
+      }
+      if(have_vertical_tail_from_below) {
+        if(tails.back()) {
+          tails.back()->pushPoint(point);
+          returnValue = tails.back();
+          returnCount.first = point;
+          returnCount.second = counts.back();
+        }
+      }
+      //assert that tails, counts and incoming are all null
+      return std::pair<std::pair<Point, int>, active_tail_arbitrary*>(returnCount, returnValue);
+    }
+
+    static inline void print(const vertex_arbitrary_count& count) {
+      for(unsigned i = 0; i < count.size(); ++i) {
+        std::cout << count[i].first.get(HORIZONTAL) << ",";
+        std::cout << count[i].first.get(VERTICAL) << ":";
+        std::cout << count[i].second << " ";
+      } std::cout << std::endl;
+    }
+
+    static inline void print(const scanline_data& data) {
+      for(typename scanline_data::const_iterator itr = data.begin(); itr != data.end(); ++itr){
+        std::cout << itr->first.pt << ", " << itr->first.other_pt << "; ";
+      } std::cout << std::endl;
+    }
+
+    template <class cT, class iT>
+    inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
+      typedef typename high_precision_type<Unit>::type high_precision;
+      //std::cout << "processEvent_\n";
+      justBefore_ = true;
+      //collect up all elements from the tree that are at the y
+      //values of events in the input queue
+      //create vector of new elements to add into tree
+      active_tail_arbitrary* verticalTail = 0;
+      std::pair<Point, int> verticalCount(Point(0, 0), 0);
+      iT currentIter = inputBegin;
+      std::vector<iterator> elementIters;
+      std::vector<std::pair<vertex_half_edge, active_tail_arbitrary*> > elements;
+      while(currentIter != inputEnd && currentIter->pt.get(HORIZONTAL) == x_) {
+        //std::cout << "loop\n";
+        Unit currentY = (*currentIter).pt.get(VERTICAL);
+        //std::cout << "current Y " << currentY << std::endl;
+        //std::cout << "scanline size " << scanData_.size() << std::endl;
+        //print(scanData_);
+        iterator iter = lookUp_(currentY);
+        //std::cout << "found element in scanline " << (iter != scanData_.end()) << std::endl;
+        //int counts[4] = {0, 0, 0, 0};
+        incoming_count counts_from_scanline;
+        //std::cout << "finding elements in tree\n";
+        //if(iter != scanData_.end())
+        //  std::cout << "first iter y is " << iter->first.evalAtX(x_) << std::endl;
+        while(iter != scanData_.end() &&
+              iter->first.evalAtX(x_) == (high_precision)currentY) {
+          //std::cout << "loop2\n";
+          elementIters.push_back(iter);
+          counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
+                                         (std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(iter->first.pt,
+                                                                                                          iter->first.other_pt), 
+                                                                                  iter->first.count),
+                                          iter->second));
+          ++iter;
+        }
+        Point currentPoint(x_, currentY);
+        //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << std::endl;
+        sort_incoming_count(counts_from_scanline, currentPoint);
+
+        vertex_arbitrary_count incoming;
+        //std::cout << "aggregating\n";
+        do {
+          //std::cout << "loop3\n";
+          const vertex_half_edge& elem = *currentIter;
+          incoming.push_back(std::pair<Point, int>(elem.other_pt, elem.count));
+          ++currentIter;
+        } while(currentIter != inputEnd && currentIter->pt.get(VERTICAL) == currentY &&
+                currentIter->pt.get(HORIZONTAL) == x_);
+        //print(incoming);
+        sort_vertex_arbitrary_count(incoming, currentPoint);
+        //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << std::endl;
+        //print(incoming);
+        //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+        //compact_vertex_arbitrary_count(currentPoint, incoming);
+        vertex_arbitrary_count tmp;
+        tmp.reserve(incoming.size());
+        for(unsigned int i = 0; i < incoming.size(); ++i) {
+          if(currentPoint < incoming[i].first) {
+            tmp.push_back(incoming[i]);
+          }
+        }
+        incoming.swap(tmp);
+        //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
+        //now counts_from_scanline has the data from the left and
+        //incoming has the data from the right at this point
+        //cancel out any end points
+        if(verticalTail) {
+          //std::cout << "adding vertical tail to counts from scanline\n";
+          //std::cout << -verticalCount.second << std::endl;
+          counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
+                                         (std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(verticalCount.first, 
+                                                                                                          currentPoint), 
+                                                                                  -verticalCount.second),
+                                          verticalTail));
+        }
+        if(!incoming.empty() && incoming.back().first.get(HORIZONTAL) == x_) {
+          //std::cout << "inverted vertical event\n";
+          incoming.back().second *= -1;
+        }
+        //std::cout << "calling processPoint_\n";
+        std::pair<std::pair<Point, int>, active_tail_arbitrary*> result = processPoint_(output, elements, Point(x_, currentY), counts_from_scanline, incoming);
+        verticalCount = result.first;
+        verticalTail = result.second;
+        //if(verticalTail) {
+        //  std::cout << "have vertical tail\n";
+        //  std::cout << verticalCount.second << std::endl;
+        //}
+        if(verticalTail && !(verticalCount.second)) {
+          //we got a hole out of the point we just processed
+          //iter is still at the next y element above the current y value in the tree
+          //std::cout << "checking whether ot handle hole\n";
+          if(currentIter == inputEnd || 
+             currentIter->pt.get(HORIZONTAL) != x_ ||
+             (high_precision)(currentIter->pt.get(VERTICAL)) >= iter->first.evalAtX(x_)) {
+            //std::cout << "handle hole here\n";
+            if(fractureHoles_) {
+              //std::cout << "fracture hole here\n";
+              //we need to handle the hole now and not at the next input vertex
+              active_tail_arbitrary* at = iter->second;
+              high_precision precise_y = iter->first.evalAtX(x_);
+              Unit fracture_y = (Unit)(precise_y);
+              if(precise_y < fracture_y) --fracture_y;
+              Point point(x_, fracture_y);
+              verticalTail->getOtherActiveTail()->pushPoint(point);
+              iter->second = verticalTail->getOtherActiveTail();
+              at->pushPoint(point);
+              verticalTail->join(at);
+              delete at;
+              delete verticalTail;
+              verticalTail = 0;
+            } else {
+              //std::cout << "push hole onto list\n";
+              iter->second->addHole(verticalTail);
+              verticalTail = 0;
+            }
+          }
+        }
+      }
+      //std::cout << "erasing\n";
+      //erase all elements from the tree
+      for(typename std::vector<iterator>::iterator iter = elementIters.begin();
+          iter != elementIters.end(); ++iter) {
+        //std::cout << "erasing loop\n";
+        scanData_.erase(*iter);
+      }
+      //switch comparison tie breaking policy
+      justBefore_ = false;
+      //add new elements into tree
+      //std::cout << "inserting\n";
+      for(typename std::vector<std::pair<vertex_half_edge, active_tail_arbitrary*> >::iterator iter = elements.begin();
+          iter != elements.end(); ++iter) {
+        //std::cout << "inserting loop\n";
+        scanData_.insert(scanData_.end(), *iter);
+      }
+      //std::cout << "end processEvent\n";
+      return currentIter;
+    }
+   
+    inline iterator lookUp_(Unit y){
+      //if just before then we need to look from 1 not -1
+      //std::cout << "just before " << justBefore_ << std::endl;
+      return scanData_.lower_bound(vertex_half_edge(Point(x_, y), Point(x_, y+1), 0));
+    }
+      
+  public: //test functions
+      
+    static inline bool testPolygonArbitraryFormationRect() {
+      std::cout << "testing polygon formation\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(10, 10), -1));
+      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationP1() {
+      std::cout << "testing polygon formation P1\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 10), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(10, 20), -1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1));
+      data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1));
+      data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationP2() {
+      std::cout << "testing polygon formation P2\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(-3, 1), Point(2, -4), 1));
+      data.push_back(vertex_half_edge(Point(-3, 1), Point(-2, 2), -1));
+      data.push_back(vertex_half_edge(Point(-2, 2), Point(2, 4), -1));
+      data.push_back(vertex_half_edge(Point(-2, 2), Point(-3, 1), 1));
+      data.push_back(vertex_half_edge(Point(2, -4), Point(-3, 1), -1));
+      data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1));
+      data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1));
+      data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+
+    static inline bool testPolygonArbitraryFormationPolys() {
+      std::cout << "testing polygon formation polys\n";
+      polygon_arbitrary_formation pf(false);
+      std::vector<polygon_with_holes_data<Unit> > polys;
+      polygon_arbitrary_formation pf2(true);
+      std::vector<polygon_with_holes_data<Unit> > polys2;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(100, 1), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(1, 100), -1));
+      data.push_back(vertex_half_edge(Point(1, 100), Point(0, 0), 1));
+      data.push_back(vertex_half_edge(Point(1, 100), Point(101, 101), -1));
+      data.push_back(vertex_half_edge(Point(100, 1), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(100, 1), Point(101, 101), 1));
+      data.push_back(vertex_half_edge(Point(101, 101), Point(100, 1), -1));
+      data.push_back(vertex_half_edge(Point(101, 101), Point(1, 100), 1));
+
+      data.push_back(vertex_half_edge(Point(2, 2), Point(10, 2), -1));
+      data.push_back(vertex_half_edge(Point(2, 2), Point(2, 10), -1));
+      data.push_back(vertex_half_edge(Point(2, 10), Point(2, 2), 1));
+      data.push_back(vertex_half_edge(Point(2, 10), Point(10, 10), 1));
+      data.push_back(vertex_half_edge(Point(10, 2), Point(2, 2), 1));
+      data.push_back(vertex_half_edge(Point(10, 2), Point(10, 10), 1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 2), -1));
+      data.push_back(vertex_half_edge(Point(10, 10), Point(2, 10), -1));
+
+      data.push_back(vertex_half_edge(Point(2, 12), Point(10, 12), -1));
+      data.push_back(vertex_half_edge(Point(2, 12), Point(2, 22), -1));
+      data.push_back(vertex_half_edge(Point(2, 22), Point(2, 12), 1));
+      data.push_back(vertex_half_edge(Point(2, 22), Point(10, 22), 1));
+      data.push_back(vertex_half_edge(Point(10, 12), Point(2, 12), 1));
+      data.push_back(vertex_half_edge(Point(10, 12), Point(10, 22), 1));
+      data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1));
+      data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1));
+
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      pf2.scan(polys2, data.begin(), data.end());
+      std::cout << "result size: " << polys2.size() << std::endl;
+      for(unsigned int i = 0; i < polys2.size(); ++i) {
+        std::cout << polys2[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationSelfTouch1() {
+      std::cout << "testing polygon formation self touch 1\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
+
+      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(5, 10), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
+
+      data.push_back(vertex_half_edge(Point(5, 10), Point(5, 5), 1));
+      data.push_back(vertex_half_edge(Point(5, 10), Point(0, 10), 1));
+      
+      data.push_back(vertex_half_edge(Point(5, 2), Point(5, 5), -1));
+      data.push_back(vertex_half_edge(Point(5, 2), Point(7, 2), -1));
+      
+      data.push_back(vertex_half_edge(Point(5, 5), Point(5, 10), -1));
+      data.push_back(vertex_half_edge(Point(5, 5), Point(5, 2), 1));
+      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
+      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
+      
+      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
+      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1));
+      
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationSelfTouch2() {
+      std::cout << "testing polygon formation self touch 2\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
+
+      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(5, 10), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
+
+      data.push_back(vertex_half_edge(Point(5, 10), Point(4, 1), -1));
+      data.push_back(vertex_half_edge(Point(5, 10), Point(0, 10), 1));
+      
+      data.push_back(vertex_half_edge(Point(4, 1), Point(5, 10), 1));
+      data.push_back(vertex_half_edge(Point(4, 1), Point(7, 2), -1));
+      
+      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
+      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
+      
+      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
+      data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
+      
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationSelfTouch3() {
+      std::cout << "testing polygon formation self touch 3\n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
+
+      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(0, 10), Point(6, 10), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
+      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
+
+      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
+      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
+
+      data.push_back(vertex_half_edge(Point(6, 10), Point(4, 1), -1));
+      data.push_back(vertex_half_edge(Point(6, 10), Point(0, 10), 1));
+      
+      data.push_back(vertex_half_edge(Point(4, 1), Point(6, 10), 1));
+      data.push_back(vertex_half_edge(Point(4, 1), Point(7, 2), -1));
+      
+      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
+      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
+      
+      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
+      data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
+      
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testPolygonArbitraryFormationColinear() {
+      std::cout << "testing polygon formation colinear 3\n";
+      std::cout << "Polygon Set Data { <-3 2, -2 2>:1 <-3 2, -1 4>:-1 <-2 2, 0 2>:1 <-1 4, 0 2>:-1 } \n";
+      polygon_arbitrary_formation pf(true);
+      std::vector<polygon_data<Unit> > polys;
+      std::vector<vertex_half_edge> data;
+      data.push_back(vertex_half_edge(Point(-3, 2), Point(-2, 2), 1));
+      data.push_back(vertex_half_edge(Point(-2, 2), Point(-3, 2), -1));
+
+      data.push_back(vertex_half_edge(Point(-3, 2), Point(-1, 4), -1));
+      data.push_back(vertex_half_edge(Point(-1, 4), Point(-3, 2), 1));
+
+      data.push_back(vertex_half_edge(Point(-2, 2), Point(0, 2), 1));
+      data.push_back(vertex_half_edge(Point(0, 2), Point(-2, 2), -1));
+
+      data.push_back(vertex_half_edge(Point(-1, 4), Point(0, 2), -1));
+      data.push_back(vertex_half_edge(Point(0, 2), Point(-1, 4), 1));
+      std::sort(data.begin(), data.end());
+      pf.scan(polys, data.begin(), data.end());
+      std::cout << "result size: " << polys.size() << std::endl;
+      for(unsigned int i = 0; i < polys.size(); ++i) {
+        std::cout << polys[i] << std::endl;
+      }
+      std::cout << "done testing polygon formation\n";
+      return true;
+    }
+
+    static inline bool testSegmentIntersection() {
+      std::cout << "testing segment intersection\n";
+      half_edge he1, he2;
+      he1.first = Point(0, 0);
+      he1.second = Point(10, 10);
+      he2.first = Point(0, 0);
+      he2.second = Point(10, 20);
+      Point result;
+      bool b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(0, 0)) return false;
+      he1.first = Point(0, 10);
+      b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(5, 10)) return false;
+      he1.first = Point(0, 11);
+      b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(5, 10)) return false;
+      he1.first = Point(0, 0);
+      he1.second = Point(1, 9);
+      he2.first = Point(0, 9);
+      he2.second = Point(1, 0);
+      b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(0, 4)) return false;
+
+      he1.first = Point(0, -10);
+      he1.second = Point(1, -1);
+      he2.first = Point(0, -1);
+      he2.second = Point(1, -10);
+      b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(0, -5)) return false;
+      he1.first = Point((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)()-1);
+      he1.second = Point((std::numeric_limits<int>::min)(), (std::numeric_limits<int>::max)());
+      //he1.second = Point(0, (std::numeric_limits<int>::max)());
+      he2.first = Point((std::numeric_limits<int>::max)()-1, (std::numeric_limits<int>::max)());
+      he2.second = Point((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::min)());
+      //he2.second = Point((std::numeric_limits<int>::max)(), 0);
+      b = compute_intersection(result, he1, he2);
+      //b is false because of overflow error
+      he1.first = Point(1000, 2000);
+      he1.second = Point(1010, 2010);
+      he2.first = Point(1000, 2000);
+      he2.second = Point(1010, 2020);
+      b = compute_intersection(result, he1, he2);
+      if(!b || result != Point(1000, 2000)) return false;
+
+      return b;
+    }
+  
+  };
+
+  template <typename Unit>
+  class poly_line_arbitrary_hole_data {
+  private:
+    typedef typename polygon_arbitrary_formation<Unit>::active_tail_arbitrary active_tail_arbitrary;
+    active_tail_arbitrary* p_;
+  public:
+    typedef point_data<Unit> Point;
+    typedef Point point_type;
+    typedef Unit coordinate_type;
+    typedef typename active_tail_arbitrary::iterator iterator_type;
+    //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
+    
+    typedef iterator_type iterator;
+    inline poly_line_arbitrary_hole_data() : p_(0) {}
+    inline poly_line_arbitrary_hole_data(active_tail_arbitrary* p) : p_(p) {}
+    //use default copy and assign
+    inline iterator begin() const { return p_->getTail()->begin(); }
+    inline iterator end() const { return p_->getTail()->end(); }
+    //inline compact_iterator_type begin_compact() const { return compact_iterator_type(begin()); }
+    //inline compact_iterator_type end_compact() const { return compact_iterator_type(end()); }
+    inline unsigned int size() const { return 0; }
+    template<class iT>
+    inline poly_line_arbitrary_hole_data& set(iT inputBegin, iT inputEnd) {
+      //assert this is not called
+      return *this;
+    }
+    template<class iT>
+    inline poly_line_arbitrary_hole_data& set_compact(iT inputBegin, iT inputEnd) {
+      //assert this is not called
+      return *this;
+    }
+  };
+
+  template <typename Unit>
+  class poly_line_arbitrary_polygon_data {
+  private:
+    typedef typename polygon_arbitrary_formation<Unit>::active_tail_arbitrary active_tail_arbitrary;
+    active_tail_arbitrary* p_;
+  public:
+    typedef point_data<Unit> Point;
+    typedef Point point_type;
+    typedef Unit coordinate_type;
+    typedef typename active_tail_arbitrary::iterator iterator_type;
+    //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
+    typedef typename coordinate_traits<Unit>::coordinate_distance area_type;
+
+    class iterator_holes_type {
+    private:
+      typedef poly_line_arbitrary_hole_data<Unit> holeType;
+      mutable holeType hole_;
+      typename active_tail_arbitrary::iteratorHoles itr_;
+        
+    public:
+      typedef std::forward_iterator_tag iterator_category;
+      typedef holeType value_type;
+      typedef std::ptrdiff_t difference_type;
+      typedef const holeType* pointer; //immutable
+      typedef const holeType& reference; //immutable
+      inline iterator_holes_type() : hole_(), itr_() {}
+      inline iterator_holes_type(typename active_tail_arbitrary::iteratorHoles itr) : hole_(), itr_(itr) {}
+      inline iterator_holes_type(const iterator_holes_type& that) : hole_(that.hole_), itr_(that.itr_) {} 
+      inline iterator_holes_type& operator=(const iterator_holes_type& that) {
+        itr_ = that.itr_;
+        return *this;
+      }
+      inline bool operator==(const iterator_holes_type& that) { return itr_ == that.itr_; }
+      inline bool operator!=(const iterator_holes_type& that) { return itr_ != that.itr_; }
+      inline iterator_holes_type& operator++() {
+        ++itr_;
+        return *this;
+      }
+      inline const iterator_holes_type operator++(int) {
+        iterator_holes_type tmp = *this;
+        ++(*this);
+        return tmp;
+      }
+      inline reference operator*() {
+        hole_ = holeType(*itr_);
+        return hole_;
+      }
+    };
+
+    typedef poly_line_arbitrary_hole_data<Unit> hole_type;
+
+    inline poly_line_arbitrary_polygon_data() : p_(0) {}
+    inline poly_line_arbitrary_polygon_data(active_tail_arbitrary* p) : p_(p) {}
+    //use default copy and assign
+    inline iterator_type begin() const { return p_->getTail()->begin(); }
+    inline iterator_type end() const { return p_->getTail()->end(); }
+    //inline compact_iterator_type begin_compact() const { return p_->getTail()->begin(); }
+    //inline compact_iterator_type end_compact() const { return p_->getTail()->end(); }
+    inline iterator_holes_type begin_holes() const { return iterator_holes_type(p_->getHoles().begin()); }
+    inline iterator_holes_type end_holes() const { return iterator_holes_type(p_->getHoles().end()); }
+    inline active_tail_arbitrary* yield() { return p_; }
+    //stub out these four required functions that will not be used but are needed for the interface
+    inline unsigned int size_holes() const { return 0; }
+    inline unsigned int size() const { return 0; }
+    template<class iT>
+    inline poly_line_arbitrary_polygon_data& set(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+    template<class iT>
+    inline poly_line_arbitrary_polygon_data& set_compact(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+    template<class iT>
+    inline poly_line_arbitrary_polygon_data& set_holes(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+  };
+    
+  template <typename T>
+  struct PolyLineArbitraryByConcept<T, polygon_with_holes_concept> { typedef poly_line_arbitrary_polygon_data<T> type; };
+  template <typename T>
+  struct PolyLineArbitraryByConcept<T, polygon_concept> { typedef poly_line_arbitrary_hole_data<T> type; };
+
+  template <typename T>
+  struct geometry_concept<poly_line_arbitrary_polygon_data<T> > { typedef polygon_45_with_holes_concept type; };
+  template <typename T>
+  struct geometry_concept<poly_line_arbitrary_hole_data<T> > { typedef polygon_45_concept type; };
+}
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/polygon_formation.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,1807 @@
+/*
+    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_POLYGON_FORMATION_HPP
+#define BOOST_POLYGON_POLYGON_FORMATION_HPP
+namespace boost { namespace polygon{
+
+namespace polygon_formation {
+
+  /*
+   * End has two states, HEAD and TAIL as is represented by a bool
+   */
+  typedef bool End;
+
+  /*
+   * HEAD End is represented as false because it is the lesser state
+   */
+  const End HEAD = false;
+
+  /*
+   * TAIL End is represented by true because TAIL comes after head and 1 after 0
+   */
+  const End TAIL = true;
+   
+  /*
+   * 2D turning direction, left and right sides (is a boolean value since it has two states.)
+   */
+  typedef bool Side;
+   
+  /*
+   * LEFT Side is 0 because we inuitively think left to right; left < right
+   */
+  const Side LEFT = false;
+   
+  /*
+   * RIGHT Side is 1 so that right > left
+   */
+  const Side RIGHT = true;
+
+  /*
+   * The PolyLine class is data storage and services for building and representing partial polygons.  
+   * As the polyline is added to it extends its storage to accomodate the data.
+   * PolyLines can be joined head-to-head/head-to-tail when it is determined that two polylines are
+   * part of the same polygon.
+   * PolyLines keep state information about what orientation their incomplete head and tail geometry have,
+   * which side of the polyline is solid and whether the polyline is joined head-to-head and tail-to-head.
+   * PolyLines have nothing whatsoever to do with holes.
+   * It may be valuable to collect a histogram of PolyLine lengths used by an algorithm on its typical data
+   * sets and tune the allocation of the initial vector of coordinate data to be greater than or equal to
+   * the mean, median, mode, or mean plus some number of standard deviation, or just generally large enough
+   * to prevent too much unnecesary reallocations, but not too big that it wastes a lot of memory and degrades cache
+   * performance.
+   */
+  template <typename Unit>
+  class PolyLine {
+  private:
+    //data
+     
+    /*
+     * ptdata_ a vector of coordiantes
+     * if VERTICAL_HEAD, first coordiante is an X
+     * else first coordinate is a Y
+     */
+    std::vector<Unit> ptdata_;
+   
+    /*
+     * head and tail points to other polylines before and after this in a chain
+     */
+    PolyLine* headp_;
+    PolyLine* tailp_;
+   
+    /*
+     * state bitmask
+     * bit zero is orientation, 0 H, 1 V
+     * bit 1 is head connectivity, 0 for head, 1 for tail
+     * bit 2 is tail connectivity, 0 for head, 1 for tail
+     * bit 3 is solid to left of PolyLine when 1, right when 0
+     */
+    int state_;
+   
+  public:
+    /*
+     * default constructor (for preallocation)
+     */
+    PolyLine();
+   
+    /*
+     * constructor that takes the orientation, coordiante and side to which there is solid
+     */
+    PolyLine(orientation_2d orient, Unit coord, Side side);
+   
+    //copy constructor
+    PolyLine(const PolyLine& pline);
+   
+    //destructor
+    ~PolyLine();
+   
+    //assignment operator
+    PolyLine& operator=(const PolyLine& that);
+
+    //equivalence operator
+    bool operator==(const PolyLine& b) const;
+
+    /*
+     * valid PolyLine (only default constructed polylines are invalid.)
+     */
+    bool isValid() const;
+
+    /*
+     * Orientation of Head
+     */
+    orientation_2d headOrient() const;
+
+    /*
+     * returns true if first coordinate is an X value (first segment is vertical)
+     */
+    bool verticalHead() const; 
+
+    /*
+     * returns the orientation_2d fo the tail
+     */
+    orientation_2d tailOrient() const;
+      
+    /*
+     * returns true if last coordinate is an X value (last segment is vertical)
+     */
+    bool verticalTail() const;
+     
+    /*
+     * retrun true if PolyLine has odd number of coordiantes
+     */
+    bool oddLength() const;
+
+    /*
+     * retrun the End of the other polyline that the specified end of this polyline is connected to
+     */
+    End endConnectivity(End end) const;
+
+    /*
+     * retrun true if the head of this polyline is connect to the tail of a polyline
+     */
+    bool headToTail() const;
+    /*
+     * retrun true if the head of this polyline is connect to the head of a polyline
+     */
+    bool headToHead() const;
+
+    /*
+     * retrun true if the tail of this polyline is connect to the tail of a polyline
+     */
+    bool tailToTail() const;
+    /*
+     * retrun true if the tail of this polyline is connect to the head of a polyline
+     */
+    bool tailToHead() const;
+     
+    /*
+     * retrun the side on which there is solid for this polyline
+     */
+    Side solidSide() const;
+
+    /*
+     * retrun true if there is solid to the right of this polyline
+     */
+    bool solidToRight() const;
+
+    /*
+     * returns true if the polyline tail is not connected
+     */
+    bool active() const;
+
+    /*
+     * adds a coordinate value to the end of the polyline changing the tail orientation
+     */
+    PolyLine& pushCoordinate(Unit coord);
+       
+    /*
+     * removes a coordinate value at the end of the polyline changing the tail orientation
+     */
+    PolyLine& popCoordinate();
+      
+    /*
+     * extends the tail of the polyline to include the point, changing orientation if needed
+     */
+    PolyLine& pushPoint(const point_data<Unit>& point);
+
+    /*
+     * changes the last coordinate of the tail of the polyline by the amount of the delta
+     */
+    PolyLine& extendTail(Unit delta);
+
+    /*
+     * join thisEnd of this polyline to that polyline's end
+     */
+    PolyLine& joinTo(End thisEnd, PolyLine& that, End end);
+
+    /*
+     * join an end of this polyline to the tail of that polyline
+     */
+    PolyLine& joinToTail(PolyLine& that, End end);
+
+    /*
+     * join an end of this polyline to the head of that polyline
+     */
+    PolyLine& joinToHead(PolyLine& that, End end);
+
+    /*
+     * join the head of this polyline to the head of that polyline
+     */
+    //join this to that in the given way
+    PolyLine& joinHeadToHead(PolyLine& that);
+
+    /*
+     * join the head of this polyline to the tail of that polyline
+     */
+    PolyLine& joinHeadToTail(PolyLine& that);
+
+    /*
+     * join the tail of this polyline to the head of that polyline
+     */
+    PolyLine& joinTailToHead(PolyLine& that);
+
+    /*
+     * join the tail of this polyline to the tail of that polyline
+     */
+    PolyLine& joinTailToTail(PolyLine& that);
+
+    /*
+     * dissconnect the tail at the end of the polygon
+     */
+    PolyLine& disconnectTails();
+
+    /*
+     * get the coordinate at one end of this polyline, by default the tail end
+     */
+    Unit getEndCoord(End end = TAIL) const;
+
+    /*
+     * get the point on the polyline at the given index (polylines have the same number of coordinates as points
+     */
+    point_data<Unit> getPoint(unsigned int index) const;
+
+    /*
+     * get the point on one end of the polyline, by default the tail
+     */
+    point_data<Unit> getEndPoint(End end = TAIL) const;
+
+    /*
+     * get the orientation of a segment by index
+     */
+    orientation_2d segmentOrient(unsigned int index = 0) const;
+
+    /*
+     * get a coordinate by index using the square bracket operator
+     */
+    Unit operator[] (unsigned int index) const;
+
+    /*
+     * get the number of segments/points/coordinates in the polyline
+     */
+    unsigned int numSegments() const;
+
+    /*
+     * get the pointer to the next polyline at one end of this
+     */
+    PolyLine* next(End end) const;
+
+    /*
+     * write out coordinates of this and all attached polylines to a single vector
+     */
+    PolyLine* writeOut(std::vector<Unit>& outVec, End startEnd = TAIL) const;
+
+  private:
+    //methods
+    PolyLine& joinTo_(End thisEnd, PolyLine& that, End end);
+  };
+
+  //forward declaration
+  template<bool orientT, typename Unit>
+  class PolyLinePolygonData;
+
+  //forward declaration
+  template<bool orientT, typename Unit>
+  class PolyLinePolygonWithHolesData;
+
+  /*
+   * ActiveTail represents an edge of an incomplete polygon.
+   *
+   * An ActiveTail object is the active tail end of a polyline object, which may (should) be the attached to
+   * a chain of polyline objects through a pointer.  The ActiveTail class provides an abstraction between
+   * and algorithm that builds polygons and the PolyLine data representation of incomplete polygons that are
+   * being built.  It does this by providing an iterface to access the information about the last edge at the
+   * tail of the PolyLine it is associated with.  To a polygon constructing algorithm, an ActiveTail is a floating
+   * edge of an incomplete polygon and has an orientation and coordinate value, as well as knowing which side of
+   * that edge is supposed to be solid or space.  Any incomplete polygon will have two active tails.  Active tails
+   * may be joined together to merge two incomplete polygons into a larger incomplete polygon.  If two active tails
+   * that are to be merged are the oppositve ends of the same incomplete polygon that indicates that the polygon
+   * has been closed and is complete.  The active tail keeps a pointer to the other active tail of its incomplete 
+   * polygon so that it is easy to check this condition.  These pointers are updated when active tails are joined.
+   * The active tail also keeps a list of pointers to active tail objects that serve as handles to closed holes.  In
+   * this way a hole can be associated to another incomplete polygon, which will eventually be its enclosing shell,
+   * or reassociate the hole to another incomplete polygon in the case that it become a hole itself.  Alternately,
+   * the active tail may add a filiment to stitch a hole into a shell and "fracture" the hole out of the interior
+   * of a polygon.  The active tail maintains a static output buffer to temporarily write polygon data to when
+   * it outputs a figure so that outputting a polygon does not require the allocation of a temporary buffer.  This
+   * static buffer should be destroyed whenever the program determines that it won't need it anymore and would prefer to
+   * release the memory it has allocated back to the system.
+   */
+  template <typename Unit>
+  class ActiveTail {
+  private:
+    //data
+    PolyLine<Unit>* tailp_; 
+    ActiveTail *otherTailp_;
+    std::list<ActiveTail*> holesList_;
+  public:
+
+    /*
+     * iterator over coordinates of the figure
+     */
+    class iterator {
+    private:
+      const PolyLine<Unit>* pLine_;
+      const PolyLine<Unit>* pLineEnd_;
+      unsigned int index_;
+      unsigned int indexEnd_;
+      End startEnd_;
+    public:
+      inline iterator() : pLine_(), pLineEnd_(), index_(), indexEnd_(), startEnd_() {}
+      inline iterator(const ActiveTail* at, bool isHole, orientation_2d orient) : 
+        pLine_(), pLineEnd_(), index_(), indexEnd_(), startEnd_() {
+        //if it is a hole and orientation is vertical or it is not a hole and orientation is horizontal
+        //we want to use this active tail, otherwise we want to use the other active tail
+        startEnd_ = TAIL;
+        if(!isHole ^ (orient == HORIZONTAL)) {
+          //switch winding direction
+          at = at->getOtherActiveTail();
+        }
+        //now we have the right winding direction
+        //if it is horizontal we need to skip the first element
+        pLine_ = at->getTail();
+        index_ = at->getTail()->numSegments() - 1;
+        if((at->getOrient() == HORIZONTAL) ^ (orient == HORIZONTAL)) {
+          pLineEnd_ = at->getTail();
+          indexEnd_ = pLineEnd_->numSegments() - 1;
+          if(index_ == 0) {
+            pLine_ = at->getTail()->next(HEAD);
+            if(at->getTail()->endConnectivity(HEAD) == TAIL) {
+              index_ = pLine_->numSegments() -1;
+            } else {
+              startEnd_ = HEAD;
+              index_ = 0;
+            }
+          } else { --index_; }
+        } else {
+          pLineEnd_ = at->getOtherActiveTail()->getTail();
+          indexEnd_ = pLineEnd_->numSegments() - 1;
+        }
+        at->getTail()->joinTailToTail(*(at->getOtherActiveTail()->getTail()));
+      }
+      //use bitwise copy and assign provided by the compiler
+      inline iterator& operator++() {
+        if(pLine_ == pLineEnd_ && index_ == indexEnd_) {
+          pLine_ = 0;
+          index_ = 0;
+          return *this;
+        }
+        if(startEnd_ == HEAD) {
+          ++index_;
+          if(index_ == pLine_->numSegments()) {
+            End end = pLine_->endConnectivity(TAIL);
+            pLine_ = pLine_->next(TAIL);
+            if(end == TAIL) {
+              startEnd_ = TAIL;
+              index_ = pLine_->numSegments() -1;
+            } else {
+              index_ = 0;
+            }
+          }
+        } else {
+          if(index_ == 0) {
+            End end = pLine_->endConnectivity(HEAD);
+            pLine_ = pLine_->next(HEAD);
+            if(end == TAIL) {
+              index_ = pLine_->numSegments() -1;
+            } else {
+              startEnd_ = HEAD;
+              index_ = 0;
+            }
+          } else {
+            --index_;
+          }
+        }
+        return *this;
+      }
+      inline const iterator operator++(int) {
+        iterator tmp(*this);
+        ++(*this);
+        return tmp;
+      }
+      inline bool operator==(const iterator& that) const {
+        return pLine_ == that.pLine_ && index_ == that.index_;
+      }
+      inline bool operator!=(const iterator& that) const {
+        return pLine_ != that.pLine_ || index_ != that.index_;
+      }
+      inline Unit operator*() { return (*pLine_)[index_]; }
+    };
+
+    /*
+     * iterator over holes contained within the figure
+     */
+    typedef typename std::list<ActiveTail*>::const_iterator iteratorHoles;
+
+    //default constructor
+    ActiveTail();
+
+    //constructor
+    ActiveTail(orientation_2d orient, Unit coord, Side solidToRight, ActiveTail* otherTailp);
+
+    //constructor
+    ActiveTail(PolyLine<Unit>* active, ActiveTail* otherTailp);
+
+    //copy constructor
+    ActiveTail(const ActiveTail& that);
+
+    //destructor
+    ~ActiveTail();
+
+    //assignment operator
+    ActiveTail& operator=(const ActiveTail& that);
+
+    //equivalence operator
+    bool operator==(const ActiveTail& b) const;
+
+    /*
+     * comparison operators, ActiveTail objects are sortable by geometry
+     */
+    bool operator<(const ActiveTail& b) const;
+    bool operator<=(const ActiveTail& b) const;
+    bool operator>(const ActiveTail& b) const;
+    bool operator>=(const ActiveTail& b) const;
+
+    /*
+     * get the pointer to the polyline that this is an active tail of
+     */
+    PolyLine<Unit>* getTail() const;
+
+    /*
+     * get the pointer to the polyline at the other end of the chain
+     */
+    PolyLine<Unit>* getOtherTail() const;
+
+    /*
+     * get the pointer to the activetail at the other end of the chain
+     */
+    ActiveTail* getOtherActiveTail() const;
+
+    /*
+     * test if another active tail is the other end of the chain
+     */
+    bool isOtherTail(const ActiveTail& b);
+
+    /*
+     * update this end of chain pointer to new polyline
+     */
+    ActiveTail& updateTail(PolyLine<Unit>* newTail);
+
+    /*
+     * associate a hole to this active tail by the specified policy
+     */
+    ActiveTail* addHole(ActiveTail* hole, bool fractureHoles);
+
+    /*
+     * get the list of holes
+     */
+    const std::list<ActiveTail*>& getHoles() const;
+
+    /*
+     * copy holes from that to this
+     */
+    void copyHoles(ActiveTail& that);
+
+    /*
+     * find out if solid to right
+     */
+    bool solidToRight() const;
+
+    /*
+     * get coordinate (getCoord and getCoordinate are aliases for eachother)
+     */
+    Unit getCoord() const;
+    Unit getCoordinate() const;
+
+    /*
+     * get the tail orientation
+     */
+    orientation_2d getOrient() const;
+
+    /*
+     * add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
+     */
+    void pushCoordinate(Unit coord);
+
+    /*
+     * write the figure that this active tail points to out to the temp buffer
+     */
+    void writeOutFigure(std::vector<Unit>& outVec, bool isHole = false) const;
+
+    /*
+     * write the figure that this active tail points to out through iterators
+     */
+    void writeOutFigureItrs(iterator& beginOut, iterator& endOut, bool isHole = false, orientation_2d orient = VERTICAL) const;
+    iterator begin(bool isHole, orientation_2d orient) const;
+    iterator end() const;
+
+    /*
+     * write the holes that this active tail points to out through iterators
+     */
+    void writeOutFigureHoleItrs(iteratorHoles& beginOut, iteratorHoles& endOut) const;
+    iteratorHoles beginHoles() const;
+    iteratorHoles endHoles() const;
+
+    /*
+     * joins the two chains that the two active tail tails are ends of
+     * checks for closure of figure and writes out polygons appropriately
+     * returns a handle to a hole if one is closed
+     */
+    static ActiveTail* joinChains(ActiveTail* at1, ActiveTail* at2, bool solid, std::vector<Unit>& outBufferTmp);
+    template <typename PolygonT>
+    static ActiveTail* joinChains(ActiveTail* at1, ActiveTail* at2, bool solid, typename std::vector<PolygonT>& outBufferTmp);
+
+    /*
+     * deallocate temp buffer
+     */
+    static void destroyOutBuffer();
+
+    /*
+     * deallocate all polygon data this active tail points to (deep delete, call only from one of a pair of active tails)
+     */
+    void destroyContents();
+  };
+
+  /* allocate a polyline object */
+  template <typename Unit>
+  PolyLine<Unit>* createPolyLine(orientation_2d orient, Unit coord, Side side);
+
+  /* deallocate a polyline object */
+  template <typename Unit>
+  void destroyPolyLine(PolyLine<Unit>* pLine);
+
+  /* allocate an activetail object */
+  template <typename Unit>
+  ActiveTail<Unit>* createActiveTail();
+
+  /* deallocate an activetail object */
+  template <typename Unit>
+  void destroyActiveTail(ActiveTail<Unit>* aTail);
+     
+  template<bool orientT, typename Unit>
+  class PolyLineHoleData {
+  private:
+    ActiveTail<Unit>* p_;
+  public:
+    typedef Unit coordinate_type;
+    typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
+    typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
+    inline PolyLineHoleData() : p_(0) {}
+    inline PolyLineHoleData(ActiveTail<Unit>* p) : p_(p) {}
+    //use default copy and assign
+    inline compact_iterator_type begin_compact() const { return p_->begin(true, (orientT ? VERTICAL : HORIZONTAL)); }
+    inline compact_iterator_type end_compact() const { return p_->end(); }
+    inline iterator_type begin() const { return iterator_type(begin_compact(), end_compact()); }
+    inline iterator_type end() const { return iterator_type(end_compact(), end_compact()); }
+    inline unsigned int size() const { return 0; }
+    inline ActiveTail<Unit>* yield() { return p_; }
+    template<class iT>
+    inline PolyLineHoleData& set(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+    template<class iT>
+    inline PolyLineHoleData& set_compact(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+   
+  };
+
+  template<bool orientT, typename Unit>
+  class PolyLinePolygonWithHolesData {
+  private:
+    ActiveTail<Unit>* p_;
+  public:
+    typedef Unit coordinate_type;
+    typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
+    typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
+    typedef PolyLineHoleData<orientT, Unit> hole_type;
+    typedef typename coordinate_traits<Unit>::area_type area_type;
+    class iteratorHoles {
+    private:
+      typename ActiveTail<Unit>::iteratorHoles itr_;
+    public:
+      inline iteratorHoles() : itr_() {}
+      inline iteratorHoles(typename ActiveTail<Unit>::iteratorHoles itr) : itr_(itr) {}
+      //use bitwise copy and assign provided by the compiler
+      inline iteratorHoles& operator++() {
+        ++itr_;
+        return *this;
+      }
+      inline const iteratorHoles operator++(int) {
+        iteratorHoles tmp(*this);
+        ++(*this);
+        return tmp;
+      }
+      inline bool operator==(const iteratorHoles& that) const {
+        return itr_ == that.itr_;
+      }
+      inline bool operator!=(const iteratorHoles& that) const {
+        return itr_ != that.itr_;
+      }
+      inline PolyLineHoleData<orientT, Unit> operator*() { return PolyLineHoleData<orientT, Unit>(*itr_);}
+    };
+    typedef iteratorHoles iterator_holes_type;
+
+    inline PolyLinePolygonWithHolesData() : p_(0) {}
+    inline PolyLinePolygonWithHolesData(ActiveTail<Unit>* p) : p_(p) {}
+    //use default copy and assign
+    inline compact_iterator_type begin_compact() const { return p_->begin(false, (orientT ? VERTICAL : HORIZONTAL)); }
+    inline compact_iterator_type end_compact() const { return p_->end(); }
+    inline iterator_type begin() const { return iterator_type(begin_compact(), end_compact()); }
+    inline iterator_type end() const { return iterator_type(end_compact(), end_compact()); }
+    inline iteratorHoles begin_holes() const { return iteratorHoles(p_->beginHoles()); }
+    inline iteratorHoles end_holes() const { return iteratorHoles(p_->endHoles()); }
+    inline ActiveTail<Unit>* yield() { return p_; }
+    //stub out these four required functions that will not be used but are needed for the interface
+    inline unsigned int size_holes() const { return 0; }
+    inline unsigned int size() const { return 0; }
+    template<class iT>
+    inline PolyLinePolygonWithHolesData& set(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+    template<class iT>
+    inline PolyLinePolygonWithHolesData& set_compact(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+   
+    // initialize a polygon from x,y values, it is assumed that the first is an x
+    // and that the input is a well behaved polygon
+    template<class iT>
+    inline PolyLinePolygonWithHolesData& set_holes(iT inputBegin, iT inputEnd) {
+      return *this;
+    }
+  };
+
+
+  template <bool orientT, typename Unit, typename polygon_concept_type>
+  struct PolyLineType { };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_90_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_45_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_90_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_45_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
+  template <bool orientT, typename Unit>
+  struct PolyLineType<orientT, Unit, polygon_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
+
+  template <bool orientT, typename Unit, typename polygon_concept_type>
+  class ScanLineToPolygonItrs {
+  private:
+    std::map<Unit, ActiveTail<Unit>*> tailMap_;
+    typedef typename PolyLineType<orientT, Unit, polygon_concept_type>::type PolyLinePolygonData;
+    std::vector<PolyLinePolygonData> outputPolygons_;
+    bool fractureHoles_;
+  public:
+    typedef typename std::vector<PolyLinePolygonData>::iterator iterator; 
+    inline ScanLineToPolygonItrs() : tailMap_(), outputPolygons_(), fractureHoles_(false)  {}
+    /* construct a scanline with the proper offsets, protocol and options */
+    inline ScanLineToPolygonItrs(bool fractureHoles) : tailMap_(), outputPolygons_(), fractureHoles_(fractureHoles) {}
+   
+    ~ScanLineToPolygonItrs() { clearOutput_(); }
+   
+    /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
+    void processEdges(iterator& beginOutput, iterator& endOutput, 
+                      Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
+                      std::vector<interval_data<Unit> >& rightEdges);
+   
+  private:
+    void clearOutput_();
+  };
+
+  /*
+   * ScanLine does all the work of stitching together polygons from incoming vertical edges
+   */
+//   template <typename Unit, typename polygon_concept_type>
+//   class ScanLineToPolygons {
+//   private:
+//     ScanLineToPolygonItrs<true, Unit> scanline_;
+//   public:
+//     inline ScanLineToPolygons() : scanline_() {}
+//     /* construct a scanline with the proper offsets, protocol and options */
+//     inline ScanLineToPolygons(bool fractureHoles) : scanline_(fractureHoles) {}
+   
+//     /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
+//     inline void processEdges(std::vector<Unit>& outBufferTmp, Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
+//                              std::vector<interval_data<Unit> >& rightEdges) {
+//       typename ScanLineToPolygonItrs<true, Unit>::iterator itr, endItr;
+//       scanline_.processEdges(itr, endItr, currentX, leftEdges, rightEdges);
+//       //copy data into outBufferTmp
+//       while(itr != endItr) {
+//         typename PolyLinePolygonData<true, Unit>::iterator pditr;
+//         outBufferTmp.push_back(0);
+//         unsigned int sizeIndex = outBufferTmp.size() - 1;
+//         int count = 0;
+//         for(pditr = (*itr).begin(); pditr != (*itr).end(); ++pditr) {
+//           outBufferTmp.push_back(*pditr);
+//           ++count;
+//         }
+//         outBufferTmp[sizeIndex] = count;
+//         typename PolyLinePolygonData<true, Unit>::iteratorHoles pdHoleItr;
+//         for(pdHoleItr = (*itr).beginHoles(); pdHoleItr != (*itr).endHoles(); ++pdHoleItr) {
+//           outBufferTmp.push_back(0);
+//           unsigned int sizeIndex2 = outBufferTmp.size() - 1;
+//           int count2 = 0;
+//           for(pditr = (*pdHoleItr).begin(); pditr != (*pdHoleItr).end(); ++pditr) {
+//             outBufferTmp.push_back(*pditr);
+//             ++count2;
+//           }
+//           outBufferTmp[sizeIndex2] = -count;
+//         }
+//         ++itr;
+//       }
+//     }
+//   };
+
+  const int VERTICAL_HEAD = 1, HEAD_TO_TAIL = 2, TAIL_TO_TAIL = 4, SOLID_TO_RIGHT = 8;
+
+  //EVERY FUNCTION in this DEF file should be explicitly defined as inline
+
+  //microsoft compiler improperly warns whenever you cast an integer to bool
+  //call this function on an integer to convert it to bool without a warning
+  template <class T>
+  inline bool to_bool(const T& val) { return val != 0; }
+
+  //default constructor (for preallocation)
+  template <typename Unit>
+  inline PolyLine<Unit>::PolyLine() : ptdata_() ,headp_(0), tailp_(0), state_(-1) {}
+
+  //constructor
+  template <typename Unit>
+  inline PolyLine<Unit>::PolyLine(orientation_2d orient, Unit coord, Side side) : 
+    ptdata_(1, coord),
+    headp_(0),
+    tailp_(0),
+    state_(orient.to_int() +
+           (side << 3)) {}
+
+  //copy constructor
+  template <typename Unit>
+  inline PolyLine<Unit>::PolyLine(const PolyLine<Unit>& pline) : ptdata_(pline.ptdata_),
+                                                     headp_(pline.headp_),
+                                                     tailp_(pline.tailp_),
+                                                     state_(pline.state_) {}
+
+  //destructor
+  template <typename Unit>
+  inline PolyLine<Unit>::~PolyLine() {
+    //clear out data just in case it is read later
+    headp_ = tailp_ = 0;
+    state_ = 0;
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::operator=(const PolyLine<Unit>& that) {
+    if(!(this == &that)) {
+      headp_ = that.headp_;
+      tailp_ = that.tailp_;
+      ptdata_ = that.ptdata_;
+      state_ = that.state_;
+    }
+    return *this;
+  }
+
+  template <typename Unit>
+  inline bool PolyLine<Unit>::operator==(const PolyLine<Unit>& b) const {
+    return this == &b || (state_ == b.state_ &&
+                          headp_ == b.headp_ &&
+                          tailp_ == b.tailp_);
+  }
+
+  //valid PolyLine
+  template <typename Unit>
+  inline bool PolyLine<Unit>::isValid() const { 
+    return state_ > -1; }
+
+  //first coordinate is an X value
+  //first segment is vertical
+  template <typename Unit>
+  inline bool PolyLine<Unit>::verticalHead() const {
+    return state_ & VERTICAL_HEAD;
+  }
+
+  //retrun true is PolyLine has odd number of coordiantes
+  template <typename Unit>
+  inline bool PolyLine<Unit>::oddLength() const {
+    return to_bool((ptdata_.size()-1) % 2);
+  }
+
+  //last coordiante is an X value
+  //last segment is vertical
+  template <typename Unit>
+  inline bool PolyLine<Unit>::verticalTail() const {
+    return to_bool(verticalHead() ^ oddLength());
+  }
+     
+  template <typename Unit>
+  inline orientation_2d PolyLine<Unit>::tailOrient() const {
+    return (verticalTail() ? VERTICAL : HORIZONTAL);
+  }
+
+  template <typename Unit>
+  inline orientation_2d PolyLine<Unit>::headOrient() const {
+    return (verticalHead() ? VERTICAL : HORIZONTAL);
+  }
+
+  template <typename Unit>
+  inline End PolyLine<Unit>::endConnectivity(End end) const {
+    //Tail should be defined as true
+    if(end) { return tailToTail(); }
+    return headToTail();
+  }
+
+  template <typename Unit>
+  inline bool PolyLine<Unit>::headToTail() const {
+    return to_bool(state_ & HEAD_TO_TAIL);
+  }
+
+  template <typename Unit>
+  inline bool PolyLine<Unit>::headToHead() const {
+    return to_bool(!headToTail());
+  }
+
+  template <typename Unit>
+  inline bool PolyLine<Unit>::tailToHead() const {
+    return to_bool(!tailToTail());
+  }
+     
+  template <typename Unit>
+  inline bool PolyLine<Unit>::tailToTail() const {
+    return to_bool(state_ & TAIL_TO_TAIL);
+  }
+
+  template <typename Unit>
+  inline Side PolyLine<Unit>::solidSide() const { 
+    return solidToRight(); }
+      
+  template <typename Unit>
+  inline bool PolyLine<Unit>::solidToRight() const {
+    return to_bool(state_ & SOLID_TO_RIGHT) != 0;
+  }
+
+  template <typename Unit>
+  inline bool PolyLine<Unit>::active() const {
+    return !to_bool(tailp_);
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::pushCoordinate(Unit coord) {
+    ptdata_.push_back(coord);
+    return *this;
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::popCoordinate() {
+    ptdata_.pop_back();
+    return *this;
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::pushPoint(const point_data<Unit>& point) {
+    point_data<Unit> endPt = getEndPoint();
+    //vertical is true, horizontal is false
+    if((tailOrient().to_int() ? point.get(VERTICAL) == endPt.get(VERTICAL) : point.get(HORIZONTAL) == endPt.get(HORIZONTAL))) {
+      //we were pushing a colinear segment
+      return popCoordinate();
+    }
+    return pushCoordinate(tailOrient().to_int() ? point.get(VERTICAL) : point.get(HORIZONTAL));
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::extendTail(Unit delta) {
+    ptdata_.back() += delta;
+    return *this;
+  }
+
+  //private member function that creates a link from this PolyLine to that
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinTo_(End thisEnd, PolyLine<Unit>& that, End end) {
+    if(thisEnd){
+      tailp_ = &that;
+      state_ &= ~TAIL_TO_TAIL; //clear any previous state_ of bit (for safety)
+      state_ |= (end << 2); //place bit into mask
+    } else {
+      headp_ = &that;
+      state_ &= ~HEAD_TO_TAIL; //clear any previous state_ of bit (for safety)
+      state_ |= (end << 1); //place bit into mask
+    }
+    return *this;
+  }
+
+  //join two PolyLines (both ways of the association)
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinTo(End thisEnd, PolyLine<Unit>& that, End end) {
+    joinTo_(thisEnd, that, end);
+    that.joinTo_(end, *this, thisEnd);
+    return *this;
+  }
+
+  //convenience functions for joining PolyLines
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinToTail(PolyLine<Unit>& that, End end) {
+    return joinTo(TAIL, that, end);
+  }
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinToHead(PolyLine<Unit>& that, End end) {
+    return joinTo(HEAD, that, end);
+  }
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinHeadToHead(PolyLine<Unit>& that) {
+    return joinToHead(that, HEAD);
+  }
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinHeadToTail(PolyLine<Unit>& that) {
+    return joinToHead(that, TAIL);
+  }
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinTailToHead(PolyLine<Unit>& that) {
+    return joinToTail(that, HEAD);
+  }
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::joinTailToTail(PolyLine<Unit>& that) {
+    return joinToTail(that, TAIL);
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>& PolyLine<Unit>::disconnectTails() {
+    next(TAIL)->state_ &= !TAIL_TO_TAIL;
+    next(TAIL)->tailp_ = 0;
+    state_ &= !TAIL_TO_TAIL;
+    tailp_ = 0;
+    return *this;
+  }
+
+  template <typename Unit>
+  inline Unit PolyLine<Unit>::getEndCoord(End end) const {
+    if(end)
+      return ptdata_.back();
+    return ptdata_.front();
+  }
+
+  template <typename Unit>
+  inline orientation_2d PolyLine<Unit>::segmentOrient(unsigned int index) const {
+    return (to_bool((unsigned int)verticalHead() ^ (index % 2)) ? VERTICAL : HORIZONTAL);
+  }
+
+  template <typename Unit>
+  inline point_data<Unit> PolyLine<Unit>::getPoint(unsigned int index) const {
+    //assert(isValid() && headp_->isValid()) ("PolyLine: headp_ must be valid");
+    point_data<Unit> pt;
+    pt.set(HORIZONTAL, ptdata_[index]);
+    pt.set(VERTICAL, ptdata_[index]);
+    Unit prevCoord;
+    if(index == 0) {
+      prevCoord = headp_->getEndCoord(headToTail());
+    } else {
+      prevCoord = ptdata_[index-1];
+    }
+    pt.set(segmentOrient(index), prevCoord);
+    return pt;
+  }
+
+  template <typename Unit>
+  inline point_data<Unit> PolyLine<Unit>::getEndPoint(End end) const {
+    return getPoint((end ? numSegments() - 1 : (unsigned int)0));
+  }
+
+  template <typename Unit>
+  inline Unit PolyLine<Unit>::operator[] (unsigned int index) const {
+    //assert(ptdata_.size() > index) ("PolyLine: out of bounds index");
+    return ptdata_[index];
+  }
+
+  template <typename Unit>
+  inline unsigned int PolyLine<Unit>::numSegments() const {
+    return ptdata_.size();
+  }
+
+  template <typename Unit>
+  inline PolyLine<Unit>* PolyLine<Unit>::next(End end) const {
+    return (end ? tailp_ : headp_);
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>::ActiveTail() : tailp_(0), otherTailp_(0), holesList_() {}
+
+  template <typename Unit>
+  inline ActiveTail<Unit>::ActiveTail(orientation_2d orient, Unit coord, Side solidToRight, ActiveTail* otherTailp) : 
+    tailp_(0), otherTailp_(0), holesList_() {
+    tailp_ = createPolyLine(orient, coord, solidToRight);
+    otherTailp_ = otherTailp;
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>::ActiveTail(PolyLine<Unit>* active, ActiveTail<Unit>* otherTailp) : 
+    tailp_(active), otherTailp_(otherTailp), holesList_() {}
+
+  //copy constructor
+  template <typename Unit>
+  inline ActiveTail<Unit>::ActiveTail(const ActiveTail<Unit>& that) : tailp_(that.tailp_), otherTailp_(that.otherTailp_), holesList_() {}
+
+  //destructor
+  template <typename Unit>
+  inline ActiveTail<Unit>::~ActiveTail() { 
+    //clear them in case the memory is read later
+    tailp_ = 0; otherTailp_ = 0; 
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>& ActiveTail<Unit>::operator=(const ActiveTail<Unit>& that) {
+    //self assignment is safe in this case
+    tailp_ = that.tailp_;
+    otherTailp_ = that.otherTailp_;
+    return *this;
+  }
+
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::operator==(const ActiveTail<Unit>& b) const {
+    return tailp_ == b.tailp_ && otherTailp_ == b.otherTailp_;
+  }
+
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::operator<(const ActiveTail<Unit>& b) const {
+    return tailp_->getEndPoint().get(VERTICAL) < b.tailp_->getEndPoint().get(VERTICAL);
+  }
+
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::operator<=(const ActiveTail<Unit>& b) const { 
+    return !(*this > b); }
+   
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::operator>(const ActiveTail<Unit>& b) const { 
+    return b < (*this); }
+   
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::operator>=(const ActiveTail<Unit>& b) const { 
+    return !(*this < b); }
+
+  template <typename Unit>
+  inline PolyLine<Unit>* ActiveTail<Unit>::getTail() const { 
+    return tailp_; }
+
+  template <typename Unit>
+  inline PolyLine<Unit>* ActiveTail<Unit>::getOtherTail() const { 
+    return otherTailp_->tailp_; }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>* ActiveTail<Unit>::getOtherActiveTail() const { 
+    return otherTailp_; }
+
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::isOtherTail(const ActiveTail<Unit>& b) {
+    //       assert( (tailp_ == b.getOtherTail() && getOtherTail() == b.tailp_) ||
+    //                     (tailp_ != b.getOtherTail() && getOtherTail() != b.tailp_)) 
+    //         ("ActiveTail: Active tails out of sync");
+    return otherTailp_ == &b;
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>& ActiveTail<Unit>::updateTail(PolyLine<Unit>* newTail) {
+    tailp_ = newTail;
+    return *this;
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>* ActiveTail<Unit>::addHole(ActiveTail<Unit>* hole, bool fractureHoles) {
+    if(!fractureHoles){
+      holesList_.push_back(hole);
+      copyHoles(*hole);
+      copyHoles(*(hole->getOtherActiveTail()));
+      return this;
+    }
+    ActiveTail<Unit>* h, *v;
+    ActiveTail<Unit>* other = hole->getOtherActiveTail();
+    if(other->getOrient() == VERTICAL) {
+      //assert that hole.getOrient() == HORIZONTAL
+      //this case should never happen
+      h = hole;  
+      v = other;
+    } else {
+      //assert that hole.getOrient() == VERTICAL
+      h = other;
+      v = hole;
+    }
+    h->pushCoordinate(v->getCoordinate());
+    //assert that h->getOrient() == VERTICAL
+    //v->pushCoordinate(getCoordinate());
+    //assert that v->getOrient() == VERTICAL
+    //I can't close a figure by adding a hole, so pass zero for xMin and yMin
+    std::vector<Unit> tmpVec;
+    ActiveTail<Unit>::joinChains(this, h, false, tmpVec);
+    return v;
+  }
+
+  template <typename Unit>
+  inline const std::list<ActiveTail<Unit>*>& ActiveTail<Unit>::getHoles() const {
+    return holesList_;
+  }
+
+  template <typename Unit>
+  inline void ActiveTail<Unit>::copyHoles(ActiveTail<Unit>& that) {
+    holesList_.splice(holesList_.end(), that.holesList_); //splice the two lists together
+  }
+
+  template <typename Unit>
+  inline bool ActiveTail<Unit>::solidToRight() const { 
+    return getTail()->solidToRight(); }
+
+  template <typename Unit>
+  inline Unit ActiveTail<Unit>::getCoord() const { 
+    return getTail()->getEndCoord(); }
+ 
+  template <typename Unit>
+  inline Unit ActiveTail<Unit>::getCoordinate() const { 
+    return getCoord(); } 
+
+  template <typename Unit>
+  inline orientation_2d ActiveTail<Unit>::getOrient() const { 
+    return getTail()->tailOrient(); }
+
+  template <typename Unit>
+  inline void ActiveTail<Unit>::pushCoordinate(Unit coord) { 
+    //appropriately handle any co-linear polyline segments by calling push point internally
+    point_data<Unit> p;
+    p.set(HORIZONTAL, coord);
+    p.set(VERTICAL, coord);
+    //if we are vertical assign the last coordinate (an X) to p.x, else to p.y
+    p.set(getOrient().get_perpendicular(), getCoordinate());
+    tailp_->pushPoint(p);
+  }
+
+
+  //global utility functions
+  template <typename Unit>
+  inline PolyLine<Unit>* createPolyLine(orientation_2d orient, Unit coord, Side side) {
+    return new PolyLine<Unit>(orient, coord, side);
+  }
+
+  template <typename Unit>
+  inline void destroyPolyLine(PolyLine<Unit>* pLine) {
+    delete pLine;
+  }
+
+  template <typename Unit>
+  inline ActiveTail<Unit>* createActiveTail() {
+    //consider replacing system allocator with ActiveTail memory pool
+    return new ActiveTail<Unit>();
+  }
+
+  template <typename Unit>
+  inline void destroyActiveTail(ActiveTail<Unit>* aTail) {
+    delete aTail;
+  }
+
+
+  //no recursion, to prevent max recursion depth errors
+  template <typename Unit>
+  inline void ActiveTail<Unit>::destroyContents() {
+    tailp_->disconnectTails();
+    PolyLine<Unit>* nextPolyLinep = tailp_->next(HEAD);
+    End end = tailp_->endConnectivity(HEAD);
+    destroyPolyLine(tailp_);
+    while(nextPolyLinep) {
+      End nextEnd = nextPolyLinep->endConnectivity(!end); //get the direction of next polyLine
+      PolyLine<Unit>* nextNextPolyLinep = nextPolyLinep->next(!end); //get the next polyline
+      destroyPolyLine(nextPolyLinep); //destroy the current polyline
+      end = nextEnd;
+      nextPolyLinep = nextNextPolyLinep;
+    }
+  }
+
+  template <typename Unit>
+  inline typename ActiveTail<Unit>::iterator ActiveTail<Unit>::begin(bool isHole, orientation_2d orient) const {
+    return iterator(this, isHole, orient);
+  }
+
+  template <typename Unit>
+  inline typename ActiveTail<Unit>::iterator ActiveTail<Unit>::end() const {
+    return iterator();
+  }
+
+  template <typename Unit>
+  inline typename ActiveTail<Unit>::iteratorHoles ActiveTail<Unit>::beginHoles() const {
+    return holesList_.begin();
+  }
+
+  template <typename Unit>
+  inline typename ActiveTail<Unit>::iteratorHoles ActiveTail<Unit>::endHoles() const {
+    return holesList_.end();
+  }
+
+  template <typename Unit>
+  inline void ActiveTail<Unit>::writeOutFigureItrs(iterator& beginOut, iterator& endOut, bool isHole, orientation_2d orient) const {
+    beginOut = begin(isHole, orient);
+    endOut = end();
+  }
+
+  template <typename Unit>
+  inline void ActiveTail<Unit>::writeOutFigureHoleItrs(iteratorHoles& beginOut, iteratorHoles& endOut) const {
+    beginOut = beginHoles();
+    endOut = endHoles();
+  }
+
+  template <typename Unit>
+  inline void ActiveTail<Unit>::writeOutFigure(std::vector<Unit>& outVec, bool isHole) const {
+    //we start writing out the polyLine that this active tail points to at its tail
+    unsigned int size = outVec.size();
+    outVec.push_back(0); //place holder for size
+    PolyLine<Unit>* nextPolyLinep = 0;
+    if(!isHole){
+      nextPolyLinep = otherTailp_->tailp_->writeOut(outVec);
+    } else {
+      nextPolyLinep = tailp_->writeOut(outVec);
+    }
+    Unit firsty = outVec[size + 1];
+    if((getOrient() == HORIZONTAL) ^ !isHole) {
+      //our first coordinate is a y value, so we need to rotate it to the end
+      typename std::vector<Unit>::iterator tmpItr = outVec.begin();
+      tmpItr += size; 
+      outVec.erase(++tmpItr); //erase the 2nd element
+    }
+    End startEnd = tailp_->endConnectivity(HEAD);
+    if(isHole) startEnd = otherTailp_->tailp_->endConnectivity(HEAD);
+    while(nextPolyLinep) {
+      bool nextStartEnd = nextPolyLinep->endConnectivity(!startEnd);
+      nextPolyLinep = nextPolyLinep->writeOut(outVec, startEnd); 
+      startEnd = nextStartEnd;
+    }      
+    if((getOrient() == HORIZONTAL) ^ !isHole) {
+      //we want to push the y value onto the end since we ought to have ended with an x
+      outVec.push_back(firsty); //should never be executed because we want first value to be an x
+    }
+    //the vector contains the coordinates of the linked list of PolyLines in the correct order
+    //first element is supposed to be the size
+    outVec[size] = outVec.size() - 1 - size;  //number of coordinates in vector
+    //assert outVec[size] % 2 == 0 //it should be even
+    //make the size negative for holes
+    outVec[size] *= (isHole ? -1 : 1);
+  }
+
+  //no recursion to prevent max recursion depth errors
+  template <typename Unit>
+  inline PolyLine<Unit>* PolyLine<Unit>::writeOut(std::vector<Unit>& outVec, End startEnd) const {
+    if(startEnd == HEAD){
+      //forward order
+      outVec.insert(outVec.end(), ptdata_.begin(), ptdata_.end());
+      return tailp_;
+    }else{
+      //reverse order
+      //do not reserve because we expect outVec to be large enough already
+      for(int i = ptdata_.size() - 1; i >= 0; --i){
+        outVec.push_back(ptdata_[i]);
+      }
+      //NT didn't know about this version of the API....
+      //outVec.insert(outVec.end(), ptdata_.rbegin(), ptdata_.rend());
+      return headp_;
+    }
+  }
+
+  //solid indicates if it was joined by a solit or a space
+  template <typename Unit>
+  inline ActiveTail<Unit>* ActiveTail<Unit>::joinChains(ActiveTail<Unit>* at1, ActiveTail<Unit>* at2, bool solid, std::vector<Unit>& outBufferTmp) 
+  {
+    //checks to see if we closed a figure
+    if(at1->isOtherTail(*at2)){
+      //value of solid tells us if we closed solid or hole
+      //and output the solid or handle the hole appropriately
+      //if the hole needs to fracture across horizontal partition boundary we need to notify
+      //the calling context to do so
+      if(solid) {
+        //the chains are being joined because there is solid to the right
+        //this means that if the figure is closed at this point it must be a hole
+        //because otherwise it would have to have another vertex to the right of this one
+        //and would not be closed at this point
+        return at1;
+      } else {    
+        //assert pG != 0
+        //the figure that was closed is a shell
+        at1->writeOutFigure(outBufferTmp);
+        //process holes of the polygon
+        at1->copyHoles(*at2); //there should not be holes on at2, but if there are, copy them over
+        const std::list<ActiveTail<Unit>*>& holes = at1->getHoles();
+        for(typename std::list<ActiveTail<Unit>*>::const_iterator litr = holes.begin(); litr != holes.end(); ++litr) {
+          (*litr)->writeOutFigure(outBufferTmp, true);
+          //delete the hole
+          (*litr)->destroyContents();
+          destroyActiveTail((*litr)->getOtherActiveTail());
+          destroyActiveTail((*litr));
+        }
+        //delete the polygon
+        at1->destroyContents();
+        //at2 contents are the same as at1, so it should not destroy them
+        destroyActiveTail(at1);
+        destroyActiveTail(at2);
+      }
+      return 0;
+    }
+    //join the two partial polygons into one large partial polygon
+    at1->getTail()->joinTailToTail(*(at2->getTail()));
+    *(at1->getOtherActiveTail()) = ActiveTail(at1->getOtherTail(), at2->getOtherActiveTail());
+    *(at2->getOtherActiveTail()) = ActiveTail(at2->getOtherTail(), at1->getOtherActiveTail());
+    at1->getOtherActiveTail()->copyHoles(*at1);
+    at1->getOtherActiveTail()->copyHoles(*at2);
+    destroyActiveTail(at1);
+    destroyActiveTail(at2);
+    return 0;
+  }
+
+  //solid indicates if it was joined by a solit or a space
+  template <typename Unit>
+  template <typename PolygonT>
+  inline ActiveTail<Unit>* ActiveTail<Unit>::joinChains(ActiveTail<Unit>* at1, ActiveTail<Unit>* at2, bool solid, 
+                                                        std::vector<PolygonT>& outBufferTmp) {
+    //checks to see if we closed a figure
+    if(at1->isOtherTail(*at2)){
+      //value of solid tells us if we closed solid or hole
+      //and output the solid or handle the hole appropriately
+      //if the hole needs to fracture across horizontal partition boundary we need to notify
+      //the calling context to do so
+      if(solid) {
+        //the chains are being joined because there is solid to the right
+        //this means that if the figure is closed at this point it must be a hole
+        //because otherwise it would have to have another vertex to the right of this one
+        //and would not be closed at this point
+        return at1;
+      } else {    
+        //assert pG != 0
+        //the figure that was closed is a shell
+        outBufferTmp.push_back(at1);
+        at1->copyHoles(*at2); //there should not be holes on at2, but if there are, copy them over
+      }
+      return 0;
+    }
+    //join the two partial polygons into one large partial polygon
+    at1->getTail()->joinTailToTail(*(at2->getTail()));
+    *(at1->getOtherActiveTail()) = ActiveTail<Unit>(at1->getOtherTail(), at2->getOtherActiveTail());
+    *(at2->getOtherActiveTail()) = ActiveTail<Unit>(at2->getOtherTail(), at1->getOtherActiveTail());
+    at1->getOtherActiveTail()->copyHoles(*at1);
+    at1->getOtherActiveTail()->copyHoles(*at2);
+    destroyActiveTail(at1);
+    destroyActiveTail(at2);
+    return 0;
+  }
+
+  template <class TKey, class T> inline typename std::map<TKey, T>::iterator findAtNext(std::map<TKey, T>& theMap, 
+                                                                                        typename std::map<TKey, T>::iterator pos, const TKey& key) 
+  {
+    if(pos == theMap.end()) return theMap.find(key);
+    //if they match the mapItr is pointing to the correct position
+    if(pos->first < key) {
+      return theMap.find(key);
+    }
+    if(pos->first > key) {
+      return theMap.end();
+    } 
+    //else they are equal and no need to do anything to the iterator
+    return pos;
+  }
+
+  // createActiveTailsAsPair is called in these two end cases of geometry
+  // 1. lower left concave corner
+  //         ###| 
+  //         ###|
+  //         ###|### 
+  //         ###|###
+  // 2. lower left convex corner
+  //            |###          
+  //            |###         
+  //            |            
+  //            |     
+  // In case 1 there may be a hole propigated up from the bottom.  If the fracture option is enabled
+  // the two active tails that form the filament fracture line edges can become the new active tail pair
+  // by pushing x and y onto them.  Otherwise the hole simply needs to be associated to one of the new active tails
+  // with add hole
+  template <typename Unit>
+  inline std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> createActiveTailsAsPair(Unit x, Unit y, bool solid, ActiveTail<Unit>* phole, bool fractureHoles) {
+    ActiveTail<Unit>* at1 = 0;
+    ActiveTail<Unit>* at2 = 0;
+    if(!phole || !fractureHoles){
+      at1 = createActiveTail<Unit>();
+      at2 = createActiveTail<Unit>();
+      (*at1) = ActiveTail<Unit>(VERTICAL, x, solid, at2);
+      (*at2) = ActiveTail<Unit>(HORIZONTAL, y, !solid, at1);
+      //provide a function through activeTail class to provide this
+      at1->getTail()->joinHeadToHead(*(at2->getTail()));
+      if(phole) 
+        at1->addHole(phole, fractureHoles); //assert fractureHoles == false
+      return std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*>(at1, at2);
+    }
+    //assert phole is not null
+    //assert fractureHoles is true
+    if(phole->getOrient() == VERTICAL) {
+      at2 = phole;
+    } else {
+      at2 = phole->getOtherActiveTail(); //should never be executed since orientation is expected to be vertical
+    }
+    //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
+    at1 = at2->getOtherActiveTail();
+    //assert at1 is horizontal
+    at1->pushCoordinate(x);
+    //assert at2 is vertical
+    at2->pushCoordinate(y);
+    return std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*>(at1, at2);
+  }
+ 
+  //Process edges connects vertical input edges (right or left edges of figures) to horizontal edges stored as member
+  //data of the scanline object.  It also creates now horizontal edges as needed to construct figures from edge data.
+  //
+  //There are only 12 geometric end cases where the scanline intersects a horizontal edge and even fewer unique 
+  //actions to take:
+  // 1. Solid on both sides of the vertical partition after the current position and space on both sides before
+  //         ###|###          
+  //         ###|###         
+  //            |            
+  //            |            
+  //    This case does not need to be handled because there is no vertical edge at the current x coordinate.
+  //
+  // 2. Solid on both sides of the vertical partition before the current position and space on both sides after
+  //            |            
+  //            |            
+  //         ###|###          
+  //         ###|###         
+  //    This case does not need to be handled because there is no vertical edge at the current x coordinate.
+  //
+  // 3. Solid on the left of the vertical partition after the current position and space elsewhere
+  //         ###|          
+  //         ###|         
+  //            |            
+  //            |     
+  //    The horizontal edge from the left is found and turns upward because of the vertical right edge to become
+  //    the currently active vertical edge.
+  //
+  // 4. Solid on the left of the vertical partion before the current position and space elsewhere
+  //            |            
+  //            |            
+  //         ###| 
+  //         ###|
+  //    The horizontal edge from the left is found and joined to the currently active vertical edge.
+  //
+  // 5. Solid to the right above and below and solid to the left above current position.
+  //         ###|###          
+  //         ###|###         
+  //            |###            
+  //            |###            
+  //    The horizontal edge from the left is found and joined to the currently active vertical edge,
+  //    potentially closing a hole.
+  //
+  // 6. Solid on the left of the vertical partion before the current position and solid to the right above and below
+  //            |###
+  //            |###            
+  //         ###|### 
+  //         ###|###
+  //    The horizontal edge from the left is found and turns upward because of the vertical right edge to become
+  //    the currently active vertical edge.
+  //
+  // 7. Solid on the right of the vertical partition after the current position and space elsewhere
+  //            |###          
+  //            |###         
+  //            |            
+  //            |     
+  //    Create two new ActiveTails, one is added to the horizontal edges and the other becomes the vertical currentTail
+  //
+  // 8. Solid on the right of the vertical partion before the current position and space elsewhere
+  //            |            
+  //            |            
+  //            |### 
+  //            |###
+  //    The currentTail vertical edge turns right and is added to the horizontal edges data
+  //
+  // 9. Solid to the right above and solid to the left above and below current position.
+  //         ###|###          
+  //         ###|###         
+  //         ###| 
+  //         ###|
+  //    The currentTail vertical edge turns right and is added to the horizontal edges data
+  //
+  // 10. Solid on the left of the vertical partion above and below the current position and solid to the right below
+  //         ###| 
+  //         ###|
+  //         ###|### 
+  //         ###|###
+  //    Create two new ActiveTails, one is added to the horizontal edges data and the other becomes the vertical currentTail
+  //
+  // 11. Solid to the right above and solid to the left below current position.
+  //            |### 
+  //            |###
+  //         ###| 
+  //         ###|
+  //    The currentTail vertical edge joins the horizontal edge from the left (may close a polygon)
+  //    Create two new ActiveTails, one is added to the horizontal edges data and the other becomes the vertical currentTail
+  //
+  // 12. Solid on the left of the vertical partion above the current position and solid to the right below
+  //         ###| 
+  //         ###|
+  //            |### 
+  //            |###
+  //    The currentTail vertical edge turns right and is added to the horizontal edges data.
+  //    The horizontal edge from the left turns upward and becomes the currentTail vertical edge
+  //
+  template <bool orientT, typename Unit, typename polygon_concept_type>
+  inline void ScanLineToPolygonItrs<orientT, Unit, polygon_concept_type>::
+  processEdges(iterator& beginOutput, iterator& endOutput, 
+               Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
+               std::vector<interval_data<Unit> >& rightEdges) {
+    clearOutput_();
+    typename std::map<Unit, ActiveTail<Unit>*>::iterator nextMapItr = tailMap_.begin();
+    //foreach edge
+    unsigned int leftIndex = 0;
+    unsigned int rightIndex = 0;
+    bool bottomAlreadyProcessed = false;
+    ActiveTail<Unit>* currentTail = 0;
+    const Unit UnitMax = (std::numeric_limits<Unit>::max)();
+    while(leftIndex < leftEdges.size() || rightIndex < rightEdges.size()) {
+      interval_data<Unit>  edges[2] = {interval_data<Unit> (UnitMax, UnitMax), interval_data<Unit> (UnitMax, UnitMax)};
+      bool haveNextEdge = true;
+      if(leftIndex < leftEdges.size())
+        edges[0] = leftEdges[leftIndex];
+      else
+        haveNextEdge = false;
+      if(rightIndex < rightEdges.size())
+        edges[1] = rightEdges[rightIndex];
+      else
+        haveNextEdge = false;
+      bool trailingEdge = edges[1].get(LOW) < edges[0].get(LOW);
+      interval_data<Unit> & edge = edges[trailingEdge];
+      interval_data<Unit> & nextEdge = edges[!trailingEdge];
+      //process this edge
+      if(!bottomAlreadyProcessed) {
+        //assert currentTail = 0 
+
+        //process the bottom end of this edge
+        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(LOW));
+        if(thisMapItr != tailMap_.end()) {
+          //there is an edge in the map at the low end of this edge
+          //it needs to turn upward and become the current tail
+          ActiveTail<Unit>* tail = thisMapItr->second;
+          if(currentTail) {
+            //stitch currentTail into this tail
+            currentTail = tail->addHole(currentTail, fractureHoles_);
+            if(!fractureHoles_)
+              currentTail->pushCoordinate(currentX);
+          } else {
+            currentTail = tail;
+            currentTail->pushCoordinate(currentX);
+          }
+          //assert currentTail->getOrient() == VERTICAL
+          nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
+          ++nextMapItr;
+          //remove thisMapItr from the map
+          tailMap_.erase(thisMapItr);
+        } else {
+          //there is no edge in the map at the low end of this edge
+          //we need to create one and another one to be the current vertical tail
+          //if this is a trailing edge then there is space to the right of the vertical edge
+          //so pass the inverse of trailingEdge to indicate solid to the right
+          std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> tailPair = 
+            createActiveTailsAsPair(currentX, edge.get(LOW), !trailingEdge, currentTail, fractureHoles_);
+          currentTail = tailPair.first;
+          tailMap_.insert(nextMapItr, std::pair<Unit, ActiveTail<Unit>*>(edge.get(LOW), tailPair.second));
+          // leave nextMapItr unchanged
+        }
+
+      }
+      if(haveNextEdge && edge.get(HIGH) == nextEdge.get(LOW)) {
+        //the top of this edge is equal to the bottom of the next edge, process them both
+        bottomAlreadyProcessed = true;
+        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(HIGH));
+        if(thisMapItr == tailMap_.end()) //assert this should never happen
+          return;
+        if(trailingEdge) {
+          //geometry at this position
+          //   |##
+          //   |##
+          // -----
+          // ##|
+          // ##|
+          //current tail should join thisMapItr tail
+          ActiveTail<Unit>* tail = thisMapItr->second;
+          //pass false because they are being joined because space is to the right and it will close a solid figure
+          ActiveTail<Unit>::joinChains(currentTail, tail, false, outputPolygons_);
+          //two new tails are created, the vertical becomes current tail, the horizontal becomes thisMapItr tail
+          //pass true becuase they are created at the lower left corner of some solid
+          //pass null because there is no hole pointer possible
+          std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> tailPair = 
+            createActiveTailsAsPair<Unit>(currentX, edge.get(HIGH), true, 0, fractureHoles_);
+          currentTail = tailPair.first;
+          thisMapItr->second = tailPair.second;
+        } else {
+          //geometry at this position
+          // ##|
+          // ##|
+          // -----
+          //   |##
+          //   |##
+          //current tail should turn right
+          currentTail->pushCoordinate(edge.get(HIGH));
+          //thisMapItr tail should turn up
+          thisMapItr->second->pushCoordinate(currentX);
+          //thisMapItr tail becomes current tail and current tail becomes thisMapItr tail
+          std::swap(currentTail, thisMapItr->second);
+        }
+        nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
+        ++nextMapItr;
+      } else {
+        //there is a gap between the top of this edge and the bottom of the next, process the top of this edge
+        bottomAlreadyProcessed = false;
+        //process the top of this edge
+        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(HIGH));
+        if(thisMapItr != tailMap_.end()) {
+          //thisMapItr is pointing to a horizontal edge in the map at the top of this vertical edge
+          //we need to join them and potentially close a figure
+          //assert currentTail != 0
+          ActiveTail<Unit>* tail = thisMapItr->second;
+          //pass the opositve of trailing edge to mean that they are joined because of solid to the right
+          currentTail = ActiveTail<Unit>::joinChains(currentTail, tail, !trailingEdge, outputPolygons_);
+          nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
+          ++nextMapItr;
+          if(currentTail) {
+            Unit nextItrY = UnitMax;
+            if(nextMapItr != tailMap_.end()) {
+              nextItrY = nextMapItr->first;
+            }
+            //for it to be a hole this must have been a left edge
+            Unit leftY = UnitMax;
+            if(leftIndex + 1 < leftEdges.size())
+              leftY = leftEdges[leftIndex+1].get(LOW);
+            Unit rightY = nextEdge.get(LOW);
+            if(!haveNextEdge || (nextItrY < leftY && nextItrY < rightY)) {
+              //we need to add it to the next edge above it in the map
+              tail = nextMapItr->second;
+              tail = tail->addHole(currentTail, fractureHoles_);
+              if(fractureHoles_) {
+                //some small additional work stitching in the filament
+                tail->pushCoordinate(nextItrY);
+                nextMapItr->second = tail;
+              }
+              //set current tail to null
+              currentTail = 0;
+            }
+          }  
+          //delete thisMapItr from the map
+          tailMap_.erase(thisMapItr);
+        } else {
+          //currentTail must turn right and be added into the map
+          currentTail->pushCoordinate(edge.get(HIGH));
+          //assert currentTail->getOrient() == HORIZONTAL
+          tailMap_.insert(nextMapItr, std::pair<Unit, ActiveTail<Unit>*>(edge.get(HIGH), currentTail));
+          //set currentTail to null
+          currentTail = 0;
+          //leave nextMapItr unchanged, it is still next
+        }
+      }
+ 
+      //increment index
+      leftIndex += !trailingEdge;
+      rightIndex += trailingEdge;
+    } //end while
+    beginOutput = outputPolygons_.begin();
+    endOutput = outputPolygons_.end();
+  } //end function
+
+  template<bool orientT, typename Unit, typename polygon_concept_type>
+  inline void ScanLineToPolygonItrs<orientT, Unit, polygon_concept_type>::clearOutput_() {
+    for(unsigned int i = 0; i < outputPolygons_.size(); ++i) {
+      ActiveTail<Unit>* at1 = outputPolygons_[i].yield();
+      const std::list<ActiveTail<Unit>*>& holes = at1->getHoles();
+      for(typename std::list<ActiveTail<Unit>*>::const_iterator litr = holes.begin(); litr != holes.end(); ++litr) {
+        //delete the hole
+        (*litr)->destroyContents();
+        destroyActiveTail((*litr)->getOtherActiveTail());
+        destroyActiveTail((*litr));
+      }
+      //delete the polygon
+      at1->destroyContents();
+      //at2 contents are the same as at1, so it should not destroy them
+      destroyActiveTail((at1)->getOtherActiveTail());
+      destroyActiveTail(at1);
+    }
+    outputPolygons_.clear();
+  }
+
+} //polygon_formation namespace
+
+  template <bool orientT, typename Unit>
+  struct geometry_concept<polygon_formation::PolyLinePolygonWithHolesData<orientT, Unit> > {
+    typedef polygon_90_with_holes_concept type;
+  };
+
+  template <bool orientT, typename Unit>
+  struct geometry_concept<polygon_formation::PolyLineHoleData<orientT, Unit> > {
+    typedef polygon_90_concept type;
+  };
+
+  //public API to access polygon formation algorithm
+  template <typename output_container, typename iterator_type, typename concept_type>
+  unsigned int get_polygons(output_container& container, iterator_type begin, iterator_type end,
+                    orientation_2d orient, bool fracture_holes, concept_type tag) {
+    typedef typename output_container::value_type polygon_type;
+    typedef typename iterator_type::value_type::first_type coordinate_type;
+    polygon_type poly;
+    unsigned int countPolygons = 0;
+    typedef typename geometry_concept<polygon_type>::type polygon_concept_type;
+    polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type> scanlineToPolygonItrsV(fracture_holes);
+    polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type> scanlineToPolygonItrsH(fracture_holes);
+    std::vector<interval_data<coordinate_type> > leftEdges;
+    std::vector<interval_data<coordinate_type> > rightEdges;
+    coordinate_type prevPos = (std::numeric_limits<coordinate_type>::max)();
+    coordinate_type prevY = (std::numeric_limits<coordinate_type>::max)();
+    int count = 0;
+    for(iterator_type itr = begin;
+        itr != end; ++ itr) {
+      coordinate_type pos = (*itr).first;
+      if(pos != prevPos) {
+        if(orient == VERTICAL) {
+          typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
+          scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+          for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+            ++countPolygons;
+            assign(poly, *itrPoly);
+            container.insert(container.end(), poly);
+          }
+        } else {
+          typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
+          scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+          for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+            ++countPolygons;
+            assign(poly, *itrPoly);
+            container.insert(container.end(), poly);
+          }
+        }
+        leftEdges.clear();
+        rightEdges.clear();
+        prevPos = pos;
+        prevY = (*itr).second.first;
+        count = (*itr).second.second;
+        continue;
+      }
+      coordinate_type y = (*itr).second.first;
+      if(count != 0 && y != prevY) {
+        std::pair<interval_data<coordinate_type>, int> element(interval_data<coordinate_type>(prevY, y), count);
+        if(element.second == 1) {
+          if(leftEdges.size() && leftEdges.back().high() == element.first.low()) {
+            encompass(leftEdges.back(), element.first);
+          } else {
+            leftEdges.push_back(element.first);
+          }
+        } else {
+          if(rightEdges.size() && rightEdges.back().high() == element.first.low()) {
+            encompass(rightEdges.back(), element.first);
+          } else {
+            rightEdges.push_back(element.first);
+          }
+        }
+
+      }
+      prevY = y;
+      count += (*itr).second.second;
+    }
+    if(orient == VERTICAL) {
+      typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
+      scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+      for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+        ++countPolygons;
+        assign(poly, *itrPoly);
+        container.insert(container.end(), poly);
+      }
+    } else {
+      typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
+      scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+      for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+        ++countPolygons;
+        assign(poly, *itrPoly);
+        container.insert(container.end(), poly);
+      }
+    }
+    return countPolygons;
+  }
+
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/polygon_set_view.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/polygon_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,201 @@
+/*
+  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_POLYGON_SET_VIEW_HPP
+#define BOOST_POLYGON_POLYGON_SET_VIEW_HPP
+namespace boost { namespace polygon{
+  
+  
+  template <typename coordinate_type>
+  inline void polygon_set_data<coordinate_type>::clean() const {
+    if(dirty_) {
+      polygon_45_set_data<coordinate_type> tmp;
+      if(downcast(tmp) ) {
+        tmp.clean();
+        data_.clear();
+        is_45_ = true;
+        polygon_set_data<coordinate_type> tmp2;
+        tmp2.insert(tmp);
+        data_.swap(tmp2.data_);
+        dirty_ = false;
+        sort();
+      } else {
+        sort();
+        arbitrary_boolean_op<coordinate_type> abo;
+        polygon_set_data<coordinate_type> tmp2;
+        abo.execute(tmp2, begin(), end(), end(), end(), 0);
+        data_.swap(tmp2.data_);
+        is_45_ = tmp2.is_45_;
+        dirty_ = false;
+      }
+    }
+  }
+
+  template <>
+  inline void polygon_set_data<double>::clean() const {
+    if(dirty_) {
+      sort();
+      arbitrary_boolean_op<double> abo;
+      polygon_set_data<double> tmp2;
+      abo.execute(tmp2, begin(), end(), end(), end(), 0);
+      data_.swap(tmp2.data_);
+      is_45_ = tmp2.is_45_;
+      dirty_ = false;
+    }
+  }
+
+  template <typename value_type, typename arg_type>
+  inline void insert_into_view_arg(value_type& dest, const arg_type& arg);
+
+  template <typename ltype, typename rtype, int op_type>
+  class polygon_set_view;
+
+  template <typename ltype, typename rtype, int op_type>
+  struct polygon_set_traits<polygon_set_view<ltype, rtype, op_type> > {
+    typedef typename polygon_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
+    typedef typename polygon_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
+    typedef typename polygon_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
+
+    static inline iterator_type begin(const polygon_set_view<ltype, rtype, op_type>& polygon_set); 
+    static inline iterator_type end(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
+
+    static inline bool clean(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
+
+    static inline bool sort(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
+  };
+
+  template <typename value_type, typename geometry_type_1, typename geometry_type_2, int op_type>
+  void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_,
+                          double coord) {
+    typedef geometry_type_1 ltype;
+    typedef geometry_type_2 rtype;
+    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
+    value_type linput_;
+    value_type rinput_;
+    insert_into_view_arg(linput_, lvalue_);
+    insert_into_view_arg(rinput_, rvalue_);
+    arbitrary_boolean_op<coordinate_type> abo;
+    abo.execute(output_, linput_.begin(), linput_.end(),
+                rinput_.begin(), rinput_.end(), op_type);
+  }
+
+  template <typename value_type, typename geometry_type_1, typename geometry_type_2, int op_type>
+  void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_,
+                          int coord) {
+    typedef geometry_type_1 ltype;
+    typedef geometry_type_2 rtype;
+    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
+    value_type linput_;
+    value_type rinput_;
+    insert_into_view_arg(linput_, lvalue_);
+    insert_into_view_arg(rinput_, rvalue_);
+    polygon_45_set_data<coordinate_type> l45, r45, o45;
+    if(linput_.downcast(l45) && rinput_.downcast(r45)) {
+      //the op codes are screwed up between 45 and arbitrary
+      if(op_type < 2)
+        l45.template applyAdaptiveBoolean_<op_type>(o45, r45);
+      else if(op_type == 2)
+        l45.template applyAdaptiveBoolean_<3>(o45, r45);
+      else
+        l45.template applyAdaptiveBoolean_<2>(o45, r45);
+      output_.insert(o45);
+    } else {
+      arbitrary_boolean_op<coordinate_type> abo;
+      abo.execute(output_, linput_.begin(), linput_.end(),
+                  rinput_.begin(), rinput_.end(), op_type);
+    }
+  }
+
+  template <typename ltype, typename rtype, int op_type>
+  class polygon_set_view {
+  public:
+    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_set_data<coordinate_type> value_type;
+    typedef typename value_type::iterator_type iterator_type;
+    typedef polygon_set_view operator_arg_type;
+  private:
+    const ltype& lvalue_;
+    const rtype& rvalue_;
+    mutable value_type output_;
+    mutable bool evaluated_;
+  public:
+    polygon_set_view(const ltype& lvalue,
+                     const rtype& rvalue ) :
+      lvalue_(lvalue), rvalue_(rvalue), output_(), evaluated_(false) {}
+
+    // get iterator to begin vertex data
+  public:
+    const value_type& value() const {
+      if(!evaluated_) {
+        evaluated_ = true;
+        execute_boolean_op<value_type, ltype, rtype, op_type>(output_, lvalue_, rvalue_, coordinate_type());
+      }
+      return output_;
+    }
+  public:
+    iterator_type begin() const { return value().begin(); }
+    iterator_type end() const { return value().end(); }
+
+    bool dirty() const { return false; } //result of a boolean is clean
+    bool sorted() const { return true; } //result of a boolean is sorted
+
+    void sort() const {} //is always sorted
+  };
+
+  template <typename ltype, typename rtype, int op_type>
+  typename polygon_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
+  begin(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
+    return polygon_set.begin();
+  }
+  template <typename ltype, typename rtype, int op_type>
+  typename polygon_set_view<ltype, rtype, op_type>::iterator_type 
+  polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
+  end(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
+    return polygon_set.end();
+  }
+  template <typename ltype, typename rtype, int op_type>
+  bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
+  clean(const polygon_set_view<ltype, rtype, op_type>& polygon_set) { 
+    return true; }
+  template <typename ltype, typename rtype, int op_type>
+  bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
+  sort(const polygon_set_view<ltype, rtype, op_type>& polygon_set) { 
+    return true; }
+
+  template <typename value_type, typename arg_type>
+  inline void insert_into_view_arg(value_type& dest, const arg_type& arg) {
+    typedef typename polygon_set_traits<arg_type>::iterator_type literator;
+    literator itr1, itr2;
+    itr1 = polygon_set_traits<arg_type>::begin(arg);
+    itr2 = polygon_set_traits<arg_type>::end(arg);
+    dest.insert(itr1, itr2);
+  }
+  
+  template <typename geometry_type_1, typename geometry_type_2, int op_type>
+  geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
+    typedef geometry_type_1 ltype;
+    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
+    typedef polygon_set_data<coordinate_type> value_type;
+    value_type output_;
+    execute_boolean_op<value_type, geometry_type_1, geometry_type_2, op_type>(output_, lvalue_, rvalue_, coordinate_type());
+    polygon_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end());
+    return lvalue_;
+  }
+
+  // copy constructor
+  template <typename coordinate_type>
+  template <typename ltype, typename rtype, int op_type> 
+  polygon_set_data<coordinate_type>::polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that) :
+    data_(that.value().data_), dirty_(that.value().dirty_), unsorted_(that.value().unsorted_), is_45_(that.value().is_45_) {}
+
+  template <typename ltype, typename rtype, int op_type>
+  struct geometry_concept<polygon_set_view<ltype, rtype, op_type> > { typedef polygon_set_concept type; };
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/property_merge.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/property_merge.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,588 @@
+/*
+  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_PROPERTY_MERGE_HPP
+#define BOOST_POLYGON_PROPERTY_MERGE_HPP
+namespace boost { namespace polygon{
+
+template <typename coordinate_type>
+class property_merge_point {
+private:
+  coordinate_type x_, y_;
+public:
+  inline property_merge_point() : x_(), y_() {}
+  inline property_merge_point(coordinate_type x, coordinate_type y) : x_(x), y_(y) {}
+  //use builtin assign and copy
+  inline bool operator==(const property_merge_point& that) const { return x_ == that.x_ && y_ == that.y_; }
+  inline bool operator!=(const property_merge_point& that) const { return !((*this) == that); }
+  inline bool operator<(const property_merge_point& that) const {
+    if(x_ < that.x_) return true;
+    if(x_ > that.x_) return false;
+    return y_ < that.y_;
+  }
+  inline coordinate_type x() const { return x_; }
+  inline coordinate_type y() const { return y_; }
+  inline void x(coordinate_type value) { x_ = value; }
+  inline void y(coordinate_type value) { y_ = value; }
+};
+
+template <typename coordinate_type>
+class property_merge_interval {
+private:
+  coordinate_type low_, high_;
+public:
+  inline property_merge_interval() : low_(), high_() {}
+  inline property_merge_interval(coordinate_type low, coordinate_type high) : low_(low), high_(high) {}
+  //use builtin assign and copy
+  inline bool operator==(const property_merge_interval& that) const { return low_ == that.low_ && high_ == that.high_; }
+  inline bool operator!=(const property_merge_interval& that) const { return !((*this) == that); }
+  inline bool operator<(const property_merge_interval& that) const {
+    if(low_ < that.low_) return true;
+    if(low_ > that.low_) return false;
+    return high_ < that.high_;
+  }
+  inline coordinate_type low() const { return low_; }
+  inline coordinate_type high() const { return high_; }
+  inline void low(coordinate_type value) { low_ = value; }
+  inline void high(coordinate_type value) { high_ = value; }
+};
+
+template <typename coordinate_type, typename property_type, typename polygon_set_type, typename keytype = std::set<property_type> >
+class merge_scanline {
+public:
+  //definitions
+
+  typedef keytype property_set;
+  typedef std::vector<std::pair<property_type, int> > property_map;
+  typedef std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > vertex_property;
+  typedef std::pair<property_merge_point<coordinate_type>, property_map> vertex_data;
+  typedef std::vector<vertex_property> property_merge_data;
+  //typedef std::map<property_set, polygon_set_type> Result;
+  typedef std::map<coordinate_type, property_map> scanline_type;
+  typedef typename scanline_type::iterator scanline_iterator;
+  typedef std::pair<property_merge_interval<coordinate_type>, std::pair<property_set, property_set> > edge_property;
+  typedef std::vector<edge_property> edge_property_vector;
+
+  //static public member functions
+
+  template <typename iT, typename orientation_2d_type>
+  static inline void 
+  populate_property_merge_data(property_merge_data& pmd, iT input_begin, iT input_end, 
+                               const property_type& property, orientation_2d_type orient) {
+    for( ; input_begin != input_end; ++input_begin) {
+      std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > element;
+      if(orient == HORIZONTAL)
+        element.first = property_merge_point<coordinate_type>((*input_begin).second.first, (*input_begin).first);
+      else
+        element.first = property_merge_point<coordinate_type>((*input_begin).first, (*input_begin).second.first);
+      element.second.first = property;
+      element.second.second = (*input_begin).second.second;
+      pmd.push_back(element);
+    }
+  }
+
+  //public member functions
+
+  merge_scanline() : output(), scanline(), currentVertex(), tmpVector(), previousY(), countFromBelow(), scanlinePosition() {}
+  merge_scanline(const merge_scanline& that) :
+    output(that.output),
+    scanline(that.scanline),
+    currentVertex(that.currentVertex),
+    tmpVector(that.tmpVector),
+    previousY(that.previousY),
+    countFromBelow(that.countFromBelow),
+    scanlinePosition(that.scanlinePosition)
+  {}
+  merge_scanline& operator=(const merge_scanline& that) {
+    output = that.output;
+    scanline = that.scanline;
+    currentVertex = that.currentVertex;
+    tmpVector = that.tmpVector;
+    previousY = that.previousY;
+    countFromBelow = that.countFromBelow;
+    scanlinePosition = that.scanlinePosition;
+    return *this;
+  }
+
+  template <typename result_type>
+  inline void perform_merge(result_type& result, property_merge_data& data) {
+    if(data.empty()) return;
+    //sort
+    std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>());
+    //scanline
+    bool firstIteration = true;
+    scanlinePosition = scanline.end();
+    for(unsigned int i = 0; i < data.size(); ++i) {
+      if(firstIteration) {
+        mergeProperty(currentVertex.second, data[i].second);
+        currentVertex.first = data[i].first;
+        firstIteration = false;
+      } else {
+        if(data[i].first != currentVertex.first) {
+          if(data[i].first.x() != currentVertex.first.x()) {
+            processVertex(output);
+            //std::cout << scanline.size() << " ";
+            countFromBelow.clear(); //should already be clear
+            writeOutput(currentVertex.first.x(), result, output);
+            currentVertex.second.clear();
+            mergeProperty(currentVertex.second, data[i].second);
+            currentVertex.first = data[i].first;
+            //std::cout << assertRedundant(scanline) << "/" << scanline.size() << " ";
+          } else {
+            processVertex(output);
+            currentVertex.second.clear();
+            mergeProperty(currentVertex.second, data[i].second);
+            currentVertex.first = data[i].first;
+          }
+        } else {
+          mergeProperty(currentVertex.second, data[i].second);
+        }
+      }
+    }
+    processVertex(output);
+    writeOutput(currentVertex.first.x(), result, output);
+    //std::cout << assertRedundant(scanline) << "/" << scanline.size() << "\n";
+    //std::cout << scanline.size() << "\n";
+  }
+
+private:
+  //private supporting types
+
+  template <class T>
+  class less_vertex_data {
+  public:
+    less_vertex_data() {}
+    bool operator()(const T& lvalue, const T& rvalue) {
+      if(lvalue.first.x() < rvalue.first.x()) return true;
+      if(lvalue.first.x() > rvalue.first.x()) return false;
+      if(lvalue.first.y() < rvalue.first.y()) return true;
+      return false;
+    }
+  };
+
+  template <typename T>
+  struct lessPropertyCount {
+    lessPropertyCount() {}
+    bool operator()(const T& a, const T& b) {
+      return a.first < b.first;
+    }
+  };
+
+  //private static member functions
+
+  static inline void mergeProperty(property_map& lvalue, std::pair<property_type, int>& rvalue) {
+    typename property_map::iterator itr = std::lower_bound(lvalue.begin(), lvalue.end(), rvalue, 
+                                                          lessPropertyCount<std::pair<property_type, int> >());
+    if(itr == lvalue.end() ||
+       (*itr).first != rvalue.first) {
+      lvalue.insert(itr, rvalue);
+    } else {
+      (*itr).second += rvalue.second;
+      if((*itr).second == 0)
+        lvalue.erase(itr);
+    }
+//     if(assertSorted(lvalue)) {
+//       std::cout << "in mergeProperty\n";
+//       exit(0);
+//     }
+  }
+
+  static inline bool assertSorted(property_map& pset) {
+    bool result = false;
+    for(unsigned int i = 1; i < pset.size(); ++i) {
+      if(pset[i] < pset[i-1]) {
+        std::cout << "Out of Order Error ";
+        result = true;
+      }
+      if(pset[i].first == pset[i-1].first) {
+        std::cout << "Duplicate Property Error ";
+        result = true;
+      }
+      if(pset[0].second == 0 || pset[1].second == 0) {
+        std::cout << "Empty Property Error ";
+        result = true;
+      }
+    }
+    return result;
+  }
+
+  static inline void setProperty(property_set& pset, property_map& pmap) {
+    for(typename property_map::iterator itr = pmap.begin(); itr != pmap.end(); ++itr) {
+      if((*itr).second > 0) {
+        pset.insert(pset.end(), (*itr).first);
+      }
+    }
+  }
+
+  //private data members
+
+  edge_property_vector output;
+  scanline_type scanline;
+  vertex_data currentVertex;
+  property_map tmpVector;
+  coordinate_type previousY;
+  property_map countFromBelow;
+  scanline_iterator scanlinePosition;
+
+  //private member functions
+
+  inline void mergeCount(property_map& lvalue, property_map& rvalue) {
+    typename property_map::iterator litr = lvalue.begin();
+    typename property_map::iterator ritr = rvalue.begin();
+    tmpVector.clear();
+    while(litr != lvalue.end() && ritr != rvalue.end()) {
+      if((*litr).first <= (*ritr).first) {
+        if(!tmpVector.empty() &&
+           (*litr).first == tmpVector.back().first) {
+          tmpVector.back().second += (*litr).second;
+        } else {
+          tmpVector.push_back(*litr);
+        }
+        ++litr;
+      } else if((*ritr).first <= (*litr).first) {
+        if(!tmpVector.empty() &&
+           (*ritr).first == tmpVector.back().first) {
+          tmpVector.back().second += (*ritr).second;
+        } else {
+          tmpVector.push_back(*ritr);
+        }
+        ++ritr;
+      }
+    }
+    while(litr != lvalue.end()) {
+      if(!tmpVector.empty() &&
+         (*litr).first == tmpVector.back().first) {
+        tmpVector.back().second += (*litr).second;
+      } else {
+        tmpVector.push_back(*litr);
+      }
+      ++litr;
+    }
+    while(ritr != rvalue.end()) {
+      if(!tmpVector.empty() &&
+         (*ritr).first == tmpVector.back().first) {
+        tmpVector.back().second += (*ritr).second;
+      } else {
+        tmpVector.push_back(*ritr);
+      }
+      ++ritr;
+    }
+    lvalue.clear();
+    for(unsigned int i = 0; i < tmpVector.size(); ++i) {
+      if(tmpVector[i].second != 0) {
+        lvalue.push_back(tmpVector[i]);
+      }
+    }
+//     if(assertSorted(lvalue)) {
+//       std::cout << "in mergeCount\n";
+//       exit(0);
+//     }
+  }
+
+  inline void processVertex(edge_property_vector& output) {
+    if(!countFromBelow.empty()) {
+      //we are processing an interval of change in scanline state between
+      //previous vertex position and current vertex position where 
+      //count from below represents the change on the interval
+      //foreach scanline element from previous to current we
+      //write the interval on the scanline that is changing
+      //the old value and the new value to output
+      property_merge_interval<coordinate_type> currentInterval(previousY, currentVertex.first.y());
+      coordinate_type currentY = currentInterval.low();
+      if(scanlinePosition == scanline.end() ||
+         (*scanlinePosition).first != previousY) {
+        scanlinePosition = scanline.lower_bound(previousY);
+      }
+      scanline_iterator previousScanlinePosition = scanlinePosition;
+      ++scanlinePosition;
+      while(scanlinePosition != scanline.end()) {
+        coordinate_type elementY = (*scanlinePosition).first;
+        if(elementY <= currentInterval.high()) {
+          property_map& countOnLeft = (*previousScanlinePosition).second;
+          edge_property element;
+          output.push_back(element);
+          output.back().first = property_merge_interval<coordinate_type>((*previousScanlinePosition).first, elementY);
+          setProperty(output.back().second.first, countOnLeft);
+          mergeCount(countOnLeft, countFromBelow);
+          setProperty(output.back().second.second, countOnLeft);
+          if(output.back().second.first == output.back().second.second) {
+            output.pop_back(); //it was an internal vertical edge, not to be output
+          }
+          else if(output.size() > 1) {
+            edge_property& secondToLast = output[output.size()-2];
+            if(secondToLast.first.high() == output.back().first.low() &&
+               secondToLast.second.first == output.back().second.first &&
+               secondToLast.second.second == output.back().second.second) {
+              //merge output onto previous output because properties are
+              //identical on both sides implying an internal horizontal edge
+              secondToLast.first.high(output.back().first.high());
+              output.pop_back();
+            }
+          }
+          if(previousScanlinePosition == scanline.begin()) {
+            if(countOnLeft.empty()) {
+              scanline.erase(previousScanlinePosition);
+            }
+          } else {
+            scanline_iterator tmpitr = previousScanlinePosition;
+            --tmpitr;
+            if((*tmpitr).second == (*previousScanlinePosition).second)
+              scanline.erase(previousScanlinePosition);
+          }
+             
+        } else if(currentY < currentInterval.high()){
+          //elementY > currentInterval.high()
+          //split the interval between previous and current scanline elements
+          std::pair<coordinate_type, property_map> elementScan;
+          elementScan.first = currentInterval.high();
+          elementScan.second = (*previousScanlinePosition).second;
+          scanlinePosition = scanline.insert(scanlinePosition, elementScan);
+          continue;
+        } else {
+          break;
+        }
+        previousScanlinePosition = scanlinePosition;
+        currentY = previousY = elementY;
+        ++scanlinePosition;
+        if(scanlinePosition == scanline.end() &&
+           currentY < currentInterval.high()) {
+          //insert a new element for top of range
+          std::pair<coordinate_type, property_map> elementScan;
+          elementScan.first = currentInterval.high();
+          scanlinePosition = scanline.insert(scanline.end(), elementScan);
+        } 
+      }
+      if(scanlinePosition == scanline.end() &&
+         currentY < currentInterval.high()) {
+        //handle case where we iterated to end of the scanline
+        //we need to insert an element into the scanline at currentY
+        //with property value coming from below
+        //and another one at currentInterval.high() with empty property value
+        mergeCount(scanline[currentY], countFromBelow);
+        std::pair<coordinate_type, property_map> elementScan;
+        elementScan.first = currentInterval.high();
+        scanline.insert(scanline.end(), elementScan);
+
+        edge_property element;
+        output.push_back(element);
+        output.back().first = property_merge_interval<coordinate_type>(currentY, currentInterval.high());
+        setProperty(output.back().second.second, countFromBelow);
+        mergeCount(countFromBelow, currentVertex.second);
+      } else {
+        mergeCount(countFromBelow, currentVertex.second);
+        if(countFromBelow.empty()) {
+          if(previousScanlinePosition == scanline.begin()) {
+            if((*previousScanlinePosition).second.empty()) {
+              scanline.erase(previousScanlinePosition);
+              //previousScanlinePosition = scanline.end();
+              //std::cout << "ERASE_A ";
+            }
+          } else {
+            scanline_iterator tmpitr = previousScanlinePosition;
+            --tmpitr;
+            if((*tmpitr).second == (*previousScanlinePosition).second) {
+              scanline.erase(previousScanlinePosition);
+              //previousScanlinePosition = scanline.end();
+              //std::cout << "ERASE_B ";
+            }
+          }
+        }
+      }
+    } else {
+      //count from below is empty, we are starting a new interval of change
+      countFromBelow = currentVertex.second;
+      scanlinePosition = scanline.lower_bound(currentVertex.first.y());
+      if(scanlinePosition != scanline.end()) {
+        if((*scanlinePosition).first != currentVertex.first.y()) {
+          if(scanlinePosition != scanline.begin()) {
+            //decrement to get the lower position of the first interval this vertex intersects
+            --scanlinePosition;
+            //insert a new element into the scanline for the incoming vertex
+            property_map& countOnLeft = (*scanlinePosition).second;
+            std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
+            scanlinePosition = scanline.insert(scanlinePosition, element);
+          } else {
+            property_map countOnLeft;
+            std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
+            scanlinePosition = scanline.insert(scanlinePosition, element);
+          }
+        }
+      } else {
+        property_map countOnLeft;
+        std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
+        scanlinePosition = scanline.insert(scanlinePosition, element);
+      }
+    }
+    previousY = currentVertex.first.y();
+  }
+
+  template <typename T>
+  inline int assertRedundant(T& t) {
+    if(t.empty()) return 0;
+    int count = 0; 
+    typename T::iterator itr = t.begin();
+    if((*itr).second.empty())
+      ++count;
+    typename T::iterator itr2 = itr;
+    ++itr2;
+    while(itr2 != t.end()) {
+      if((*itr).second == (*itr2).second)
+        ++count;
+      itr = itr2;
+      ++itr2;
+    }
+    return count;
+  }
+
+  template <typename T>
+  inline void performExtract(T& result, property_merge_data& data) {
+    if(data.empty()) return;
+    //sort
+    std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>());
+    
+    //scanline
+    bool firstIteration = true;
+    scanlinePosition = scanline.end();
+    for(unsigned int i = 0; i < data.size(); ++i) {
+      if(firstIteration) {
+        mergeProperty(currentVertex.second, data[i].second);
+        currentVertex.first = data[i].first;
+        firstIteration = false;
+      } else {
+        if(data[i].first != currentVertex.first) {
+          if(data[i].first.x() != currentVertex.first.x()) {
+            processVertex(output);
+            //std::cout << scanline.size() << " ";
+            countFromBelow.clear(); //should already be clear
+            writeGraph(currentVertex.first.x(), result, output, scanline);
+            currentVertex.second.clear();
+            mergeProperty(currentVertex.second, data[i].second);
+            currentVertex.first = data[i].first;
+          } else {
+            processVertex(output);
+            currentVertex.second.clear();
+            mergeProperty(currentVertex.second, data[i].second);
+            currentVertex.first = data[i].first;
+          }
+        } else {
+          mergeProperty(currentVertex.second, data[i].second);
+        }
+      }
+    }
+    processVertex(output);
+    writeGraph(currentVertex.first.x(), result, output, scanline);
+    //std::cout << scanline.size() << "\n";
+  }
+
+  template <typename T>
+  inline void insertEdges(T& graph, property_set& p1, property_set& p2) {
+    for(typename property_set::iterator itr = p1.begin(); itr != p1.end(); ++itr) {
+      for(typename property_set::iterator itr2 = p2.begin(); itr2 != p2.end(); ++itr2) {
+        if(*itr != *itr2) {
+          graph[*itr].insert(*itr2);
+          graph[*itr2].insert(*itr);
+        }
+      }
+    }
+  }
+
+  template <typename T>
+  inline void propertySetAbove(coordinate_type y, property_set& ps, T& scanline) {
+    ps.clear();
+    typename T::iterator itr = scanline.find(y);
+    if(itr != scanline.end())
+      setProperty(ps, (*itr).second);
+  }
+
+  template <typename T>
+  inline void propertySetBelow(coordinate_type y, property_set& ps, T& scanline) {
+    ps.clear();
+    typename T::iterator itr = scanline.find(y);
+    if(itr != scanline.begin()) {
+      --itr;
+      setProperty(ps, (*itr).second);
+    }
+  }
+
+  template <typename T, typename T2>
+  inline void writeGraph(coordinate_type x, T& graph, edge_property_vector& output, T2& scanline) {
+    if(output.empty()) return;
+    edge_property* previousEdgeP = &(output[0]);
+    bool firstIteration = true;
+    property_set ps;
+    for(unsigned int i = 0; i < output.size(); ++i) {
+      edge_property& previousEdge = *previousEdgeP;
+      edge_property& edge = output[i];
+      if(previousEdge.first.high() == edge.first.low()) {
+        //horizontal edge
+        insertEdges(graph, edge.second.first, previousEdge.second.first);
+        //corner 1
+        insertEdges(graph, edge.second.first, previousEdge.second.second);
+        //other horizontal edge
+        insertEdges(graph, edge.second.second, previousEdge.second.second);
+        //corner 2
+        insertEdges(graph, edge.second.second, previousEdge.second.first);
+      } else {
+        if(!firstIteration){
+          //look up regions above previous edge 
+          propertySetAbove(previousEdge.first.high(), ps, scanline);
+          insertEdges(graph, ps, previousEdge.second.first);
+          insertEdges(graph, ps, previousEdge.second.second);
+        }
+        //look up regions below current edge in the scanline
+        propertySetBelow(edge.first.high(), ps, scanline);
+        insertEdges(graph, ps, edge.second.first);
+        insertEdges(graph, ps, edge.second.second);
+      }
+      firstIteration = false;
+      //vertical edge
+      insertEdges(graph, edge.second.second, edge.second.first);
+      //shared region to left
+      insertEdges(graph, edge.second.second, edge.second.second);
+      //shared region to right
+      insertEdges(graph, edge.second.first, edge.second.first);
+      previousEdgeP = &(output[i]);
+    }
+    edge_property& previousEdge = *previousEdgeP;
+    propertySetAbove(previousEdge.first.high(), ps, scanline);
+    insertEdges(graph, ps, previousEdge.second.first);
+    insertEdges(graph, ps, previousEdge.second.second);
+    output.clear();
+  }
+
+  template <typename Result>
+  inline void writeOutput(coordinate_type x, Result& result, edge_property_vector& output) {
+    for(unsigned int i = 0; i < output.size(); ++i) {
+      edge_property& edge = output[i];
+      //edge.second.first is the property set on the left of the edge
+      if(!edge.second.first.empty()) {
+        typename Result::iterator itr = result.find(edge.second.first);
+        if(itr == result.end()) {
+          std::pair<property_set, polygon_set_type> element(edge.second.first, polygon_set_type(VERTICAL));
+          itr = result.insert(result.end(), element);
+        }
+        std::pair<interval_data<coordinate_type>, int> element2(interval_data<coordinate_type>(edge.first.low(), edge.first.high()), -1); //right edge of figure
+        (*itr).second.insert(x, element2);
+      }
+      if(!edge.second.second.empty()) {
+        //edge.second.second is the property set on the right of the edge
+        typename Result::iterator itr = result.find(edge.second.second);
+        if(itr == result.end()) {
+          std::pair<property_set, polygon_set_type> element(edge.second.second, polygon_set_type(VERTICAL));
+          itr = result.insert(result.end(), element);
+        }
+        std::pair<interval_data<coordinate_type>, int> element3(interval_data<coordinate_type>(edge.first.low(), edge.first.high()), 1); //left edge of figure
+        (*itr).second.insert(x, element3);
+      }
+    }
+    output.clear();
+  }
+};
+
+}
+}
+#endif
Added: sandbox/gtl/boost/polygon/detail/rectangle_formation.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/rectangle_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,267 @@
+/*
+    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_RECTANGLE_FORMATION_HPP
+#define BOOST_POLYGON_RECTANGLE_FORMATION_HPP
+namespace boost { namespace polygon{
+
+namespace rectangle_formation {
+  template <class T> 
+  class ScanLineToRects {
+  public:
+    typedef T rectangle_type;
+    typedef typename rectangle_traits<T>::coordinate_type coordinate_type;
+    typedef rectangle_data<coordinate_type> scan_rect_type;
+  private:
+    
+    typedef std::set<scan_rect_type, less_rectangle_concept<scan_rect_type, scan_rect_type> > ScanData;
+    ScanData scanData_;
+    bool haveCurrentRect_;
+    scan_rect_type currentRect_;
+    orientation_2d orient_;
+    typename rectangle_traits<T>::coordinate_type currentCoordinate_;
+  public:
+    inline ScanLineToRects() : scanData_(), haveCurrentRect_(), currentRect_(), orient_(), currentCoordinate_() {}
+    
+    inline ScanLineToRects(orientation_2d orient, rectangle_type model) :
+      scanData_(orientation_2d(orient.to_int() ? VERTICAL : HORIZONTAL)),
+      haveCurrentRect_(false), currentRect_(), orient_(orient), currentCoordinate_() {
+      assign(currentRect_, model);
+      currentCoordinate_ = (std::numeric_limits<coordinate_type>::max)();
+    }
+    
+    template <typename CT>
+    inline ScanLineToRects& processEdge(CT& rectangles, const interval_data<coordinate_type>& edge);
+    
+    inline ScanLineToRects& nextMajorCoordinate(coordinate_type currentCoordinate) {
+      if(haveCurrentRect_) {
+        scanData_.insert(scanData_.end(), currentRect_);
+        haveCurrentRect_ = false;
+      }
+      currentCoordinate_ = currentCoordinate;
+      return *this;
+    }
+    
+  };
+
+  template <class CT, class ST, class rectangle_type, typename interval_type, typename coordinate_type> inline CT& 
+  processEdge_(CT& rectangles, ST& scanData, const interval_type& edge, 
+               bool& haveCurrentRect, rectangle_type& currentRect, coordinate_type currentCoordinate, orientation_2d orient) 
+  {
+    typedef typename CT::value_type result_type;
+    bool edgeProcessed = false;
+    if(!scanData.empty()) {
+
+      //process all rectangles in the scanData that touch the edge
+      typename ST::iterator dataIter = scanData.lower_bound(rectangle_type(edge, edge));
+      //decrement beginIter until its low is less than edge's low
+      while((dataIter == scanData.end() || (*dataIter).get(orient).get(LOW) > edge.get(LOW)) && 
+            dataIter != scanData.begin())
+        {
+          --dataIter;
+        }
+      //process each rectangle until the low end of the rectangle 
+      //is greater than the high end of the edge
+      while(dataIter != scanData.end() &&
+            (*dataIter).get(orient).get(LOW) <= edge.get(HIGH)) 
+        {
+          const rectangle_type& rect = *dataIter;
+          //if the rectangle data intersects the edge at all
+          if(rect.get(orient).get(HIGH) >= edge.get(LOW)) {
+            if(contains(rect.get(orient), edge, true)) {
+              //this is a closing edge
+              //we need to write out the intersecting rectangle and
+              //insert between 0 and 2 rectangles into the scanData
+              //write out rectangle
+              rectangle_type tmpRect = rect;
+
+              if(rect.get(orient.get_perpendicular()).get(LOW) < currentCoordinate) {
+                //set the high coordinate perpedicular to slicing orientation
+                //to the current coordinate of the scan event
+                tmpRect.set(orient.get_perpendicular().get_direction(HIGH),
+                            currentCoordinate);
+                result_type result;
+                assign(result, tmpRect);
+                rectangles.insert(rectangles.end(), result);
+              }
+              //erase the rectangle from the scan data
+              typename ST::iterator nextIter = dataIter;
+              ++nextIter;
+              scanData.erase(dataIter);
+              if(tmpRect.get(orient).get(LOW) < edge.get(LOW)) {
+                //insert a rectangle for the overhang of the bottom
+                //of the rectangle back into scan data
+                rectangle_type lowRect(tmpRect);
+                lowRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
+                                                                currentCoordinate));
+                lowRect.set(orient.get_direction(HIGH), edge.get(LOW));
+                scanData.insert(nextIter, lowRect);
+              }
+              if(tmpRect.get(orient).get(HIGH) > edge.get(HIGH)) {
+                //insert a rectangle for the overhang of the top
+                //of the rectangle back into scan data
+                rectangle_type highRect(tmpRect);
+                highRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
+                                                                 currentCoordinate));
+                highRect.set(orient.get_direction(LOW), edge.get(HIGH));
+                scanData.insert(nextIter, highRect);
+              }
+              //we are done with this edge
+              edgeProcessed = true;                 
+              break;
+            } else {
+              //it must be an opening edge
+              //assert that rect does not overlap the edge but only touches
+              //write out rectangle
+              rectangle_type tmpRect = rect;
+              //set the high coordinate perpedicular to slicing orientation
+              //to the current coordinate of the scan event
+              if(tmpRect.get(orient.get_perpendicular().get_direction(LOW)) < currentCoordinate) {
+                tmpRect.set(orient.get_perpendicular().get_direction(HIGH),
+                            currentCoordinate);
+                result_type result;
+                assign(result, tmpRect);
+                rectangles.insert(rectangles.end(), result);
+              }
+              //erase the rectangle from the scan data
+              typename ST::iterator nextIter = dataIter;
+              ++nextIter;
+              scanData.erase(dataIter);
+              dataIter = nextIter;
+              if(haveCurrentRect) {
+                if(currentRect.get(orient).get(HIGH) >= edge.get(LOW)){
+                  if(!edgeProcessed && currentRect.get(orient.get_direction(HIGH)) > edge.get(LOW)){
+                    rectangle_type tmpRect2(currentRect);
+                    tmpRect2.set(orient.get_direction(HIGH), edge.get(LOW));
+                    scanData.insert(nextIter, tmpRect2);
+                    if(currentRect.get(orient.get_direction(HIGH)) > edge.get(HIGH)) {
+                      currentRect.set(orient, interval_data<coordinate_type>(edge.get(HIGH), currentRect.get(orient.get_direction(HIGH))));
+                    } else {
+                      haveCurrentRect = false;
+                    }
+                  } else {
+                    //extend the top of current rect
+                    currentRect.set(orient.get_direction(HIGH), 
+                                    (std::max)(edge.get(HIGH), 
+                                               tmpRect.get(orient.get_direction(HIGH))));
+                  }
+                } else {
+                  //insert current rect into the scanData
+                  scanData.insert(nextIter, currentRect);
+                  //create a new current rect
+                  currentRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
+                                                                      currentCoordinate));
+                  currentRect.set(orient, interval_data<coordinate_type>((std::min)(tmpRect.get(orient).get(LOW), 
+                                                       edge.get(LOW)),
+                                                                         (std::max)(tmpRect.get(orient).get(HIGH),
+                                                       edge.get(HIGH))));
+                }
+              } else {
+                haveCurrentRect = true;
+                currentRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
+                                                                    currentCoordinate));
+                currentRect.set(orient, interval_data<coordinate_type>((std::min)(tmpRect.get(orient).get(LOW), 
+                                                     edge.get(LOW)),
+                                                                       (std::max)(tmpRect.get(orient).get(HIGH),
+                                                     edge.get(HIGH))));
+              }
+              //skip to nextIter position
+              edgeProcessed = true;
+              continue;
+            }
+            //edgeProcessed = true;
+          }
+          ++dataIter;
+        } //end while edge intersects rectangle data 
+
+    }
+    if(!edgeProcessed) {
+      if(haveCurrentRect) {
+        if(currentRect.get(orient.get_perpendicular().get_direction(HIGH)) 
+           == currentCoordinate &&
+           currentRect.get(orient.get_direction(HIGH)) >= edge.get(LOW)) 
+          {
+            if(currentRect.get(orient.get_direction(HIGH)) > edge.get(LOW)){
+              rectangle_type tmpRect(currentRect);
+              tmpRect.set(orient.get_direction(HIGH), edge.get(LOW));
+              scanData.insert(scanData.end(), tmpRect);
+              if(currentRect.get(orient.get_direction(HIGH)) > edge.get(HIGH)) {
+                currentRect.set(orient, 
+                                interval_data<coordinate_type>(edge.get(HIGH), 
+                                         currentRect.get(orient.get_direction(HIGH))));
+                return rectangles;
+              } else {
+                haveCurrentRect = false;
+                return rectangles;
+              }
+            }
+            //extend current rect
+            currentRect.set(orient.get_direction(HIGH), edge.get(HIGH));
+            return rectangles;
+          }
+        scanData.insert(scanData.end(), currentRect);
+        haveCurrentRect = false;
+      } 
+      rectangle_type tmpRect(currentRect);
+      tmpRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
+                                                      currentCoordinate));
+      tmpRect.set(orient, edge);
+      scanData.insert(tmpRect);
+      return rectangles;
+    }
+    return rectangles;
+  
+  }
+
+  template <class T> 
+  template <class CT> 
+  inline 
+  ScanLineToRects<T>& ScanLineToRects<T>::processEdge(CT& rectangles, const interval_data<coordinate_type>& edge) 
+  {
+    processEdge_(rectangles, scanData_, edge, haveCurrentRect_, currentRect_, currentCoordinate_, orient_);
+    return *this;
+  }
+
+
+} //namespace rectangle_formation
+
+  template <typename T, typename T2>
+  struct get_coordinate_type_for_rectangles {
+    typedef typename polygon_traits<T>::coordinate_type type;
+  };
+  template <typename T>
+  struct get_coordinate_type_for_rectangles<T, rectangle_concept> {
+    typedef typename rectangle_traits<T>::coordinate_type type;
+  };
+
+  template <typename output_container, typename iterator_type, typename rectangle_concept>
+  void form_rectangles(output_container& output, iterator_type begin, iterator_type end,
+                       orientation_2d orient, rectangle_concept tag) {
+    typedef typename output_container::value_type rectangle_type;
+    typedef typename get_coordinate_type_for_rectangles<rectangle_type, typename geometry_concept<rectangle_type>::type>::type Unit;
+    rectangle_data<Unit> model;
+    Unit prevPos = (std::numeric_limits<Unit>::max)();
+    rectangle_formation::ScanLineToRects<rectangle_data<Unit> > scanlineToRects(orient, model);
+    for(iterator_type itr = begin;
+        itr != end; ++ itr) {
+      Unit pos = (*itr).first;
+      if(pos != prevPos) {
+        scanlineToRects.nextMajorCoordinate(pos);
+        prevPos = pos;
+      }
+      Unit lowy = (*itr).second.first;
+      iterator_type tmp_itr = itr;
+      ++itr;
+      Unit highy = (*itr).second.first;
+      scanlineToRects.processEdge(output, interval_data<Unit>(lowy, highy));
+      if(abs((*itr).second.second) > 1) itr = tmp_itr; //next edge begins from this vertex
+    }
+  }
+}
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/scan_arbitrary.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/scan_arbitrary.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,2533 @@
+/*
+  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
+#include <fstream>
+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) {
+      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_() { (*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);
+    }
+    
+    //quadratic algorithm to do same work as optimal scan for cross checking
+    //assume sorted input
+    template <typename iT>
+    static inline void validate_scan(std::map<segment_id, std::set<Point> >& intersection_points,
+                                     iT begin, iT end) {
+      std::set<Point> pts;
+      std::vector<std::pair<half_edge, segment_id> > data(begin, end);
+      for(unsigned int i = 0; i < data.size(); ++i) {
+        if(data[i].first.second < data[i].first.first) {
+          std::swap(data[i].first.first, data[i].first.second);
+        }
+      }
+      std::sort(data.begin(), data.end());
+      //find all intersection points
+      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
+          outer != data.end(); ++outer) {
+        const half_edge& he1 = (*outer).first;
+        //its own end points
+        pts.insert(he1.first);
+        pts.insert(he1.second);
+        for(typename std::vector<std::pair<half_edge, segment_id> >::iterator inner = outer;
+            inner != data.end(); ++inner) {
+          const half_edge& he2 = (*inner).first;
+          if(he1 == he2) continue;
+          if((std::min)(he2. first.get(HORIZONTAL),
+                        he2.second.get(HORIZONTAL)) > 
+             (std::max)(he1.second.get(HORIZONTAL),
+                        he1.first.get(HORIZONTAL)))
+            break;
+          Point intersection;
+          if(compute_intersection(intersection, he1, he2)) {
+            //their intersection point
+            pts.insert(intersection);
+          } 
+        }
+      }
+      //find all segments that interact with intersection points
+      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
+          outer != data.end(); ++outer) {
+        const half_edge& he1 = (*outer).first;
+        segment_id id1 = (*outer).second;
+        typedef rectangle_data<Unit> Rectangle;
+        Rectangle rect1;
+        set_points(rect1, he1.first, he1.second);
+        typename std::set<Point>::iterator itr = pts.lower_bound((std::min)(he1.first, he1.second));
+        typename std::set<Point>::iterator itr2 = pts.upper_bound((std::max)(he1.first, he1.second));
+        while(itr != pts.end() && itr != pts.begin() && (*itr).get(HORIZONTAL) >= (std::min)(he1.first.get(HORIZONTAL), he1.second.get(HORIZONTAL))) --itr;
+        while(itr2 != pts.end() && (*itr2).get(HORIZONTAL) <= (std::max)(he1.first.get(HORIZONTAL), he1.second.get(HORIZONTAL))) ++itr2;
+        //itr = pts.begin();
+        //itr2 = pts.end();
+        for( ; itr != itr2; ++itr) {
+          if(intersects_grid(*itr, he1))
+            intersection_points[id1].insert(*itr);
+        }
+      }
+    }
+
+    template <typename iT, typename property_type>
+    static inline void validate_scan(std::vector<std::pair<half_edge, std::pair<property_type, int> > >& output_segments,
+                                     iT begin, iT end) {
+      std::vector<std::pair<property_type, int> > input_properties;
+      std::vector<std::pair<half_edge, int> > input_segments, intermediate_segments;
+      int index = 0;
+      for( ; begin != end; ++begin) {
+        input_properties.push_back((*begin).second);
+        input_segments.push_back(std::make_pair((*begin).first, index++));
+      }
+      validate_scan(intermediate_segments, input_segments.begin(), input_segments.end());
+      for(unsigned int i = 0; i < intermediate_segments.size(); ++i) {
+        output_segments.push_back(std::make_pair(intermediate_segments[i].first,
+                                                 input_properties[intermediate_segments[i].second]));
+        less_point lp;
+        if(lp(output_segments.back().first.first, output_segments.back().first.second) !=
+           lp(input_segments[intermediate_segments[i].second].first.first,
+              input_segments[intermediate_segments[i].second].first.second)) {
+          //edge changed orientation, invert count on edge
+          output_segments.back().second.second *= -1;
+        }
+        if(!is_vertical(input_segments[intermediate_segments[i].second].first) &&
+           is_vertical(output_segments.back().first)) {
+          output_segments.back().second.second *= -1;
+        }
+        if(lp(output_segments.back().first.second, output_segments.back().first.first)) {
+          std::swap(output_segments.back().first.first, output_segments.back().first.second);
+        }
+      }
+    }
+
+    template <typename iT>
+    static inline void validate_scan(std::vector<std::pair<half_edge, int> >& output_segments,
+                                     iT begin, iT end) {
+      std::map<segment_id, std::set<Point> > intersection_points;
+      validate_scan(intersection_points, begin, end);
+      segment_intersections(output_segments, intersection_points, begin, end);
+    }
+
+    //quadratic algorithm to find intersections
+    template <typename iT, typename segment_id>
+    static inline bool verify_scan(std::pair<segment_id, segment_id>& offenders,
+                                   iT begin, iT end) {
+
+      std::vector<std::pair<half_edge, segment_id> > data(begin, end);
+      for(unsigned int i = 0; i < data.size(); ++i) {
+        if(data[i].first.second < data[i].first.first) {
+          std::swap(data[i].first.first, data[i].first.second);
+        }
+      }
+      std::sort(data.begin(), data.end());
+      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
+          outer != data.end(); ++outer) {
+        const half_edge& he1 = (*outer).first;
+        segment_id id1 = (*outer).second;
+        for(typename std::vector<std::pair<half_edge, segment_id> >::iterator inner = outer;
+            inner != data.end(); ++inner) {
+          const half_edge& he2 = (*inner).first;
+          if(he1 == he2) continue;
+          if((std::min)(he2. first.get(HORIZONTAL),
+                        he2.second.get(HORIZONTAL)) > 
+             (std::max)(he1.second.get(HORIZONTAL),
+                        he1.first.get(HORIZONTAL)))
+            break;
+          segment_id id2 = (*inner).second;
+          if(scanline_base<Unit>::intersects(he1, he2)) {
+            offenders.first = id1;
+            offenders.second = id2;
+            return false;
+          }
+        }
+      }
+      return true;
+    }
+
+    class less_point_down_slope : public std::binary_function<Point, Point, bool> {
+    public:
+      inline less_point_down_slope() {}
+      inline bool operator () (const Point& pt1, const Point& pt2) const {
+        if(pt1.get(HORIZONTAL) < pt2.get(HORIZONTAL)) return true;
+        if(pt1.get(HORIZONTAL) == pt2.get(HORIZONTAL)) {
+          if(pt1.get(VERTICAL) > pt2.get(VERTICAL)) return true;
+        }
+        return false;
+      }
+    };
+
+    template <typename iT>
+    static inline void segment_edge(std::vector<std::pair<half_edge, int> >& output_segments,
+                                    const half_edge& he, segment_id id, iT begin, iT end) {
+      iT current = begin;
+      iT next = begin;
+      ++next;
+      while(next != end) {
+        output_segments.push_back(std::make_pair(half_edge(*current, *next), id));
+        current = next;
+        ++next;
+      }
+    }
+
+    template <typename iT>
+    static inline void segment_intersections(std::vector<std::pair<half_edge, int> >& output_segments,
+                                             std::map<segment_id, std::set<Point> >& intersection_points,
+                                             iT begin, iT end) {
+      for(iT iter = begin; iter != end; ++iter) {
+        //less_point lp;
+        const half_edge& he = (*iter).first;
+        //if(lp(he.first, he.second)) {
+        //  //it is the begin event
+          segment_id id = (*iter).second;
+          const std::set<Point>& pts = intersection_points[id];
+          Point hpt(he.first.get(HORIZONTAL)+1, he.first.get(VERTICAL));
+          if(!is_vertical(he) && less_slope(he.first.get(HORIZONTAL), he.first.get(VERTICAL),
+                                            he.second, hpt)) {
+            //slope is below horizontal
+            std::vector<Point> tmpPts;
+            tmpPts.reserve(pts.size());
+            tmpPts.insert(tmpPts.end(), pts.begin(), pts.end());
+            less_point_down_slope lpds;
+            std::sort(tmpPts.begin(), tmpPts.end(), lpds);
+            segment_edge(output_segments, he, id, tmpPts.begin(), tmpPts.end());
+          } else {
+            segment_edge(output_segments, he, id, pts.begin(), pts.end());
+          }
+          //}
+      }
+    }
+
+    //iT iterator over unsorted pair<Point> representing line segments of input
+    //output_segments is populated with fully intersected output line segment half
+    //edges and the index of the input segment that they are assoicated with
+    //duplicate output half edges with different ids will be generated in the case
+    //that parallel input segments intersection
+    //outputs are in sorted order and include both begin and end events for
+    //each segment
+    template <typename iT>
+    inline void scan(std::vector<std::pair<half_edge, int> >& output_segments,
+                     iT begin, iT end) {
+      std::map<segment_id, std::set<Point> > intersection_points;
+      scan(intersection_points, begin, end);
+      segment_intersections(output_segments, intersection_points, begin, end);
+    }
+
+    //iT iterator over sorted sequence of half edge, segment id pairs representing segment begin and end points
+    //intersection points provides a mapping from input segment id (vector index) to the set
+    //of intersection points assocated with that input segment
+    template <typename iT>
+    inline void scan(std::map<segment_id, std::set<Point> >& intersection_points,
+                     iT begin, iT end) {
+      for(iT iter = begin; iter != end; ++iter) {
+        const std::pair<half_edge, int>& elem = *iter;
+        const half_edge& he = elem.first;
+        Unit current_x = he.first.get(HORIZONTAL);
+        if(current_x != x_) {
+          process_scan_event(intersection_points);
+          while(!intersection_queue_.empty() &&
+                (*(intersection_queue_.begin()).get(HORIZONTAL) < current_x)) {
+            x_ = *(intersection_queue_.begin()).get(HORIZONTAL);
+            process_intersections_at_scan_event(intersection_points);
+          }
+          x_ = current_x;
+        }
+        event_edges_.push_back(elem);
+      }
+      process_scan_event(intersection_points);
+    }
+
+    inline iterator lookup(const half_edge& he) {
+      return edge_scanline_.find(he);
+    }
+
+    inline void insert_into_scanline(const half_edge& he, int id) {
+      edge_scanline_[he].insert(id);
+    }
+
+    inline void lookup_and_remove(const half_edge& he, int id) {
+      iterator remove_iter = lookup(he);
+      if(remove_iter == edge_scanline_.end()) {
+        std::cout << "failed to find removal segment in scanline\n";
+        return;
+      }
+      std::set<segment_id>& ids = (*remove_iter).second;
+      std::set<segment_id>::iterator id_iter = ids.find(id);
+      if(id_iter == ids.end()) {
+        std::cout << "failed to find removal segment id in scanline set\n";
+        return;
+      }
+      ids.erase(id_iter);
+      if(ids.empty())
+        edge_scanline_.erase(remove_iter);
+    }
+
+    static inline void update_segments(std::map<segment_id, std::set<Point> >& intersection_points, 
+                                       const std::set<segment_id>& segments, Point pt) {
+      for(std::set<segment_id>::const_iterator itr = segments.begin(); itr != segments.end(); ++itr) {
+        intersection_points[*itr].insert(pt);
+      }
+    }
+
+    inline void process_intersections_at_scan_event(std::map<segment_id, std::set<Point> >& intersection_points) {
+      //there may be additional intersection points at this x location that haven't been
+      //found yet if vertical or near vertical line segments intersect more than
+      //once before the next x location
+      just_before_ = true;
+      std::set<iterator> intersecting_elements;
+      std::set<Unit> intersection_locations;
+      typedef typename std::set<Point>::iterator intersection_iterator;
+      intersection_iterator iter;
+      //first find all secondary intersection locations and all scanline iterators
+      //that are intersecting
+      for(iter = intersection_queue_.begin();
+          iter != intersection_queue_.end() && (*iter).get(HORIZONTAL) == x_; ++iter) {
+        Point pt = *iter;
+        Unit y = pt.get(VERTICAL);
+        intersection_locations.insert(y);
+        //if x_ is max there can be only end events and no sloping edges
+        if(x_ != (std::numeric_limits<Unit>::max)()) {
+          //deal with edges that project to the right of scanline
+          //first find the edges in the scanline adjacent to primary intersectin points
+          //lookup segment in scanline at pt
+          iterator itr = edge_scanline_.lower_bound(half_edge(pt, Point(x_+1, y)));
+          //look above pt in scanline until reaching end or segment that doesn't intersect
+          //1x1 grid upper right of pt
+          //look below pt in scanline until reaching begin or segment that doesn't interset
+          //1x1 grid upper right of pt
+
+          //second find edges in scanline on the y interval of each edge found in the previous
+          //step for x_ to x_ + 1
+
+          //third find overlaps in the y intervals of all found edges to find all
+          //secondary intersection points
+
+        }
+      }
+      //erase the intersection points from the queue
+      intersection_queue_.erase(intersection_queue_.begin(), iter);
+      std::vector<scanline_element> insertion_edges;
+      insertion_edges.reserve(intersecting_elements.size());
+      std::vector<std::pair<Unit, iterator> > sloping_ends;
+      //do all the work of updating the output of all intersecting 
+      for(typename std::set<iterator>::iterator inter_iter = intersecting_elements.begin();
+          inter_iter != intersecting_elements.end(); ++inter_iter) {
+        //if it is horizontal update it now and continue
+        if(is_horizontal((*inter_iter).first)) {
+          update_segments(intersection_points, (*inter_iter).second, Point(x_, (*inter_iter).first.get(VERTICAL)));
+        } else {
+          //if x_ is max there can be only end events and no sloping edges
+          if(x_ != (std::numeric_limits<Unit>::max)()) {
+            //insert its end points into the vector of sloping ends
+            const half_edge& he = (*inter_iter).first;
+            Unit y = evalAtXforY(x_, he.first, he.second);
+            Unit y2 = evalAtXforY(x_+1, he.first, he.second); 
+            if(y2 >= y) y2 +=1; //we round up, in exact case we don't worry about overbite of one
+            else y += 1; //downward sloping round up
+            sloping_ends.push_back(std::make_pair(y, inter_iter));
+            sloping_ends.push_back(std::make_pair(y2, inter_iter));
+          }
+        }
+      }
+        
+      //merge sloping element data
+      std::sort(sloping_ends.begin(), sloping_ends.end());
+      std::map<Unit, std::set<iterator> > sloping_elements;
+      std::set<iterator> merge_elements;
+      for(typename std::vector<std::pair<Unit, iterator> >::iterator slop_iter = sloping_ends.begin();
+          slop_iter = sloping_ends.end(); ++slop_iter) {
+        //merge into sloping elements
+        typename std::set<iterator>::iterator merge_iterator = merge_elements.find((*slop_iter).second);
+        if(merge_iterator = merge_elements.end()) {
+          merge_elements.insert((*slop_iter).second);
+        } else {
+          merge_elements.erase(merge_iterator);
+        }
+        sloping_elements[(*slop_iter).first] = merge_elements;
+      }
+
+      //scan intersection points
+      typename std::map<Unit, std::set<segment_id> >::iterator vertical_iter = vertical_data_.begin();
+      typename std::map<Unit, std::set<iterator> >::iterator sloping_iter = sloping_elements.begin();
+      for(typename std::set<Unit>::iterator position_iter = intersection_locations.begin();
+          position_iter = intersection_locations.end(); ++position_iter) {
+        //look for vertical segments that intersect this point and update them
+        Unit y = *position_iter;
+        Point pt(x_, y);
+        //handle vertical segments
+        if(vertical_iter != vertical_data_.end()) {
+          typename std::map<Unit, std::set<segment_id> >::iterator next_vertical = vertical_iter;
+          for(++next_vertical; next_vertical != vertical_data_.end() &&
+                (*next_vertical).first < y; ++next_vertical) {
+            vertical_iter = next_vertical;
+          }
+          if((*vertical_iter).first < y && !(*vertical_iter).second.empty()) {
+            update_segments(intersection_points, (*vertical_iter).second, pt);
+            ++vertical_iter;
+            if(vertical_iter != vertical_data_.end() && (*vertical_iter).first == y)
+              update_segments(intersection_points, (*vertical_iter).second, pt);
+          }
+        }
+        //handle sloping segments
+        if(sloping_iter != sloping_elements.end()) {
+          typename std::map<Unit, std::set<iterator> >::iterator next_sloping = sloping_iter;
+          for(++next_sloping; next_sloping != sloping_elements.end() &&
+                (*next_sloping).first < y; ++next_sloping) {
+            sloping_iter = next_sloping;
+          }
+          if((*sloping_iter).first < y && !(*sloping_iter).second.empty()) {
+            for(typename std::set<iterator>::iterator element_iter = (*sloping_iter).second.begin();
+                element_iter != (*sloping_iter).second.end(); ++element_iter) {
+              const half_edge& he = (*element_iter).first;
+              if(intersects_grid(pt, he)) {
+                update_segments(intersection_points, (*element_iter).second, pt);
+              }
+            }
+            ++sloping_iter;
+            if(sloping_iter != sloping_elements.end() && (*sloping_iter).first == y &&
+               !(*sloping_iter).second.empty()) {
+              for(typename std::set<iterator>::iterator element_iter = (*sloping_iter).second.begin();
+                  element_iter != (*sloping_iter).second.end(); ++element_iter) {
+                const half_edge& he = (*element_iter).first;
+                if(intersects_grid(pt, he)) {
+                  update_segments(intersection_points, (*element_iter).second, pt);
+                }
+              }
+            }
+          }
+        }
+      }
+
+      //erase and reinsert edges into scanline with check for future intersection
+    }
+
+    inline void process_scan_event(std::map<segment_id, std::set<Point> >& intersection_points) {
+      just_before_ = true;
+
+      //process end events by removing those segments from the scanline 
+      //and insert vertices of all events into intersection queue
+      Point prev_point((std::numeric_limits<Unit>::min)(), (std::numeric_limits<Unit>::min)());
+      less_point lp;
+      std::set<segment_id> vertical_ids;
+      vertical_data_.clear();
+      for(unsigned int i = 0; i < event_edges_.size(); ++i) {
+        segment_id id = event_edges_[i].second;
+        const half_edge& he = event_edges_[i].first;
+        //vertical half edges are handled during intersection processing because
+        //they cannot be inserted into the scanline
+        if(!is_vertical(he)) {
+          if(lp(he.second, he.first)) {
+            //half edge is end event
+            lookup_and_remove(he, id);
+          } else {
+            //half edge is begin event
+            insert_into_scanline(he, id);  
+            //note that they will be immediately removed and reinserted after
+            //handling their intersection (vertex)
+            //an optimization would allow them to be processed specially to avoid the redundant
+            //removal and reinsertion
+          }
+        } else {
+          //common case if you are lucky
+          //update the map of y to set of segment id
+          if(lp(he.second, he.first)) {
+            //half edge is end event
+            std::set<segment_id>::iterator itr = vertical_ids.find(id);
+            if(itr == vertical_ids.end()) {
+              std::cout << "Failed to find end event id in vertical ids\n";
+            } else {
+              vertical_ids.erase(itr);
+              vertical_data_[he.first.get(HORIZONTAL)] = vertical_ids;
+            }
+          } else {
+            //half edge is a begin event
+            vertical_ids.insert(id);
+            vertical_data_[he.first.get(HORIZONTAL)] = vertical_ids;
+          }
+        }
+        //prevent repeated insertion of same vertex into intersection queue
+        if(prev_point != he.first)
+          intersection_queue_.insert(he.first);
+        else
+          prev_point = he.first;
+        // process intersections at scan event
+        process_intersections_at_scan_event(intersection_points);
+      }
+      event_edges_.clear();
+    }
+
+  public:
+    static inline bool test_validate_scan() {
+      std::vector<std::pair<half_edge, segment_id> > input, edges;
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), 0));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 10)), 1));
+      std::pair<segment_id, segment_id> result;
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail1 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.push_back(std::make_pair(half_edge(Point(0, 5), Point(5, 5)), 2));
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.pop_back();
+      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(11, 11)), 3));
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail3 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(10, 11)), 4));
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail4 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.pop_back();
+      input.push_back(std::make_pair(half_edge(Point(1, 2), Point(11, 11)), 5));
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail5 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.push_back(std::make_pair(half_edge(Point(0, 5), Point(0, 11)), 6));
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail6 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.pop_back();
+      for(unsigned int i = 0; i < input.size(); ++i) {
+        std::swap(input[i].first.first, input[i].first.second);
+      }
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail5 2 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      for(unsigned int i = 0; i < input.size(); ++i) {
+        input[i].first.first = Point(input[i].first.first.get(HORIZONTAL) * -1,
+                                     input[i].first.first.get(VERTICAL) * -1);
+        input[i].first.second = Point(input[i].first.second.get(HORIZONTAL) * -1,
+                                     input[i].first.second.get(VERTICAL) * -1);
+      }
+      edges.clear();
+      validate_scan(edges, input.begin(), input.end());
+      std::cout << edges.size() << std::endl;
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail5 3 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(5, 7), Point(7, 6)), 0));
+      input.push_back(std::make_pair(half_edge(Point(2, 4), Point(6, 7)), 1));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 1 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(3, 2), Point(1, 7)), 0));
+      input.push_back(std::make_pair(half_edge(Point(0, 6), Point(7, 4)), 1));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 2 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(6, 6), Point(1, 0)), 0));
+      input.push_back(std::make_pair(half_edge(Point(3, 6), Point(2, 3)), 1));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 3 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(7, 0)), 0));
+      input.push_back(std::make_pair(half_edge(Point(6, 0), Point(2, 0)), 1));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 4 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(-17333131 - -17208131, -10316869 - -10191869), Point(0, 0)), 0));
+      input.push_back(std::make_pair(half_edge(Point(-17291260 - -17208131, -10200000 - -10191869), Point(-17075000 - -17208131, -10200000 - -10191869)), 1));
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 5 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(-17333131, -10316869), Point(-17208131, -10191869)), 0));
+      input.push_back(std::make_pair(half_edge(Point(-17291260, -10200000), Point(-17075000, -10200000)), 1));
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 6 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(-9850009+9853379, -286971+290340), Point(-12777869+9853379, -3214831+290340)), 0));
+      input.push_back(std::make_pair(half_edge(Point(-5223510+9853379, -290340+290340), Point(-9858140+9853379, -290340+290340)), 1));
+      validate_scan(edges, input.begin(), input.end());
+      print(edges);
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 7 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(-9850009, -286971), Point(-12777869, -3214831)), 0));
+      input.push_back(std::make_pair(half_edge(Point(-5223510, -290340), Point(-9858140, -290340)), 1));
+      validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 8 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      //3 3 2 2: 0; 4 2 0 6: 1; 0 3 6 3: 2; 4 1 5 5: 3; 
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(3, 3), Point(2, 2)), 0));
+      input.push_back(std::make_pair(half_edge(Point(4, 2), Point(0, 6)), 1));
+      input.push_back(std::make_pair(half_edge(Point(0, 3), Point(6, 3)), 2));
+      input.push_back(std::make_pair(half_edge(Point(4, 1), Point(5, 5)), 3));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail4 1 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      //5 7 1 3: 0; 4 5 2 1: 1; 2 5 2 1: 2; 4 1 5 3: 3; 
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(5, 7), Point(1, 3)), 0));
+      input.push_back(std::make_pair(half_edge(Point(4, 5), Point(2, 1)), 1));
+      input.push_back(std::make_pair(half_edge(Point(2, 5), Point(2, 1)), 2));
+      input.push_back(std::make_pair(half_edge(Point(4, 1), Point(5, 3)), 3));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail4 2 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      //1 0 -4 -1: 0; 0 0 2 -1: 1; 
+      input.clear();
+      edges.clear();
+      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(-4, -1)), 0));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(2, -1)), 1));
+            validate_scan(edges, input.begin(), input.end());
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "s fail2 5 " << result.first << " " << result.second << "\n";
+        print(input);
+        print(edges);
+        return false;
+      }
+      Unit min_c =0;
+      Unit max_c =0;
+      for(unsigned int outer = 0; outer < 1000; ++outer) {
+        input.clear();
+        for(unsigned int i = 0; i < 4; ++i) {
+          Unit x1 = rand();
+          Unit x2 = rand();
+          Unit y1 = rand();
+          Unit y2 = rand();
+          int neg1 = rand() % 2;
+          if(neg1) x1 *= -1;
+          int neg2 = rand() % 2;
+          if(neg2) x2 *= -1;
+          int neg3 = rand() % 2;
+          if(neg3) y1 *= -1;
+          int neg4 = rand() % 2;
+          if(neg4) y2 *= -1;
+          if(x1 < min_c) min_c = x1;
+          if(x2 < min_c) min_c = x2;
+          if(y1 < min_c) min_c = y1;
+          if(y2 < min_c) min_c = y2;
+          if(x1 > max_c) max_c = x1;
+          if(x2 > max_c) max_c = x2;
+          if(y1 > max_c) max_c = y1;
+          if(y2 > max_c) max_c = y2;
+          Point pt1(x1, y1);
+          Point pt2(x2, y2);
+          if(pt1 != pt2)
+            input.push_back(std::make_pair(half_edge(pt1, pt2), i));
+        }
+        edges.clear();
+        validate_scan(edges, input.begin(), input.end());
+        if(!verify_scan(result, edges.begin(), edges.end())) {
+          std::cout << "s fail9 " << outer << ": " << result.first << " " << result.second << "\n";
+          print(input);
+          print(edges);
+          return false;
+        }
+      }
+      return true;
+    }
+
+    static void print(const std::pair<half_edge, segment_id>& segment) {
+      std::cout << segment.first.first << " " << segment.first.second << ": " << segment.second << "; ";
+    }
+    static void print(const std::vector<std::pair<half_edge, segment_id> >& vec) {
+      for(unsigned int i = 0; i < vec.size(); ++ i) {
+        print(vec[i]);
+      } std::cout << std::endl;
+    }
+
+    static inline bool test_verify_scan() {
+      std::vector<std::pair<half_edge, segment_id> > edges;
+      edges.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), 0));
+      edges.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 10)), 1));
+      std::pair<segment_id, segment_id> result;
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail1\n";
+        return false;
+      }
+      edges.push_back(std::make_pair(half_edge(Point(0, 5), Point(5, 5)), 2));
+      if(verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail2\n";
+        return false;
+      }
+      edges.pop_back();
+      edges.push_back(std::make_pair(half_edge(Point(1, 0), Point(11, 11)), 3));
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail3\n";
+        return false;
+      }
+      edges.push_back(std::make_pair(half_edge(Point(1, 0), Point(10, 11)), 4));
+      if(verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail4\n";
+        return false;
+      }
+      edges.pop_back();
+      edges.push_back(std::make_pair(half_edge(Point(1, 2), Point(11, 11)), 5));
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail5 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      edges.push_back(std::make_pair(half_edge(Point(0, 5), Point(0, 11)), 6));
+      if(verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail6 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      edges.pop_back();
+      for(unsigned int i = 0; i < edges.size(); ++i) {
+        std::swap(edges[i].first.first, edges[i].first.second);
+      }
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail5 2 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      for(unsigned int i = 0; i < edges.size(); ++i) {
+        edges[i].first.first = Point(edges[i].first.first.get(HORIZONTAL) * -1,
+                                     edges[i].first.first.get(VERTICAL) * -1);
+        edges[i].first.second = Point(edges[i].first.second.get(HORIZONTAL) * -1,
+                                     edges[i].first.second.get(VERTICAL) * -1);
+      }
+      if(!verify_scan(result, edges.begin(), edges.end())) {
+        std::cout << "fail5 3 " << result.first << " " << result.second << "\n";
+        return false;
+      }
+      return true;
+    }
+
+  };
+
+  //scanline consumes the "flattened" fully intersected line segments produced by
+  //a pass of line_intersection along with property and count information and performs a 
+  //useful operation like booleans or property merge or connectivity extraction
+  template <typename Unit, typename property_type, typename keytype = std::set<property_type> >
+  class scanline : public scanline_base<Unit> {
+  public:
+    //definitions
+    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;
+
+    typedef keytype property_set;
+    //this is the data type used internally to store the combination of property counts at a given location
+    typedef std::vector<std::pair<property_type, int> > property_map;
+    //this data structure assocates a property and count to a half edge
+    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
+    //this data type is used internally to store the combined property data for a given half edge
+    typedef std::pair<half_edge, property_map> vertex_data;
+    //this data type stores the combination of many half edges
+    typedef std::vector<vertex_property> property_merge_data;
+    //this data structure stores end points of edges in the scanline
+    typedef std::set<Point, less_point> end_point_queue;
+
+    //this is the output data type that is created by the scanline before it is post processed based on content of property sets
+    typedef std::pair<half_edge, std::pair<property_set, property_set> > half_edge_property;
+      
+    //this is the scanline data structure
+    typedef std::map<half_edge, property_map, less_half_edge> scanline_type;
+    typedef std::pair<half_edge, property_map> scanline_element;
+    typedef typename scanline_type::iterator iterator;
+    typedef typename scanline_type::const_iterator const_iterator;
+
+    //data
+    scanline_type scan_data_;
+    std::vector<iterator> removal_set_; //edges to be removed at the current scanline stop
+    std::vector<scanline_element> insertion_set_; //edge to be inserted after current scanline stop
+    end_point_queue end_point_queue_;
+    Unit x_;
+    Unit y_;
+    int just_before_;
+  public:
+    inline scanline() : scan_data_(), removal_set_(), insertion_set_(), end_point_queue_(), 
+                        x_((std::numeric_limits<Unit>::max)()), y_((std::numeric_limits<Unit>::max)()), just_before_(false) {
+      less_half_edge lessElm(&x_, &just_before_);
+      scan_data_ = scanline_type(lessElm);
+    }
+    inline scanline(const scanline& that) : scan_data_(), removal_set_(), insertion_set_(), end_point_queue_(), 
+                                            x_((std::numeric_limits<Unit>::max)()), y_((std::numeric_limits<Unit>::max)()), just_before_(false) {
+      (*this) = that; }
+    inline scanline& operator=(const scanline& that) {
+      x_ = that.x_;
+      y_ = that.y_;
+      just_before_ = that.just_before_;
+      end_point_queue_ = that.end_point_queue_;
+      //I cannot simply copy that.scanline_type to this scanline_type becuase the functor store pointers to other members!
+      less_half_edge lessElm(&x_, &just_before_);
+      scan_data_ = scanline_type(lessElm);
+
+      scan_data_.insert(that.scan_data_.begin(), that.scan_data_.end());
+      return *this;
+    }
+
+    template <typename result_type, typename result_functor>
+    void write_out(result_type& result, result_functor rf, const half_edge& he,
+                   const property_map& pm_left, const property_map& pm_right) {
+      //std::cout << "write out ";
+      //std::cout << he.first << ", " << he.second << std::endl;
+      property_set ps_left, ps_right;
+      set_unique_property(ps_left, pm_left);
+      set_unique_property(ps_right, pm_right);
+      if(ps_left != ps_right) {
+        //std::cout << "!equivalent\n";
+        rf(result, he, ps_left, ps_right);
+      }
+    }
+
+    template <typename result_type, typename result_functor, typename iT>
+    iT handle_input_events(result_type& result, result_functor rf, iT begin, iT end) {
+      typedef typename high_precision_type<Unit>::type high_precision;
+      //for each event
+      property_map vertical_properties_above;
+      property_map vertical_properties_below;
+      half_edge vertical_edge_above;
+      half_edge vertical_edge_below;
+      std::vector<scanline_element> insertion_elements;
+      //current_iter should increase monotonically toward end as we process scanline stop
+      iterator current_iter = scan_data_.begin();
+      just_before_ = true;
+      high_precision y = (high_precision)((std::numeric_limits<Unit>::min)());
+      bool first_iteration = true;
+      //we want to return from inside the loop when we hit end or new x
+      while(true) {
+        if(begin == end || (!first_iteration && (high_precision)(((*begin).first.first.get(VERTICAL)) != y || 
+                                                                 (*begin).first.first.get(HORIZONTAL) != x_))) {
+          //lookup iterator range in scanline for elements coming in from the left
+          //that end at this y
+          Point pt(x_, (Unit)y);
+          //grab the properties coming in from below
+          property_map properties_below;
+          if(current_iter != scan_data_.end()) {
+            //make sure we are looking at element in scanline just below y
+            if(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) != y) {
+              Point e2(pt);
+              if(e2.get(VERTICAL) != (std::numeric_limits<Unit>::max)())
+                e2.set(VERTICAL, e2.get(VERTICAL) + 1);
+              else
+                e2.set(VERTICAL, e2.get(VERTICAL) - 1);
+              half_edge vhe(pt, e2);
+              current_iter = scan_data_.lower_bound(vhe);
+            }
+            if(current_iter != scan_data_.end()) {
+              //get the bottom iterator for elements at this point
+              while(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) >= y && 
+                    current_iter != scan_data_.begin()) {
+                --current_iter;
+              }
+              if(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) >= y) {
+                properties_below.clear();
+              } else {
+                properties_below = (*current_iter).second;
+                //move back up to y or one past y
+                ++current_iter;
+              }
+            }
+          }
+          std::vector<iterator> edges_from_left;
+          while(current_iter != scan_data_.end() &&
+                evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) == y) {
+            //removal_set_.push_back(current_iter);
+            ++current_iter;
+          }
+          //merge vertical count with count from below
+          if(!vertical_properties_below.empty()) {
+            merge_property_maps(vertical_properties_below, properties_below);
+            //write out vertical edge
+            write_out(result, rf, vertical_edge_below, properties_below, vertical_properties_below);
+          } else {
+            merge_property_maps(vertical_properties_below, properties_below);
+          }
+          //iteratively add intertion element counts to count from below
+          //and write them to insertion set
+          for(unsigned int i = 0; i < insertion_elements.size(); ++i) {
+            if(i == 0) {
+              merge_property_maps(insertion_elements[i].second, vertical_properties_below);
+              write_out(result, rf, insertion_elements[i].first, insertion_elements[i].second, vertical_properties_below);
+            } else {
+              merge_property_maps(insertion_elements[i].second, insertion_elements[i-1].second);
+              write_out(result, rf, insertion_elements[i].first, insertion_elements[i].second, insertion_elements[i-1].second);
+            }
+            insertion_set_.push_back(insertion_elements[i]);
+          }
+          if((begin == end || (*begin).first.first.get(HORIZONTAL) != x_)) {
+            if(vertical_properties_above.empty()) {
+              return begin;
+            } else {
+              y = (high_precision)(vertical_edge_above.second.get(VERTICAL));
+              vertical_properties_below.clear();
+              vertical_properties_above.swap(vertical_properties_below);
+              vertical_edge_below = vertical_edge_above;
+              insertion_elements.clear();
+              continue;
+            }
+          }
+          vertical_properties_below.clear();
+          vertical_properties_above.swap(vertical_properties_below);
+          vertical_edge_below = vertical_edge_above;
+          insertion_elements.clear();
+        }
+        if(begin != end) {
+          const vertex_property& vp = *begin;
+          const half_edge& he = vp.first;
+          y = (high_precision)(he.first.get(VERTICAL));
+          first_iteration = false;
+          if(! vertical_properties_below.empty() &&
+             vertical_edge_below.second.get(VERTICAL) < y) {
+            y = (high_precision)(vertical_edge_below.second.get(VERTICAL));
+            continue;
+          }
+          if(is_vertical(he)) {
+            update_property_map(vertical_properties_above, vp.second);
+            vertical_edge_above = he;
+          } else {
+            if(insertion_elements.empty() ||
+               insertion_elements.back().first != he) {
+              insertion_elements.push_back(scanline_element(he, property_map()));
+            }
+            update_property_map(insertion_elements.back().second, vp.second);
+          }
+          ++begin;
+        }
+      }
+    }
+
+    inline void erase_end_events(typename end_point_queue::iterator epqi) {
+      end_point_queue_.erase(end_point_queue_.begin(), epqi);
+      for(typename std::vector<iterator>::iterator retire_itr = removal_set_.begin();
+          retire_itr != removal_set_.end(); ++retire_itr) {
+        scan_data_.erase(*retire_itr);
+      }
+      removal_set_.clear();
+    }
+
+
+    inline void remove_retired_edges_from_scanline() {
+      just_before_ = true;
+      typename end_point_queue::iterator epqi = end_point_queue_.begin();
+      Unit current_x = x_;
+      Unit previous_x = x_;
+      while(epqi != end_point_queue_.end() &&
+            (*epqi).get(HORIZONTAL) <= current_x) {
+        x_ = (*epqi).get(HORIZONTAL);
+        if(x_ != previous_x) erase_end_events(epqi);
+        previous_x = x_;
+        //lookup elements
+        Point e2(*epqi);
+        if(e2.get(VERTICAL) != (std::numeric_limits<Unit>::max)())
+          e2.set(VERTICAL, e2.get(VERTICAL) + 1);
+        else
+          e2.set(VERTICAL, e2.get(VERTICAL) - 1);
+        half_edge vhe_e(*epqi, e2);
+        iterator current_iter = scan_data_.lower_bound(vhe_e);
+        while(current_iter != scan_data_.end() && (*current_iter).first.second == (*epqi)) {
+          //evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) == (*epqi).get(VERTICAL)) {
+          removal_set_.push_back(current_iter);
+          ++current_iter;
+        }
+        ++epqi;
+      }
+      x_ = current_x;
+      erase_end_events(epqi);
+    }
+
+    inline void insert_new_edges_into_scanline() {
+      just_before_ = false;
+      for(typename std::vector<scanline_element>::iterator insert_itr = insertion_set_.begin();
+          insert_itr != insertion_set_.end(); ++insert_itr) {
+        scan_data_.insert(*insert_itr);
+        end_point_queue_.insert((*insert_itr).first.second);
+      }
+      insertion_set_.clear();
+    }
+
+    //iterator over range of vertex property elements and call result functor
+    //passing edge to be output, the merged data on both sides and the result
+    template <typename result_type, typename result_functor, typename iT>
+    void scan(result_type& result, result_functor rf, iT begin, iT end) {
+      while(begin != end) {
+        x_ = (*begin).first.first.get(HORIZONTAL); //update scanline stop location
+        //print_scanline();
+        --x_;
+        remove_retired_edges_from_scanline();
+        ++x_;
+        begin = handle_input_events(result, rf, begin, end);
+        remove_retired_edges_from_scanline();
+        //print_scanline();
+        insert_new_edges_into_scanline();
+      }
+      //print_scanline();
+      x_ = (std::numeric_limits<Unit>::max)();
+      remove_retired_edges_from_scanline();
+    }
+
+    inline void print_scanline() {
+      std::cout << "scanline at " << x_ << ": ";
+      for(iterator itr = scan_data_.begin(); itr != scan_data_.end(); ++itr) {
+        const scanline_element& se = *itr;
+        const half_edge& he = se.first;
+        const property_map& mp = se.second;
+        std::cout << he.first << ", " << he.second << " ( ";
+        for(unsigned int i = 0; i < mp.size(); ++i) {
+          std::cout << mp[i].first << ":" << mp[i].second << " ";
+        } std::cout << ") ";
+      } std::cout << std::endl;
+    }
+
+    static inline void merge_property_maps(property_map& mp, const property_map& mp2) {
+      property_map newmp;
+      newmp.reserve(mp.size() + mp2.size());
+      unsigned int i = 0;
+      unsigned int j = 0;
+      while(i != mp.size() && j != mp2.size()) {
+        if(mp[i].first < mp2[j].first) {
+          newmp.push_back(mp[i]);
+          ++i;
+        } else if(mp[i].first > mp2[j].first) {
+          newmp.push_back(mp2[j]);
+          ++j;
+        } else {
+          int count = mp[i].second;
+          count += mp2[j].second; 
+          if(count) {
+            newmp.push_back(mp[i]);
+            newmp.back().second = count;
+          }
+          ++i;
+          ++j;
+        }
+      }
+      while(i != mp.size()) {
+        newmp.push_back(mp[i]);
+        ++i;
+      }
+      while(j != mp2.size()) {
+        newmp.push_back(mp2[j]);
+        ++j;
+      }
+      mp.swap(newmp);
+    }
+
+    static inline void update_property_map(property_map& mp, const std::pair<property_type, int>& prop_data) {
+      property_map newmp;
+      newmp.reserve(mp.size() +1);
+      bool consumed = false;
+      for(unsigned int i = 0; i < mp.size(); ++i) {
+        if(!consumed && prop_data.first == mp[i].first) {
+          consumed = true;
+          int count = prop_data.second + mp[i].second;
+          if(count)
+            newmp.push_back(std::make_pair(prop_data.first, count));
+        } else if(!consumed && prop_data.first < mp[i].first) {
+          consumed = true;
+          newmp.push_back(prop_data);
+          newmp.push_back(mp[i]);
+        } else {
+          newmp.push_back(mp[i]);
+        }
+      }
+      if(!consumed) newmp.push_back(prop_data);
+      mp.swap(newmp);
+    }
+
+    static inline void set_unique_property(property_set& unqiue_property, const property_map& property) {
+      unqiue_property.clear();
+      for(typename property_map::const_iterator itr = property.begin(); itr != property.end(); ++itr) {
+        if((*itr).second > 0)
+          unqiue_property.insert(unqiue_property.end(), (*itr).first);
+      }
+    }
+
+    static inline bool common_vertex(const half_edge& he1, const half_edge& he2) {
+      return he1.first == he2.first ||
+        he1.first == he2.second ||
+        he1.second == he2.first ||
+        he1.second == he2.second;
+    }
+
+    typedef typename scanline_base<Unit>::vertex_half_edge vertex_half_edge;
+    template <typename iT>
+    static inline void convert_segments_to_vertex_half_edges(std::vector<vertex_half_edge>& output, iT begin, iT end) {
+      for( ; begin != end; ++begin) {
+        const half_edge& he = (*begin).first;
+        int count = (*begin).second;
+        output.push_back(vertex_half_edge(he.first, he.second, count));
+        output.push_back(vertex_half_edge(he.second, he.first, -count));
+      }
+      std::sort(output.begin(), output.end());
+    }
+
+    class test_functor {
+    public:
+      inline test_functor() {}
+      inline void operator()(std::vector<std::pair<half_edge, std::pair<property_set, property_set> > >& result,
+                             const half_edge& he, const property_set& ps_left, const property_set& ps_right) {
+        result.push_back(std::make_pair(he, std::make_pair(ps_left, ps_right)));
+      }
+    };
+    static inline bool test_scanline() {
+      std::vector<std::pair<half_edge, std::pair<property_set, property_set> > > result;
+      std::vector<std::pair<half_edge, std::pair<property_type, int> > > input;
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
+      scanline sl;
+      test_functor tf;
+      sl.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(0, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(11, 11)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, 1)));
+      scanline sl2;
+      sl2.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(8, 2)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(2, 8)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(2, 8), Point(9, 9)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(8, 2), Point(9, 9)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
+      scanline sl3;
+      sl3.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(8, 2)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(2, 8)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(2, 8), Point(9, 9)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(8, 2), Point(9, 9)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
+      scanline sl4;
+      sl4.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
+      scanline sl5;
+      sl5.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
+      scanline sl6;
+      sl6.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(10, 20)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(9, 21)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(1, 29)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(0, 30)), std::make_pair(0, 1)));
+      input.push_back(std::make_pair(half_edge(Point(0, 30), Point(10, 30)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(1, 29), Point(10, 30)), std::make_pair(1, -1)));
+      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(9, 21), Point(10, 30)), std::make_pair(1, 1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 20), Point(10, 30)), std::make_pair(0, -1)));
+      input.push_back(std::make_pair(half_edge(Point(10, 20), Point(10, 30)), std::make_pair(0, -1)));
+      scanline sl7;
+      sl7.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      input.clear();
+      result.clear();
+      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1))); //a
+      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(0, 10)), std::make_pair(0, -1))); //a
+      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(11, 11)), std::make_pair(0, -1))); //a
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(20, 0)), std::make_pair(0, 1))); //b
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, -1))); //b
+      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, 1))); //a
+      input.push_back(std::make_pair(half_edge(Point(11, 11), Point(20, 10)), std::make_pair(0, -1))); //b
+      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(30, 0)), std::make_pair(0, 1))); //c
+      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(20, 10)), std::make_pair(0, -1))); //b
+      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(20, 10)), std::make_pair(0, 1))); //c
+      input.push_back(std::make_pair(half_edge(Point(20, 10), Point(30, 10)), std::make_pair(0, -1))); //c
+      input.push_back(std::make_pair(half_edge(Point(30, 0), Point(30, 10)), std::make_pair(0, -1))); //c
+      scanline sl8;
+      sl8.scan(result, tf, input.begin(), input.end());
+      std::cout << "scanned\n";
+      for(unsigned int i = 0; i < result.size(); ++i) {
+        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
+      } std::cout << std::endl;
+      return true;
+    }
+
+  };
+
+  template <typename Unit>
+  class merge_output_functor {
+  public:
+    typedef typename scanline_base<Unit>::half_edge half_edge;
+    merge_output_functor() {}
+    template <typename result_type, typename key_type>
+    void operator()(result_type& result, const half_edge& edge, const key_type& left, const key_type& right) {
+      typename std::pair<half_edge, int> elem;
+      elem.first = edge;
+      elem.second = 1;
+      if(edge.second < edge.first) elem.second *= -1;
+      if(scanline_base<Unit>::is_vertical(edge)) elem.second *= -1;
+      if(!left.empty())
+        result[left].insert_clean(elem);
+      elem.second *= -1;
+      if(!right.empty())
+        result[right].insert_clean(elem);
+    }
+  };
+
+  template <typename Unit, typename property_type, typename key_type = std::set<property_type>, 
+            typename output_functor_type = merge_output_functor<Unit> >
+  class property_merge : public scanline_base<Unit> {
+  protected:
+    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;
+
+    //this data structure assocates a property and count to a half edge
+    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
+    //this data type stores the combination of many half edges
+    typedef std::vector<vertex_property> property_merge_data;
+
+    //this is the data type used internally to store the combination of property counts at a given location
+    typedef std::vector<std::pair<property_type, int> > property_map;
+    //this data type is used internally to store the combined property data for a given half edge
+    typedef std::pair<half_edge, property_map> vertex_data;
+
+    property_merge_data pmd;
+
+    template<typename vertex_data_type>
+    class less_vertex_data {
+    public:
+      less_vertex_data() {}
+      bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
+        less_point lp;
+        if(lp(lvalue.first.first, rvalue.first.first)) return true;
+        if(lp(rvalue.first.first, lvalue.first.first)) return false;
+        Unit x = lvalue.first.first.get(HORIZONTAL);
+        int just_before_ = 0;
+        less_half_edge lhe(&x, &just_before_);
+        return lhe(lvalue.first, rvalue.first);
+      }
+    };
+
+
+    inline void sort_property_merge_data() {
+      less_vertex_data<vertex_property> lvd;
+      std::sort(pmd.begin(), pmd.end(), lvd);
+    }
+  public:
+    inline property_merge_data& get_property_merge_data() { return pmd; }
+    inline property_merge() : pmd() {}
+    inline property_merge(const property_merge& pm) : pmd(pm.pmd) {}
+    inline property_merge& operator=(const property_merge& pm) { pmd = pm.pmd; return *this; }
+
+    template <typename polygon_type>
+    void insert(const polygon_type& polygon_object, const property_type& property_value, bool is_hole = false) {
+      insert(polygon_object, property_value, is_hole, typename geometry_concept<polygon_type>::type());
+    }
+
+    //result type should be std::map<std::set<property_type>, polygon_set_type>
+    //or std::map<std::vector<property_type>, polygon_set_type>
+    template <typename result_type>
+    void merge(result_type& result) {
+      //intersect data
+      property_merge_data tmp_pmd;
+      line_intersection<Unit>::validate_scan(tmp_pmd, pmd.begin(), pmd.end());
+      pmd.swap(tmp_pmd);
+      sort_property_merge_data();
+      scanline<Unit, property_type, key_type> sl;
+      output_functor_type mof;
+      sl.scan(result, mof, pmd.begin(), pmd.end());
+    }
+
+    inline bool verify() {
+      std::pair<int, int> offenders;
+      std::vector<std::pair<half_edge, int> > lines;
+      int count = 0;
+      for(unsigned int i = 0; i < pmd.size(); ++i) {
+        lines.push_back(std::make_pair(pmd[i].first, count++));
+      }
+      if(!line_intersection<Unit>::verify_scan(offenders, lines.begin(), lines.end())) {
+        std::cout << "Intersection failed!\n";
+        std::cout << offenders.first << " " << offenders.second << std::endl;
+        return false;
+      }
+      std::vector<Point> pts;
+      for(unsigned int i = 0; i < lines.size(); ++i) {
+        pts.push_back(lines[i].first.first);
+        pts.push_back(lines[i].first.second);
+      }
+      std::sort(pts.begin(), pts.end());
+      for(unsigned int i = 0; i < pts.size(); i+=2) {
+        if(pts[i] != pts[i+1]) {
+          std::cout << "Non-closed figures after line intersection!\n";
+          return false;
+        }
+      }
+      return true;
+    }
+
+    void clear() {*this = property_merge();}
+
+  protected:
+    template <typename polygon_type>
+    void insert(const polygon_type& polygon_object, const property_type& property_value, bool is_hole, 
+                polygon_concept tag) {
+      bool first_iteration = true;
+      bool second_iteration = true;
+      Point first_point;
+      Point second_point;
+      Point previous_previous_point;
+      Point previous_point;
+      Point current_point;
+      direction_1d winding_dir = winding(polygon_object);
+      for(typename polygon_traits<polygon_type>::iterator_type itr = begin_points(polygon_object);
+          itr != end_points(polygon_object); ++itr) {
+        assign(current_point, *itr);
+        if(first_iteration) {
+          first_iteration = false;
+          first_point = previous_point = current_point;
+        } else if(second_iteration) {
+          if(previous_point != current_point) {
+            second_iteration = false;
+            previous_previous_point = previous_point;
+            second_point = previous_point = current_point;
+          }
+        } else {
+          if(previous_point != current_point) {
+            create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
+                          is_hole, property_value);
+            previous_previous_point = previous_point;
+            previous_point = current_point;
+          }
+        }
+      }
+      current_point = first_point;
+      if(!first_iteration && !second_iteration) {
+        if(previous_point != current_point) {
+          create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
+                        is_hole, property_value);
+          previous_previous_point = previous_point;
+          previous_point = current_point;
+        }
+        current_point = second_point;
+        create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
+                      is_hole, property_value);
+        previous_previous_point = previous_point;
+        previous_point = current_point;
+      }
+    }
+
+    template <typename polygon_with_holes_type>
+    void insert(const polygon_with_holes_type& polygon_with_holes_object, const property_type& property_value, bool is_hole, 
+                polygon_with_holes_concept tag) {
+      insert(polygon_with_holes_object, property_value, is_hole, polygon_concept());
+      for(typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itr = 
+            begin_holes(polygon_with_holes_object);
+          itr != end_holes(polygon_with_holes_object); ++itr) {
+        insert(*itr, property_value, !is_hole, polygon_concept());
+      }
+    }
+
+    template <typename rectangle_type>
+    void insert(const rectangle_type& rectangle_object, const property_type& property_value, bool is_hole, 
+                rectangle_concept tag) {
+      polygon_90_data<Unit> poly;
+      assign(poly, rectangle_object);
+      insert(poly, property_value, is_hole, polygon_concept());
+    }
+
+  public: //change to private when done testing
+
+    static inline void create_vertex(property_merge_data& pmd, 
+                                     const Point& previous_point, 
+                                     const Point& current_point, 
+                                     const Point& next_point, 
+                                     direction_1d winding,
+                                     bool is_hole, const property_type& property) {
+      if(current_point == next_point) return;
+      vertex_property current_vertex;
+      current_vertex.first.first = current_point;
+      current_vertex.first.second = next_point;
+      current_vertex.second.first = property;
+      int multiplier = 1;
+      if(winding == CLOCKWISE) 
+        multiplier = -1;
+      if(is_hole)
+        multiplier *= -1;
+      if(current_point < next_point) {
+        multiplier *= -1;
+        std::swap(current_vertex.first.first, current_vertex.first.second);
+      }
+      current_vertex.second.second = multiplier * (euclidean_distance(next_point, current_point, HORIZONTAL) == 0 ? -1: 1);
+      pmd.push_back(current_vertex);
+      //current_vertex.first.second = previous_point;
+      //current_vertex.second.second *= -1;
+      //pmd.push_back(current_vertex);
+    }
+
+    static inline void sort_vertex_half_edges(vertex_data& vertex) {
+      less_half_edge_pair lessF(vertex.first);
+      std::sort(vertex.second.begin(), vertex.second.end(), lessF);
+    }
+
+    class less_half_edge_pair {
+    private:
+      Point pt_;
+    public:
+      less_half_edge_pair(const Point& pt) : pt_(pt) {}
+      bool operator()(const half_edge& e1, const half_edge& e2) {
+        const Point& pt1 = e1.first;
+        const Point& pt2 = e2.first;
+        if(get(pt1, HORIZONTAL) == 
+           get(pt_, HORIZONTAL)) {
+          //vertical edge is always largest
+          return false;
+        }
+        if(get(pt2, HORIZONTAL) == 
+           get(pt_, HORIZONTAL)) {
+          //if half edge 1 is not vertical its slope is less than that of half edge 2
+          return get(pt1, HORIZONTAL) != get(pt2, HORIZONTAL);
+        }
+        return less_slope(get(pt_, HORIZONTAL),
+                          get(pt_, VERTICAL), pt1, pt2);
+      }
+    };
+
+  public:
+    //test functions
+    static std::ostream& print (std::ostream& o, const property_map& c)
+    {
+      o << "count: {";
+      for(typename property_map::const_iterator itr = c.begin(); itr != c.end(); ++itr) {
+        o << ((*itr).first) << ":" << ((*itr).second) << " ";
+      }
+      return o << "} ";
+    }
+
+
+    static std::ostream& print (std::ostream& o, const half_edge& he)
+    {
+      o << "half edge: (";
+      o << (he.first);
+      return o << ", " << (he.second) << ") ";
+    }
+
+    static std::ostream& print (std::ostream& o, const vertex_property& c)
+    {
+      o << "vertex property: {";
+      print(o, c.first);
+      o << ", " << c.second.first << ":" << c.second.second << " ";
+      return o;
+    }
+
+    static std::ostream& print (std::ostream& o, const std::vector<vertex_property>& hev)
+    {
+      o << "vertex properties: {";
+      for(unsigned int i = 0; i < hev.size(); ++i) {
+        print(o, (hev[i])) << " ";
+      }
+      return o << "} ";
+    }
+
+    static std::ostream& print (std::ostream& o, const std::vector<half_edge>& hev)
+    {
+      o << "half edges: {";
+      for(unsigned int i = 0; i < hev.size(); ++i) {
+        print(o, (hev[i])) << " ";
+      }
+      return o << "} ";
+    }
+
+    static std::ostream& print (std::ostream& o, const vertex_data& v)
+    {
+      return print(o << "vertex: <" << (v.first) << ", ", (v.second)) << "> ";
+    }
+
+    static std::ostream& print (std::ostream& o, const std::vector<vertex_data>& vv)
+    {
+      o << "vertices: {";
+      for(unsigned int i = 0; i < vv.size(); ++i) {
+        print(o, (vv[i])) << " ";
+      }
+      return o << "} ";
+    }
+
+
+
+    static inline bool test_insertion() {
+      property_merge si;
+      rectangle_data<Unit> rect;
+      xl(rect, 0);
+      yl(rect, 1);
+      xh(rect, 10);
+      yh(rect, 11);
+
+      si.insert(rect, 333);
+      print(std::cout, si.pmd) << std::endl;
+      
+      Point pts[4] = {Point(0, 0), Point(10,-3), Point(13, 8), Point(0, 0) };
+      polygon_data<Unit> poly;
+      property_merge si2;
+      poly.set(pts, pts+3);
+      si2.insert(poly, 444);
+      si2.sort_property_merge_data();
+      print(std::cout, si2.pmd) << std::endl;
+      property_merge si3;
+      poly.set(pts, pts+4);
+      si3.insert(poly, 444);
+      si3.sort_property_merge_data();
+      std::cout << (si2.pmd == si3.pmd) << std::endl;
+      std::reverse(pts, pts+4);
+      property_merge si4;
+      poly.set(pts, pts+4);
+      si4.insert(poly, 444);
+      si4.sort_property_merge_data();
+      print(std::cout, si4.pmd) << std::endl;
+      std::cout << (si2.pmd == si4.pmd) << std::endl;
+      std::reverse(pts, pts+3);
+      property_merge si5;
+      poly.set(pts, pts+4);
+      si5.insert(poly, 444);
+      si5.sort_property_merge_data();
+      std::cout << (si2.pmd == si5.pmd) << std::endl;
+      
+      return true;
+    }
+
+    static inline bool test_merge() {
+      property_merge si;
+      rectangle_data<Unit> rect;
+      xl(rect, 0);
+      yl(rect, 1);
+      xh(rect, 10);
+      yh(rect, 11);
+
+      si.insert(rect, 333);
+      std::map<std::set<property_type>, polygon_set_data<Unit> > result;
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      polygon_set_data<Unit> psd = (*(result.begin())).second;
+      std::vector<polygon_data<Unit> > polys;
+      psd.get(polys);
+      if(polys.size() != 1) {
+        std::cout << "fail merge 1\n";
+        return false;
+      }
+      std::cout << (polys[0]) << std::endl;
+      si.clear();
+      std::vector<Point> pts;
+      pts.push_back(Point(0, 0));
+      pts.push_back(Point(10, -10));
+      pts.push_back(Point(10, 10));
+      polygon_data<Unit> poly;
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(5, 0));
+      pts.push_back(Point(-5, -10));
+      pts.push_back(Point(-5, 10));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      psd = (*(result.begin())).second;
+      std::cout << psd << std::endl;
+      polys.clear();
+      psd.get(polys);
+      if(polys.size() != 1) {
+        std::cout << "fail merge 2\n";
+        return false;
+      }
+      //Polygon { -4 -1, 3 3, -2 3 } 
+      //Polygon { 0 -4, -4 -2, -2 1 } 
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(-4, -1));
+      pts.push_back(Point(3, 3));
+      pts.push_back(Point(-2, 3));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(0, -4));
+      pts.push_back(Point(-4, -2));
+      pts.push_back(Point(-2, 1));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      psd = (*(result.begin())).second;
+      std::cout << psd << std::endl;
+      polys.clear();
+      psd.get(polys);
+      if(polys.size() != 1) {
+        std::cout << "fail merge 3\n";
+        return false;
+      }
+      std::cout << "Polygon { -2 2, -2 2, 1 4 } \n";
+      std::cout << "Polygon { 2 4, 2 -4, -3 1 } \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(-2, 2));
+      pts.push_back(Point(-2, 2));
+      pts.push_back(Point(1, 4));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(2, 4));
+      pts.push_back(Point(2, -4));
+      pts.push_back(Point(-3, 1));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      psd = (*(result.begin())).second;
+      std::cout << psd << std::endl;
+      polys.clear();
+      psd.get(polys);
+      if(polys.size() != 1) {
+        std::cout << "fail merge 4\n";
+        return false;
+      }
+      std::cout << (polys[0]) << std::endl;
+      std::cout << "Polygon { -4 0, -2 -3, 3 -4 } \n";
+      std::cout << "Polygon { -1 1, 1 -2, -4 -3 } \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(-4, 0));
+      pts.push_back(Point(-2, -3));
+      pts.push_back(Point(3, -4));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(-1, 1));
+      pts.push_back(Point(1, -2));
+      pts.push_back(Point(-4, -3));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      psd = (*(result.begin())).second;
+      std::cout << psd << std::endl;
+      polys.clear();
+      psd.get(polys);
+      if(polys.size() != 1) {
+        std::cout << "fail merge 5\n";
+        return false;
+      }
+      std::cout << "Polygon { 2 2, -2 0, 0 1 }  \n";
+      std::cout << "Polygon { 4 -2, 3 -1, 2 3 }  \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(2, 2));
+      pts.push_back(Point(-2, 0));
+      pts.push_back(Point(0, 1));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(4, -2));
+      pts.push_back(Point(3, -1));
+      pts.push_back(Point(2, 3));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      if(!result.empty()) {
+        psd = (*(result.begin())).second;
+        std::cout << psd << std::endl;
+        polys.clear();
+        psd.get(polys);
+        if(polys.size() != 1) {
+          std::cout << "fail merge 6\n";
+          return false;
+        }
+        std::cout << (polys[0]) << std::endl;
+      }
+      std::cout << "Polygon { 0 2, 3 -1, 4 1 }  \n";
+      std::cout << "Polygon { -4 3, 3 3, 4 2 }  \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(0, 2));
+      pts.push_back(Point(3, -1));
+      pts.push_back(Point(4, 1));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(-4, 3));
+      pts.push_back(Point(3, 3));
+      pts.push_back(Point(4, 2));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      if(!result.empty()) {
+        psd = (*(result.begin())).second;
+        std::cout << psd << std::endl;
+        polys.clear();
+        psd.get(polys);
+        if(polys.size() == 0) {
+          std::cout << "fail merge 7\n";
+          return false;
+        }
+        std::cout << (polys[0]) << std::endl;
+      }
+std::cout << "Polygon { 1 -2, -1 4, 3 -2 }   \n";
+std::cout << "Polygon { 0 -3, 3 1, -3 -4 }   \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(1, -2));
+      pts.push_back(Point(-1, 4));
+      pts.push_back(Point(3, -2));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(0, -3));
+      pts.push_back(Point(3, 1));
+      pts.push_back(Point(-3, -4));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      if(!result.empty()) {
+        psd = (*(result.begin())).second;
+        std::cout << psd << std::endl;
+        polys.clear();
+        psd.get(polys);
+        if(polys.size() == 0) {
+          std::cout << "fail merge 8\n";
+          return false;
+        }
+        std::cout << (polys[0]) << std::endl;
+      }
+std::cout << "Polygon { 2 2, 3 0, -3 4 }  \n";
+std::cout << "Polygon { -2 -2, 0 0, -1 -1 }  \n";
+      si.clear();
+      pts.clear();
+      pts.push_back(Point(2, 2));
+      pts.push_back(Point(3, 0));
+      pts.push_back(Point(-3, 4));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      pts.clear();
+      pts.push_back(Point(-2, -2));
+      pts.push_back(Point(0, 0));
+      pts.push_back(Point(-1, -1));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      if(!result.empty()) {
+        psd = (*(result.begin())).second;
+        std::cout << psd << std::endl;
+        polys.clear();
+        psd.get(polys);
+        if(polys.size() == 0) {
+          std::cout << "fail merge 9\n";
+          return false;
+        }
+        std::cout << (polys[0]) << std::endl;
+      }
+      si.clear();
+      pts.clear();
+      //5624841,17616200,75000,9125000
+      //pts.push_back(Point(5624841,75000));
+      //pts.push_back(Point(5624841,9125000));
+      //pts.push_back(Point(17616200,9125000));
+      //pts.push_back(Point(17616200,75000));
+pts.push_back(Point(12262940, 6652520 )); pts.push_back(Point(12125750, 6652520 )); pts.push_back(Point(12121272, 6652961 )); pts.push_back(Point(12112981, 6656396 )); pts.push_back(Point(12106636, 6662741 )); pts.push_back(Point(12103201, 6671032 )); pts.push_back(Point(12103201, 6680007 )); pts.push_back(Point(12106636, 6688298 )); 
+pts.push_back(Point(12109500, 6691780 )); pts.push_back(Point(12748600, 7330890 )); pts.push_back(Point(15762600, 7330890 )); pts.push_back(Point(15904620, 7472900 )); pts.push_back(Point(15909200, 7473030 )); pts.push_back(Point(15935830, 7476006 )); pts.push_back(Point(15992796, 7499602 )); pts.push_back(Point(16036397, 7543203 )); 
+pts.push_back(Point(16059993, 7600169 )); pts.push_back(Point(16059993, 7661830 )); pts.push_back(Point(16036397, 7718796 )); pts.push_back(Point(15992796, 7762397 )); pts.push_back(Point(15935830, 7785993 )); pts.push_back(Point(15874169, 7785993 )); pts.push_back(Point(15817203, 7762397 )); pts.push_back(Point(15773602, 7718796 )); 
+pts.push_back(Point(15750006, 7661830 )); pts.push_back(Point(15747030, 7635200 )); pts.push_back(Point(15746900, 7630620 )); pts.push_back(Point(15670220, 7553930 )); pts.push_back(Point(14872950, 7553930 )); pts.push_back(Point(14872950, 7626170 )); 
+pts.push_back(Point(14869973, 7661280 )); pts.push_back(Point(14846377, 7718246 )); pts.push_back(Point(14802776, 7761847 )); pts.push_back(Point(14745810, 7785443 )); pts.push_back(Point(14684149, 7785443 )); pts.push_back(Point(14627183, 7761847 )); pts.push_back(Point(14583582, 7718246 )); 
+pts.push_back(Point(14559986, 7661280 )); pts.push_back(Point(14557070, 7636660 )); pts.push_back(Point(14556670, 7625570 )); pts.push_back(Point(13703330, 7625570 )); pts.push_back(Point(13702930, 7636660 )); pts.push_back(Point(13699993, 7661830 )); pts.push_back(Point(13676397, 7718796 )); 
+pts.push_back(Point(13632796, 7762397 )); pts.push_back(Point(13575830, 7785993 )); pts.push_back(Point(13514169, 7785993 )); pts.push_back(Point(13457203, 7762397 )); pts.push_back(Point(13436270, 7745670 )); pts.push_back(Point(13432940, 7742520 )); pts.push_back(Point(12963760, 7742520 )); 
+pts.push_back(Point(12959272, 7742961 )); pts.push_back(Point(12950981, 7746396 )); pts.push_back(Point(12944636, 7752741 )); pts.push_back(Point(12941201, 7761032 )); pts.push_back(Point(12941201, 7770007 )); pts.push_back(Point(12944636, 7778298 )); pts.push_back(Point(12947490, 7781780 )); 
+pts.push_back(Point(13425330, 8259620 )); pts.push_back(Point(15601330, 8259620 )); pts.push_back(Point(15904620, 8562900 )); pts.push_back(Point(15909200, 8563030 )); pts.push_back(Point(15935830, 8566006 )); pts.push_back(Point(15992796, 8589602 )); pts.push_back(Point(16036397, 8633203 )); 
+pts.push_back(Point(16059993, 8690169 )); pts.push_back(Point(16059993, 8751830 )); pts.push_back(Point(16036397, 8808796 )); pts.push_back(Point(15992796, 8852397 )); pts.push_back(Point(15935830, 8875993 )); pts.push_back(Point(15874169, 8875993 )); pts.push_back(Point(15817203, 8852397 )); pts.push_back(Point(15773602, 8808796 )); 
+pts.push_back(Point(15750006, 8751830 )); pts.push_back(Point(15747030, 8725200 )); pts.push_back(Point(15746900, 8720620 )); pts.push_back(Point(15508950, 8482660 )); pts.push_back(Point(14689890, 8482660 )); pts.push_back(Point(14685412, 8483101 )); pts.push_back(Point(14677121, 8486536 )); 
+pts.push_back(Point(14670776, 8492881 )); pts.push_back(Point(14667341, 8501172 )); pts.push_back(Point(14667341, 8510147 )); pts.push_back(Point(14670776, 8518438 )); pts.push_back(Point(14673630, 8521920 )); pts.push_back(Point(14714620, 8562900 )); pts.push_back(Point(14719200, 8563030 )); pts.push_back(Point(14745830, 8566006 )); 
+pts.push_back(Point(14802796, 8589602 )); pts.push_back(Point(14846397, 8633203 )); pts.push_back(Point(14869993, 8690169 )); pts.push_back(Point(14869993, 8751830 )); pts.push_back(Point(14846397, 8808796 )); pts.push_back(Point(14802796, 8852397 )); pts.push_back(Point(14745830, 8875993 )); pts.push_back(Point(14684169, 8875993 )); 
+pts.push_back(Point(14627203, 8852397 )); pts.push_back(Point(14583602, 8808796 )); pts.push_back(Point(14560006, 8751830 )); pts.push_back(Point(14557030, 8725200 )); pts.push_back(Point(14556900, 8720620 )); pts.push_back(Point(14408270, 8571980 )); pts.push_back(Point(13696320, 8571980 )); pts.push_back(Point(13696320, 8675520 )); 
+pts.push_back(Point(13699963, 8690161 )); pts.push_back(Point(13699963, 8751818 )); pts.push_back(Point(13676368, 8808781 )); pts.push_back(Point(13632771, 8852378 )); pts.push_back(Point(13575808, 8875973 )); pts.push_back(Point(13514151, 8875973 )); pts.push_back(Point(13457188, 8852378 )); pts.push_back(Point(13436270, 8835670 )); pts.push_back(Point(13432940, 8832520 )); 
+pts.push_back(Point(13281760, 8832520 )); pts.push_back(Point(13277272, 8832961 )); pts.push_back(Point(13268981, 8836396 )); pts.push_back(Point(13262636, 8842741 )); pts.push_back(Point(13259201, 8851032 )); pts.push_back(Point(13259201, 8860007 )); pts.push_back(Point(13262636, 8868298 )); pts.push_back(Point(13265500, 8871780 )); 
+pts.push_back(Point(13518710, 9125000 )); pts.push_back(Point(16270720, 9125000 )); pts.push_back(Point(16270720, 8939590 )); pts.push_back(Point(17120780, 8939590 )); pts.push_back(Point(17120780, 9125000 )); pts.push_back(Point(17616200, 9125000 )); pts.push_back(Point(17616200,   75000 )); pts.push_back(Point(16024790,   75000 )); 
+pts.push_back(Point(16021460,   80700 )); pts.push_back(Point(16016397,   88796 )); pts.push_back(Point(15972796,  132397 )); pts.push_back(Point(15915830,  155993 )); pts.push_back(Point(15908730,  157240 )); pts.push_back(Point(15905000,  157800 )); pts.push_back(Point(15516800,  546000 )); pts.push_back(Point(15905000,  934200 )); 
+pts.push_back(Point(15908730,  934760 )); pts.push_back(Point(15915830,  936006 )); pts.push_back(Point(15972796,  959602 )); pts.push_back(Point(16016397, 1003203 )); pts.push_back(Point(16039993, 1060169 )); pts.push_back(Point(16039993, 1121830 )); pts.push_back(Point(16016397, 1178796 )); pts.push_back(Point(15972796, 1222397 )); 
+pts.push_back(Point(15915830, 1245993 )); pts.push_back(Point(15854169, 1245993 )); pts.push_back(Point(15797203, 1222397 )); pts.push_back(Point(15753602, 1178796 )); pts.push_back(Point(15730006, 1121830 )); pts.push_back(Point(15728760, 1114730 )); pts.push_back(Point(15728200, 1111000 )); pts.push_back(Point(15363500,  746300 )); 
+pts.push_back(Point(14602620,  746300 )); pts.push_back(Point(14598142,  746741 )); pts.push_back(Point(14589851,  750176 )); pts.push_back(Point(14583506,  756521 )); pts.push_back(Point(14580071,  764812 )); pts.push_back(Point(14580071,  773787 )); pts.push_back(Point(14583506,  782078 )); pts.push_back(Point(14586360,  785560 )); 
+pts.push_back(Point(14586370,  785560 )); pts.push_back(Point(14735000,  934200 )); pts.push_back(Point(14738730,  934760 )); pts.push_back(Point(14745830,  936006 )); pts.push_back(Point(14802796,  959602 )); pts.push_back(Point(14846397, 1003203 )); pts.push_back(Point(14869993, 1060169 )); 
+pts.push_back(Point(14870450, 1062550 )); pts.push_back(Point(14872170, 1071980 )); pts.push_back(Point(14972780, 1071980 )); pts.push_back(Point(15925000, 2024200 )); pts.push_back(Point(15928730, 2024760 )); pts.push_back(Point(15935830, 2026006 )); pts.push_back(Point(15992796, 2049602 )); 
+pts.push_back(Point(16036397, 2093203 )); pts.push_back(Point(16059993, 2150169 )); pts.push_back(Point(16059993, 2211830 )); pts.push_back(Point(16036397, 2268796 )); pts.push_back(Point(15992796, 2312397 )); pts.push_back(Point(15935830, 2335993 )); pts.push_back(Point(15874169, 2335993 )); 
+pts.push_back(Point(15817203, 2312397 )); pts.push_back(Point(15773602, 2268796 )); pts.push_back(Point(15750006, 2211830 )); pts.push_back(Point(15748760, 2204730 )); pts.push_back(Point(15748200, 2201000 )); pts.push_back(Point(14869220, 1322020 )); pts.push_back(Point(14088350, 1322020 )); 
+pts.push_back(Point(14083862, 1322461 )); pts.push_back(Point(14075571, 1325896 )); pts.push_back(Point(14069226, 1332241 )); pts.push_back(Point(14065791, 1340532 )); pts.push_back(Point(14065791, 1349507 )); pts.push_back(Point(14069226, 1357798 )); pts.push_back(Point(14072080, 1361280 )); 
+pts.push_back(Point(14072090, 1361280 )); pts.push_back(Point(14735000, 2024200 )); pts.push_back(Point(14738730, 2024760 )); pts.push_back(Point(14745830, 2026006 )); pts.push_back(Point(14802796, 2049602 )); pts.push_back(Point(14846397, 2093203 )); pts.push_back(Point(14869993, 2150169 )); 
+pts.push_back(Point(14869993, 2211830 )); pts.push_back(Point(14846397, 2268796 )); pts.push_back(Point(14802796, 2312397 )); pts.push_back(Point(14745830, 2335993 )); pts.push_back(Point(14684169, 2335993 )); pts.push_back(Point(14627203, 2312397 )); pts.push_back(Point(14583602, 2268796 )); pts.push_back(Point(14560006, 2211830 )); 
+pts.push_back(Point(14558760, 2204730 )); pts.push_back(Point(14558200, 2201000 )); pts.push_back(Point(13752220, 1395020 )); pts.push_back(Point(12991340, 1395020 )); pts.push_back(Point(12986862, 1395461 )); pts.push_back(Point(12978571, 1398896 )); pts.push_back(Point(12972226, 1405241 )); 
+pts.push_back(Point(12968791, 1413532 )); pts.push_back(Point(12968791, 1422507 )); pts.push_back(Point(12972226, 1430798 )); pts.push_back(Point(12975080, 1434280 )); pts.push_back(Point(12975090, 1434280 )); pts.push_back(Point(13565000, 2024200 )); pts.push_back(Point(13568730, 2024760 )); pts.push_back(Point(13575830, 2026006 )); 
+pts.push_back(Point(13632796, 2049602 )); pts.push_back(Point(13676397, 2093203 )); pts.push_back(Point(13699993, 2150169 )); pts.push_back(Point(13699993, 2211830 )); pts.push_back(Point(13676397, 2268796 )); pts.push_back(Point(13632796, 2312397 )); pts.push_back(Point(13575830, 2335993 )); 
+pts.push_back(Point(13514169, 2335993 )); pts.push_back(Point(13457203, 2312397 )); pts.push_back(Point(13413602, 2268796 )); pts.push_back(Point(13390006, 2211830 )); pts.push_back(Point(13388760, 2204730 )); pts.push_back(Point(13388200, 2201000 )); pts.push_back(Point(12655220, 1468020 )); 
+pts.push_back(Point(11894340, 1468020 )); pts.push_back(Point(11889862, 1468461 )); pts.push_back(Point(11881571, 1471896 )); pts.push_back(Point(11875226, 1478241 )); pts.push_back(Point(11871791, 1486532 )); pts.push_back(Point(11871791, 1495507 )); 
+pts.push_back(Point(11875226, 1503798 )); pts.push_back(Point(11878090, 1507280 )); pts.push_back(Point(12395000, 2024200 )); pts.push_back(Point(12398730, 2024760 )); pts.push_back(Point(12405830, 2026006 )); pts.push_back(Point(12462796, 2049602 )); pts.push_back(Point(12506397, 2093203 )); 
+pts.push_back(Point(12529993, 2150169 )); pts.push_back(Point(12529993, 2211830 )); pts.push_back(Point(12506397, 2268796 )); pts.push_back(Point(12462796, 2312397 )); pts.push_back(Point(12405830, 2335993 )); pts.push_back(Point(12344169, 2335993 )); 
+pts.push_back(Point(12287203, 2312397 )); pts.push_back(Point(12243602, 2268796 )); pts.push_back(Point(12220006, 2211830 )); pts.push_back(Point(12218760, 2204730 )); pts.push_back(Point(12218200, 2201000 )); pts.push_back(Point(11558220, 1541020 )); 
+pts.push_back(Point(10797340, 1541020 )); pts.push_back(Point(10792862, 1541461 )); pts.push_back(Point(10784571, 1544896 )); pts.push_back(Point(10778226, 1551241 )); pts.push_back(Point(10774791, 1559532 )); pts.push_back(Point(10774791, 1568507 )); pts.push_back(Point(10778226, 1576798 )); pts.push_back(Point(10781080, 1580280 )); 
+pts.push_back(Point(10781090, 1580280 )); pts.push_back(Point(11225000, 2024200 )); pts.push_back(Point(11228730, 2024760 )); pts.push_back(Point(11235830, 2026006 )); pts.push_back(Point(11292796, 2049602 )); pts.push_back(Point(11336397, 2093203 )); pts.push_back(Point(11359993, 2150169 )); 
+pts.push_back(Point(11359993, 2211830 )); pts.push_back(Point(11336397, 2268796 )); pts.push_back(Point(11292796, 2312397 )); pts.push_back(Point(11235830, 2335993 )); pts.push_back(Point(11174169, 2335993 )); pts.push_back(Point(11117203, 2312397 )); pts.push_back(Point(11073602, 2268796 )); pts.push_back(Point(11050006, 2211830 )); 
+pts.push_back(Point(11048760, 2204730 )); pts.push_back(Point(11048200, 2201000 )); pts.push_back(Point(10461220, 1614020 )); pts.push_back(Point( 5647400, 1614020 )); pts.push_back(Point( 5642912, 1614461 )); 
+pts.push_back(Point( 5634621, 1617896 )); pts.push_back(Point( 5628276, 1624241 )); pts.push_back(Point( 5624841, 1632532 )); pts.push_back(Point( 5624841, 1641507 )); pts.push_back(Point( 5628276, 1649798 )); pts.push_back(Point( 5631130, 1653280 )); 
+pts.push_back(Point( 5688490, 1710640 )); pts.push_back(Point( 9722350, 1710640 )); pts.push_back(Point(10034620, 2022900 )); pts.push_back(Point(10039200, 2023030 )); pts.push_back(Point(10065830, 2026006 )); pts.push_back(Point(10122796, 2049602 )); 
+pts.push_back(Point(10166397, 2093203 )); pts.push_back(Point(10189993, 2150169 )); pts.push_back(Point(10189993, 2211830 )); pts.push_back(Point(10166397, 2268796 )); pts.push_back(Point(10158620, 2279450 )); pts.push_back(Point(10158620, 2404900 )); pts.push_back(Point(10548950, 2795240 )); 
+pts.push_back(Point(15586950, 2795240 )); pts.push_back(Point(15904620, 3112900 )); pts.push_back(Point(15909200, 3113030 )); pts.push_back(Point(15935830, 3116006 )); pts.push_back(Point(15992796, 3139602 )); pts.push_back(Point(16036397, 3183203 )); pts.push_back(Point(16059993, 3240169 )); pts.push_back(Point(16059993, 3301830 )); 
+pts.push_back(Point(16036397, 3358796 )); pts.push_back(Point(15992796, 3402397 )); pts.push_back(Point(15935830, 3425993 )); pts.push_back(Point(15874169, 3425993 )); pts.push_back(Point(15817203, 3402397 )); pts.push_back(Point(15773602, 3358796 )); pts.push_back(Point(15750006, 3301830 )); pts.push_back(Point(15747030, 3275200 )); 
+pts.push_back(Point(15746900, 3270620 )); pts.push_back(Point(15494570, 3018280 )); pts.push_back(Point(14675510, 3018280 )); pts.push_back(Point(14671032, 3018721 )); pts.push_back(Point(14662741, 3022156 )); pts.push_back(Point(14656396, 3028501 )); pts.push_back(Point(14652961, 3036792 )); 
+pts.push_back(Point(14652961, 3045767 )); pts.push_back(Point(14656396, 3054058 )); pts.push_back(Point(14659260, 3057540 )); pts.push_back(Point(14714620, 3112900 )); pts.push_back(Point(14719200, 3113030 )); pts.push_back(Point(14745830, 3116006 )); pts.push_back(Point(14802796, 3139602 )); 
+pts.push_back(Point(14846397, 3183203 )); pts.push_back(Point(14869993, 3240169 )); pts.push_back(Point(14869993, 3301830 )); pts.push_back(Point(14846397, 3358796 )); pts.push_back(Point(14802796, 3402397 )); pts.push_back(Point(14745830, 3425993 )); pts.push_back(Point(14684169, 3425993 )); pts.push_back(Point(14627203, 3402397 )); 
+pts.push_back(Point(14583602, 3358796 )); pts.push_back(Point(14560006, 3301830 )); pts.push_back(Point(14557030, 3275200 )); pts.push_back(Point(14556900, 3270620 )); pts.push_back(Point(14370700, 3084410 )); pts.push_back(Point(13702830, 3084410 )); pts.push_back(Point(13702830, 3263160 )); 
+pts.push_back(Point(13700003, 3302210 )); pts.push_back(Point(13676407, 3359176 )); pts.push_back(Point(13632806, 3402777 )); pts.push_back(Point(13575840, 3426373 )); pts.push_back(Point(13514179, 3426373 )); pts.push_back(Point(13457213, 3402777 )); pts.push_back(Point(13413612, 3359176 )); 
+pts.push_back(Point(13390016, 3302210 )); pts.push_back(Point(13387030, 3275200 )); pts.push_back(Point(13386900, 3270620 )); pts.push_back(Point(13266840, 3150550 )); pts.push_back(Point(12532920, 3150550 )); pts.push_back(Point(12532920, 3264990 )); pts.push_back(Point(12529993, 3301820 )); 
+pts.push_back(Point(12506397, 3358786 )); pts.push_back(Point(12462796, 3402387 )); pts.push_back(Point(12405830, 3425983 )); pts.push_back(Point(12344169, 3425983 )); pts.push_back(Point(12287203, 3402387 )); pts.push_back(Point(12243602, 3358786 )); pts.push_back(Point(12220006, 3301820 )); pts.push_back(Point(12217030, 3275200 )); 
+pts.push_back(Point(12216900, 3270620 )); pts.push_back(Point(12157460, 3211170 )); pts.push_back(Point(11362030, 3211170 )); pts.push_back(Point(11360250, 3220520 )); pts.push_back(Point(11359993, 3221830 )); pts.push_back(Point(11336397, 3278796 )); 
+pts.push_back(Point(11292796, 3322397 )); pts.push_back(Point(11235830, 3345993 )); pts.push_back(Point(11174169, 3345993 )); pts.push_back(Point(11117203, 3322397 )); pts.push_back(Point(11096270, 3305670 )); pts.push_back(Point(11092940, 3302520 )); pts.push_back(Point(10680760, 3302520 )); 
+pts.push_back(Point(10676272, 3302961 )); pts.push_back(Point(10667981, 3306396 )); pts.push_back(Point(10661636, 3312741 )); pts.push_back(Point(10658201, 3321032 )); pts.push_back(Point(10658201, 3330007 )); pts.push_back(Point(10661636, 3338298 )); pts.push_back(Point(10664500, 3341780 )); 
+pts.push_back(Point(11264260, 3941550 )); pts.push_back(Point(15643260, 3941550 )); pts.push_back(Point(15904620, 4202900 )); pts.push_back(Point(15909200, 4203030 )); pts.push_back(Point(15935830, 4206006 )); pts.push_back(Point(15992796, 4229602 )); 
+pts.push_back(Point(16036397, 4273203 )); pts.push_back(Point(16059993, 4330169 )); pts.push_back(Point(16059993, 4391830 )); pts.push_back(Point(16036397, 4448796 )); pts.push_back(Point(15992796, 4492397 )); 
+pts.push_back(Point(15935830, 4515993 )); pts.push_back(Point(15874169, 4515993 )); pts.push_back(Point(15817203, 4492397 )); pts.push_back(Point(15773602, 4448796 )); pts.push_back(Point(15750006, 4391830 )); pts.push_back(Point(15747030, 4365200 )); pts.push_back(Point(15746900, 4360620 )); 
+pts.push_back(Point(15550880, 4164590 )); pts.push_back(Point(14825070, 4164590 )); pts.push_back(Point(14825070, 4247610 )); pts.push_back(Point(14846397, 4273213 )); pts.push_back(Point(14869993, 4330179 )); pts.push_back(Point(14869993, 4391840 )); pts.push_back(Point(14846397, 4448806 )); 
+pts.push_back(Point(14802796, 4492407 )); pts.push_back(Point(14745830, 4516003 )); pts.push_back(Point(14684169, 4516003 )); pts.push_back(Point(14627203, 4492407 )); pts.push_back(Point(14583602, 4448806 )); pts.push_back(Point(14560006, 4391840 )); pts.push_back(Point(14557030, 4365200 )); 
+pts.push_back(Point(14556900, 4360620 )); pts.push_back(Point(14432520, 4236230 )); pts.push_back(Point(13702830, 4236230 )); pts.push_back(Point(13702830, 4352930 )); pts.push_back(Point(13699993, 4391750 )); pts.push_back(Point(13676397, 4448716 )); 
+pts.push_back(Point(13632796, 4492317 )); pts.push_back(Point(13575830, 4515913 )); pts.push_back(Point(13514169, 4515913 )); pts.push_back(Point(13457203, 4492317 )); pts.push_back(Point(13413602, 4448716 )); pts.push_back(Point(13390006, 4391750 )); pts.push_back(Point(13387030, 4365200 )); 
+pts.push_back(Point(13386900, 4360620 )); pts.push_back(Point(13334170, 4307880 )); pts.push_back(Point(12532990, 4307880 )); pts.push_back(Point(12532990, 4357550 )); pts.push_back(Point(12529993, 4391760 )); pts.push_back(Point(12506397, 4448726 )); pts.push_back(Point(12462796, 4492327 )); 
+pts.push_back(Point(12405830, 4515923 )); pts.push_back(Point(12344169, 4515923 )); pts.push_back(Point(12287203, 4492327 )); pts.push_back(Point(12243602, 4448726 )); pts.push_back(Point(12220006, 4391760 )); pts.push_back(Point(12217970, 4378710 )); pts.push_back(Point(12216810, 4368500 )); 
+pts.push_back(Point(11363190, 4368500 )); pts.push_back(Point(11362030, 4378710 )); pts.push_back(Point(11359983, 4391828 )); pts.push_back(Point(11336388, 4448791 )); pts.push_back(Point(11292791, 4492388 )); pts.push_back(Point(11235828, 4515983 )); pts.push_back(Point(11174171, 4515983 )); pts.push_back(Point(11117208, 4492388 )); 
+pts.push_back(Point(11096270, 4475670 )); pts.push_back(Point(11092940, 4472520 )); pts.push_back(Point(11057750, 4472520 )); pts.push_back(Point(11053272, 4472961 )); pts.push_back(Point(11044981, 4476396 )); pts.push_back(Point(11038636, 4482741 )); pts.push_back(Point(11035201, 4491032 )); 
+pts.push_back(Point(11035201, 4500007 )); pts.push_back(Point(11038636, 4508298 )); pts.push_back(Point(11041490, 4511780 )); pts.push_back(Point(11573490, 5043780 )); pts.push_back(Point(15655490, 5043780 )); pts.push_back(Point(15904620, 5292900 )); 
+pts.push_back(Point(15909200, 5293030 )); pts.push_back(Point(15935830, 5296006 )); pts.push_back(Point(15992796, 5319602 )); pts.push_back(Point(16036397, 5363203 )); pts.push_back(Point(16059993, 5420169 )); pts.push_back(Point(16059993, 5481830 )); pts.push_back(Point(16036397, 5538796 )); 
+pts.push_back(Point(15992796, 5582397 )); pts.push_back(Point(15935830, 5605993 )); pts.push_back(Point(15874169, 5605993 )); pts.push_back(Point(15817203, 5582397 )); pts.push_back(Point(15773602, 5538796 )); pts.push_back(Point(15750006, 5481830 )); pts.push_back(Point(15747030, 5455200 )); 
+pts.push_back(Point(15746900, 5450620 )); pts.push_back(Point(15563110, 5266820 )); pts.push_back(Point(14857380, 5266820 )); pts.push_back(Point(14857380, 5382430 )); pts.push_back(Point(14869993, 5420179 )); pts.push_back(Point(14869993, 5481840 )); pts.push_back(Point(14846397, 5538806 )); pts.push_back(Point(14802796, 5582407 )); 
+pts.push_back(Point(14745830, 5606003 )); pts.push_back(Point(14684169, 5606003 )); pts.push_back(Point(14627203, 5582407 )); pts.push_back(Point(14583602, 5538806 )); pts.push_back(Point(14560006, 5481840 )); pts.push_back(Point(14557030, 5455200 )); pts.push_back(Point(14556900, 5450620 )); pts.push_back(Point(14444750, 5338460 )); 
+pts.push_back(Point(13702890, 5338460 )); pts.push_back(Point(13702890, 5364400 )); pts.push_back(Point(13699993, 5401800 )); pts.push_back(Point(13676397, 5458766 )); pts.push_back(Point(13632796, 5502367 )); pts.push_back(Point(13575830, 5525963 )); pts.push_back(Point(13514169, 5525963 )); pts.push_back(Point(13457203, 5502367 )); 
+pts.push_back(Point(13413602, 5458766 )); pts.push_back(Point(13390006, 5401800 )); pts.push_back(Point(13389230, 5397620 )); pts.push_back(Point(13387590, 5388060 )); pts.push_back(Point(12532960, 5388060 )); pts.push_back(Point(12532960, 5446220 )); pts.push_back(Point(12529993, 5481820 )); 
+pts.push_back(Point(12506397, 5538786 )); pts.push_back(Point(12462796, 5582387 )); pts.push_back(Point(12405830, 5605983 )); pts.push_back(Point(12344169, 5605983 )); pts.push_back(Point(12287203, 5582387 )); pts.push_back(Point(12266270, 5565670 )); pts.push_back(Point(12262940, 5562520 )); pts.push_back(Point(11737750, 5562520 )); 
+pts.push_back(Point(11733272, 5562961 )); pts.push_back(Point(11724981, 5566396 )); pts.push_back(Point(11718636, 5572741 )); pts.push_back(Point(11715201, 5581032 )); pts.push_back(Point(11715201, 5590007 )); pts.push_back(Point(11718636, 5598298 )); pts.push_back(Point(11721500, 5601780 )); 
+pts.push_back(Point(12287760, 6168050 )); pts.push_back(Point(15689760, 6168050 )); pts.push_back(Point(15904620, 6382900 )); pts.push_back(Point(15909200, 6383030 )); pts.push_back(Point(15935830, 6386006 )); pts.push_back(Point(15992796, 6409602 )); 
+pts.push_back(Point(16036397, 6453203 )); pts.push_back(Point(16059993, 6510169 )); pts.push_back(Point(16059993, 6571830 )); pts.push_back(Point(16036397, 6628796 )); pts.push_back(Point(15992796, 6672397 )); pts.push_back(Point(15935830, 6695993 )); pts.push_back(Point(15874169, 6695993 )); 
+pts.push_back(Point(15817203, 6672397 )); pts.push_back(Point(15773602, 6628796 )); pts.push_back(Point(15750006, 6571830 )); pts.push_back(Point(15747030, 6545200 )); pts.push_back(Point(15746900, 6540620 )); pts.push_back(Point(15597380, 6391090 )); pts.push_back(Point(14858060, 6391090 )); 
+pts.push_back(Point(14858060, 6473860 )); pts.push_back(Point(14869993, 6510179 )); pts.push_back(Point(14869993, 6571840 )); pts.push_back(Point(14846397, 6628806 )); pts.push_back(Point(14802796, 6672407 )); pts.push_back(Point(14745830, 6696003 )); pts.push_back(Point(14684169, 6696003 )); 
+pts.push_back(Point(14627203, 6672407 )); pts.push_back(Point(14583602, 6628806 )); pts.push_back(Point(14560006, 6571840 )); pts.push_back(Point(14557030, 6545200 )); pts.push_back(Point(14556900, 6540620 )); pts.push_back(Point(14479020, 6462730 )); 
+pts.push_back(Point(13702990, 6462730 )); pts.push_back(Point(13702990, 6537170 )); pts.push_back(Point(13700003, 6571840 )); pts.push_back(Point(13676407, 6628806 )); pts.push_back(Point(13632806, 6672407 )); pts.push_back(Point(13575840, 6696003 )); 
+pts.push_back(Point(13514179, 6696003 )); pts.push_back(Point(13457213, 6672407 )); pts.push_back(Point(13413612, 6628806 )); pts.push_back(Point(13390016, 6571840 )); pts.push_back(Point(13387040, 6545550 )); pts.push_back(Point(13386710, 6534380 )); 
+pts.push_back(Point(12533290, 6534380 )); pts.push_back(Point(12532960, 6545550 )); pts.push_back(Point(12529983, 6571828 )); pts.push_back(Point(12506388, 6628791 )); pts.push_back(Point(12462791, 6672388 )); pts.push_back(Point(12405828, 6695983 )); 
+pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 )); pts.push_back(Point(12266270, 6655670 ));
+      poly.set(pts.begin(), pts.end());
+      si.insert(poly, 444);
+      result.clear();
+      si.merge(result);
+      si.verify();
+      print(std::cout, si.pmd) << std::endl;
+      if(!result.empty()) {
+        psd = (*(result.begin())).second;
+        std::cout << psd << std::endl;
+        std::vector<Point> outpts;
+        for(typename polygon_set_data<Unit>::iterator_type itr = psd.begin();
+            itr != psd.end(); ++itr) {
+          outpts.push_back((*itr).first.first);
+          outpts.push_back((*itr).first.second);
+        }
+        std::sort(outpts.begin(), outpts.end());
+        for(unsigned int i = 0; i < outpts.size(); i+=2) {
+          if(outpts[i] != outpts[i+1]) {
+            std::cout << "Polygon set not a closed figure\n";
+            std::cout << i << std::endl;
+            std::cout << outpts[i] << " " << outpts[i+1] << std::endl;
+            return 0;
+          }
+        }
+        polys.clear();
+        psd.get(polys);
+        if(polys.size() == 0) {
+          std::cout << "fail merge 10\n";
+          return false;
+        }
+        std::cout << (polys[0]) << std::endl;
+      }
+      for(unsigned int i = 0; i < 10; ++i) {
+        std::cout << "random case # " << i << std::endl;
+        si.clear();
+        pts.clear();
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        polygon_data<Unit> poly1;
+        poly1.set(pts.begin(), pts.end());
+        std::cout << poly1 << std::endl;
+        si.insert(poly1, 444);
+        pts.clear();
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        polygon_data<Unit> poly2;
+        poly2.set(pts.begin(), pts.end());
+        std::cout << poly2 << std::endl;
+        si.insert(poly2, 444);
+        result.clear();
+        si.merge(result);
+        print(std::cout, si.pmd) << std::endl;
+        if(!result.empty()) {
+          psd = (*(result.begin())).second;
+          std::cout << psd << std::endl;
+          polys.clear();
+          psd.get(polys);
+          if(polys.size() == 0) {
+            si.clear();
+            si.insert(poly1, 333);
+            result.clear();
+            si.merge(result);
+            psd = (*(result.begin())).second;
+            std::vector<polygon_data<Unit> > polys1;
+            psd.get(polys1);
+            si.clear();
+            si.insert(poly2, 333);
+            result.clear();
+            si.merge(result);
+            psd = (*(result.begin())).second;
+            std::vector<polygon_data<Unit> > polys2;
+            psd.get(polys2);
+            if(!polys1.empty() || !polys2.empty()) {
+              std::cout << "fail random merge " << i << std::endl;
+              return false;
+            }
+          }
+        }
+        if(!polys.empty())
+          std::cout << polys.size() << ": " << (polys[0]) << std::endl;
+      }
+      return true;
+    }
+
+    static inline bool check_rectangle_trio(rectangle_data<Unit> rect1, rectangle_data<Unit> rect2, rectangle_data<Unit> rect3) {
+        property_merge si;
+        std::map<std::set<property_type>, polygon_set_data<Unit> > result;
+        std::vector<polygon_data<Unit> > polys;
+        property_merge_90<property_type, Unit> si90;
+        std::map<std::set<property_type>, polygon_90_set_data<Unit> > result90;
+        std::vector<polygon_data<Unit> > polys90;
+        si.insert(rect1, 111);
+        si90.insert(rect1, 111);
+        std::cout << rect1 << std::endl;
+        si.insert(rect2, 222);
+        si90.insert(rect2, 222);
+        std::cout << rect2 << std::endl;
+        si.insert(rect3, 333);
+        si90.insert(rect3, 333);
+        std::cout << rect3 << std::endl;
+        si.merge(result);
+        si90.merge(result90);
+        if(result.size() != result90.size()) {
+          std::cout << "merge failed with size mismatch\n";
+          return 0;
+        }
+        typename std::map<std::set<property_type>, polygon_90_set_data<Unit> >::iterator itr90 = result90.begin();
+        for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
+            itr != result.end(); ++itr) {
+          for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
+              set_itr != (*itr).first.end(); ++set_itr) {
+            std::cout << (*set_itr) << " ";
+          } std::cout << ") \n";
+          polygon_set_data<Unit> psd = (*itr).second;
+          polygon_90_set_data<Unit> psd90 = (*itr90).second;
+          polys.clear();
+          polys90.clear();
+          psd.get(polys);
+          psd90.get(polys90);
+          if(polys.size() != polys90.size()) {
+            std::cout << "merge failed with polygon count mismatch\n";
+            std::cout << psd << std::endl;
+            for(unsigned int j = 0; j < polys.size(); ++j) {
+              std::cout << polys[j] << std::endl;
+            }
+            std::cout << "reference\n";
+            for(unsigned int j = 0; j < polys90.size(); ++j) {
+              std::cout << polys90[j] << std::endl;
+            }
+            return 0;
+          }
+          bool failed = false;
+          for(unsigned int j = 0; j < polys.size(); ++j) {
+            std::cout << polys[j] << std::endl;
+            std::cout << polys90[j] << std::endl;
+#ifdef BOOST_POLYGON_ICC
+#pragma warning (disable:1572)
+#endif
+            if(area(polys[j]) != area(polys90[j])) {
+#ifdef BOOST_POLYGON_ICC
+#pragma warning (default:1572)
+#endif
+              std::cout << "merge failed with area mismatch\n";
+              failed = true;
+            }
+          }
+          if(failed) return 0;
+          ++itr90;
+        }
+        return true;
+    }
+
+    static inline bool test_manhattan_intersection() {
+      rectangle_data<Unit> rect1, rect2, rect3;
+      set_points(rect1, (Point(-1, 2)), (Point(1, 4)));
+      set_points(rect2, (Point(-1, 2)), (Point(2, 3)));
+      set_points(rect3, (Point(-3, 0)), (Point(4, 2)));
+      if(!check_rectangle_trio(rect1, rect2, rect3)) {
+        return false;
+      }
+      for(unsigned int i = 0; i < 100; ++i) {
+        property_merge si;
+        std::map<std::set<property_type>, polygon_set_data<Unit> > result;
+        std::vector<polygon_data<Unit> > polys;
+        property_merge_90<property_type, Unit> si90;
+        std::map<std::set<property_type>, polygon_90_set_data<Unit> > result90;
+        std::vector<polygon_data<Unit> > polys90;
+        std::cout << "random case # " << i << std::endl;
+        set_points(rect1, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
+        set_points(rect2, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
+        set_points(rect3, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
+        if(!check_rectangle_trio(rect1, rect2, rect3)) {
+          return false;
+        }
+      }
+      return true;
+    }
+
+    static inline bool test_intersection() {
+      property_merge si;
+      rectangle_data<Unit> rect;
+      xl(rect, 0);
+      yl(rect, 10);
+      xh(rect, 30);
+      yh(rect, 20);
+      si.insert(rect, 333);
+      xl(rect, 10);
+      yl(rect, 0);
+      xh(rect, 20);
+      yh(rect, 30);
+      si.insert(rect, 444);
+      xl(rect, 15);
+      yl(rect, 0);
+      xh(rect, 25);
+      yh(rect, 30);
+      si.insert(rect, 555);
+      std::map<std::set<property_type>, polygon_set_data<Unit> > result;
+      si.merge(result);
+      print(std::cout, si.pmd) << std::endl;
+      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
+          itr != result.end(); ++itr) {
+        std::cout << "( ";
+        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
+            set_itr != (*itr).first.end(); ++set_itr) {
+          std::cout << (*set_itr) << " ";
+        } std::cout << ") \n";
+        polygon_set_data<Unit> psd = (*itr).second;
+        std::cout << psd << std::endl;
+        std::vector<polygon_data<Unit> > polys;
+        psd.get(polys);
+        for(unsigned int i = 0; i < polys.size(); ++i) {
+          std::cout << polys[i] << std::endl;
+        }
+      }
+      std::vector<Point> pts;
+      std::vector<polygon_data<Unit> > polys;
+      for(unsigned int i = 0; i < 10; ++i) {
+        property_merge si2;
+        std::cout << "random case # " << i << std::endl;
+        si.clear();
+        pts.clear();
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        polygon_data<Unit> poly1;
+        poly1.set(pts.begin(), pts.end());
+        std::cout << poly1 << std::endl;
+        si.insert(poly1, 444);
+        si2.insert(poly1, 333);
+        pts.clear();
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        polygon_data<Unit> poly2;
+        poly2.set(pts.begin(), pts.end());
+        std::cout << poly2 << std::endl;
+        si.insert(poly2, 444);
+        si2.insert(poly2, 444);
+        pts.clear();
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        pts.push_back(Point(rand()%9-4, rand()%9-4));
+        polygon_data<Unit> poly3;
+        poly3.set(pts.begin(), pts.end());
+        std::cout << poly3 << std::endl;
+        si.insert(poly3, 444);
+        si2.insert(poly3, 555);
+        result.clear();
+        std::map<std::set<property_type>, polygon_set_data<Unit> > result2;
+        si.merge(result);
+        si2.merge(result2);
+        std::cout << "merged result\n";
+      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
+          itr != result.end(); ++itr) {
+        std::cout << "( ";
+        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
+            set_itr != (*itr).first.end(); ++set_itr) {
+          std::cout << (*set_itr) << " ";
+        } std::cout << ") \n";
+        polygon_set_data<Unit> psd = (*itr).second;
+        std::cout << psd << std::endl;
+        std::vector<polygon_data<Unit> > polys2;
+        psd.get(polys2);
+        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
+          std::cout << polys2[ii] << std::endl;
+        }
+      }
+      std::cout << "intersected pmd\n";
+      print(std::cout, si2.pmd) << std::endl;
+      std::cout << "intersected result\n";
+      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
+          itr != result2.end(); ++itr) {
+        std::cout << "( ";
+        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
+            set_itr != (*itr).first.end(); ++set_itr) {
+          std::cout << (*set_itr) << " ";
+        } std::cout << ") \n";
+        polygon_set_data<Unit> psd = (*itr).second;
+        std::cout << psd << std::endl;
+        std::vector<polygon_data<Unit> > polys2;
+        psd.get(polys2);
+        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
+          std::cout << polys2[ii] << std::endl;
+        }
+      }
+        si.clear();
+        for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
+            itr != result2.end(); ++itr) {
+          polys.clear();
+          (*itr).second.get(polys);
+          for(unsigned int j = 0; j < polys.size(); ++j) {
+            si.insert(polys[j], 444);
+          }
+        }
+        result2.clear();
+        si.merge(result2);
+      std::cout << "remerged result\n";
+      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
+          itr != result2.end(); ++itr) {
+        std::cout << "( ";
+        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
+            set_itr != (*itr).first.end(); ++set_itr) {
+          std::cout << (*set_itr) << " ";
+        } std::cout << ") \n";
+        polygon_set_data<Unit> psd = (*itr).second;
+        std::cout << psd << std::endl;
+        std::vector<polygon_data<Unit> > polys2;
+        psd.get(polys2);
+        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
+          std::cout << polys2[ii] << std::endl;
+        }
+      }
+      std::vector<polygon_data<Unit> > polys2;
+      polys.clear();
+      (*(result.begin())).second.get(polys);
+      (*(result2.begin())).second.get(polys2);
+      if(!(polys == polys2)) {
+          std::cout << "failed intersection check # " << i << std::endl;
+          return false;
+        }
+      }
+      return true;
+    }
+  };
+
+  template <typename Unit>
+  class arbitrary_boolean_op : public scanline_base<Unit> {
+  private:
+    
+    typedef int property_type;
+    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;
+
+    //this data structure assocates a property and count to a half edge
+    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
+    //this data type stores the combination of many half edges
+    typedef std::vector<vertex_property> property_merge_data;
+
+    //this is the data type used internally to store the combination of property counts at a given location
+    typedef std::vector<std::pair<property_type, int> > property_map;
+    //this data type is used internally to store the combined property data for a given half edge
+    typedef std::pair<half_edge, property_map> vertex_data;
+
+    property_merge_data pmd;
+
+    template<typename vertex_data_type>
+    class less_vertex_data {
+    public:
+      less_vertex_data() {}
+      bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
+        less_point lp;
+        if(lp(lvalue.first.first, rvalue.first.first)) return true;
+        if(lp(rvalue.first.first, lvalue.first.first)) return false;
+        Unit x = lvalue.first.first.get(HORIZONTAL);
+        int just_before_ = 0;
+        less_half_edge lhe(&x, &just_before_);
+        return lhe(lvalue.first, rvalue.first);
+      }
+    };
+
+    template <typename result_type, typename key_type, int op_type>
+    class boolean_output_functor {
+    public:
+      boolean_output_functor() {}
+      void operator()(result_type& result, const half_edge& edge, const key_type& left, const key_type& right) {
+        typename std::pair<half_edge, int> elem;
+        elem.first = edge;
+        elem.second = 1;
+        if(edge.second < edge.first) elem.second *= -1;
+        if(is_vertical(edge)) elem.second *= -1;
+        if(op_type == 0) { //OR
+          if(!left.empty() && right.empty()) {
+            result.insert_clean(elem);
+          } else if(!right.empty() && left.empty()) {
+            elem.second *= -1;
+            result.insert_clean(elem);
+          }
+        } else if(op_type == 1) { //AND
+          if(left.size() == 2 && right.size() != 2) {
+            result.insert_clean(elem);
+          } else if(right.size() == 2 && left.size() != 2) {
+            elem.second *= -1;
+            result.insert_clean(elem);
+          }
+        } else if(op_type == 2) { //XOR
+          if(left.size() == 1 && right.size() != 1) {
+            result.insert_clean(elem);
+          } else if(right.size() == 1 && left.size() != 1) {
+            elem.second *= -1;
+            result.insert_clean(elem);
+          }
+        } else { //SUBTRACT
+          if(left.size() == 1) {
+            if((*(left.begin())) == 0) {
+              result.insert_clean(elem);
+            }
+          } 
+          if(right.size() == 1) {
+            if((*(right.begin())) == 0) {
+              elem.second *= -1;
+              result.insert_clean(elem);
+            }
+          }
+        }
+      }
+    };
+
+    inline void sort_property_merge_data() {
+      less_vertex_data<vertex_property> lvd;
+      std::sort(pmd.begin(), pmd.end(), lvd);
+    }
+  public:
+    inline arbitrary_boolean_op() : pmd() {}
+    inline arbitrary_boolean_op(const arbitrary_boolean_op& pm) : pmd(pm.pmd) {}
+    inline arbitrary_boolean_op& operator=(const arbitrary_boolean_op& pm) { pmd = pm.pmd; return *this; }
+
+    enum BOOLEAN_OP_TYPE {
+      BOOLEAN_OR = 0,
+      BOOLEAN_AND = 1,
+      BOOLEAN_XOR = 2, 
+      BOOLEAN_NOT = 3
+    };
+    template <typename result_type, typename iT1, typename iT2>
+    inline void execute(result_type& result, iT1 b1, iT1 e1, iT2 b2, iT2 e2, int op) {
+      //intersect data
+      insert(b1, e1, 0);
+      insert(b2, e2, 1);
+      property_merge_data tmp_pmd;
+      //#define BOOST_POLYGON_DEBUG_FILE
+#ifdef BOOST_POLYGON_DEBUG_FILE
+      std::fstream debug_file;
+      debug_file.open("gtl_debug.txt", std::ios::out);
+      property_merge<Unit, property_type, std::vector<property_type> >::print(debug_file, pmd);
+      debug_file.close();
+#endif
+      line_intersection<Unit>::validate_scan(tmp_pmd, pmd.begin(), pmd.end());
+      pmd.swap(tmp_pmd);
+      sort_property_merge_data();
+      scanline<Unit, property_type, std::vector<property_type> > sl;
+      if(op == BOOLEAN_OR) {
+        boolean_output_functor<result_type, std::vector<property_type>, 0> bof;
+        sl.scan(result, bof, pmd.begin(), pmd.end());
+      } else if(op == BOOLEAN_AND) {
+        boolean_output_functor<result_type, std::vector<property_type>, 1> bof;
+        sl.scan(result, bof, pmd.begin(), pmd.end());
+      } else if(op == BOOLEAN_XOR) {
+        boolean_output_functor<result_type, std::vector<property_type>, 2> bof;
+        sl.scan(result, bof, pmd.begin(), pmd.end());
+      } else if(op == BOOLEAN_NOT) {
+        boolean_output_functor<result_type, std::vector<property_type>, 3> bof;
+        sl.scan(result, bof, pmd.begin(), pmd.end());
+      } 
+    }
+    
+    inline void clear() {*this = arbitrary_boolean_op();}
+
+  private:
+    template <typename iT>
+    void insert(iT b, iT e, int id) {
+      for(; 
+          b != e; ++b) {
+        pmd.push_back(vertex_property(half_edge((*b).first.first, (*b).first.second), 
+                                      std::pair<property_type, int>(id, (*b).second)));
+      }
+    }
+
+  };
+
+  template <typename Unit>
+  bool test_arbitrary_boolean_op() {
+    polygon_set_data<Unit> psd;
+    rectangle_data<Unit> rect;
+    set_points(rect, point_data<Unit>(0, 0), point_data<Unit>(10, 10));
+    psd.insert(rect);
+    polygon_set_data<Unit> psd2;
+    set_points(rect, point_data<Unit>(5, 5), point_data<Unit>(15, 15));
+    psd2.insert(rect);
+    std::vector<polygon_data<Unit> > pv;
+    pv.clear();
+    arbitrary_boolean_op<Unit> abo;
+    polygon_set_data<Unit> psd3;
+    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_OR);
+    psd3.get(pv);
+    for(unsigned int i = 0; i < pv.size(); ++i) {
+      std::cout << pv[i] << std::endl;
+    }
+    pv.clear();
+    abo.clear();
+    psd3.clear();
+    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_AND);
+    psd3.get(pv);
+    for(unsigned int i = 0; i < pv.size(); ++i) {
+      std::cout << pv[i] << std::endl;
+    }
+    pv.clear();
+    abo.clear();
+    psd3.clear();
+    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_XOR);
+    psd3.get(pv);
+    for(unsigned int i = 0; i < pv.size(); ++i) {
+      std::cout << pv[i] << std::endl;
+    }
+    pv.clear();
+    abo.clear();
+    psd3.clear();
+    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_NOT);
+    psd3.get(pv);
+    for(unsigned int i = 0; i < pv.size(); ++i) {
+      std::cout << pv[i] << std::endl;
+    }
+    return true;
+  }
+
+}  
+}
+#endif
+
Added: sandbox/gtl/boost/polygon/detail/transform_detail.hpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/boost/polygon/detail/transform_detail.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,553 @@
+/*
+    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_TRANSFORM_DETAIL_HPP
+#define BOOST_POLYGON_TRANSFORM_DETAIL_HPP
+
+namespace boost { namespace polygon{
+  // inline std::ostream& operator<< (std::ostream& o, const axis_transformation& r) {
+  //   o << r.atr_;
+  //   return o;
+  // }
+
+  // inline std::istream& operator>> (std::istream& i, axis_transformation& r) {
+  //   int tmp;
+  //   i >> tmp;
+  //   r = axis_transformation((axis_transformation::ATR)tmp);
+  //   return i;
+  // }
+
+  // template <typename scale_factor_type>
+  // inline std::ostream& operator<< (std::ostream& o, const anisotropic_scale_factor<scale_factor_type>& sc) {
+  //   o << sc.scale_[0] << BOOST_POLYGON_SEP << sc.scale_[1] << GTL_SEP << sc.scale_[2];
+  //   return o;
+  // }
+
+  // template <typename scale_factor_type>
+  // inline std::istream& operator>> (std::istream& i, anisotropic_scale_factor<scale_factor_type>& sc) {
+  //   i >> sc.scale_[0] >> sc.scale_[1] >> sc.scale_[2];
+  //   return i;
+  // }
+
+  // template <typename coordinate_type>
+  // inline std::ostream& operator<< (std::ostream& o, const transformation& tr) {
+  //   o << tr.atr_ << BOOST_POLYGON_SEP << tr.p_;
+  //   return o;
+  // }
+
+  // template <typename coordinate_type>
+  // inline std::istream& operator>> (std::istream& i, transformation& tr) {
+  //   i >> tr.atr_ >> tr.p_;
+  //   return i;
+  // }
+
+
+  inline axis_transformation::axis_transformation(const orientation_3d& orient) : atr_(NULL_TRANSFORM) {
+    const ATR tmp[3] = {
+      UP_EAST_NORTH, //sort by x, then z, then y
+      EAST_UP_NORTH, //sort by y, then z, then x
+      EAST_NORTH_UP  //sort by z, then y, then x
+    };
+    atr_ = tmp[orient.to_int()];
+  }
+  
+  inline axis_transformation::axis_transformation(const orientation_2d& orient) : atr_(NULL_TRANSFORM) {
+    const ATR tmp[3] = {
+      NORTH_EAST_UP, //sort by z, then x, then y
+      EAST_NORTH_UP  //sort by z, then y, then x
+    };
+    atr_ = tmp[orient.to_int()];
+  }
+  
+  inline axis_transformation::axis_transformation(const direction_3d& dir) : atr_(NULL_TRANSFORM) {
+    const ATR tmp[6] = {
+      DOWN_EAST_NORTH, //sort by -x, then z, then y
+      UP_EAST_NORTH,   //sort by x, then z, then y
+      EAST_DOWN_NORTH, //sort by -y, then z, then x
+      EAST_UP_NORTH,   //sort by y, then z, then x
+      EAST_NORTH_DOWN, //sort by -z, then y, then x
+      EAST_NORTH_UP    //sort by z, then y, then x
+    };
+    atr_ = tmp[dir.to_int()];
+  }
+  
+  inline axis_transformation::axis_transformation(const direction_2d& dir) : atr_(NULL_TRANSFORM) {
+    const ATR tmp[4] = {
+      SOUTH_EAST_UP, //sort by z, then x, then y
+      NORTH_EAST_UP, //sort by z, then x, then y
+      EAST_SOUTH_UP, //sort by z, then y, then x
+      EAST_NORTH_UP  //sort by z, then y, then x
+    };
+    atr_ = tmp[dir.to_int()];
+  }
+  
+  inline axis_transformation& axis_transformation::operator=(const axis_transformation& a) {
+    atr_ = a.atr_;
+    return *this;
+  }
+
+  inline axis_transformation& axis_transformation::operator=(const ATR& atr) {
+    atr_ = atr;
+    return *this;
+  }
+
+  inline bool axis_transformation::operator==(const axis_transformation& a) const {
+    return atr_ == a.atr_;
+  }
+
+  inline bool axis_transformation::operator!=(const axis_transformation& a) const {
+    return !(*this == a);
+  }
+
+  inline bool axis_transformation::operator<(const axis_transformation& a) const {
+    return atr_ < a.atr_;
+  }
+
+  inline axis_transformation& axis_transformation::operator+=(const axis_transformation& a){
+    bool abit5 = a.atr_ & 32;
+    bool abit4 = a.atr_ & 16;
+    bool abit3 = a.atr_ & 8;
+    bool abit2 = a.atr_ & 4;
+    bool abit1 = a.atr_ & 2;
+    bool abit0 = a.atr_ & 1;      
+    bool bit5 = atr_ & 32;
+    bool bit4 = atr_ & 16;
+    bool bit3 = atr_ & 8;
+    bool bit2 = atr_ & 4;
+    bool bit1 = atr_ & 2;
+    bool bit0 = atr_ & 1;      
+    int indexes[2][3] = {
+      {
+        ((int)((bit5 & bit2) | (bit4 & !bit2)) << 1) +
+        (int)(bit2 & !bit5),
+        ((int)((bit4 & bit2) | (bit5 & !bit2)) << 1) +
+        (int)(!bit5 & !bit2),
+        ((int)(!bit4 & !bit5) << 1) +
+        (int)(bit5) 
+      },
+      {
+        ((int)((abit5 & abit2) | (abit4 & !abit2)) << 1) +
+        (int)(abit2 & !abit5),
+        ((int)((abit4 & abit2) | (abit5 & !abit2)) << 1) +
+        (int)(!abit5 & !abit2),
+        ((int)(!abit4 & !abit5) << 1) +
+        (int)(abit5) 
+      }
+    };
+    int zero_bits[2][3] = {
+      {bit0, bit1, bit3},
+      {abit0, abit1, abit3}
+    };
+    int nbit3 = zero_bits[0][2] ^ zero_bits[1][indexes[0][2]];
+    int nbit1 = zero_bits[0][1] ^ zero_bits[1][indexes[0][1]];
+    int nbit0 = zero_bits[0][0] ^ zero_bits[1][indexes[0][0]];
+    indexes[0][0] = indexes[1][indexes[0][0]];
+    indexes[0][1] = indexes[1][indexes[0][1]];
+    indexes[0][2] = indexes[1][indexes[0][2]];
+    int nbit5 = (indexes[0][2] == 1);
+    int nbit4 = (indexes[0][2] == 0);
+    int nbit2 = (!(nbit5 | nbit4) & (bool)(indexes[0][0] & 1)) | //swap xy
+      (nbit5 & ((indexes[0][0] & 2) >> 1)) | //z->y x->z
+      (nbit4 & ((indexes[0][1] & 2) >> 1));  //z->x y->z
+    atr_ = (ATR)((nbit5 << 5) + 
+                 (nbit4 << 4) + 
+                 (nbit3 << 3) + 
+                 (nbit2 << 2) + 
+                 (nbit1 << 1) + nbit0);
+    return *this;
+  }
+  
+  inline axis_transformation axis_transformation::operator+(const axis_transformation& a) const {
+    axis_transformation retval(*this);
+    return retval+=a;
+  }
+  
+  // populate_axis_array writes the three INDIVIDUAL_AXIS values that the
+  // ATR enum value of 'this' represent into axis_array
+  inline void axis_transformation::populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const {
+    bool bit5 = atr_ & 32;
+    bool bit4 = atr_ & 16;
+    bool bit3 = atr_ & 8;
+    bool bit2 = atr_ & 4;
+    bool bit1 = atr_ & 2;
+    bool bit0 = atr_ & 1;      
+    axis_array[2] = 
+      (INDIVIDUAL_AXIS)((((int)(!bit4 & !bit5)) << 2) +
+                        ((int)(bit5) << 1) + 
+                        bit3);
+    axis_array[1] = 
+      (INDIVIDUAL_AXIS)((((int)((bit4 & bit2) | (bit5 & !bit2))) << 2)+
+                        ((int)(!bit5 & !bit2) << 1) + 
+                        bit1);
+    axis_array[0] = 
+      (INDIVIDUAL_AXIS)((((int)((bit5 & bit2) | (bit4 & !bit2))) << 2) +
+                        ((int)(bit2 & !bit5) << 1) + 
+                        bit0);
+  }
+  
+  // combine_axis_arrays concatenates this_array and that_array overwriting
+  // the result into this_array
+  inline void 
+  axis_transformation::combine_axis_arrays (INDIVIDUAL_AXIS this_array[],
+                                            const INDIVIDUAL_AXIS that_array[]){
+    int indexes[3] = {this_array[0] >> 1,
+                      this_array[1] >> 1,
+                      this_array[2] >> 1};
+    int zero_bits[2][3] = {
+      {this_array[0] & 1, this_array[1] & 1, this_array[2] & 1},
+      {that_array[0] & 1, that_array[1] & 1, that_array[2] & 1}
+    };
+    this_array[0] = that_array[indexes[0]];
+    this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] & (int)((int)PZ+(int)PY));
+    this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] | 
+                                      ((int)zero_bits[0][0] ^ 
+                                       (int)zero_bits[1][indexes[0]]));
+    this_array[1] = that_array[indexes[1]];
+    this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] & (int)((int)PZ+(int)PY));
+    this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] | 
+                                      ((int)zero_bits[0][1] ^ 
+                                       (int)zero_bits[1][indexes[1]]));
+    this_array[2] = that_array[indexes[2]];
+    this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] & (int)((int)PZ+(int)PY));
+    this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] | 
+                                      ((int)zero_bits[0][2] ^ 
+                                       (int)zero_bits[1][indexes[2]]));
+  }
+  
+  // write_back_axis_array converts an array of three INDIVIDUAL_AXIS values
+  // to the ATR enum value and sets 'this' to that value
+  inline void axis_transformation::write_back_axis_array(const INDIVIDUAL_AXIS this_array[]) {
+    int bit5 = (bool)((int)this_array[2] & 2);
+    int bit4 = !((bool)((int)this_array[2] & 4) | (bool)((int)this_array[2] & 2));
+    int bit3 = (bool)((int)this_array[2] & 1);
+    //bit 2 is the tricky bit
+    int bit2 = (!(bit5 | bit4) & (bool)((int)this_array[0] & 2)) | //swap xy
+      (bit5 & (((int)this_array[0] & 4) >> 2)) | //z->y x->z
+      (bit4 & (((int)this_array[1] & 4) >> 2));  //z->x y->z
+    int bit1 = ((int)this_array[1] & 1);
+    int bit0 = ((int)this_array[0] & 1);
+    atr_ = ATR((bit5 << 5) + 
+               (bit4 << 4) + 
+               (bit3 << 3) + 
+               (bit2 << 2) + 
+               (bit1 << 1) + bit0);
+  }
+  
+  // behavior is deterministic but undefined in the case where illegal
+  // combinations of directions are passed in. 
+  inline axis_transformation& 
+  axis_transformation::set_directions(const direction_2d& horizontalDir,
+                                      const direction_2d& verticalDir){
+    int bit2 = bool(static_cast<orientation_2d>(horizontalDir).to_int());
+    int bit1 = !(verticalDir.to_int() & 1);
+    int bit0 = !(horizontalDir.to_int() & 1);
+    atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
+    return *this;
+  }
+  
+  // behavior is deterministic but undefined in the case where illegal
+  // combinations of directions are passed in.
+  inline axis_transformation& axis_transformation::set_directions(const direction_3d& horizontalDir,
+                                                                  const direction_3d& verticalDir,
+                                                                  const direction_3d& proximalDir){
+    int this_array[3] = {horizontalDir.to_int(),
+                         verticalDir.to_int(),
+                         proximalDir.to_int()};
+    int bit5 = (bool)(this_array[2] & 2);
+    int bit4 = !((bool)(this_array[2] & 4) | (bool)(this_array[2] & 2));
+    int bit3 = !(bool)(this_array[2] & 1);
+    //bit 2 is the tricky bit
+    int bit2 = (!(bit5 | bit4) & (bool)(this_array[0] & 2)) | //swap xy
+      (bit5 & ((this_array[0] & 4) >> 2)) | //z->y x->z
+      (bit4 & ((this_array[1] & 4) >> 2));  //z->x y->z
+    int bit1 = !(this_array[1] & 1);
+    int bit0 = !(this_array[0] & 1);
+    atr_ = ATR((bit5 << 5) + 
+               (bit4 << 4) + 
+               (bit3 << 3) + 
+               (bit2 << 2) + 
+               (bit1 << 1) + bit0);
+    return *this;
+  }
+  
+  template <typename coordinate_type_2>
+  inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y) const {
+    int bit2 = (bool)(atr_ & 4);
+    int bit1 = (bool)(atr_ & 2);
+    int bit0 = (bool)(atr_ & 1);
+    x *= -((bit0 << 1) - 1);
+    y *= -((bit1 << 1) - 1);    
+    predicated_swap(bit2,x,y);
+  }
+  
+  template <typename coordinate_type_2>
+  inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
+    int bit5 = (bool)(atr_ & 32);
+    int bit4 = (bool)(atr_ & 16);
+    int bit3 = (bool)(atr_ & 8);
+    int bit2 = (bool)(atr_ & 4);
+    int bit1 = (bool)(atr_ & 2);
+    int bit0 = (bool)(atr_ & 1);
+    x *= -((bit0 << 1) - 1);
+    y *= -((bit1 << 1) - 1);    
+    z *= -((bit3 << 1) - 1);
+    predicated_swap(bit2, x, y);
+    predicated_swap(bit5, y, z);
+    predicated_swap(bit4, x, z);
+  }
+  
+  inline axis_transformation& axis_transformation::invert_2d() {
+    int bit2 = (bool)(atr_ & 4);
+    int bit1 = (bool)(atr_ & 2);
+    int bit0 = (bool)(atr_ & 1);
+    //swap bit 0 and bit 1 if bit2 is 1
+    predicated_swap(bit2, bit0, bit1);
+    bit1 = bit1 << 1;
+    atr_ = (ATR)(atr_ & (32+16+8+4)); //mask away bit0 and bit1
+    atr_ = (ATR)(atr_ | bit0 | bit1);
+    return *this;
+  }
+  
+  inline axis_transformation axis_transformation::inverse_2d() const {
+    axis_transformation retval(*this);
+    return retval.invert_2d();
+  }
+  
+  inline axis_transformation& axis_transformation::invert() {
+    int bit5 = (bool)(atr_ & 32);
+    int bit4 = (bool)(atr_ & 16);    
+    int bit3 = (bool)(atr_ & 8);
+    int bit2 = (bool)(atr_ & 4);
+    int bit1 = (bool)(atr_ & 2);
+    int bit0 = (bool)(atr_ & 1);
+    predicated_swap(bit2, bit4, bit5);
+    predicated_swap(bit4, bit0, bit3);
+    predicated_swap(bit5, bit1, bit3);
+    predicated_swap(bit2, bit0, bit1);
+    atr_ = (ATR)((bit5 << 5) + 
+                 (bit4 << 4) + 
+                 (bit3 << 3) + 
+                 (bit2 << 2) + 
+                 (bit1 << 1) + bit0);
+    return *this;
+  }
+  
+  inline axis_transformation axis_transformation::inverse() const {
+    axis_transformation retval(*this);
+    return retval.invert();
+  }
+  
+  template <typename scale_factor_type>
+  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::get(orientation_3d orient) const {
+    return scale_[orient.to_int()];
+  }
+  
+  template <typename scale_factor_type>
+  inline void anisotropic_scale_factor<scale_factor_type>::set(orientation_3d orient, scale_factor_type value) {
+    scale_[orient.to_int()] = value;
+  }
+
+  template <typename scale_factor_type>
+  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::x() const { return scale_[HORIZONTAL]; }
+  template <typename scale_factor_type>
+  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::y() const { return scale_[VERTICAL]; }
+  template <typename scale_factor_type>
+  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::z() const { return scale_[PROXIMAL]; }
+  template <typename scale_factor_type>
+  inline void anisotropic_scale_factor<scale_factor_type>::x(scale_factor_type value) { scale_[HORIZONTAL] = value; }
+  template <typename scale_factor_type>
+  inline void anisotropic_scale_factor<scale_factor_type>::y(scale_factor_type value) { scale_[VERTICAL] = value; }
+  template <typename scale_factor_type>
+  inline void anisotropic_scale_factor<scale_factor_type>::z(scale_factor_type value) { scale_[PROXIMAL] = value; }
+  
+  //concatenation operator (convolve scale factors)
+  template <typename scale_factor_type>
+  inline anisotropic_scale_factor<scale_factor_type> anisotropic_scale_factor<scale_factor_type>::operator+(const anisotropic_scale_factor<scale_factor_type>& s) const {
+    anisotropic_scale_factor<scale_factor_type> retval(*this);
+    return retval+=s;
+  }
+  
+  //concatenate this with that
+  template <typename scale_factor_type>
+  inline const anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::operator+=(const anisotropic_scale_factor<scale_factor_type>& s){
+    scale_[0] *= s.scale_[0];
+    scale_[1] *= s.scale_[1];
+    scale_[2] *= s.scale_[2];
+    return *this;
+  }
+  
+  //transform
+  template <typename scale_factor_type>
+  inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::transform(axis_transformation atr){
+    direction_3d dirs[3];
+    atr.get_directions(dirs[0],dirs[1],dirs[2]);
+    scale_factor_type tmp[3] = {scale_[0], scale_[1], scale_[2]};
+    for(int i = 0; i < 3; ++i){
+      scale_[orientation_3d(dirs[i]).to_int()] = tmp[i];
+    }
+    return *this;
+  }
+
+  template <typename scale_factor_type>
+  template <typename coordinate_type_2>
+  inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y) const {
+    x = scaling_policy<coordinate_type_2>::round((scale_factor_type)x * get(HORIZONTAL));
+    y = scaling_policy<coordinate_type_2>::round((scale_factor_type)y * get(HORIZONTAL));
+  }
+
+  template <typename scale_factor_type>
+  template <typename coordinate_type_2>
+  inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
+    scale(x, y);
+    z = scaling_policy<coordinate_type_2>::round((scale_factor_type)z * get(HORIZONTAL));
+  }
+
+  template <typename scale_factor_type>
+  inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::invert() {
+    x(1/x());
+    y(1/y());
+    z(1/z());
+    return *this;
+  }
+
+
+  template <typename coordinate_type>
+  inline transformation<coordinate_type>::transformation() : atr_(), p_(0, 0, 0) {;}
+
+  template <typename coordinate_type>
+  inline transformation<coordinate_type>::transformation(axis_transformation atr) : atr_(atr), p_(0, 0, 0){;}
+
+  template <typename coordinate_type>
+  inline transformation<coordinate_type>::transformation(axis_transformation::ATR atr) : atr_(atr), p_(0, 0, 0){;}
+
+  template <typename coordinate_type>
+  template <typename point_type>
+  inline transformation<coordinate_type>::transformation(const point_type& p) : atr_(), p_(0, 0, 0) {
+    set_translation(p);
+  }
+
+  template <typename coordinate_type>
+  template <typename point_type>
+  inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& p) :
+    atr_(atr), p_(0, 0, 0) {
+    set_translation(p);
+  }
+
+  template <typename coordinate_type>
+  template <typename point_type>
+  inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& referencePt, const point_type& destinationPt) : atr_(), p_(0, 0, 0) {
+    transformation<coordinate_type> tmp(referencePt);
+    transformation<coordinate_type> rotRef(atr);
+    transformation<coordinate_type> tmpInverse = tmp.inverse();
+    point_type decon(referencePt);
+    deconvolve(decon, destinationPt);
+    transformation<coordinate_type> displacement(decon);
+    tmp += rotRef;
+    tmp += tmpInverse;
+    tmp += displacement;
+    (*this) = tmp;
+  }
+
+  template <typename coordinate_type>
+  inline transformation<coordinate_type>::transformation(const transformation<coordinate_type>& tr) : 
+    atr_(tr.atr_), p_(tr.p_) {;}
+  
+  template <typename coordinate_type>
+  inline bool transformation<coordinate_type>::operator==(const transformation<coordinate_type>& tr) const {
+    return atr_ == tr.atr_ && p_ == tr.p_;
+  }
+  
+  template <typename coordinate_type>
+  inline bool transformation<coordinate_type>::operator!=(const transformation<coordinate_type>& tr) const {
+    return !(*this == tr);
+  }
+  
+  template <typename coordinate_type>
+  inline bool transformation<coordinate_type>::operator<(const transformation<coordinate_type>& tr) const {
+    return atr_ < tr.atr_ || atr_ == tr.atr_ && p_ < tr.p_;
+  }
+  
+  template <typename coordinate_type>
+  inline transformation<coordinate_type> transformation<coordinate_type>::operator+(const transformation<coordinate_type>& tr) const {
+    transformation<coordinate_type> retval(*this);
+    return retval+=tr;
+  }
+  
+  template <typename coordinate_type>
+  inline const transformation<coordinate_type>& transformation<coordinate_type>::operator+=(const transformation<coordinate_type>& tr){
+    //apply the inverse transformation of this to the translation point of that
+    //and convolve it with this translation point
+    coordinate_type x, y, z;
+    transformation<coordinate_type> inv = inverse();
+    inv.transform(x, y, z);
+    p_.set(HORIZONTAL, p_.get(HORIZONTAL) + x);
+    p_.set(VERTICAL, p_.get(VERTICAL) + y);
+    p_.set(PROXIMAL, p_.get(PROXIMAL) + z);
+    //concatenate axis transforms
+    atr_ += tr.atr_;
+    return *this;
+  }
+  
+  template <typename coordinate_type>
+  inline void transformation<coordinate_type>::set_axis_transformation(const axis_transformation& atr) {
+    atr_ = atr;
+  }
+  
+  template <typename coordinate_type>
+  template <typename point_type>
+  inline void transformation<coordinate_type>::get_translation(point_type& p) const {
+    assign(p, p_);
+  }
+  
+  template <typename coordinate_type>
+  template <typename point_type>
+  inline void transformation<coordinate_type>::set_translation(const point_type& p) {
+    assign(p_, p);
+  }
+  
+  template <typename coordinate_type>
+  inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y) const {
+    //subtract each component of new origin point
+    y -= p_.get(VERTICAL);
+    x -= p_.get(HORIZONTAL);
+    atr_.transform(x, y);
+  }
+
+  template <typename coordinate_type>
+  inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const {
+    //subtract each component of new origin point
+    z -= p_.get(PROXIMAL);
+    y -= p_.get(VERTICAL);
+    x -= p_.get(HORIZONTAL);
+    atr_.transform(x,y,z);
+  }
+  
+  // sets the axis_transform portion to its inverse
+  // transforms the tranlastion portion by that inverse axis_transform
+  // multiplies the translation portion by -1 to reverse it
+  template <typename coordinate_type>
+  inline transformation<coordinate_type>& transformation<coordinate_type>::invert() {
+    coordinate_type x = p_.get(HORIZONTAL), y = p_.get(VERTICAL), z = p_.get(PROXIMAL);
+    atr_.transform(x, y, z);
+    x *= -1;
+    y *= -1;
+    z *= -1;
+    p_ = point_3d_data<coordinate_type>(x, y, z);
+    atr_.invert();
+    return *this;
+  }
+  
+  template <typename coordinate_type>
+  inline transformation<coordinate_type> transformation<coordinate_type>::inverse() const {
+    transformation<coordinate_type> retval(*this);
+    return retval.invert();
+  }
+}
+}
+#endif
+
+
Modified: sandbox/gtl/boost/polygon/gmp_override.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/gmp_override.hpp	(original)
+++ sandbox/gtl/boost/polygon/gmp_override.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_RECTANGLE_CONCEPT_HPP
-#define GTL_RECTANGLE_CONCEPT_HPP
+#ifndef BOOST_POLYGON_GMP_OVERRIDE_HPP
+#define BOOST_POLYGON_GMP_OVERRIDE_HPP
 #include <gmpxx.h>
 namespace boost { namespace polygon {
 
Modified: sandbox/gtl/boost/polygon/gtl_boost_unit_test.cpp
==============================================================================
--- sandbox/gtl/boost/polygon/gtl_boost_unit_test.cpp	(original)
+++ sandbox/gtl/boost/polygon/gtl_boost_unit_test.cpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -13,6 +13,83 @@
 #include <stdlib.h>
 
 namespace boost { namespace polygon{
+
+  void test_assign() {
+    using namespace gtl;
+    std::vector<polygon_data<int> > ps;
+    polygon_90_set_data<int> ps90;
+    assign(ps, ps90);
+  }
+
+  //this is a compile time test, if it compiles it passes
+  void test_view_as() {
+    using namespace gtl;
+    polygon_data<int> p;
+    polygon_45_data<int> p45;
+    polygon_90_data<int> p90;
+    polygon_with_holes_data<int> pwh;
+    polygon_45_with_holes_data<int> p45wh;
+    polygon_90_with_holes_data<int> p90wh;
+    rectangle_data<int> rect(0, 1, 10, 11);
+    polygon_90_set_data<int> ps90;
+    polygon_45_set_data<int> ps45;
+    polygon_set_data<int> ps;
+  
+    assign(p, rect);
+    assign(p90, view_as<polygon_90_concept>(p));
+    if(!equivalence(p90, rect))
+      std::cout << "fail 1\n";
+    assign(p45, view_as<polygon_45_concept>(p));
+    if(!equivalence(p45, rect))
+      std::cout << "fail 2\n";
+    assign(p90, view_as<polygon_90_concept>(p45));
+    if(!equivalence(p90, rect))
+      std::cout << "fail 3\n";
+    if(!equivalence(rect, view_as<rectangle_concept>(p)))
+      std::cout << "fail 4\n";
+    if(!equivalence(rect, view_as<rectangle_concept>(p45)))
+      std::cout << "fail 5\n";
+    if(!equivalence(rect, view_as<rectangle_concept>(p90)))
+      std::cout << "fail 6\n";
+    assign(pwh, rect);
+    assign(p90wh, rect);
+    assign(p45wh, rect);
+    if(!equivalence(rect, view_as<rectangle_concept>(pwh)))
+      std::cout << "fail 7\n";
+    if(!equivalence(rect, view_as<rectangle_concept>(p45wh)))
+      std::cout << "fail 8\n";
+    if(!equivalence(rect, view_as<rectangle_concept>(p90wh)))
+      std::cout << "fail 9\n";
+    assign(p90wh, view_as<polygon_90_with_holes_concept>(pwh));
+    if(!equivalence(p90wh, rect))
+      std::cout << "fail 10\n";
+    assign(p45wh, view_as<polygon_45_with_holes_concept>(pwh));
+    if(!equivalence(p45wh, rect))
+      std::cout << "fail 11\n";
+    assign(p90wh, view_as<polygon_90_with_holes_concept>(p45wh));
+    if(!equivalence(p90wh, rect))
+      std::cout << "fail 12\n"; 
+    assign(p90, view_as<polygon_90_concept>(pwh));
+    if(!equivalence(p90, rect))
+      std::cout << "fail 13\n";
+    assign(p45, view_as<polygon_45_concept>(pwh));
+    if(!equivalence(p45, rect))
+      std::cout << "fail 14\n";
+    assign(p90, view_as<polygon_90_concept>(p45wh));
+    if(!equivalence(p90, rect))
+      std::cout << "fail 15\n";
+    assign(ps, rect);
+    assign(ps90, view_as<polygon_90_set_concept>(ps));
+    if(!equivalence(ps90, rect))
+      std::cout << "fail 16\n";
+    assign(ps45, view_as<polygon_45_set_concept>(ps));
+    if(!equivalence(ps45, rect))
+      std::cout << "fail 17\n";
+    assign(ps90, view_as<polygon_90_set_concept>(ps45));
+    if(!equivalence(ps90, rect))
+      std::cout << "fail 18\n";
+  }
+
   inline bool testPolygon45SetRect() {
     std::vector<point_data<int> > points;
     points.push_back(point_data<int>(0,0));
@@ -1568,84 +1645,84 @@
   }
 }
 
-namespace boost { namespace polygon{
-  template <typename GCT, typename T>
-  struct view_of {};
-
-  template <typename T>
-  struct view_of<polygon_45_concept, T> {
-    const T* t;
-    view_of(const T& obj) : t(&obj) {}
-    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
-    typedef typename polygon_traits<T>::iterator_type iterator_type;
-    typedef typename polygon_traits<T>::point_type point_type;
-
-    /// Get the begin iterator
-    inline iterator_type begin() const {
-      return polygon_traits<T>::begin_points(*t);
-    }
+// namespace boost { namespace polygon{
+//   template <typename GCT, typename T>
+//   struct view_of {};
+
+//   template <typename T>
+//   struct view_of<polygon_45_concept, T> {
+//     const T* t;
+//     view_of(const T& obj) : t(&obj) {}
+//     typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+//     typedef typename polygon_traits<T>::iterator_type iterator_type;
+//     typedef typename polygon_traits<T>::point_type point_type;
+
+//     /// Get the begin iterator
+//     inline iterator_type begin() const {
+//       return polygon_traits<T>::begin_points(*t);
+//     }
   
-    /// Get the end iterator
-    inline iterator_type end() const {
-      return polygon_traits<T>::end_points(*t);
-    }
+//     /// Get the end iterator
+//     inline iterator_type end() const {
+//       return polygon_traits<T>::end_points(*t);
+//     }
   
-    /// Get the number of sides of the polygon
-    inline unsigned int size() const {
-      return polygon_traits<T>::size(*t);
-    }
+//     /// Get the number of sides of the polygon
+//     inline unsigned int size() const {
+//       return polygon_traits<T>::size(*t);
+//     }
   
-    /// Get the winding direction of the polygon
-    inline winding_direction winding() const {
-      return polygon_traits<T>::winding(*t);
-    }
-  };
+//     /// Get the winding direction of the polygon
+//     inline winding_direction winding() const {
+//       return polygon_traits<T>::winding(*t);
+//     }
+//   };
   
-  template <typename T1, typename T2>
-  view_of<T1, T2> view_as(const T2& obj) { return view_of<T1, T2>(obj); }
+//   template <typename T1, typename T2>
+//   view_of<T1, T2> view_as(const T2& obj) { return view_of<T1, T2>(obj); }
 
-  template <typename T>
-  struct geometry_concept<view_of<polygon_45_concept, T> > {
-    typedef polygon_45_concept type;
-  };
-
-  template <typename T>
-  struct view_of<polygon_90_concept, T> {
-    const T* t;
-    view_of(const T& obj) : t(&obj) {}
-    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
-    typedef typename polygon_traits<T>::iterator_type iterator_type;
-    typedef typename polygon_traits<T>::point_type point_type;
-    typedef iterator_points_to_compact<iterator_type, point_type> compact_iterator_type;
-
-    /// Get the begin iterator
-    inline compact_iterator_type begin_compact() const {
-      return compact_iterator_type(polygon_traits<T>::begin_points(*t),
-                                   polygon_traits<T>::end_points(*t));
-    }
+//   template <typename T>
+//   struct geometry_concept<view_of<polygon_45_concept, T> > {
+//     typedef polygon_45_concept type;
+//   };
+
+//   template <typename T>
+//   struct view_of<polygon_90_concept, T> {
+//     const T* t;
+//     view_of(const T& obj) : t(&obj) {}
+//     typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+//     typedef typename polygon_traits<T>::iterator_type iterator_type;
+//     typedef typename polygon_traits<T>::point_type point_type;
+//     typedef iterator_points_to_compact<iterator_type, point_type> compact_iterator_type;
+
+//     /// Get the begin iterator
+//     inline compact_iterator_type begin_compact() const {
+//       return compact_iterator_type(polygon_traits<T>::begin_points(*t),
+//                                    polygon_traits<T>::end_points(*t));
+//     }
   
-    /// Get the end iterator
-    inline compact_iterator_type end_compact() const {
-      return compact_iterator_type(polygon_traits<T>::end_points(*t),
-                                   polygon_traits<T>::end_points(*t));
-    }
+//     /// Get the end iterator
+//     inline compact_iterator_type end_compact() const {
+//       return compact_iterator_type(polygon_traits<T>::end_points(*t),
+//                                    polygon_traits<T>::end_points(*t));
+//     }
   
-    /// Get the number of sides of the polygon
-    inline unsigned int size() const {
-      return polygon_traits<T>::size(*t);
-    }
+//     /// Get the number of sides of the polygon
+//     inline unsigned int size() const {
+//       return polygon_traits<T>::size(*t);
+//     }
   
-    /// Get the winding direction of the polygon
-    inline winding_direction winding() const {
-      return polygon_traits<T>::winding(*t);
-    }
-  };
-
-  template <typename T>
-  struct geometry_concept<view_of<polygon_90_concept, T> > {
-    typedef polygon_90_concept type;
-  };
-}}
+//     /// Get the winding direction of the polygon
+//     inline winding_direction winding() const {
+//       return polygon_traits<T>::winding(*t);
+//     }
+//   };
+
+//   template <typename T>
+//   struct geometry_concept<view_of<polygon_90_concept, T> > {
+//     typedef polygon_90_concept type;
+//   };
+// }}
 using namespace gtl;
 
 //this test fails and I'd like to get it to pass
@@ -1712,6 +1789,7 @@
 }
 
 int main() {
+  test_view_as();
   //this test fails and I'd like to get it to pass
   //if(!test_colinear_duplicate_points()) return 1;
   if(!test_extents2()) return 1;
Modified: sandbox/gtl/boost/polygon/interval_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/interval_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/interval_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_INTERVAL_CONCEPT_HPP
-#define GTL_INTERVAL_CONCEPT_HPP
+#ifndef BOOST_POLYGON_INTERVAL_CONCEPT_HPP
+#define BOOST_POLYGON_INTERVAL_CONCEPT_HPP
 #include "isotropy.hpp"
 #include "interval_data.hpp"
 #include "interval_traits.hpp"
Modified: sandbox/gtl/boost/polygon/interval_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/interval_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/interval_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_INTERVAL_DATA_HPP
-#define GTL_INTERVAL_DATA_HPP
+#ifndef BOOST_POLYGON_INTERVAL_DATA_HPP
+#define BOOST_POLYGON_INTERVAL_DATA_HPP
 #include "isotropy.hpp"
 namespace boost { namespace polygon{
   template <typename T>
Modified: sandbox/gtl/boost/polygon/interval_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/interval_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/interval_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_INTERVAL_TRAITS_HPP
-#define GTL_INTERVAL_TRAITS_HPP
+#ifndef BOOST_POLYGON_INTERVAL_TRAITS_HPP
+#define BOOST_POLYGON_INTERVAL_TRAITS_HPP
 namespace boost { namespace polygon{
   template <typename T>
   struct interval_traits {
Modified: sandbox/gtl/boost/polygon/isotropy.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/isotropy.hpp	(original)
+++ sandbox/gtl/boost/polygon/isotropy.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -6,14 +6,32 @@
   http://www.boost.org/LICENSE_1_0.txt).
 */
 
-#ifndef GTL_ISOTROPY_HPP
-#define GTL_ISOTROPY_HPP
+#ifndef BOOST_POLYGON_ISOTROPY_HPP
+#define BOOST_POLYGON_ISOTROPY_HPP
 
 #ifndef BOOST_POLYGON_NO_DEPS
+
+#include <boost/config.hpp> 
+#ifdef BOOST_MSVC
+#define BOOST_POLYGON_WIN32
+#endif
+#ifdef BOOST_INTEL
+#define BOOST_POLYGON_ICC
+#endif
+#ifdef BOOST_HAS_LONG_LONG
+#define BOOST_POLYGON_USE_LONG_LONG
+#endif
 #include <boost/utility/enable_if.hpp>
 
 #else
 
+#ifdef WIN32
+#define BOOST_POLYGON_WIN32
+#endif
+#ifdef __ICC
+#define BOOST_POLYGON_ICC
+#endif
+#define BOOST_POLYGON_USE_LONG_LONG
   namespace boost { 
     template <bool B, class T   = void>
     struct enable_if_c {
@@ -87,6 +105,12 @@
   template <typename T>
   struct geometry_concept { typedef undefined_concept type; }; 
 
+  template <typename GCT, typename T>
+  struct view_of {};
+
+  template <typename T1, typename T2>
+  view_of<T1, T2> view_as(const T2& obj) { return view_of<T1, T2>(obj); }  
+
   template <typename T>
   struct coordinate_traits {};
 
@@ -99,12 +123,19 @@
   struct coordinate_traits<int> {
     typedef int coordinate_type;
     typedef long double area_type;
+#ifdef BOOST_POLYGON_USE_LONG_LONG
     typedef long long manhattan_area_type;
     typedef unsigned long long unsigned_area_type;
     typedef long long coordinate_difference;
+#else
+    typedef long manhattan_area_type;
+    typedef unsigned long unsigned_area_type;
+    typedef long coordinate_difference;
+#endif
     typedef long double coordinate_distance;
   };
 
+#ifdef BOOST_POLYGON_USE_LONG_LONG
   template <>
   struct coordinate_traits<long long> {
     typedef long long coordinate_type;
@@ -114,6 +145,7 @@
     typedef long long coordinate_difference;
     typedef long double coordinate_distance;
   };
+#endif
 
   template <>
   struct coordinate_traits<float> {
Deleted: sandbox/gtl/boost/polygon/iterator_compact_to_points.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/iterator_compact_to_points.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,69 +0,0 @@
-/*
-  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 GTL_ITERATOR_COMPACT_TO_POINTS_HPP
-#define GTL_ITERATOR_COMPACT_TO_POINTS_HPP
-namespace boost { namespace polygon{
-template <typename iterator_type, typename point_type>
-class iterator_compact_to_points {
-private:
-  iterator_type iter_;
-  iterator_type iter_end_;
-  point_type pt_;
-  typename point_traits<point_type>::coordinate_type firstX_;
-  orientation_2d orient_;
-public:
-  typedef std::forward_iterator_tag iterator_category;
-  typedef point_type value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef const point_type* pointer; //immutable
-  typedef const point_type& reference; //immutable
-
-  inline iterator_compact_to_points() : iter_(), iter_end_(), pt_(), firstX_(), orient_() {}
-  inline iterator_compact_to_points(iterator_type iter, iterator_type iter_end) : 
-    iter_(iter), iter_end_(iter_end), pt_(), firstX_(), orient_(HORIZONTAL) {
-    if(iter_ != iter_end_) {
-      firstX_ = *iter_;
-      x(pt_, firstX_);
-      ++iter_;
-      if(iter_ != iter_end_) {
-        y(pt_, *iter_);
-      }
-    }
-  }
-  //use bitwise copy and assign provided by the compiler
-  inline iterator_compact_to_points& operator++() {
-    iterator_type prev_iter = iter_;
-    ++iter_;
-    if(iter_ == iter_end_) {
-      if(x(pt_) != firstX_) {
-        iter_ = prev_iter;
-        x(pt_, firstX_);
-      }
-    } else {
-      set(pt_, orient_, *iter_);
-      orient_.turn_90();
-    }
-    return *this;
-  }
-  inline const iterator_compact_to_points operator++(int) {
-    iterator_compact_to_points tmp(*this);
-    ++(*this);
-    return tmp;
-  }
-  inline bool operator==(const iterator_compact_to_points& that) const {
-    return (iter_ == that.iter_);
-  }
-  inline bool operator!=(const iterator_compact_to_points& that) const {
-    return (iter_ != that.iter_);
-  }
-  inline reference operator*() const { return pt_; }
-};
-}
-}
-#endif
-
Deleted: sandbox/gtl/boost/polygon/iterator_geometry_to_set.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/iterator_geometry_to_set.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,309 +0,0 @@
-/*
-  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 GTL_ITERATOR_GEOMETRY_TO_SET_HPP
-#define GTL_ITERATOR_GEOMETRY_TO_SET_HPP
-namespace boost { namespace polygon{
-template <typename concept_type, typename geometry_type>
-class iterator_geometry_to_set {};
-
-template <typename rectangle_type>
-class iterator_geometry_to_set<rectangle_concept, rectangle_type> {
-public:
-  typedef typename rectangle_traits<rectangle_type>::coordinate_type coordinate_type;
-  typedef std::forward_iterator_tag iterator_category;
-  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef const value_type* pointer; //immutable
-  typedef const value_type& reference; //immutable
-private:
-  rectangle_data<coordinate_type> rectangle_;
-  mutable value_type vertex_;
-  unsigned int corner_;
-  orientation_2d orient_;
-  bool is_hole_;
-public:
-  iterator_geometry_to_set() : rectangle_(), vertex_(), corner_(4), orient_(), is_hole_() {}
-  iterator_geometry_to_set(const rectangle_type& rectangle, direction_1d dir, 
-                           orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
-    rectangle_(), vertex_(), corner_(0), orient_(orient), is_hole_(is_hole) {
-    assign(rectangle_, rectangle);
-    if(dir == HIGH) corner_ = 4;
-  }
-  inline iterator_geometry_to_set& operator++() {
-    ++corner_;
-    return *this;
-  }
-  inline const iterator_geometry_to_set operator++(int) {
-    iterator_geometry_to_set tmp(*this);
-    ++(*this);
-    return tmp;
-  }
-  inline bool operator==(const iterator_geometry_to_set& that) const {
-    return corner_ == that.corner_;
-  }
-  inline bool operator!=(const iterator_geometry_to_set& that) const {
-    return !(*this == that);
-  }
-  inline reference operator*() const {
-    if(corner_ == 0) {
-      vertex_.first = get(get(rectangle_, orient_.get_perpendicular()), LOW);
-      vertex_.second.first = get(get(rectangle_, orient_), LOW);
-      vertex_.second.second = 1;
-      if(is_hole_) vertex_.second.second *= -1;
-    } else if(corner_ == 1) {
-      vertex_.second.first = get(get(rectangle_, orient_), HIGH);
-      vertex_.second.second = -1;
-      if(is_hole_) vertex_.second.second *= -1;
-    } else if(corner_ == 2) {
-      vertex_.first = get(get(rectangle_, orient_.get_perpendicular()), HIGH);
-      vertex_.second.first = get(get(rectangle_, orient_), LOW);
-    } else {
-      vertex_.second.first = get(get(rectangle_, orient_), HIGH);
-      vertex_.second.second = 1;
-      if(is_hole_) vertex_.second.second *= -1;
-    }
-    return vertex_; 
-  }
-};
-
-template <typename polygon_type>
-class iterator_geometry_to_set<polygon_90_concept, polygon_type> {
-public:
-  typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
-  typedef std::forward_iterator_tag iterator_category;
-  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef const value_type* pointer; //immutable
-  typedef const value_type& reference; //immutable
-  typedef typename polygon_traits<polygon_type>::iterator_type coord_iterator_type;
-private:
-  value_type vertex_;
-  typename polygon_traits<polygon_type>::iterator_type itrb, itre;
-  bool last_vertex_;
-  bool is_hole_;
-  int multiplier_;
-  point_data<coordinate_type> first_pt, second_pt, pts[3];
-  bool use_wrap;
-  orientation_2d orient_;
-  int polygon_index;
-public:
-  iterator_geometry_to_set() : vertex_(), itrb(), itre(), last_vertex_(), is_hole_(), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(), orient_(), polygon_index(-1) {}
-  iterator_geometry_to_set(const polygon_type& polygon, direction_1d dir, orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
-    vertex_(), itrb(), itre(), last_vertex_(), 
-    is_hole_(is_hole), multiplier_(), first_pt(), second_pt(), pts(), use_wrap(), 
-    orient_(orient), polygon_index(0) {
-    itrb = begin_points(polygon);
-    itre = end_points(polygon);
-    use_wrap = false;
-    if(itrb == itre || dir == HIGH || size(polygon) < 4) {
-      polygon_index = -1;
-    } else {
-      direction_1d wdir = winding(polygon);
-      multiplier_ = wdir == LOW ? -1 : 1;
-      if(is_hole_) multiplier_ *= -1;
-      first_pt = pts[0] = *itrb;
-      ++itrb;
-      second_pt = pts[1] = *itrb;
-      ++itrb;
-      pts[2] = *itrb;
-      evaluate_();
-    }
-  }
-  iterator_geometry_to_set(const iterator_geometry_to_set& that) : 
-    vertex_(), itrb(), itre(), last_vertex_(), is_hole_(), multiplier_(), first_pt(),
-    second_pt(), pts(), use_wrap(), orient_(), polygon_index(-1) {
-    vertex_ = that.vertex_;
-    itrb = that.itrb;
-    itre = that.itre;
-    last_vertex_ = that.last_vertex_;
-    is_hole_ = that.is_hole_;
-    multiplier_ = that.multiplier_;
-    first_pt = that.first_pt;
-    second_pt = that.second_pt;
-    pts[0] = that.pts[0];
-    pts[1] = that.pts[1];
-    pts[2] = that.pts[2];
-    use_wrap = that.use_wrap;
-    orient_ = that.orient_;
-    polygon_index = that.polygon_index;
-  }
-  inline iterator_geometry_to_set& operator++() {
-    ++polygon_index;
-    if(itrb == itre) {
-      if(first_pt == pts[1]) polygon_index = -1;
-      else {
-        pts[0] = pts[1];
-        pts[1] = pts[2];
-        if(first_pt == pts[2]) {
-          pts[2] = second_pt;
-        } else {
-          pts[2] = first_pt;
-        }
-      }
-    } else {
-      ++itrb;
-      pts[0] = pts[1];
-      pts[1] = pts[2];
-      if(itrb == itre) {
-        if(first_pt == pts[2]) {
-          pts[2] = second_pt;
-        } else {
-          pts[2] = first_pt;
-        }
-      } else {
-        pts[2] = *itrb;
-      }
-    }
-    evaluate_();
-    return *this;
-  }
-  inline const iterator_geometry_to_set operator++(int) {
-    iterator_geometry_to_set tmp(*this);
-    ++(*this);
-    return tmp;
-  }
-  inline bool operator==(const iterator_geometry_to_set& that) const {
-    return polygon_index == that.polygon_index;
-  }
-  inline bool operator!=(const iterator_geometry_to_set& that) const {
-    return !(*this == that);
-  }
-  inline reference operator*() const {
-    return vertex_; 
-  }
-
-  inline void evaluate_() {
-    vertex_.first = pts[1].get(orient_.get_perpendicular());
-    vertex_.second.first =pts[1].get(orient_);
-    if(pts[1] == pts[2]) {
-      vertex_.second.second = 0;
-      return;
-    }
-    if(pts[0].get(HORIZONTAL) != pts[1].get(HORIZONTAL)) {
-      vertex_.second.second = -1; 
-    } else if(pts[0].get(VERTICAL) != pts[1].get(VERTICAL)) {
-      vertex_.second.second = 1;
-    } else {
-      vertex_.second.second = 0;
-    }
-    vertex_.second.second *= multiplier_;
-  }
-};
-
-template <typename polygon_with_holes_type>
-class iterator_geometry_to_set<polygon_90_with_holes_concept, polygon_with_holes_type> {
-public:
-  typedef typename polygon_90_traits<polygon_with_holes_type>::coordinate_type coordinate_type;
-  typedef std::forward_iterator_tag iterator_category;
-  typedef std::pair<coordinate_type, std::pair<coordinate_type, int> > value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef const value_type* pointer; //immutable
-  typedef const value_type& reference; //immutable
-private:
-  iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type> itrb, itre;
-  iterator_geometry_to_set<polygon_90_concept, typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type> itrhib, itrhie;
-  typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itrhb, itrhe;
-  orientation_2d orient_;
-  bool is_hole_;
-  bool started_holes;
-public:
-  iterator_geometry_to_set() : itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(), is_hole_(), started_holes() {}
-  iterator_geometry_to_set(const polygon_with_holes_type& polygon, direction_1d dir, 
-                           orientation_2d orient = HORIZONTAL, bool is_hole = false) : 
-    itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(orient), is_hole_(is_hole), started_holes() {
-    itre = iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type>(polygon, HIGH, orient, is_hole_);
-    itrhe = end_holes(polygon);
-    if(dir == HIGH) {
-      itrb = itre;
-      itrhb = itrhe;
-      started_holes = true;
-    } else {
-      itrb = iterator_geometry_to_set<polygon_90_concept, polygon_with_holes_type>(polygon, LOW, orient, is_hole_);
-      itrhb = begin_holes(polygon);
-      started_holes = false;
-    }
-  }
-  iterator_geometry_to_set(const iterator_geometry_to_set& that) : 
-    itrb(), itre(), itrhib(), itrhie(), itrhb(), itrhe(), orient_(), is_hole_(), started_holes() {
-    itrb = that.itrb;
-    itre = that.itre;
-    if(that.itrhib != that.itrhie) {
-      itrhib = that.itrhib;
-      itrhie = that.itrhie;
-    }
-    itrhb = that.itrhb;
-    itrhe = that.itrhe;
-    orient_ = that.orient_;
-    is_hole_ = that.is_hole_;
-    started_holes = that.started_holes;
-  }
-  inline iterator_geometry_to_set& operator++() {
-    //this code can be folded with flow control factoring
-    if(itrb == itre) {
-      if(itrhib == itrhie) {
-        if(itrhb != itrhe) {
-          itrhib = iterator_geometry_to_set<polygon_90_concept, 
-            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
-          itrhie = iterator_geometry_to_set<polygon_90_concept, 
-            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
-          ++itrhb;
-        } else {
-          itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept, 
-            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
-        }
-      } else {
-        ++itrhib;
-        if(itrhib == itrhie) {
-          if(itrhb != itrhe) {
-            itrhib = iterator_geometry_to_set<polygon_90_concept, 
-              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
-            itrhie = iterator_geometry_to_set<polygon_90_concept, 
-              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
-            ++itrhb;
-          } else {
-            itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept, 
-              typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
-          }
-        }
-      }
-    } else {
-      ++itrb;
-      if(itrb == itre) {
-        if(itrhb != itrhe) {
-          itrhib = iterator_geometry_to_set<polygon_90_concept, 
-            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, LOW, orient_, !is_hole_);
-          itrhie = iterator_geometry_to_set<polygon_90_concept, 
-            typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>(*itrhb, HIGH, orient_, !is_hole_);
-          ++itrhb;
-        }
-      }
-    }
-    return *this;
-  }
-  inline const iterator_geometry_to_set operator++(int) {
-    iterator_geometry_to_set tmp(*this);
-    ++(*this);
-    return tmp;
-  }
-  inline bool operator==(const iterator_geometry_to_set& that) const {
-    return itrb == that.itrb && itrhb == that.itrhb && itrhib == that.itrhib;
-  }
-  inline bool operator!=(const iterator_geometry_to_set& that) const {
-    return !(*this == that);
-  }
-  inline reference operator*() const {
-    if(itrb != itre) return *itrb;
-    return *itrhib;
-  }
-};
-
-
-}
-}
-#endif
-
Deleted: sandbox/gtl/boost/polygon/iterator_points_to_compact.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/iterator_points_to_compact.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,60 +0,0 @@
-/*
-  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 GTL_ITERATOR_POINTS_TO_COMPACT_HPP
-#define GTL_ITERATOR_POINTS_TO_COMPACT_HPP
-namespace boost { namespace polygon{
-template <typename iT, typename point_type>
-class iterator_points_to_compact {
-private:
-  iT iter_, iterEnd_;
-  orientation_2d orient_;
-  mutable typename point_traits<point_type>::coordinate_type coord_;
-public:
-  typedef typename point_traits<point_type>::coordinate_type coordinate_type;
-  typedef std::forward_iterator_tag iterator_category;
-  typedef coordinate_type value_type;
-  typedef std::ptrdiff_t difference_type;
-  typedef const coordinate_type* pointer; //immutable
-  typedef const coordinate_type& reference; //immutable
-
-  inline iterator_points_to_compact() : iter_(), iterEnd_(), orient_(), coord_() {}
-  explicit inline iterator_points_to_compact(iT iter, iT iterEnd) : 
-    iter_(iter), iterEnd_(iterEnd), orient_(HORIZONTAL), coord_() {}
-  inline iterator_points_to_compact(const iterator_points_to_compact& that) : 
-    iter_(that.iter_), iterEnd_(that.iterEnd_), orient_(that.orient_), coord_(that.coord_) {}
-  //use bitwise copy and assign provided by the compiler
-  inline iterator_points_to_compact& operator++() {
-    //iT tmp = iter_;
-    ++iter_;
-    //iT tmp2 = iter_;
-    orient_.turn_90();
-    //while(tmp2 != iterEnd_ && get(*tmp2, orient_) == get(*tmp, orient_)) {
-    //  iter_ = tmp2;
-    //  ++tmp2;
-    //}
-    return *this;
-  }
-  inline const iterator_points_to_compact operator++(int) {
-    iT tmp(*this);
-    ++(*this);
-    return tmp;
-  }
-  inline bool operator==(const iterator_points_to_compact& that) const {
-    return (iter_ == that.iter_);
-  }
-  inline bool operator!=(const iterator_points_to_compact& that) const {
-    return (iter_ != that.iter_);
-  }
-  inline reference operator*() const { coord_ = get(*iter_, orient_); 
-    return coord_;
-  }
-};
-}
-}
-#endif
-
Deleted: sandbox/gtl/boost/polygon/max_cover.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/max_cover.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,278 +0,0 @@
-/*
-  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 GTL_MAX_COVER_HPP
-#define GTL_MAX_COVER_HPP
-namespace boost { namespace polygon{
-
-  template <typename Unit>
-  struct MaxCover {
-    typedef interval_data<Unit> Interval;
-    typedef rectangle_data<Unit> Rectangle;
-
-    class Node {
-    private:
-      std::vector<Node*> children_;
-      std::set<Interval> tracedPaths_;
-    public:
-      Rectangle rect;
-      Node() : children_(), tracedPaths_(), rect() {}
-      Node(const Rectangle rectIn) : children_(), tracedPaths_(), rect(rectIn) {}
-      typedef typename std::vector<Node*>::iterator iterator;
-      inline iterator begin() { return children_.begin(); }
-      inline iterator end() { return children_.end(); }
-      inline void add(Node* child) { children_.push_back(child); }
-      inline bool tracedPath(const Interval& ivl) const {
-        return tracedPaths_.find(ivl) != tracedPaths_.end();
-      }
-      inline void addPath(const Interval& ivl) {
-        tracedPaths_.insert(tracedPaths_.end(), ivl);
-      }
-    };
-
-    typedef std::pair<std::pair<Unit, Interval>, Node* > EdgeAssociation;
-  
-    class lessEdgeAssociation : public std::binary_function<const EdgeAssociation&, const EdgeAssociation&, bool> {
-    public:
-      inline lessEdgeAssociation() {}
-      inline bool operator () (const EdgeAssociation& elem1, const EdgeAssociation& elem2) const {
-        if(elem1.first.first < elem2.first.first) return true;
-        if(elem1.first.first > elem2.first.first) return false;
-        return elem1.first.second < elem2.first.second;
-      }
-    };
-
-    template <class cT>
-    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient) {
-      Interval rectIvl = node->rect.get(orient);
-      if(node->tracedPath(rectIvl)) {
-        return;
-      }
-      node->addPath(rectIvl);
-      if(node->begin() == node->end()) {
-        //std::cout << "WRITE OUT 3: " << node->rect << std::endl;
-        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(node->rect));
-        return;
-      }
-      bool writeOut = true;
-      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
-        getMaxCover(outputContainer, *itr, orient, node->rect); //get rectangles down path
-        Interval nodeIvl = (*itr)->rect.get(orient);
-        if(contains(nodeIvl, rectIvl, true)) writeOut = false;
-      }
-      if(writeOut) {
-        //std::cout << "WRITE OUT 2: " << node->rect << std::endl;
-        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(node->rect));
-      }
-    }
-
-    struct stack_element {
-      inline stack_element() :
-        node(), rect(), itr() {}
-      inline stack_element(Node* n,
-                           const Rectangle& r,
-                           typename Node::iterator i) :
-        node(n), rect(r), itr(i) {}
-      Node* node;
-      Rectangle rect;
-      typename Node::iterator itr;
-    };
-
-    template <class cT>
-    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient, 
-                                   Rectangle rect) {
-      //std::cout << "New Root\n";
-      std::vector<stack_element> stack;
-      typename Node::iterator itr = node->begin();
-      do {
-        //std::cout << "LOOP\n";
-        //std::cout << node->rect << std::endl;
-        Interval rectIvl = rect.get(orient);
-        Interval nodeIvl = node->rect.get(orient);
-        bool iresult = intersect(rectIvl, nodeIvl, false);
-        bool tresult = !node->tracedPath(rectIvl);
-        //std::cout << (itr != node->end()) << " " << iresult << " " << tresult << std::endl;
-        Rectangle nextRect = Rectangle(rectIvl, rectIvl);
-        Unit low = rect.get(orient.get_perpendicular()).low();
-        Unit high = node->rect.get(orient.get_perpendicular()).high();
-        nextRect.set(orient.get_perpendicular(), Interval(low, high));
-        if(iresult && tresult) {
-          node->addPath(rectIvl);
-          bool writeOut = true;
-          //check further visibility beyond this node
-          for(typename Node::iterator itr2 = node->begin(); itr2 != node->end(); ++itr2) {
-            Interval nodeIvl3 = (*itr2)->rect.get(orient);
-            //if a child of this node can contain the interval then we can extend through
-            if(contains(nodeIvl3, rectIvl, true)) writeOut = false;
-            //std::cout << "child " << (*itr2)->rect << std::endl;
-          }
-          Rectangle nextRect = Rectangle(rectIvl, rectIvl);
-          Unit low = rect.get(orient.get_perpendicular()).low();
-          Unit high = node->rect.get(orient.get_perpendicular()).high();
-          nextRect.set(orient.get_perpendicular(), Interval(low, high));
-          if(writeOut) {
-            //std::cout << "write out " << nextRect << std::endl;
-            outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
-          } else {
-            //std::cout << "supress " << nextRect << std::endl;
-          }
-        }
-        if(itr != node->end() && iresult && tresult) {
-          //std::cout << "recurse into child\n";
-          stack.push_back(stack_element(node, rect, itr));
-          rect = nextRect;
-          node = *itr;
-          itr = node->begin();
-        } else {
-          if(!stack.empty()) {
-            //std::cout << "recurse out of child\n";
-            node = stack.back().node;
-            rect = stack.back().rect;
-            itr = stack.back().itr;
-            stack.pop_back();
-          } else {
-            //std::cout << "empty stack\n";
-            //if there were no children of the root node
-//             Rectangle nextRect = Rectangle(rectIvl, rectIvl);
-//             Unit low = rect.get(orient.get_perpendicular()).low();
-//             Unit high = node->rect.get(orient.get_perpendicular()).high();
-//             nextRect.set(orient.get_perpendicular(), Interval(low, high));
-//             outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
-          }
-          //std::cout << "increment " << (itr != node->end()) << std::endl;
-          if(itr != node->end()) {
-            ++itr;
-            if(itr != node->end()) {
-              //std::cout << "recurse into next child.\n";
-              stack.push_back(stack_element(node, rect, itr));
-              Interval rectIvl2 = rect.get(orient);
-              Interval nodeIvl2 = node->rect.get(orient);
-              /*bool iresult =*/ intersect(rectIvl2, nodeIvl2, false);
-              Rectangle nextRect2 = Rectangle(rectIvl2, rectIvl2);
-              Unit low2 = rect.get(orient.get_perpendicular()).low();
-              Unit high2 = node->rect.get(orient.get_perpendicular()).high();
-              nextRect2.set(orient.get_perpendicular(), Interval(low2, high2));
-              rect = nextRect2;
-              //std::cout << "rect for next child" << rect << std::endl;
-              node = *itr;
-              itr = node->begin();
-            }
-          }
-        }
-      } while(!stack.empty() || itr != node->end());
-    }
-
-    /*  Function recursive version of getMaxCover
-        Because the code is so much simpler than the loop algorithm I retain it for clarity
-
-    template <class cT>
-    static inline void getMaxCover(cT& outputContainer, Node* node, orientation_2d orient, 
-                                   const Rectangle& rect) {
-      Interval rectIvl = rect.get(orient);
-      Interval nodeIvl = node->rect.get(orient);
-      if(!intersect(rectIvl, nodeIvl, false)) {
-        return;
-      }
-      if(node->tracedPath(rectIvl)) {
-        return;
-      }
-      node->addPath(rectIvl);
-      Rectangle nextRect(rectIvl, rectIvl);
-      Unit low = rect.get(orient.get_perpendicular()).low();
-      Unit high = node->rect.get(orient.get_perpendicular()).high();
-      nextRect.set(orient.get_perpendicular(), Interval(low, high));
-      bool writeOut = true;
-      rectIvl = nextRect.get(orient);
-      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
-        nodeIvl = (*itr)->rect.get(orient);
-        if(contains(nodeIvl, rectIvl, true)) writeOut = false;
-      }
-      if(writeOut) {
-        outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(nextRect));
-      }
-      for(typename Node::iterator itr = node->begin(); itr != node->end(); ++itr) {
-        getMaxCover(outputContainer, *itr, orient, nextRect);
-      }
-    }
-    */
-
-    //iterator range is assummed to be in topological order meaning all node's trailing
-    //edges are in sorted order
-    template <class iT>
-    static inline void computeDag(iT beginNode, iT endNode, orientation_2d orient,
-                           unsigned int size) {
-      std::vector<EdgeAssociation> leadingEdges; 
-      leadingEdges.reserve(size);
-      for(iT iter = beginNode; iter != endNode; ++iter) {
-        Node* nodep = &(*iter);
-        Unit leading = nodep->rect.get(orient.get_perpendicular()).low();
-        Interval rectIvl = nodep->rect.get(orient);
-        leadingEdges.push_back(EdgeAssociation(std::pair<Unit, Interval>(leading, rectIvl), nodep));
-      }
-      std::sort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation());
-      typename std::vector<EdgeAssociation>::iterator leadingBegin = leadingEdges.begin();
-      iT trailingBegin = beginNode;
-      while(leadingBegin != leadingEdges.end()) {
-        EdgeAssociation& leadingSegment = (*leadingBegin);
-        Unit trailing = (*trailingBegin).rect.get(orient.get_perpendicular()).high();
-        Interval ivl = (*trailingBegin).rect.get(orient);
-        std::pair<Unit, Interval> trailingSegment(trailing, ivl);
-        if(leadingSegment.first.first < trailingSegment.first) {
-          ++leadingBegin;
-          continue;
-        }
-        if(leadingSegment.first.first > trailingSegment.first) {
-          ++trailingBegin;
-          continue;
-        }
-        if(leadingSegment.first.second.high() <= trailingSegment.second.low()) {
-          ++leadingBegin;
-          continue;
-        }
-        if(trailingSegment.second.high() <= leadingSegment.first.second.low()) {
-          ++trailingBegin;
-          continue;
-        }
-        //leading segment intersects trailing segment
-        (*trailingBegin).add((*leadingBegin).second);
-        if(leadingSegment.first.second.high() > trailingSegment.second.high()) {
-          ++trailingBegin;
-          continue;
-        }
-        if(trailingSegment.second.high() > leadingSegment.first.second.high()) {
-          ++leadingBegin;
-          continue;
-        }
-        ++leadingBegin;
-        ++trailingBegin;
-      }
-    }
-
-    template <class cT>
-    static inline void getMaxCover(cT& outputContainer,
-                                   const std::vector<Rectangle>& rects, orientation_2d orient) {
-      if(rects.empty()) return;
-      std::vector<Node> nodes;
-      {
-        if(rects.size() == 1) {
-          outputContainer.push_back(copy_construct<typename cT::value_type, Rectangle>(rects[0]));
-          return;
-        }
-        nodes.reserve(rects.size());
-        for(unsigned int i = 0; i < rects.size(); ++i) { nodes.push_back(Node(rects[i])); }
-      }
-      computeDag(nodes.begin(), nodes.end(), orient, nodes.size());
-      for(unsigned int i = 0; i < nodes.size(); ++i) {
-        getMaxCover(outputContainer, &(nodes[i]), orient);
-      }
-    }
-
-  };
-}
-}
-
-#endif
Modified: sandbox/gtl/boost/polygon/point_3d_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/point_3d_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/point_3d_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -7,6 +7,9 @@
 */
 #ifndef GLT_POINT_3D_CONCEPT_HPP
 #define GLT_POINT_3D_CONCEPT_HPP
+#include "point_concept.hpp"
+#include "point_3d_data.hpp"
+#include "point_3d_traits.hpp"
 namespace boost { namespace polygon{
   struct point_3d_concept {};
  
Modified: sandbox/gtl/boost/polygon/point_3d_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/point_3d_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/point_3d_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POINT_3D_DATA_HPP
-#define GTL_POINT_3D_DATA_HPP
+#ifndef BOOST_POLYGON_POINT_3D_DATA_HPP
+#define BOOST_POLYGON_POINT_3D_DATA_HPP
 namespace boost { namespace polygon{
   template <typename T>
   class point_3d_data {
Modified: sandbox/gtl/boost/polygon/point_3d_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/point_3d_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/point_3d_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POINT_3D_TRAITS_HPP
-#define GTL_POINT_3D_TRAITS_HPP
+#ifndef BOOST_POLYGON_POINT_3D_TRAITS_HPP
+#define BOOST_POLYGON_POINT_3D_TRAITS_HPP
 namespace boost { namespace polygon{
   template <typename T>
   struct point_3d_traits {
Modified: sandbox/gtl/boost/polygon/point_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/point_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/point_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POINT_CONCEPT_HPP
-#define GTL_POINT_CONCEPT_HPP
+#ifndef BOOST_POLYGON_POINT_CONCEPT_HPP
+#define BOOST_POLYGON_POINT_CONCEPT_HPP
 #include "isotropy.hpp"
 #include "point_data.hpp"
 #include "point_traits.hpp"
Modified: sandbox/gtl/boost/polygon/point_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/point_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/point_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POINT_TRAITS_HPP
-#define GTL_POINT_TRAITS_HPP
+#ifndef BOOST_POLYGON_POINT_TRAITS_HPP
+#define BOOST_POLYGON_POINT_TRAITS_HPP
 
 namespace boost { namespace polygon{
   template <typename T>
Modified: sandbox/gtl/boost/polygon/polygon.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_HPP
-#define GTL_POLYGON_HPP
+#ifndef BOOST_POLYGON_POLYGON_HPP
+#define BOOST_POLYGON_POLYGON_HPP
 
 //external
 #include <cmath>
@@ -21,10 +21,6 @@
 #include <iterator>
 #include <string>
 
-#ifndef BOOST_POLYGON_NO_DEPS
-#include <boost/config.hpp> 
-#endif
-
 #include "isotropy.hpp"
 
 //point
@@ -38,7 +34,7 @@
 #include "point_3d_concept.hpp"
 
 #include "transform.hpp"
-#include "transform_detail.hpp"
+#include "detail/transform_detail.hpp"
 
 //interval
 #include "interval_data.hpp"
@@ -51,8 +47,8 @@
 #include "rectangle_concept.hpp"
 
 //algorithms needed by polygon types
-#include "iterator_points_to_compact.hpp"
-#include "iterator_compact_to_points.hpp"
+#include "detail/iterator_points_to_compact.hpp"
+#include "detail/iterator_compact_to_points.hpp"
 
 //polygons
 #include "polygon_45_data.hpp"
@@ -64,17 +60,17 @@
 #include "polygon_traits.hpp"
 
 //manhattan boolean algorithms
-#include "boolean_op.hpp"
-#include "polygon_formation.hpp"
-#include "rectangle_formation.hpp"
-#include "max_cover.hpp"
-#include "property_merge.hpp"
-#include "polygon_90_touch.hpp"
-#include "iterator_geometry_to_set.hpp"
+#include "detail/boolean_op.hpp"
+#include "detail/polygon_formation.hpp"
+#include "detail/rectangle_formation.hpp"
+#include "detail/max_cover.hpp"
+#include "detail/property_merge.hpp"
+#include "detail/polygon_90_touch.hpp"
+#include "detail/iterator_geometry_to_set.hpp"
 
 //45 boolean op algorithms
-#include "boolean_op_45.hpp"
-#include "polygon_45_formation.hpp"
+#include "detail/boolean_op_45.hpp"
+#include "detail/polygon_45_formation.hpp"
 
 //polygon set data types
 #include "polygon_90_set_data.hpp"
@@ -83,203 +79,24 @@
 //polygon set concepts
 #include "polygon_90_set_concept.hpp"
 //boolean operator syntax
-#include "polygon_90_set_view.hpp"
+#include "detail/polygon_90_set_view.hpp"
 
 //45 boolean op algorithms
-#include "boolean_op_45.hpp"
-#include "polygon_45_formation.hpp"
 #include "polygon_45_set_data.hpp"
 #include "polygon_45_set_traits.hpp"
-#include "polygon_45_touch.hpp"
+#include "detail/polygon_45_touch.hpp"
 #include "polygon_45_set_concept.hpp"
-#include "polygon_45_set_view.hpp"
+#include "detail/polygon_45_set_view.hpp"
 
 //arbitrary polygon algorithms
-#include "polygon_arbitrary_formation.hpp"
+#include "detail/polygon_arbitrary_formation.hpp"
 #include "polygon_set_data.hpp"
 
 //general scanline
-#include "scan_arbitrary.hpp"
+#include "detail/scan_arbitrary.hpp"
 #include "polygon_set_traits.hpp"
-#include "polygon_set_view.hpp"
+#include "detail/polygon_set_view.hpp"
 
 #include "polygon_set_concept.hpp"
 
-/// \mainpage gtl -- Geometry Template Library
-/// The geometry template library is a Concepts based typesystem that implements that API and algorithms for a large number of planar (2D) geometry operations.  The primary algorithms provided by gtl are polygon set operations, so-called Booleans, such as polygon intersection and union.  There are three classes of Booleans and associated types, which are axis-parallel (Manhattan), 45-degree restricted and arbitrary angle polygon operations.  This is done because it is significantly more efficient to process geometry data when assumptions about whether it is axis-parallel or restricted to 45-degree can be made.
-
-/// \file "gtl.hpp"
-/// \brief Includes all gtl header files in the correct order to use all gtl features.  Include gtl.hpp to treat gtl like a package.
-
-/// \file "isotropy.hpp"
-/// \brief Defines abstract ideas such as orientation and direction as data types that are used extensively to aid geometric programming.
-
-//point
-/// \file "point_data.hpp"
-/// \brief Defines a data structure that models point_concept by satisfying the default point_traits.
-/// \file "point_traits.hpp"
-/// \brief Defines the point_traits that must be satisfied for an object to model point_concept.
-/// \file "point_concept.hpp"
-/// \brief Defines behaviors specific to objects that model point_concept.
-
-//point 3d
-/// \file "point_3d_data.hpp"
-/// \brief Defines a data structure that models point_3d_concept by satisfying the default point_3d_traits.
-/// \file "point_3d_traits.hpp"
-/// \brief Defines the point_3d_traits that must be satisfied for an object to model point_3d_concept.
-/// \file "point_3d_concept.hpp"
-/// \brief Defines behaviors specific to objects that model point_3d_concept.
-
-/// \file "transform.hpp"
-/// \brief Defines transformations of cartesian coordinate systems through several types
-/// \file "transform_detail.hpp"
-/// \brief Details of transforms implementation
-
-//interval
-/// \file "interval_data.hpp"
-/// \brief Defines a data structure that models interval_concept by satisfying the default interval_traits.
-/// \file "interval_traits.hpp"
-/// \brief Defines the interval_traits that must be satisfied for an object to model interval_concept.
-/// \file "interval_concept.hpp"
-/// \brief Defines behaviors specific to objects that model interval_concept.
-
-//rectangle
-/// \file "rectangle_data.hpp"
-/// \brief Defines a data structure that models rectangle_concept by satisfying the default rectangle_traits.
-/// \file "rectangle_traits.hpp"
-/// \brief Defines the rectangle_traits that must be satisfied for an object to model rectangle_concept.
-/// \file "rectangle_concept.hpp"
-/// \brief Defines behaviors specific to objects that model rectangle_concept.
-
-//algorithms needed by polygon types
-/// \file "iterator_points_to_compact.hpp"
-/// \brief Details of an iterator filter that converts a sequence of points of a manhattan polygon to non-redundant coordinate values.
-/// \file "iterator_compact_to_points.hpp"
-/// \brief Details of an iterator filter that converts a sequence of non-redundant coordinate values to the points of a manhattan polygon.
-
-//polygons
-/// \file "polygon_45_data.hpp"
-/// \brief Defines a data structure that models polygon_45_concept by satisfying the default rectangle_traits.
-/// \file "polygon_data.hpp"
-/// \brief Defines a data structure that models polygon_concept by satisfying the default rectangle_traits.
-/// \file "polygon_90_data.hpp"
-/// \brief Defines a data structure that models polygon_90_concept by satisfying the default rectangle_traits.
-/// \file "polygon_90_with_holes_data.hpp"
-/// \brief Defines a data structure that models polygon_90_with_holes_concept by satisfying the default rectangle_traits.
-/// \file "polygon_45_with_holes_data.hpp"
-/// \brief Defines a data structure that models polygon_45_with_holes_concept by satisfying the default rectangle_traits.
-/// \file "polygon_with_holes_data.hpp"
-/// \brief Defines a data structure that models polygon_with_holes_concept by satisfying the default rectangle_traits.
-/// \file "polygon_traits.hpp"
-/// \brief Defines the traits that must be satisfied for an object to model any of the polygonal concepts as well as behaviors of those concepts.
-
-//manhattan boolean algorithms
-/// \file "boolean_op.hpp"
-/// \brief Details of the generic framework for scanline algorithm on manhattan polygonal data.
-/// \file "polygon_formation.hpp"
-/// \brief Details of the scanline algorithm for forming polygons from manhattan polygonal data and associating holes to outer shells.
-/// \file "rectangle_formation.hpp"
-/// \brief Details of the scanline algorithm for forming rectangles from manhattan polygonal data. 
-/// \file "max_cover.hpp"
-/// \brief Details of the visibility algorithm for computing largest enclosed rectangles contained within manhattan polygonal data.
-/// \file "property_merge.hpp"
-/// \brief Details of the scanline algorithm for merging properties from many manhattan polygonal data inputs. 
-/// \file "polygon_90_touch.hpp"
-//
-/// \file "iterator_geometry_to_set.hpp"
-//
-
-//45 boolean op algorithms
-/// \file "boolean_op_45.hpp"
-//
-/// \file "polygon_45_formation.hpp"
-
-//polygon set data types
-/// \file "polygon_90_set_data.hpp"
-//polygon set trait types
-/// \file "polygon_90_set_traits.hpp"
-//polygon set concepts
-/// \file "polygon_90_set_concept.hpp"
-//boolean operator syntax
-/// \file "polygon_90_set_view.hpp"
-//
-
-//45 boolean op algorithms
-/// \file "boolean_op_45.hpp"
-//
-/// \file "polygon_45_formation.hpp"
-//
-/// \file "polygon_45_set_data.hpp"
-//
-/// \file "polygon_45_set_traits.hpp"
-//
-/// \file "polygon_45_touch.hpp"
-//
-/// \file "polygon_45_set_concept.hpp"
-//
-/// \file "polygon_45_set_view.hpp"
-//
-
-//arbitrary polygon algorithms
-/// \file "polygon_arbitrary_formation.hpp"
-//
-/// \file "polygon_set_data.hpp"
-//
-
-//general scanline
-/// \file "scan_arbitrary.hpp"
-//
-/// \file "polygon_set_traits.hpp"
-//
-/// \file "polygon_set_view.hpp"
-//
-
-/// \file "polygon_set_concept.hpp"
-//
-
-
-/// \defgroup d_concepts Concepts
-/// \brief These are the geometry concepts provided by gtl.
-/// \details A geometry concept is the idea of a geometry, a given data structure may model a certain geometry concept if it is able to provide a complete concept traits definition for that concept.
-/// @{
-/// \struct coordinate_concept 
-/// \brief coordinate_concept is a numeric
-/// \details Behaviors specific to coordinate_concept are defined in \ref isotropy.hpp
-/// defgroup d_polygon_concept_functions Polygon Concept Functions
-
-/// \struct interval_concept 
-/// \brief interval_concept is one dimensional interval
-/// \details Behaviors specific to interval_concept are defined in \ref interval_concept.hpp
-/// \par An interval is inclusive of all the values one the number line between its low and high coordinate values.
-
-/// \struct point_concept
-/// \brief point_concept is two dimensional point
-//
-/// \struct point_3d_concept
-/// \brief point_3d_concept is two dimensional point
-//
-/// \struct rectangle_concept
-/// \brief rectangle_concept is two dimensional axis-parallel (Manhattan) rectangle often used as a bounding box
-//
-/// \struct polygon_concept
-/// \brief polygon_concept is a two dimensional polygon
-//
-/// \struct polygon_with_holes_concept
-/// \brief polygon_with_holes_concept is a refinement of polygon_concept and extends it with holes that are themselves two dimensional polygons
-//
-/// \struct polygon_45_concept
-/// \brief polygon_45_concept is a refinement of polygon_concept and extends it with the restriction that angles formed at corners are multiples of 45 degrees
-//
-/// \struct polygon_45_with_holes_concept
-/// \brief polygon_45_with_holes_concept is a refinement of polygon_45_concept and polygon_with_holes_concept and extends them with the restriction that holes are of conceptual type polygon_45_concept
-//
-/// \struct polygon_90_concept
-/// \brief polygon_90_concept is a refinement of polygon_45_concept and extends it with the restriction that angles formed at corners are right angles and edges are axis-parallel (Manhattan)
-//
-/// \struct polygon_90_with_holes_concept
-/// \brief polygon_90_with_holes_concept is a refinement of polygon_90_concept and polygon_45_with_holes_concept and extends them with the restriction that holes are of conceptual type polygon_90_concept
-//
-/// @}
-//
-
 #endif
Modified: sandbox/gtl/boost/polygon/polygon_45_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_45_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,9 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_45_DATA_HPP
-#define GTL_POLYGON_45_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_45_DATA_HPP
+#define BOOST_POLYGON_POLYGON_45_DATA_HPP
+#include "isotropy.hpp"
 namespace boost { namespace polygon{
 struct polygon_45_concept;
 template <typename T> class polygon_data;
@@ -61,7 +62,7 @@
 
   inline std::size_t size() const { return coords_.size(); }
 
-protected:
+private:
   std::vector<point_data<coordinate_type> > coords_; 
 };
 
Deleted: sandbox/gtl/boost/polygon/polygon_45_formation.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,2213 +0,0 @@
-/*
-    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 GTL_POLYGON_45_FORMATION_HPP
-#define GTL_POLYGON_45_FORMATION_HPP
-namespace boost { namespace polygon{
-
-  template <typename T, typename T2>
-  struct PolyLineByConcept {};
-
-  template <typename T>
-  class PolyLine45PolygonData;
-  template <typename T>
-  class PolyLine45HoleData;
-
-  //polygon45formation algorithm
-  template <typename Unit>
-  struct polygon_45_formation : public boolean_op_45<Unit> {
-    typedef point_data<Unit> Point;
-    typedef polygon_45_data<Unit> Polygon45;
-    typedef polygon_45_with_holes_data<Unit> Polygon45WithHoles;
-    typedef typename boolean_op_45<Unit>::Vertex45 Vertex45;
-    typedef typename boolean_op_45<Unit>::lessVertex45 lessVertex45;
-    typedef typename boolean_op_45<Unit>::Count2 Count2;
-    typedef typename boolean_op_45<Unit>::Scan45Count Scan45Count;
-    typedef std::pair<Point, Scan45Count> Scan45Vertex;
-    typedef typename boolean_op_45<Unit>::template
-    Scan45<Count2, typename boolean_op_45<Unit>::template boolean_op_45_output_functor<0> > Scan45;
-    
-    class PolyLine45 {
-    public:
-      typedef typename std::list<Point>::const_iterator iterator;
-
-      // default constructor of point does not initialize x and y
-      inline PolyLine45() : points() {} //do nothing default constructor
-
-      // initialize a polygon from x,y values, it is assumed that the first is an x
-      // and that the input is a well behaved polygon
-      template<class iT>
-      inline PolyLine45& set(iT inputBegin, iT inputEnd) {
-        points.clear();  //just in case there was some old data there
-        while(inputBegin != inputEnd) {
-          points.insert(points.end(), *inputBegin);
-          ++inputBegin;
-        }
-        return *this;
-      }
-
-      // copy constructor (since we have dynamic memory)
-      inline PolyLine45(const PolyLine45& that) : points(that.points) {}
-  
-      // assignment operator (since we have dynamic memory do a deep copy)
-      inline PolyLine45& operator=(const PolyLine45& that) {
-        points = that.points;
-        return *this;
-      }
-
-      // get begin iterator, returns a pointer to a const Unit
-      inline iterator begin() const { return points.begin(); }
-
-      // get end iterator, returns a pointer to a const Unit
-      inline iterator end() const { return points.end(); }
-
-      inline std::size_t size() const { return points.size(); }
-
-      //public data member
-      std::list<Point> points; 
-    };
-
-    class ActiveTail45 {
-    private:
-      //data
-      PolyLine45* tailp_; 
-      ActiveTail45 *otherTailp_;
-      std::list<ActiveTail45*> holesList_;
-      bool head_;
-    public:
-   
-      /**
-       * @brief iterator over coordinates of the figure
-       */
-      typedef typename PolyLine45::iterator iterator;
-   
-      /**
-       * @brief iterator over holes contained within the figure
-       */
-      typedef typename std::list<ActiveTail45*>::const_iterator iteratorHoles;
-   
-      //default constructor
-      inline ActiveTail45() : tailp_(0), otherTailp_(0), holesList_(), head_(0) {}
-   
-      //constructor
-      inline ActiveTail45(const Vertex45& vertex, ActiveTail45* otherTailp = 0) :
-        tailp_(0), otherTailp_(0), holesList_(), head_(0) {
-        tailp_ = new PolyLine45;
-        tailp_->points.push_back(vertex.pt);
-        bool headArray[4] = {false, true, true, true};
-        bool inverted = vertex.count == -1;
-        head_ = headArray[vertex.rise+1] ^ inverted;
-        otherTailp_ = otherTailp;
-      }
-
-      inline ActiveTail45(Point point, ActiveTail45* otherTailp, bool head = true) :
-        tailp_(0), otherTailp_(0), holesList_(), head_(0) {
-        tailp_ = new PolyLine45;
-        tailp_->points.push_back(point);
-        head_ = head;
-        otherTailp_ = otherTailp;
-      
-      }
-      inline ActiveTail45(ActiveTail45* otherTailp) :
-        tailp_(0), otherTailp_(0), holesList_(), head_(0)  {
-        tailp_ = otherTailp->tailp_;
-        otherTailp_ = otherTailp;
-      }
-
-      //copy constructor
-      inline ActiveTail45(const ActiveTail45& that) :
-        tailp_(0), otherTailp_(0), holesList_(), head_(0)  { (*this) = that; }
-
-      //destructor
-      inline ~ActiveTail45() {
-        destroyContents();
-      }
-
-      //assignment operator
-      inline ActiveTail45& operator=(const ActiveTail45& that) {
-        tailp_ = new PolyLine45(*(that.tailp_));
-        head_ = that.head_;
-        otherTailp_ = that.otherTailp_;
-        holesList_ = that.holesList_;
-        return *this;
-      }
-
-      //equivalence operator
-      inline bool operator==(const ActiveTail45& b) const {
-        return tailp_ == b.tailp_ && head_ == b.head_;
-      }
-
-      /**
-       * @brief get the pointer to the polyline that this is an active tail of
-       */
-      inline PolyLine45* getTail() const { return tailp_; }
-
-      /**
-       * @brief get the pointer to the polyline at the other end of the chain
-       */
-      inline PolyLine45* getOtherTail() const { return otherTailp_->tailp_; }
-
-      /**
-       * @brief get the pointer to the activetail at the other end of the chain
-       */
-      inline ActiveTail45* getOtherActiveTail() const { return otherTailp_; }
-   
-      /**
-       * @brief test if another active tail is the other end of the chain
-       */
-      inline bool isOtherTail(const ActiveTail45& b) const { return &b == otherTailp_; }
-
-      /**
-       * @brief update this end of chain pointer to new polyline
-       */
-      inline ActiveTail45& updateTail(PolyLine45* newTail) { tailp_ = newTail; return *this; }
-
-      inline bool join(ActiveTail45* tail) {
-        if(tail == otherTailp_) {
-          //std::cout << "joining to other tail!\n";
-          return false;
-        }
-        if(tail->head_ == head_) {
-          //std::cout << "joining head to head!\n";
-          return false;
-        }
-        if(!tailp_) {
-          //std::cout << "joining empty tail!\n";
-          return false;
-        }
-        if(!(otherTailp_->head_)) {
-          otherTailp_->copyHoles(*tail);
-          otherTailp_->copyHoles(*this);
-        } else {
-          tail->otherTailp_->copyHoles(*this);
-          tail->otherTailp_->copyHoles(*tail);
-        }
-        PolyLine45* tail1 = tailp_;
-        PolyLine45* tail2 = tail->tailp_;
-        if(head_) std::swap(tail1, tail2);
-        tail1->points.splice(tail1->points.end(), tail2->points);
-        delete tail2;
-        otherTailp_->tailp_ = tail1;
-        tail->otherTailp_->tailp_ = tail1;
-        otherTailp_->otherTailp_ = tail->otherTailp_;
-        tail->otherTailp_->otherTailp_ = otherTailp_;
-        tailp_ = 0;
-        tail->tailp_ = 0;
-        tail->otherTailp_ = 0;
-        otherTailp_ = 0;
-        return true;
-      }
-
-      /**
-       * @brief associate a hole to this active tail by the specified policy
-       */
-      inline ActiveTail45* addHole(ActiveTail45* hole) {
-        holesList_.push_back(hole);
-        copyHoles(*hole);
-        copyHoles(*(hole->otherTailp_));
-        return this;
-      }
-
-      /**
-       * @brief get the list of holes
-       */
-      inline const std::list<ActiveTail45*>& getHoles() const { return holesList_; }
-
-      /**
-       * @brief copy holes from that to this
-       */
-      inline void copyHoles(ActiveTail45& that) { holesList_.splice(holesList_.end(), that.holesList_); }
-
-      /**
-       * @brief find out if solid to right
-       */
-      inline bool solidToRight() const { return !head_; }
-      inline bool solidToLeft() const { return head_; }
-
-      /**
-       * @brief get vertex
-       */
-      inline Point getPoint() const {
-        if(head_) return tailp_->points.front();
-        return tailp_->points.back();
-      }
-
-      /**
-       * @brief add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
-       */
-      inline void pushPoint(Point point) {
-        if(head_) {
-          //if(tailp_->points.size() < 2) {
-          //   tailp_->points.push_front(point);
-          //   return;
-          //}
-          typename std::list<Point>::iterator iter = tailp_->points.begin();
-          if(iter == tailp_->points.end()) {
-            tailp_->points.push_front(point);
-            return;
-          }
-          Unit firstY = (*iter).y();
-          ++iter;
-          if(iter == tailp_->points.end()) {
-            tailp_->points.push_front(point);
-            return;
-          }
-          if(iter->y() == point.y() && firstY == point.y()) {
-            --iter;
-            *iter = point;
-          } else {
-            tailp_->points.push_front(point);
-          }
-          return;
-        }
-        //if(tailp_->points.size() < 2) {
-        //   tailp_->points.push_back(point);
-        //   return;
-        //}
-        typename std::list<Point>::reverse_iterator iter = tailp_->points.rbegin();
-        if(iter == tailp_->points.rend()) {
-          tailp_->points.push_back(point);
-          return;
-        }
-        Unit firstY = (*iter).y();
-        ++iter;
-        if(iter == tailp_->points.rend()) {
-          tailp_->points.push_back(point);
-          return;
-        }
-        if(iter->y() == point.y() && firstY == point.y()) {
-          --iter;
-          *iter = point;
-        } else {
-          tailp_->points.push_back(point);
-        }
-      }
-
-      /**
-       * @brief joins the two chains that the two active tail tails are ends of
-       * checks for closure of figure and writes out polygons appropriately
-       * returns a handle to a hole if one is closed
-       */
-
-      template <class cT>
-      static inline ActiveTail45* joinChains(Point point, ActiveTail45* at1, ActiveTail45* at2, bool solid, 
-                                             cT& output) {
-        if(at1->otherTailp_ == at2) {
-          //if(at2->otherTailp_ != at1) std::cout << "half closed error\n";
-          //we are closing a figure
-          at1->pushPoint(point);
-          at2->pushPoint(point);
-          if(solid) {
-            //we are closing a solid figure, write to output
-            //std::cout << "test1\n";
-            at1->copyHoles(*(at1->otherTailp_));
-            //std::cout << "test2\n";
-            //Polygon45WithHolesImpl<PolyLine45PolygonData> poly(polyData);
-            //std::cout << poly << std::endl;
-            //std::cout << "test3\n";
-            typedef typename cT::value_type pType;
-            output.push_back(pType());
-            typedef typename geometry_concept<pType>::type cType;
-            typename PolyLineByConcept<Unit, cType>::type polyData(at1);
-            assign(output.back(), polyData);
-            //std::cout << "test4\n";
-            //std::cout << "delete " << at1->otherTailp_ << std::endl;
-            //at1->print();
-            //at1->otherTailp_->print();
-            delete at1->otherTailp_;
-            //at1->print();
-            //at1->otherTailp_->print();
-            //std::cout << "test5\n";
-            //std::cout << "delete " << at1 << std::endl;
-            delete at1;
-            //std::cout << "test6\n";
-            return 0;
-          } else {
-            //we are closing a hole, return the tail end active tail of the figure
-            return at1;
-          }
-        }
-        //we are not closing a figure
-        at1->pushPoint(point);
-        at1->join(at2);
-        delete at1;
-        delete at2;
-        return 0;
-      }
-
-      inline void destroyContents() {
-        if(otherTailp_) {
-          //std::cout << "delete p " << tailp_ << std::endl;
-          if(tailp_) delete tailp_;
-          tailp_ = 0;
-          otherTailp_->otherTailp_ = 0;
-          otherTailp_->tailp_ = 0;
-          otherTailp_ = 0;
-        }
-        for(typename std::list<ActiveTail45*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
-          //std::cout << "delete p " << (*itr) << std::endl;
-          if(*itr) {
-            if((*itr)->otherTailp_) {
-              delete (*itr)->otherTailp_;
-              (*itr)->otherTailp_ = 0;
-            }
-            delete (*itr);
-          }
-          (*itr) = 0;
-        }
-        holesList_.clear();
-      }
-
-      inline void print() {
-        std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
-      }
-
-      static inline std::pair<ActiveTail45*, ActiveTail45*> createActiveTail45sAsPair(Point point, bool solid, 
-                                                                                      ActiveTail45* phole, bool fractureHoles) {
-        ActiveTail45* at1 = 0;
-        ActiveTail45* at2 = 0;
-        if(phole && fractureHoles) {
-          //std::cout << "adding hole\n";
-          at1 = phole;
-          //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
-          at2 = at1->getOtherActiveTail();
-          at2->pushPoint(point);
-          at1->pushPoint(point);
-        } else {
-          at1 = new ActiveTail45(point, at2, solid);
-          at2 = new ActiveTail45(at1);
-          at1->otherTailp_ = at2;
-          at2->head_ = !solid;
-          if(phole) 
-            at2->addHole(phole); //assert fractureHoles == false
-        }
-        return std::pair<ActiveTail45*, ActiveTail45*>(at1, at2);
-      }
-
-    };
-
-    template <typename ct>
-    class Vertex45CountT {
-    public:
-      typedef ct count_type;
-      inline Vertex45CountT() : counts() { counts[0] = counts[1] = counts[2] = counts[3] = 0; }
-      //inline Vertex45CountT(ct count) { counts[0] = counts[1] = counts[2] = counts[3] = count; }
-      inline Vertex45CountT(const ct& count1, const ct& count2, const ct& count3, 
-                           const ct& count4) : counts() { 
-        counts[0] = count1; 
-        counts[1] = count2; 
-        counts[2] = count3;
-        counts[3] = count4; 
-      }
-      inline Vertex45CountT(const Vertex45& vertex) : counts() { 
-        counts[0] = counts[1] = counts[2] = counts[3] = 0;
-        (*this) += vertex;
-      }
-      inline Vertex45CountT(const Vertex45CountT& count) : counts() { 
-        (*this) = count;
-      }
-      inline bool operator==(const Vertex45CountT& count) const { 
-        for(unsigned int i = 0; i < 4; ++i) {
-          if(counts[i] != count.counts[i]) return false; 
-        }
-        return true;
-      }
-      inline bool operator!=(const Vertex45CountT& count) const { return !((*this) == count); }
-      inline Vertex45CountT& operator=(ct count) { 
-        counts[0] = counts[1] = counts[2] = counts[3] = count; return *this; }
-      inline Vertex45CountT& operator=(const Vertex45CountT& count) {
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] = count.counts[i]; 
-        }
-        return *this; 
-      }
-      inline ct& operator[](int index) { return counts[index]; }
-      inline ct operator[](int index) const {return counts[index]; }
-      inline Vertex45CountT& operator+=(const Vertex45CountT& count){
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] += count.counts[i]; 
-        }
-        return *this;
-      }
-      inline Vertex45CountT& operator-=(const Vertex45CountT& count){
-        for(unsigned int i = 0; i < 4; ++i) {
-          counts[i] -= count.counts[i]; 
-        }
-        return *this;
-      }
-      inline Vertex45CountT operator+(const Vertex45CountT& count) const {
-        return Vertex45CountT(*this)+=count;
-      }
-      inline Vertex45CountT operator-(const Vertex45CountT& count) const {
-        return Vertex45CountT(*this)-=count;
-      }
-      inline Vertex45CountT invert() const {
-        return Vertex45CountT()-=(*this);
-      }
-      inline Vertex45CountT& operator+=(const Vertex45& element){
-        counts[element.rise+1] += element.count; return *this;
-      }
-      inline bool is_45() const {
-        return counts[0] != 0 || counts[2] != 0;
-      }
-    private:
-      ct counts[4];
-    };
-
-    typedef Vertex45CountT<int> Vertex45Count;
-
-//     inline std::ostream& operator<< (std::ostream& o, const Vertex45Count& c) {
-//       o << c[0] << ", " << c[1] << ", ";
-//       o << c[2] << ", " << c[3];
-//       return o;
-//     }
-
-    template <typename ct>
-    class Vertex45CompactT {
-    public:
-      Point pt;
-      ct count;
-      typedef typename boolean_op_45<Unit>::template Vertex45T<typename ct::count_type> Vertex45T;
-      inline Vertex45CompactT() : pt(), count() {}
-      inline Vertex45CompactT(const Point& point, int riseIn, int countIn) : pt(point), count() {
-        count[riseIn+1] = countIn;
-      }
-      inline Vertex45CompactT(const Vertex45T& vertex) : pt(vertex.pt), count() {
-        count[vertex.rise+1] = vertex.count;
-      }
-      inline Vertex45CompactT(const Vertex45CompactT& vertex) : pt(vertex.pt), count(vertex.count) {}
-      inline Vertex45CompactT& operator=(const Vertex45CompactT& vertex){ 
-        pt = vertex.pt; count = vertex.count; return *this; }
-      inline bool operator==(const Vertex45CompactT& vertex) const {
-        return pt == vertex.pt && count == vertex.count; }
-      inline bool operator!=(const Vertex45CompactT& vertex) const { return !((*this) == vertex); }
-      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
-      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
-      inline bool operator<(const Vertex45CompactT& vertex) const {
-        if(pt.x() < vertex.pt.x()) return true;
-        if(pt.x() == vertex.pt.x()) {
-          return pt.y() < vertex.pt.y();
-        }
-        return false;
-      }
-      inline bool operator>(const Vertex45CompactT& vertex) const { return vertex < (*this); }
-      inline bool operator<=(const Vertex45CompactT& vertex) const { return !((*this) > vertex); }
-      inline bool operator>=(const Vertex45CompactT& vertex) const { return !((*this) < vertex); }
-      inline bool haveVertex45(int index) const { return count[index]; }
-      inline Vertex45T operator[](int index) const {
-        return Vertex45T(pt, index-1, count[index]); }
-    };
-
-    typedef Vertex45CompactT<Vertex45Count> Vertex45Compact;
-
-//     inline std::ostream& operator<< (std::ostream& o, const Vertex45Compact& c) {
-//       o << c.pt << ", " << c.count;
-//       return o;
-//     }
-
-    class Polygon45Formation {
-    private:
-      //definitions
-      typedef std::map<Vertex45, ActiveTail45*, lessVertex45> Polygon45FormationData;
-      typedef typename Polygon45FormationData::iterator iterator;
-      typedef typename Polygon45FormationData::const_iterator const_iterator;
-   
-      //data
-      Polygon45FormationData scanData_;
-      Unit x_;
-      int justBefore_;
-      int fractureHoles_; 
-    public:
-      inline Polygon45Formation() : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) {
-        lessVertex45 lessElm(&x_, &justBefore_);
-        scanData_ = Polygon45FormationData(lessElm);
-      }
-      inline Polygon45Formation(bool fractureHoles) : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(fractureHoles) {
-        lessVertex45 lessElm(&x_, &justBefore_);
-        scanData_ = Polygon45FormationData(lessElm);
-      }
-      inline Polygon45Formation(const Polygon45Formation& that) :
-        scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) { (*this) = that; }
-      inline Polygon45Formation& operator=(const Polygon45Formation& that) {
-        x_ = that.x_;
-        justBefore_ = that.justBefore_;
-        fractureHoles_ = that.fractureHoles_;
-        lessVertex45 lessElm(&x_, &justBefore_);
-        scanData_ = Polygon45FormationData(lessElm);
-        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
-          scanData_.insert(scanData_.end(), *itr);
-        }
-        return *this;
-      }
-   
-      //cT is an output container of Polygon45 or Polygon45WithHoles
-      //iT is an iterator over Vertex45 elements
-      //inputBegin - inputEnd is a range of sorted iT that represents
-      //one or more scanline stops worth of data
-      template <class cT, class iT>
-      void scan(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "1\n";
-        while(inputBegin != inputEnd) {
-          //std::cout << "2\n";
-          x_ = (*inputBegin).pt.x();
-          //std::cout << "SCAN FORMATION " << x_ << std::endl;
-          //std::cout << "x_ = " << x_ << std::endl;
-          //std::cout << "scan line size: " << scanData_.size() << std::endl;
-          inputBegin = processEvent_(output, inputBegin, inputEnd);
-        }
-      }
-
-    private:
-      //functions
-      template <class cT, class cT2>
-      inline std::pair<int, ActiveTail45*> processPoint_(cT& output, cT2& elements, Point point, 
-                                                         Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) { 
-        //std::cout << point << std::endl;
-        //std::cout << counts[0] << " ";
-        //std::cout << counts[1] << " ";
-        //std::cout << counts[2] << " ";
-        //std::cout << counts[3] << "\n";
-        //std::cout << incoming[0] << " ";
-        //std::cout << incoming[1] << " ";
-        //std::cout << incoming[2] << " ";
-        //std::cout << incoming[3] << "\n";
-        //join any closing solid corners
-        ActiveTail45* returnValue = 0;
-        int returnCount = 0;
-        for(int i = 0; i < 3; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] == -1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < 4; ++j) {
-              //std::cout << j << std::endl;
-              if(counts[j]) {
-                if(counts[j] == 1) {
-                  //std::cout << "case1: " << i << " " << j << std::endl;
-                  //if a figure is closed it will be written out by this function to output
-                  ActiveTail45::joinChains(point, tails[i], tails[j], true, output); 
-                  counts[i] = 0;
-                  counts[j] = 0;
-                  tails[i] = 0;
-                  tails[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-        //find any pairs of incoming edges that need to create pair for leading solid
-        //std::cout << "checking case2\n";
-        for(int i = 0; i < 3; ++i) {
-          //std::cout << i << std::endl;
-          if(incoming[i] == 1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < 4; ++j) {
-              //std::cout << j << std::endl;
-              if(incoming[j]) {
-                if(incoming[j] == -1) {
-                  //std::cout << "case2: " << i << " " << j << std::endl;
-                  //std::cout << "creating active tail pair\n";
-                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, fractureHoles_);
-                  //tailPair.first->print();
-                  //tailPair.second->print();
-                  if(j == 3) {
-                    //vertical active tail becomes return value
-                    returnValue = tailPair.first;
-                    returnCount = 1;
-                  } else {
-                    Vertex45 vertex(point, i -1, incoming[i]);
-                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
-                    elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
-                  }
-                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
-                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
-                  incoming[i] = 0;
-                  incoming[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-
-        //find any active tail that needs to pass through to an incoming edge
-        //we expect to find no more than two pass through
-
-        //find pass through with solid on top
-        //std::cout << "checking case 3\n";
-        for(int i = 0; i < 4; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] != 0) {
-            if(counts[i] == 1) {
-              //std::cout << "fixed i\n";
-              for(int j = 3; j >= 0; --j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == 1) {
-                    //std::cout << "case3: " << i << " " << j << std::endl;
-                    //tails[i]->print();
-                    //pass through solid on top
-                    tails[i]->pushPoint(point);
-                    //std::cout << "after push\n";
-                    if(j == 3) {
-                      returnValue = tails[i];
-                      returnCount = -1;
-                    } else {
-                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-        //std::cout << "checking case 4\n";
-        //find pass through with solid on bottom
-        for(int i = 3; i >= 0; --i) {
-          if(counts[i] != 0) {
-            if(counts[i] == -1) {
-              for(int j = 0; j < 4; ++j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == -1) {
-                    //std::cout << "case4: " << i << " " << j << std::endl;
-                    //pass through solid on bottom
-                    tails[i]->pushPoint(point);
-                    if(j == 3) {
-                      returnValue = tails[i];
-                      returnCount = 1;
-                    } else {
-                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-
-        //find the end of a hole or the beginning of a hole
-
-        //find end of a hole
-        for(int i = 0; i < 3; ++i) {
-          if(counts[i] != 0) {
-            for(int j = i+1; j < 4; ++j) {
-              if(counts[j] != 0) {
-                //std::cout << "case5: " << i << " " << j << std::endl;
-                //we are ending a hole and may potentially close a figure and have to handle the hole
-                returnValue = ActiveTail45::joinChains(point, tails[i], tails[j], false, output);
-                tails[i] = 0;
-                tails[j] = 0;
-                counts[i] = 0;
-                counts[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        } 
-        //find beginning of a hole
-        for(int i = 0; i < 3; ++i) {
-          if(incoming[i] != 0) {
-            for(int j = i+1; j < 4; ++j) {
-              if(incoming[j] != 0) {
-                //std::cout << "case6: " << i << " " << j << std::endl;
-                //we are beginning a empty space
-                ActiveTail45* holep = 0;
-                if(counts[3] == 0) holep = tails[3];
-                std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-                  ActiveTail45::createActiveTail45sAsPair(point, false, holep, fractureHoles_);
-                if(j == 3) {
-                  returnValue = tailPair.first;
-                  returnCount = -1;
-                } else {
-                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.first));
-                }
-                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
-                elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), tailPair.second));
-                incoming[i] = 0;
-                incoming[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        }
-        //assert that tails, counts and incoming are all null
-        return std::pair<int, ActiveTail45*>(returnCount, returnValue);
-      }
-
-      template <class cT, class iT>
-      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "processEvent_\n";
-        justBefore_ = true;
-        //collect up all elements from the tree that are at the y
-        //values of events in the input queue
-        //create vector of new elements to add into tree
-        ActiveTail45* verticalTail = 0;
-        int verticalCount = 0;
-        iT currentIter = inputBegin;
-        std::vector<iterator> elementIters;
-        std::vector<std::pair<Vertex45, ActiveTail45*> > elements;
-        while(currentIter != inputEnd && currentIter->pt.x() == x_) {
-          //std::cout << "loop\n";
-          Unit currentY = (*currentIter).pt.y();
-          iterator iter = lookUp_(currentY);
-          //int counts[4] = {0, 0, 0, 0};
-          Vertex45Count counts;
-          ActiveTail45* tails[4] = {0, 0, 0, verticalTail};
-          //std::cout << "finding elements in tree\n";
-          while(iter != scanData_.end() &&
-                iter->first.evalAtX(x_) == currentY) {
-            //std::cout << "loop2\n";
-            elementIters.push_back(iter);
-            int index = iter->first.rise + 1;
-            //std::cout << index << " " << iter->first.count << std::endl;
-            counts[index] = iter->first.count;
-            tails[index] = iter->second;
-            ++iter;
-          }
-          //int incoming[4] = {0, 0, 0, 0};
-          Vertex45Count incoming;
-          //std::cout << "aggregating\n";
-          do {
-            //std::cout << "loop3\n";
-            Vertex45Compact currentVertex(*currentIter);
-            incoming += currentVertex.count;
-            ++currentIter;
-          } while(currentIter != inputEnd && currentIter->pt.y() == currentY &&
-                  currentIter->pt.x() == x_);
-          //now counts and tails have the data from the left and
-          //incoming has the data from the right at this point
-          //cancel out any end points
-          //std::cout << counts[0] << " ";
-          //std::cout << counts[1] << " ";
-          //std::cout << counts[2] << " ";
-          //std::cout << counts[3] << "\n";
-          //std::cout << incoming[0] << " ";
-          //std::cout << incoming[1] << " ";
-          //std::cout << incoming[2] << " ";
-          //std::cout << incoming[3] << "\n";
-          if(verticalTail) {
-            counts[3] = -verticalCount;
-          }
-          incoming[3] *= -1;
-          for(unsigned int i = 0; i < 4; ++i) incoming[i] += counts[i];
-          //std::cout << "calling processPoint_\n";
-          std::pair<int, ActiveTail45*> result = processPoint_(output, elements, Point(x_, currentY), counts, tails, incoming);
-          verticalCount = result.first;
-          verticalTail = result.second;
-          //if(verticalTail) std::cout << "have vertical tail\n";
-          //std::cout << "verticalCount: " << verticalCount << std::endl;
-          if(verticalTail && !verticalCount) {
-            //we got a hole out of the point we just processed
-            //iter is still at the next y element above the current y value in the tree
-            //std::cout << "checking whether ot handle hole\n";
-            if(currentIter == inputEnd || 
-               currentIter->pt.x() != x_ ||
-               currentIter->pt.y() >= iter->first.evalAtX(x_)) {
-              //std::cout << "handle hole here\n";
-              if(fractureHoles_) {
-                //std::cout << "fracture hole here\n";
-                //we need to handle the hole now and not at the next input vertex
-                ActiveTail45* at = iter->second;
-                Point point(x_, iter->first.evalAtX(x_));
-                verticalTail->getOtherActiveTail()->pushPoint(point);
-                iter->second = verticalTail->getOtherActiveTail();
-                at->pushPoint(point);
-                verticalTail->join(at);
-                delete at;
-                delete verticalTail;
-                verticalTail = 0;
-              } else {
-                //std::cout << "push hole onto list\n";
-                iter->second->addHole(verticalTail);
-                verticalTail = 0;
-              }
-            }
-          }
-        }
-        //std::cout << "erasing\n";
-        //erase all elements from the tree
-        for(typename std::vector<iterator>::iterator iter = elementIters.begin();
-            iter != elementIters.end(); ++iter) {
-          //std::cout << "erasing loop\n";
-          scanData_.erase(*iter);
-        }
-        //switch comparison tie breaking policy
-        justBefore_ = false;
-        //add new elements into tree
-        //std::cout << "inserting\n";
-        for(typename std::vector<std::pair<Vertex45, ActiveTail45*> >::iterator iter = elements.begin();
-            iter != elements.end(); ++iter) {
-          //std::cout << "inserting loop\n";
-          scanData_.insert(scanData_.end(), *iter);
-        }
-        //std::cout << "end processEvent\n";
-        return currentIter;
-      }
-   
-      inline iterator lookUp_(Unit y){
-        //if just before then we need to look from 1 not -1
-        return scanData_.lower_bound(Vertex45(Point(x_, y), -1+2*justBefore_, 0));
-      }
-   
-    };
-
-    static inline bool testPolygon45FormationRect() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygon45FormationP1() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 1, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 1, -1));
-      data.push_back(Vertex45(Point(10, 10), 1, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, -1));
-      data.push_back(Vertex45(Point(10, 20), 2, 1));
-      data.push_back(Vertex45(Point(10, 20), 1, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-    //polygon45set class
-
-    static inline bool testPolygon45FormationP2() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 1, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 1, 1));
-      data.push_back(Vertex45(Point(10, 10), 1, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, -1));
-      data.push_back(Vertex45(Point(20, 10), 1, -1));
-      data.push_back(Vertex45(Point(20, 10), 0, 1)); 
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-    //polygon45set class
-
-    static inline bool testPolygon45FormationStar1() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45FormationStar2() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      Scan45 scan45;
-      std::vector<Vertex45 > result;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-   
-      std::sort(result.begin(), result.end());
-      pf.scan(polys, result.begin(), result.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45FormationStarHole1() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(true);
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-
-      data.push_back(Vertex45(Point(6, 4), 1, -1));
-      data.push_back(Vertex45(Point(6, 4), 2, -1));
-      data.push_back(Vertex45(Point(6, 8), -1, 1));
-      data.push_back(Vertex45(Point(6, 8), 2, 1));
-      data.push_back(Vertex45(Point(8, 6), -1, -1));
-      data.push_back(Vertex45(Point(8, 6), 1, 1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45FormationStarHole2() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(false);
-      std::vector<Polygon45WithHoles> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-
-      data.push_back(Vertex45(Point(6, 4), 1, -1));
-      data.push_back(Vertex45(Point(6, 4), 2, -1));
-      data.push_back(Vertex45(Point(6, 12), -1, 1));
-      data.push_back(Vertex45(Point(6, 12), 2, 1));
-      data.push_back(Vertex45(Point(10, 8), -1, -1));
-      data.push_back(Vertex45(Point(10, 8), 1, 1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45Formation() {
-      std::cout << "testing polygon formation\n";
-      Polygon45Formation pf(false);
-      std::vector<Polygon45WithHoles> polys;
-      std::vector<Vertex45> data;
-   
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 100), 2, -1));
-      data.push_back(Vertex45(Point(0, 100), 0, -1));
-      data.push_back(Vertex45(Point(100, 0), 0, -1));
-      data.push_back(Vertex45(Point(100, 0), 2, -1));
-      data.push_back(Vertex45(Point(100, 100), 2, 1));
-      data.push_back(Vertex45(Point(100, 100), 0, 1));
-
-      data.push_back(Vertex45(Point(2, 2), 0, -1));
-      data.push_back(Vertex45(Point(2, 2), 2, -1));
-      data.push_back(Vertex45(Point(2, 10), 2, 1));
-      data.push_back(Vertex45(Point(2, 10), 0, 1));
-      data.push_back(Vertex45(Point(10, 2), 0, 1));
-      data.push_back(Vertex45(Point(10, 2), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 0, -1));
-
-      data.push_back(Vertex45(Point(2, 12), 0, -1));
-      data.push_back(Vertex45(Point(2, 12), 2, -1));
-      data.push_back(Vertex45(Point(2, 22), 2, 1));
-      data.push_back(Vertex45(Point(2, 22), 0, 1));
-      data.push_back(Vertex45(Point(10, 12), 0, 1));
-      data.push_back(Vertex45(Point(10, 12), 2, 1));
-      data.push_back(Vertex45(Point(10, 22), 2, -1));
-      data.push_back(Vertex45(Point(10, 22), 0, -1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true; 
-    }
-
-
-    class Polygon45Tiling {
-    private:
-      //definitions
-      typedef std::map<Vertex45, ActiveTail45*, lessVertex45> Polygon45FormationData;
-      typedef typename Polygon45FormationData::iterator iterator;
-      typedef typename Polygon45FormationData::const_iterator const_iterator;
-   
-      //data
-      Polygon45FormationData scanData_;
-      Unit x_;
-      int justBefore_;
-    public:
-      inline Polygon45Tiling() : scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false) {
-        lessVertex45 lessElm(&x_, &justBefore_);
-        scanData_ = Polygon45FormationData(lessElm);
-      }
-      inline Polygon45Tiling(const Polygon45Tiling& that) : 
-        scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false) { (*this) = that; }
-      inline Polygon45Tiling& operator=(const Polygon45Tiling& that) {
-        x_ = that.x_;
-        justBefore_ = that.justBefore_;
-        lessVertex45 lessElm(&x_, &justBefore_);
-        scanData_ = Polygon45FormationData(lessElm);
-        for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
-          scanData_.insert(scanData_.end(), *itr);
-        }
-        return *this;
-      }
-   
-      //cT is an output container of Polygon45 or Polygon45WithHoles
-      //iT is an iterator over Vertex45 elements
-      //inputBegin - inputEnd is a range of sorted iT that represents
-      //one or more scanline stops worth of data
-      template <class cT, class iT>
-      void scan(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "1\n";
-        while(inputBegin != inputEnd) {
-          //std::cout << "2\n";
-          x_ = (*inputBegin).pt.x();
-          //std::cout << "SCAN FORMATION " << x_ << std::endl;
-          //std::cout << "x_ = " << x_ << std::endl;
-          //std::cout << "scan line size: " << scanData_.size() << std::endl;
-          inputBegin = processEvent_(output, inputBegin, inputEnd);
-        }
-      }
-
-    private:
-      //functions
-  
-      inline void getVerticalPair_(std::pair<ActiveTail45*, ActiveTail45*>& verticalPair, 
-                                   iterator previter) {
-        ActiveTail45* iterTail = (*previter).second;
-        Point prevPoint(x_, previter->first.evalAtX(x_));
-        iterTail->pushPoint(prevPoint);
-        std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-          ActiveTail45::createActiveTail45sAsPair(prevPoint, true, 0, false);
-        verticalPair.first = iterTail;
-        verticalPair.second = tailPair.first;
-        (*previter).second = tailPair.second;
-      }
-
-      template <class cT, class cT2>
-      inline std::pair<int, ActiveTail45*> processPoint_(cT& output, cT2& elements, 
-                                                         std::pair<ActiveTail45*, ActiveTail45*>& verticalPair, 
-                                                         iterator previter, Point point, 
-                                                         Vertex45Count& counts, ActiveTail45** tails, Vertex45Count& incoming) { 
-        //std::cout << point << std::endl;
-        //std::cout << counts[0] << " ";
-        //std::cout << counts[1] << " ";
-        //std::cout << counts[2] << " ";
-        //std::cout << counts[3] << "\n";
-        //std::cout << incoming[0] << " ";
-        //std::cout << incoming[1] << " ";
-        //std::cout << incoming[2] << " ";
-        //std::cout << incoming[3] << "\n";
-        //join any closing solid corners
-        ActiveTail45* returnValue = 0;
-        std::pair<ActiveTail45*, ActiveTail45*> verticalPairOut;
-        verticalPairOut.first = 0;
-        verticalPairOut.second = 0;
-        int returnCount = 0;
-        for(int i = 0; i < 3; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] == -1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < 4; ++j) {
-              //std::cout << j << std::endl;
-              if(counts[j]) {
-                if(counts[j] == 1) {
-                  //std::cout << "case1: " << i << " " << j << std::endl;
-                  //if a figure is closed it will be written out by this function to output
-                  ActiveTail45::joinChains(point, tails[i], tails[j], true, output); 
-                  counts[i] = 0;
-                  counts[j] = 0;
-                  tails[i] = 0;
-                  tails[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-        //find any pairs of incoming edges that need to create pair for leading solid
-        //std::cout << "checking case2\n";
-        for(int i = 0; i < 3; ++i) {
-          //std::cout << i << std::endl;
-          if(incoming[i] == 1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < 4; ++j) {
-              //std::cout << j << std::endl;
-              if(incoming[j]) {
-                if(incoming[j] == -1) {
-                  //std::cout << "case2: " << i << " " << j << std::endl;
-                  //std::cout << "creating active tail pair\n";
-                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
-                  //tailPair.first->print();
-                  //tailPair.second->print();
-                  if(j == 3) {
-                    //vertical active tail becomes return value
-                    returnValue = tailPair.first;
-                    returnCount = 1;
-                  } else {
-                    Vertex45 vertex(point, i -1, incoming[i]);
-                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
-                    elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, -1), tailPair.first));
-                  }
-                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
-                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, 1), tailPair.second));
-                  incoming[i] = 0;
-                  incoming[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-
-        //find any active tail that needs to pass through to an incoming edge
-        //we expect to find no more than two pass through
-
-        //find pass through with solid on top
-        //std::cout << "checking case 3\n";
-        for(int i = 0; i < 4; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] != 0) {
-            if(counts[i] == 1) {
-              //std::cout << "fixed i\n";
-              for(int j = 3; j >= 0; --j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == 1) {
-                    //std::cout << "case3: " << i << " " << j << std::endl;
-                    //tails[i]->print();
-                    //pass through solid on top
-                    if(i != 3)
-                      tails[i]->pushPoint(point);
-                    //std::cout << "after push\n";
-                    if(j == 3) {
-                      returnValue = tails[i];
-                      returnCount = -1;
-                    } else {
-                      verticalPairOut.first = tails[i];
-                      std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-                        ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
-                      verticalPairOut.second = tailPair.first;
-                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), 
-                                                                            tailPair.second));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-        //std::cout << "checking case 4\n";
-        //find pass through with solid on bottom
-        for(int i = 3; i >= 0; --i) {
-          if(counts[i] != 0) {
-            if(counts[i] == -1) {
-              for(int j = 0; j < 4; ++j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == -1) {
-                    //std::cout << "case4: " << i << " " << j << std::endl;
-                    //pass through solid on bottom
-                    if(i == 3) {
-                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                      if(j == 3) {
-                        returnValue = tails[i];
-                        returnCount = 1;
-                      } else {
-                        tails[i]->pushPoint(point);
-                        elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tails[i]));
-                      }
-                    } else if(j == 3) {
-                      if(verticalPair.first == 0) {
-                        getVerticalPair_(verticalPair, previter);
-                      }
-                      ActiveTail45::joinChains(point, tails[i], verticalPair.first, true, output); 
-                      returnValue = verticalPair.second;
-                      returnCount = 1;
-                    } else {
-                      if(verticalPair.first == 0) {
-                        getVerticalPair_(verticalPair, previter);
-                      }
-                      ActiveTail45::joinChains(point, tails[i], verticalPair.first, true, output); 
-                      verticalPair.second->pushPoint(point);
-                      elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), 
-                                                                            verticalPair.second));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-
-        //find the end of a hole or the beginning of a hole
-
-        //find end of a hole
-        for(int i = 0; i < 3; ++i) {
-          if(counts[i] != 0) {
-            for(int j = i+1; j < 4; ++j) {
-              if(counts[j] != 0) {
-                //std::cout << "case5: " << i << " " << j << std::endl;
-                //we are ending a hole and may potentially close a figure and have to handle the hole
-                tails[i]->pushPoint(point);
-                verticalPairOut.first = tails[i];
-                if(j == 3) {
-                  verticalPairOut.second = tails[j];
-                } else {
-                  if(verticalPair.first == 0) {
-                    getVerticalPair_(verticalPair, previter);
-                  }
-                  ActiveTail45::joinChains(point, tails[j], verticalPair.first, true, output); 
-                  verticalPairOut.second = verticalPair.second;
-                }
-                tails[i] = 0;
-                tails[j] = 0;
-                counts[i] = 0;
-                counts[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        } 
-        //find beginning of a hole
-        for(int i = 0; i < 3; ++i) {
-          if(incoming[i] != 0) {
-            for(int j = i+1; j < 4; ++j) {
-              if(incoming[j] != 0) {
-                //std::cout << "case6: " << i << " " << j << std::endl;
-                //we are beginning a empty space
-                if(verticalPair.first == 0) {
-                  getVerticalPair_(verticalPair, previter);
-                }
-                verticalPair.second->pushPoint(point);
-                if(j == 3) {
-                  returnValue = verticalPair.first;
-                  returnCount = -1;
-                } else {
-                  std::pair<ActiveTail45*, ActiveTail45*> tailPair = 
-                    ActiveTail45::createActiveTail45sAsPair(point, true, 0, false);
-                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                  elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, j -1, incoming[j]), tailPair.second));
-                  verticalPairOut.second = tailPair.first;
-                  verticalPairOut.first = verticalPair.first;
-                }
-                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
-                elements.push_back(std::pair<Vertex45, ActiveTail45*>(Vertex45(point, i -1, incoming[i]), verticalPair.second));
-                incoming[i] = 0;
-                incoming[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        }
-        verticalPair = verticalPairOut;
-        //assert that verticalPair is either both null, or neither null
-        //assert that returnValue is null if verticalPair is not null
-        //assert that tails, counts and incoming are all null
-        return std::pair<int, ActiveTail45*>(returnCount, returnValue);
-      }
-
-      template <class cT, class iT>
-      inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
-        //std::cout << "processEvent_\n";
-        justBefore_ = true;
-        //collect up all elements from the tree that are at the y
-        //values of events in the input queue
-        //create vector of new elements to add into tree
-        ActiveTail45* verticalTail = 0;
-        std::pair<ActiveTail45*, ActiveTail45*> verticalPair;
-        verticalPair.first = 0;
-        verticalPair.second = 0;
-        int verticalCount = 0;
-        iT currentIter = inputBegin;
-        std::vector<iterator> elementIters;
-        std::vector<std::pair<Vertex45, ActiveTail45*> > elements;
-        while(currentIter != inputEnd && currentIter->pt.x() == x_) {
-          //std::cout << "loop\n";
-          Unit currentY = (*currentIter).pt.y();
-          iterator iter = lookUp_(currentY);
-          //int counts[4] = {0, 0, 0, 0};
-          Vertex45Count counts;
-          ActiveTail45* tails[4] = {0, 0, 0, verticalTail};
-          //std::cout << "finding elements in tree\n";
-          iterator previter = iter;
-          if(previter != scanData_.end() &&
-             previter->first.evalAtX(x_) >= currentY &&
-             previter != scanData_.begin())
-            --previter;
-          while(iter != scanData_.end() &&
-                iter->first.evalAtX(x_) == currentY) {
-            //std::cout << "loop2\n";
-            elementIters.push_back(iter);
-            int index = iter->first.rise + 1;
-            //std::cout << index << " " << iter->first.count << std::endl;
-            counts[index] = iter->first.count;
-            tails[index] = iter->second;
-            ++iter;
-          }
-          //int incoming[4] = {0, 0, 0, 0};
-          Vertex45Count incoming;
-          //std::cout << "aggregating\n";
-          do {
-            //std::cout << "loop3\n";
-            Vertex45Compact currentVertex(*currentIter);
-            incoming += currentVertex.count;
-            ++currentIter;
-          } while(currentIter != inputEnd && currentIter->pt.y() == currentY &&
-                  currentIter->pt.x() == x_);
-          //now counts and tails have the data from the left and
-          //incoming has the data from the right at this point
-          //cancel out any end points
-          //std::cout << counts[0] << " ";
-          //std::cout << counts[1] << " ";
-          //std::cout << counts[2] << " ";
-          //std::cout << counts[3] << "\n";
-          //std::cout << incoming[0] << " ";
-          //std::cout << incoming[1] << " ";
-          //std::cout << incoming[2] << " ";
-          //std::cout << incoming[3] << "\n";
-          if(verticalTail) {
-            counts[3] = -verticalCount;
-          }
-          incoming[3] *= -1;
-          for(unsigned int i = 0; i < 4; ++i) incoming[i] += counts[i];
-          //std::cout << "calling processPoint_\n";
-          std::pair<int, ActiveTail45*> result = processPoint_(output, elements, verticalPair, previter,
-                                                               Point(x_, currentY), counts, tails, incoming);
-          verticalCount = result.first;
-          verticalTail = result.second;
-          if(verticalPair.first != 0 && iter != scanData_.end() &&
-             (currentIter == inputEnd || currentIter->pt.x() != x_ ||
-              currentIter->pt.y() > (*iter).first.evalAtX(x_))) {
-            //splice vertical pair into edge above
-            ActiveTail45* tailabove = (*iter).second;
-            Point point(x_, (*iter).first.evalAtX(x_));
-            verticalPair.second->pushPoint(point);
-            ActiveTail45::joinChains(point, tailabove, verticalPair.first, true, output);
-            (*iter).second = verticalPair.second;
-            verticalPair.first = 0;
-            verticalPair.second = 0;
-          }
-        }
-        //std::cout << "erasing\n";
-        //erase all elements from the tree
-        for(typename std::vector<iterator>::iterator iter = elementIters.begin();
-            iter != elementIters.end(); ++iter) {
-          //std::cout << "erasing loop\n";
-          scanData_.erase(*iter);
-        }
-        //switch comparison tie breaking policy
-        justBefore_ = false;
-        //add new elements into tree
-        //std::cout << "inserting\n";
-        for(typename std::vector<std::pair<Vertex45, ActiveTail45*> >::iterator iter = elements.begin();
-            iter != elements.end(); ++iter) {
-          //std::cout << "inserting loop\n";
-          scanData_.insert(scanData_.end(), *iter);
-        }
-        //std::cout << "end processEvent\n";
-        return currentIter;
-      }
-   
-      inline iterator lookUp_(Unit y){
-        //if just before then we need to look from 1 not -1
-        return scanData_.lower_bound(Vertex45(Point(x_, y), -1+2*justBefore_, 0));
-      }
-   
-    };
-
-    static inline bool testPolygon45TilingRect() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true;
-    }
-
-    static inline bool testPolygon45TilingP1() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 1, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 1, -1));
-      data.push_back(Vertex45(Point(10, 10), 1, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, -1));
-      data.push_back(Vertex45(Point(10, 20), 2, 1));
-      data.push_back(Vertex45(Point(10, 20), 1, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingP2() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 1, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 1, 1));
-      data.push_back(Vertex45(Point(10, 10), 1, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, -1));
-      data.push_back(Vertex45(Point(20, 10), 1, -1));
-      data.push_back(Vertex45(Point(20, 10), 0, 1)); 
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingP3() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(20, 0), 0, -1));
-      data.push_back(Vertex45(Point(20, 0), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 1, -1));
-      data.push_back(Vertex45(Point(10, 10), 0, 1));
-      data.push_back(Vertex45(Point(20, 20), 1, 1));
-      data.push_back(Vertex45(Point(20, 20), 2, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingP4() {
-      std::cout << "testing polygon tiling p4\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), -1, 1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(20, 10), 2, 1));
-      data.push_back(Vertex45(Point(20, 10), 0, 1));
-      data.push_back(Vertex45(Point(20, -10), -1, -1));
-      data.push_back(Vertex45(Point(20, -10), 2, -1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingP5() {
-      std::cout << "testing polygon tiling P5\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, 1));
-
-      data.push_back(Vertex45(Point(1, 1), 0, -1));
-      data.push_back(Vertex45(Point(1, 1), 1, 1));
-      data.push_back(Vertex45(Point(2, 1), 0, 1));
-      data.push_back(Vertex45(Point(2, 1), 1, -1));
-      data.push_back(Vertex45(Point(2, 2), 1, -1));
-      data.push_back(Vertex45(Point(2, 2), 0, 1));
-      data.push_back(Vertex45(Point(3, 2), 1, 1));
-      data.push_back(Vertex45(Point(3, 2), 0, -1)); 
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true;
-    }
-
-    static inline bool testPolygon45TilingP6() {
-      std::cout << "testing polygon tiling P6\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 10), 2, -1));
-      data.push_back(Vertex45(Point(0, 10), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 0, -1));
-      data.push_back(Vertex45(Point(10, 0), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 0, 1));
-
-      data.push_back(Vertex45(Point(1, 1), 0, -1));
-      data.push_back(Vertex45(Point(1, 1), 2, -1));
-      data.push_back(Vertex45(Point(1, 2), 2, 1));
-      data.push_back(Vertex45(Point(1, 2), 0, 1));
-      data.push_back(Vertex45(Point(2, 1), 0, 1));
-      data.push_back(Vertex45(Point(2, 1), 2, 1));
-      data.push_back(Vertex45(Point(2, 2), 2, -1));
-      data.push_back(Vertex45(Point(2, 2), 0, -1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true;
-    }
-
-    static inline bool testPolygon45TilingStar1() {
-      std::cout << "testing polygon tiling star1\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingStar2() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-
-      Scan45 scan45;
-      std::vector<Vertex45 > result;
-      std::vector<Scan45Vertex> vertices;
-      //is a Rectnagle(0, 0, 10, 10);
-      Count2 count(1, 0);
-      Count2 ncount(-1, 0);
-      vertices.push_back(Scan45Vertex(Point(0,4), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,4), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,12), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      count = Count2(0, 1);
-      ncount = count.invert();
-      vertices.push_back(Scan45Vertex(Point(0,8), Scan45Count(count, ncount, Count2(0, 0), Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(16,8), Scan45Count(Count2(0, 0), count, ncount, Count2(0, 0))));
-      vertices.push_back(Scan45Vertex(Point(8,0), Scan45Count(ncount, Count2(0, 0), count, Count2(0, 0))));
-      sortScan45Vector(vertices);
-      std::cout << "scanning\n";
-      scan45.scan(result, vertices.begin(), vertices.end());
-   
-      std::sort(result.begin(), result.end());
-      pf.scan(polys, result.begin(), result.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingStarHole1() {
-      std::cout << "testing polygon tiling star hole 1\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-
-      data.push_back(Vertex45(Point(6, 4), 1, -1));
-      data.push_back(Vertex45(Point(6, 4), 2, -1));
-      data.push_back(Vertex45(Point(6, 8), -1, 1));
-      data.push_back(Vertex45(Point(6, 8), 2, 1));
-      data.push_back(Vertex45(Point(8, 6), -1, -1));
-      data.push_back(Vertex45(Point(8, 6), 1, 1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45TilingStarHole2() {
-      std::cout << "testing polygon tiling star hole 2\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45WithHoles> polys;
-      std::vector<Vertex45> data;
-      // result == 0 8 -1 1
-      data.push_back(Vertex45(Point(0, 8), -1, 1));
-      // result == 0 8 1 -1
-      data.push_back(Vertex45(Point(0, 8), 1, -1));
-      // result == 4 0 1 1
-      data.push_back(Vertex45(Point(4, 0), 1, 1));
-      // result == 4 0 2 1
-      data.push_back(Vertex45(Point(4, 0), 2, 1));
-      // result == 4 4 2 -1
-      data.push_back(Vertex45(Point(4, 4), 2, -1));
-      // result == 4 4 -1 -1
-      data.push_back(Vertex45(Point(4, 4), -1, -1));
-      // result == 4 12 1 1
-      data.push_back(Vertex45(Point(4, 12), 1, 1));
-      // result == 4 12 2 1
-      data.push_back(Vertex45(Point(4, 12), 2, 1));
-      // result == 4 16 2 -1
-      data.push_back(Vertex45(Point(4, 16), 2, 1));
-      // result == 4 16 -1 -1
-      data.push_back(Vertex45(Point(4, 16), -1, -1));
-      // result == 6 2 1 -1
-      data.push_back(Vertex45(Point(6, 2), 1, -1));
-      // result == 6 14 -1 1
-      data.push_back(Vertex45(Point(6, 14), -1, 1));
-      // result == 6 2 -1 1
-      data.push_back(Vertex45(Point(6, 2), -1, 1));
-      // result == 6 14 1 -1
-      data.push_back(Vertex45(Point(6, 14), 1, -1));
-      // result == 8 0 -1 -1
-      data.push_back(Vertex45(Point(8, 0), -1, -1));
-      // result == 8 0 2 -1
-      data.push_back(Vertex45(Point(8, 0), 2, -1));
-      // result == 8 4 2 1
-      data.push_back(Vertex45(Point(8, 4), 2, 1));
-      // result == 8 4 1 1
-      data.push_back(Vertex45(Point(8, 4), 1, 1));
-      // result == 8 12 -1 -1
-      data.push_back(Vertex45(Point(8, 12), -1, -1));
-      // result == 8 12 2 -1
-      data.push_back(Vertex45(Point(8, 12), 2, -1));
-      // result == 8 16 2 1
-      data.push_back(Vertex45(Point(8, 16), 2, 1));
-      // result == 8 16 1 1
-      data.push_back(Vertex45(Point(8, 16), 1, 1));
-      // result == 12 8 1 -1
-      data.push_back(Vertex45(Point(12, 8), 1, -1));
-      // result == 12 8 -1 1
-      data.push_back(Vertex45(Point(12, 8), -1, 1));
-
-      data.push_back(Vertex45(Point(6, 4), 1, -1));
-      data.push_back(Vertex45(Point(6, 4), 2, -1));
-      data.push_back(Vertex45(Point(6, 12), -1, 1));
-      data.push_back(Vertex45(Point(6, 12), 2, 1));
-      data.push_back(Vertex45(Point(10, 8), -1, -1));
-      data.push_back(Vertex45(Point(10, 8), 1, 1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-
-    static inline bool testPolygon45Tiling() {
-      std::cout << "testing polygon tiling\n";
-      Polygon45Tiling pf;
-      std::vector<Polygon45WithHoles> polys;
-      std::vector<Vertex45> data;
-   
-      data.push_back(Vertex45(Point(0, 0), 0, 1));
-      data.push_back(Vertex45(Point(0, 0), 2, 1));
-      data.push_back(Vertex45(Point(0, 100), 2, -1));
-      data.push_back(Vertex45(Point(0, 100), 0, -1));
-      data.push_back(Vertex45(Point(100, 0), 0, -1));
-      data.push_back(Vertex45(Point(100, 0), 2, -1));
-      data.push_back(Vertex45(Point(100, 100), 2, 1));
-      data.push_back(Vertex45(Point(100, 100), 0, 1));
-
-      data.push_back(Vertex45(Point(2, 2), 0, -1));
-      data.push_back(Vertex45(Point(2, 2), 2, -1));
-      data.push_back(Vertex45(Point(2, 10), 2, 1));
-      data.push_back(Vertex45(Point(2, 10), 0, 1));
-      data.push_back(Vertex45(Point(10, 2), 0, 1));
-      data.push_back(Vertex45(Point(10, 2), 2, 1));
-      data.push_back(Vertex45(Point(10, 10), 2, -1));
-      data.push_back(Vertex45(Point(10, 10), 0, -1));
-
-      data.push_back(Vertex45(Point(2, 12), 0, -1));
-      data.push_back(Vertex45(Point(2, 12), 2, -1));
-      data.push_back(Vertex45(Point(2, 22), 2, 1));
-      data.push_back(Vertex45(Point(2, 22), 0, 1));
-      data.push_back(Vertex45(Point(10, 12), 0, 1));
-      data.push_back(Vertex45(Point(10, 12), 2, 1));
-      data.push_back(Vertex45(Point(10, 22), 2, -1));
-      data.push_back(Vertex45(Point(10, 22), 0, -1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon tiling\n";
-      return true; 
-    }
-  };
-
-  template <typename Unit>
-  class PolyLine45HoleData {
-  public:
-    typedef typename polygon_45_formation<Unit>::ActiveTail45 ActiveTail45;
-    typedef typename ActiveTail45::iterator iterator;
-    
-    typedef polygon_45_concept geometry_type;
-    typedef Unit coordinate_type;
-    typedef point_data<Unit> Point;
-    typedef Point point_type;
-    //    typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
-    typedef iterator iterator_type;
-    typedef typename coordinate_traits<Unit>::area_type area_type;
-    
-    inline PolyLine45HoleData() : p_(0) {}
-    inline PolyLine45HoleData(ActiveTail45* p) : p_(p) {}
-    //use default copy and assign
-    inline iterator begin() const { return p_->getTail()->begin(); }
-    inline iterator end() const { return p_->getTail()->end(); }
-    inline unsigned int size() const { return 0; }
-    template<class iT>
-    inline PolyLine45HoleData& set(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-  private:
-    ActiveTail45* p_;
-  };
-
-  template <typename Unit>
-  class PolyLine45PolygonData {
-  public:
-    typedef typename polygon_45_formation<Unit>::ActiveTail45 ActiveTail45;
-    typedef typename ActiveTail45::iterator iterator;
-    typedef PolyLine45HoleData<Unit> holeType;
-    
-    typedef polygon_45_with_holes_concept geometry_type;
-    typedef Unit coordinate_type;
-    typedef point_data<Unit> Point;
-    typedef Point point_type;
-    //    typedef iterator_points_to_compact<iterator, Point> compact_iterator_type;
-    typedef iterator iterator_type;
-    typedef holeType hole_type;
-    typedef typename coordinate_traits<Unit>::area_type area_type;
-    class iteratorHoles {
-    private:
-      typename ActiveTail45::iteratorHoles itr_;
-    public:
-      typedef PolyLine45HoleData<Unit> holeType;
-      typedef holeType value_type;
-      typedef std::forward_iterator_tag iterator_category;
-      typedef std::ptrdiff_t difference_type;
-      typedef const value_type* pointer; //immutable
-      typedef const value_type& reference; //immutable
-      inline iteratorHoles() : itr_() {}
-      inline iteratorHoles(typename ActiveTail45::iteratorHoles itr) : itr_(itr) {}
-      inline iteratorHoles(const iteratorHoles& that) : itr_(that.itr_) {} 
-      inline iteratorHoles& operator=(const iteratorHoles& that) {
-        itr_ = that.itr_;
-        return *this;
-      }
-      inline bool operator==(const iteratorHoles& that) { return itr_ == that.itr_; }
-      inline bool operator!=(const iteratorHoles& that) { return itr_ != that.itr_; }
-      inline iteratorHoles& operator++() {
-        ++itr_;
-        return *this;
-      }
-      inline const iteratorHoles operator++(int) {
-        iteratorHoles tmp = *this;
-        ++(*this);
-        return tmp;
-      }
-      inline holeType operator*() {
-        return *itr_;
-      }
-    };
-    typedef iteratorHoles iterator_holes_type;
-    
-    
-    inline PolyLine45PolygonData() : p_(0) {}
-    inline PolyLine45PolygonData(ActiveTail45* p) : p_(p) {}
-    //use default copy and assign
-    inline iterator begin() const { return p_->getTail()->begin(); }
-    inline iterator end() const { return p_->getTail()->end(); }
-    inline iteratorHoles begin_holes() const { return iteratorHoles(p_->getHoles().begin()); }
-    inline iteratorHoles end_holes() const { return iteratorHoles(p_->getHoles().end()); }
-    inline ActiveTail45* yield() { return p_; }
-    //stub out these four required functions that will not be used but are needed for the interface
-    inline unsigned int size_holes() const { return 0; }
-    inline unsigned int size() const { return 0; }
-    template<class iT>
-    inline PolyLine45PolygonData& set(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-    
-    // initialize a polygon from x,y values, it is assumed that the first is an x
-    // and that the input is a well behaved polygon
-    template<class iT>
-    inline PolyLine45PolygonData& set_holes(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-  private:
-    ActiveTail45* p_;
-  };
-
-  template <typename T>
-  struct PolyLineByConcept<T, polygon_45_with_holes_concept> { typedef PolyLine45PolygonData<T> type; };
-  template <typename T>
-  struct PolyLineByConcept<T, polygon_with_holes_concept> { typedef PolyLine45PolygonData<T> type; };
-  template <typename T>
-  struct PolyLineByConcept<T, polygon_45_concept> { typedef PolyLine45HoleData<T> type; };
-  template <typename T>
-  struct PolyLineByConcept<T, polygon_concept> { typedef PolyLine45HoleData<T> type; };
-
-  template <typename T>
-  struct geometry_concept<PolyLine45PolygonData<T> > { typedef polygon_45_with_holes_concept type; };
-  template <typename T>
-  struct geometry_concept<PolyLine45HoleData<T> > { typedef polygon_45_concept type; };
-}
-}
-#endif
Modified: sandbox/gtl/boost/polygon/polygon_45_set_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_set_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_45_set_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,11 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_45_SET_CONCEPT_HPP
-#define GTL_POLYGON_45_SET_CONCEPT_HPP
+#ifndef BOOST_POLYGON_POLYGON_45_SET_CONCEPT_HPP
+#define BOOST_POLYGON_POLYGON_45_SET_CONCEPT_HPP
+#include "polygon_45_set_data.hpp"
+#include "polygon_45_set_traits.hpp"
+#include "detail/polygon_45_touch.hpp"
 namespace boost { namespace polygon{
 
   template <typename T, typename T2>
@@ -345,6 +348,94 @@
     assign(polygon_set, polys);
     return polygon_set;
   }
+
+  template <typename T>
+  struct view_of<polygon_90_set_concept, T> {
+    typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
+    T* tp;
+    std::vector<polygon_90_with_holes_data<coordinate_type> > polys;
+    view_of(T& obj) : tp(&obj), polys() {
+      std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
+      assign(gpolys, obj);
+      for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
+          itr != gpolys.end(); ++itr) {
+        polys.push_back(polygon_90_with_holes_data<coordinate_type>());
+        assign(polys.back(), view_as<polygon_90_with_holes_concept>(*itr));
+      }
+    }
+    view_of(const T& obj) : tp(), polys() {
+      std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
+      assign(gpolys, obj);
+      for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
+          itr != gpolys.end(); ++itr) {
+        polys.push_back(polygon_90_with_holes_data<coordinate_type>());
+        assign(polys.back(), view_as<polygon_90_with_holes_concept>(*itr));
+      }
+    }
+
+    typedef typename std::vector<polygon_90_with_holes_data<coordinate_type> >::const_iterator iterator_type;
+    typedef view_of operator_arg_type;
+
+    inline iterator_type begin() const {
+      return polys.begin();
+    }
+
+    inline iterator_type end() const {
+      return polys.end();
+    }
+
+    inline orientation_2d orient() const { return HORIZONTAL; }
+
+    inline bool clean() const { return false; }
+
+    inline bool sorted() const { return false; }
+
+    inline T& get() { return *tp; }
+
+  };
+
+  template <typename T>
+  struct polygon_90_set_traits<view_of<polygon_90_set_concept, T> > {
+    typedef typename view_of<polygon_90_set_concept, T>::coordinate_type coordinate_type;
+    typedef typename view_of<polygon_90_set_concept, T>::iterator_type iterator_type;
+    typedef view_of<polygon_90_set_concept, T> operator_arg_type;
+
+    static inline iterator_type begin(const view_of<polygon_90_set_concept, T>& polygon_set) {
+      return polygon_set.begin();
+    }
+
+    static inline iterator_type end(const view_of<polygon_90_set_concept, T>& polygon_set) {
+      return polygon_set.end();
+    }
+
+    static inline orientation_2d orient(const view_of<polygon_90_set_concept, T>& polygon_set) { 
+      return polygon_set.orient(); }
+
+    static inline bool clean(const view_of<polygon_90_set_concept, T>& polygon_set) { 
+      return polygon_set.clean(); }
+
+    static inline bool sorted(const view_of<polygon_90_set_concept, T>& polygon_set) { 
+      return polygon_set.sorted(); }
+
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_90_set_concept, T> > {
+    typedef polygon_90_set_concept type;
+  };
+
+  template <typename T>
+  struct get_coordinate_type<view_of<polygon_90_set_concept, T>, polygon_90_set_concept> {
+    typedef typename view_of<polygon_90_set_concept, T>::coordinate_type type;
+  };
+  template <typename T>
+  struct get_iterator_type_2<view_of<polygon_90_set_concept, T>, polygon_90_set_concept> {
+    typedef typename view_of<polygon_90_set_concept, T>::iterator_type type;
+    static type begin(const view_of<polygon_90_set_concept, T>& t) { return t.begin(); }
+    static type end(const view_of<polygon_90_set_concept, T>& t) { return t.end(); }
+  };
+
 }
 }
+#include "detail/polygon_45_set_view.hpp"
 #endif
Modified: sandbox/gtl/boost/polygon/polygon_45_set_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_set_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_45_set_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,11 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_45_SET_DATA_HPP
-#define GTL_POLYGON_45_SET_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_45_SET_DATA_HPP
+#define BOOST_POLYGON_POLYGON_45_SET_DATA_HPP
+#include "polygon_90_set_data.hpp"
+#include "detail/boolean_op_45.hpp"
+#include "detail/polygon_45_formation.hpp"
 namespace boost { namespace polygon{
 
   enum RoundingOption { CLOSEST = 0, OVERSIZE = 1, UNDERSIZE = 2, SQRT2 = 3, SQRT1OVER2 = 4 };
Modified: sandbox/gtl/boost/polygon/polygon_45_set_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_set_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_45_set_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_45_SET_TRAITS_HPP
-#define GTL_POLYGON_45_SET_TRAITS_HPP
+#ifndef BOOST_POLYGON_POLYGON_45_SET_TRAITS_HPP
+#define BOOST_POLYGON_POLYGON_45_SET_TRAITS_HPP
 namespace boost { namespace polygon{
 
   //default definition of polygon 45 set traits works for any model of polygon 45, polygon 45 with holes or any vector or list thereof
Deleted: sandbox/gtl/boost/polygon/polygon_45_set_view.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,342 +0,0 @@
-/*
-  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 GTL_POLYGON_45_SET_VIEW_HPP
-#define GTL_POLYGON_45_SET_VIEW_HPP
-namespace boost { namespace polygon{
-
-  template <typename ltype, typename rtype, int op_type>
-  class polygon_45_set_view;
-
-  template <typename ltype, typename rtype, int op_type>
-  struct polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> > {
-    typedef typename polygon_45_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
-    typedef typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
-    typedef typename polygon_45_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
-
-    static inline iterator_type begin(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set); 
-    static inline iterator_type end(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set);
-
-    template <typename input_iterator_type>
-    static inline void set(polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set, 
-                           input_iterator_type input_begin, input_iterator_type input_end);
-
-    static inline bool clean(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set);
-
-  };
-
-  template <typename value_type, typename ltype, typename rtype, int op_type>
-  struct compute_45_set_value {
-    static
-    void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_) {
-      output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
-                  polygon_45_set_traits<ltype>::end(lvalue_));
-      value_type rinput_;
-      rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
-                  polygon_45_set_traits<rtype>::end(rvalue_));
-      if(op_type == 0)
-        output_ |= rinput_;
-      else if(op_type == 1)
-        output_ &= rinput_;
-      else if(op_type == 2)
-        output_ ^= rinput_;
-      else
-        output_ -= rinput_;
-    }
-  };
-
-  template <typename value_type, typename ltype, typename rcoord, int op_type>
-  struct compute_45_set_value<value_type, ltype, polygon_45_set_data<rcoord>, op_type> {
-    static
-    void value(value_type& output_, const ltype& lvalue_, const polygon_45_set_data<rcoord>& rvalue_) {
-      output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
-                  polygon_45_set_traits<ltype>::end(lvalue_));
-      if(op_type == 0)
-        output_ |= rvalue_;
-      else if(op_type == 1)
-        output_ &= rvalue_;
-      else if(op_type == 2)
-        output_ ^= rvalue_;
-      else
-        output_ -= rvalue_;
-    }
-  };
-
-  template <typename ltype, typename rtype, int op_type>
-  class polygon_45_set_view {
-  public:
-    typedef typename polygon_45_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_45_set_data<coordinate_type> value_type;
-    typedef typename value_type::iterator_type iterator_type;
-    typedef polygon_45_set_view operator_arg_type;
-  private:
-    const ltype& lvalue_;
-    const rtype& rvalue_;
-    mutable value_type output_;
-    mutable bool evaluated_;
-  public:
-    polygon_45_set_view(const ltype& lvalue,
-                        const rtype& rvalue ) :
-      lvalue_(lvalue), rvalue_(rvalue), output_(), evaluated_(false) {}
-
-    // get iterator to begin vertex data
-  public:
-    const value_type& value() const {
-      if(!evaluated_) {
-        evaluated_ = true;
-        compute_45_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_);
-      }
-      return output_;
-    }
-  public:
-    iterator_type begin() const { return value().begin(); }
-    iterator_type end() const { return value().end(); }
-
-    bool dirty() const { return value().dirty(); } //result of a boolean is clean
-    bool sorted() const { return value().sorted(); } //result of a boolean is sorted
-
-    //     template <typename input_iterator_type>
-    //     void set(input_iterator_type input_begin, input_iterator_type input_end, 
-    //              orientation_2d orient) const {
-    //       orient_ = orient;
-    //       output_.clear();
-    //       output_.insert(output_.end(), input_begin, input_end);
-    //       std::sort(output_.begin(), output_.end());
-    //     }
-  };
-
-  template <typename ltype, typename rtype, int op_type>
-  typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
-  begin(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
-    return polygon_45_set.begin();
-  }
-  template <typename ltype, typename rtype, int op_type>
-  typename polygon_45_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
-  end(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) {
-    return polygon_45_set.end();
-  }
-  template <typename ltype, typename rtype, int op_type>
-  bool polygon_45_set_traits<polygon_45_set_view<ltype, rtype, op_type> >::
-  clean(const polygon_45_set_view<ltype, rtype, op_type>& polygon_45_set) { 
-    return polygon_45_set.value().clean(); }
-
-  template <typename geometry_type_1, typename geometry_type_2, int op_type>
-  geometry_type_1& self_assignment_boolean_op_45(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
-    typedef geometry_type_1 ltype;
-    typedef geometry_type_2 rtype;
-    typedef typename polygon_45_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_45_set_data<coordinate_type> value_type;
-    value_type output_;
-    value_type rinput_;
-    output_.set(polygon_45_set_traits<ltype>::begin(lvalue_),
-                polygon_45_set_traits<ltype>::end(lvalue_));
-    rinput_.set(polygon_45_set_traits<rtype>::begin(rvalue_),
-                polygon_45_set_traits<rtype>::end(rvalue_));
-    if(op_type == 0)
-      output_ |= rinput_;
-    else if(op_type == 1)
-      output_ &= rinput_;
-    else if(op_type == 2)
-      output_ ^= rinput_;
-    else
-      output_ -= rinput_;
-    polygon_45_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end());
-    return lvalue_;
-  }
-
-  template <typename concept_type>
-  struct fracture_holes_option_by_type {
-    static const bool value = true;
-  };
-  template <>
-  struct fracture_holes_option_by_type<polygon_45_with_holes_concept> {
-    static const bool value = false;
-  };
-  template <>
-  struct fracture_holes_option_by_type<polygon_with_holes_concept> {
-    static const bool value = false;
-  };
-
-  template <typename ltype, typename rtype, int op_type>
-  struct geometry_concept<polygon_45_set_view<ltype, rtype, op_type> > { typedef polygon_45_set_concept type; };
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and_3< 
-    typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
-    typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
-    typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
-                       polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type 
-  operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
-      (lvalue, rvalue);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
-#ifdef __ICC 
-      ::type
-#endif
-  ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 0> >::type 
-  operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_45_set_view<geometry_type_1, geometry_type_2, 0>
-      (lvalue, rvalue);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
-                                           typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
-                                           typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
-                       polygon_45_set_view<geometry_type_1, geometry_type_2, 1> >::type 
-  operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_45_set_view<geometry_type_1, geometry_type_2, 1>
-      (lvalue, rvalue);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>::type,
-                                           typename is_polygon_45_or_90_set_type<geometry_type_2>::type,
-                                           typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>::type,
-                       polygon_45_set_view<geometry_type_1, geometry_type_2, 2> >::type 
-  operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_45_set_view<geometry_type_1, geometry_type_2, 2>
-      (lvalue, rvalue);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and_3< typename is_polygon_45_or_90_set_type<geometry_type_1>
-#ifdef __ICC 
-      ::type
-#endif
-  ::type, typename is_polygon_45_or_90_set_type<geometry_type_2>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, typename is_either_polygon_45_set_type<geometry_type_1, geometry_type_2>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, polygon_45_set_view<geometry_type_1, geometry_type_2, 3> >::type 
-  operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_45_set_view<geometry_type_1, geometry_type_2, 3>
-      (lvalue, rvalue);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 0>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< 
-    typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-    typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 1>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< 
-    typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                      typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-    geometry_type_1>::type &
-  operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 2>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_45_or_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op_45<geometry_type_1, geometry_type_2, 3>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_45_set_type<geometry_type_1>::type, 
-                                         typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
-                                                                coordinate_concept>::type>::type,
-                       geometry_type_1>::type &
-  operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    return resize(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>::type, 
-                                         typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
-                                                                coordinate_concept>::type>::type,
-                       geometry_type_1>::type &
-  operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    return resize(lvalue, -rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
-                                 coordinate_concept>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, geometry_type_1>::type
-  operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    geometry_type_1 retval(lvalue);
-    retval += rvalue;
-    return retval;
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<geometry_type_1>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, 
-                                 coordinate_concept>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type, geometry_type_1>::type
-  operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    geometry_type_1 retval(lvalue);
-    retval -= rvalue;
-    return retval;
-  }
-}
-}
-#endif
-
Deleted: sandbox/gtl/boost/polygon/polygon_45_touch.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_touch.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,275 +0,0 @@
-/*
-  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 GTL_POLYGON_45_TOUCH_HPP
-#define GTL_POLYGON_45_TOUCH_HPP
-namespace boost { namespace polygon{
-
-  template <typename Unit>
-  struct polygon_45_touch {
-
-    typedef point_data<Unit> Point;
-    typedef typename coordinate_traits<Unit>::manhattan_area_type LongUnit;
-
-    template <typename property_map>
-    static inline void merge_property_maps(property_map& mp, const property_map& mp2, bool subtract = false) {
-      property_map newmp;
-      newmp.reserve(mp.size() + mp2.size());
-      unsigned int i = 0;
-      unsigned int j = 0;
-      while(i != mp.size() && j != mp2.size()) {
-        if(mp[i].first < mp2[j].first) {
-          newmp.push_back(mp[i]);
-          ++i;
-        } else if(mp[i].first > mp2[j].first) {
-          newmp.push_back(mp2[j]);
-          if(subtract) newmp.back().second *= -1;
-          ++j;
-        } else {
-          int count = mp[i].second;
-          if(subtract) count -= mp2[j].second;
-          else count += mp2[j].second; 
-          if(count) {
-            newmp.push_back(mp[i]);
-            newmp.back().second = count;
-          }
-          ++i;
-          ++j;
-        }
-      }
-      while(i != mp.size()) {
-        newmp.push_back(mp[i]);
-        ++i;
-      }
-      while(j != mp2.size()) {
-        newmp.push_back(mp2[j]);
-        if(subtract) newmp.back().second *= -1;
-        ++j;
-      }
-      mp.swap(newmp);
-    }
-
-    class CountTouch {
-    public:
-      inline CountTouch() : counts() {}
-      //inline CountTouch(int count) { counts[0] = counts[1] = count; }
-      //inline CountTouch(int count1, int count2) { counts[0] = count1; counts[1] = count2; }
-      inline CountTouch(const CountTouch& count) : counts(count.counts) {}
-      inline bool operator==(const CountTouch& count) const { return counts == count.counts; }
-      inline bool operator!=(const CountTouch& count) const { return !((*this) == count); }
-      //inline CountTouch& operator=(int count) { counts[0] = counts[1] = count; return *this; }
-      inline CountTouch& operator=(const CountTouch& count) { counts = count.counts; return *this; }
-      inline int& operator[](int index) { 
-        std::vector<std::pair<int, int> >::iterator itr = lower_bound(counts.begin(), counts.end(), std::make_pair(index, int(0)));
-        if(itr != counts.end() && itr->first == index) {
-            return itr->second;
-        }
-        itr = counts.insert(itr, std::make_pair(index, int(0)));
-        return itr->second;
-      }
-//       inline int operator[](int index) const {
-//         std::vector<std::pair<int, int> >::const_iterator itr = counts.begin();
-//         for( ; itr != counts.end() && itr->first <= index; ++itr) {
-//           if(itr->first == index) {
-//             return itr->second;
-//           }
-//         }
-//         return 0;
-//       }
-      inline CountTouch& operator+=(const CountTouch& count){
-        merge_property_maps(counts, count.counts, false);
-        return *this;
-      }
-      inline CountTouch& operator-=(const CountTouch& count){
-        merge_property_maps(counts, count.counts, true);
-        return *this;
-      }
-      inline CountTouch operator+(const CountTouch& count) const {
-        return CountTouch(*this)+=count;
-      }
-      inline CountTouch operator-(const CountTouch& count) const {
-        return CountTouch(*this)-=count;
-      }
-      inline CountTouch invert() const {
-        CountTouch retval;
-        retval -= *this;
-        return retval;
-      }
-      std::vector<std::pair<int, int> > counts;
-    };
-
-    typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::map<int, std::set<int> > > map_graph_o; 
-    typedef std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, std::vector<std::set<int> > > vector_graph_o; 
-
-    template <typename cT>
-    static void process_previous_x(cT& output) {
-      std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
-      for(typename std::map<Unit, std::set<int> >::iterator itr = y_prop_map.begin();
-          itr != y_prop_map.end(); ++itr) {
-        for(std::set<int>::iterator inner_itr = itr->second.begin();
-            inner_itr != itr->second.end(); ++inner_itr) {
-          std::set<int>& output_edges = (*(output.second))[*inner_itr];
-          std::set<int>::iterator inner_inner_itr = inner_itr;
-          ++inner_inner_itr;
-          for( ; inner_inner_itr != itr->second.end(); ++inner_inner_itr) {
-            output_edges.insert(output_edges.end(), *inner_inner_itr);
-            std::set<int>& output_edges_2 = (*(output.second))[*inner_inner_itr];
-            output_edges_2.insert(output_edges_2.end(), *inner_itr);
-          }
-        }
-      }
-      y_prop_map.clear();
-    }
-    
-    struct touch_45_output_functor {
-      template <typename cT>
-      void operator()(cT& output, const CountTouch& count1, const CountTouch& count2, 
-                      const Point& pt, int rise, direction_1d end) {
-        Unit& x = output.first.first;
-        std::map<Unit, std::set<int> >& y_prop_map = output.first.second;
-        if(pt.x() != x) process_previous_x(output);
-        x = pt.x();
-        std::set<int>& output_set = y_prop_map[pt.y()];
-        for(std::vector<std::pair<int, int> >::const_iterator itr1 = count1.counts.begin();
-            itr1 != count1.counts.end(); ++itr1) {
-          if(itr1->second > 0) {
-            output_set.insert(output_set.end(), itr1->first);
-          } 
-        }
-        for(std::vector<std::pair<int, int> >::const_iterator itr2 = count2.counts.begin();
-            itr2 != count2.counts.end(); ++itr2) {
-          if(itr2->second > 0) {
-            output_set.insert(output_set.end(), itr2->first);
-          }
-        }
-      }
-    };
-    typedef typename std::pair<Point, 
-                               typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > Vertex45Compact;
-    typedef std::vector<Vertex45Compact> TouchSetData;
-    
-    struct lessVertex45Compact {
-      bool operator()(const Vertex45Compact& l, const Vertex45Compact& r) {
-        return l.first < r.first;
-      }
-    };
-    
-    template <typename TSD>
-    static void print_tsd(TSD& tsd) {
-      for(unsigned int i = 0; i < tsd.size(); ++i) {
-        std::cout << tsd[i].first << ": ";
-        for(unsigned int r = 0; r < 4; ++r) {
-          std::cout << r << " { ";
-          for(std::vector<std::pair<int, int> >::iterator itr = tsd[i].second[r].counts.begin();
-              itr != tsd[i].second[r].counts.end(); ++itr) {
-            std::cout << itr->first << "," << itr->second << " ";
-          } std::cout << "} ";
-        }
-      } std::cout << std::endl;
-    }
-
-    template <typename T>
-    static void print_scanline(T& t) {
-      for(typename T::iterator itr = t.begin(); itr != t.end(); ++itr) {
-        std::cout << itr->x << "," << itr->y << " " << itr->rise << " ";
-        for(std::vector<std::pair<int, int> >::iterator itr2 = itr->count.counts.begin();
-            itr2 != itr->count.counts.end(); ++itr2) {
-          std::cout << itr2->first << ":" << itr2->second << " ";
-        } std::cout << std::endl;
-      }
-    }
-
-    template <typename graph_type>
-    static void performTouch(graph_type& graph, TouchSetData& tsd) {
-      
-      std::sort(tsd.begin(), tsd.end(), lessVertex45Compact());
-      typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountTouch> > > TSD;
-      TSD tsd_;
-      tsd_.reserve(tsd.size());
-      for(typename TouchSetData::iterator itr = tsd.begin(); itr != tsd.end(); ) {
-        typename TouchSetData::iterator itr2 = itr;
-        ++itr2;
-        for(; itr2 != tsd.end() && itr2->first == itr->first; ++itr2) {
-          (itr->second) += (itr2->second); //accumulate
-        }
-        tsd_.push_back(std::make_pair(itr->first, itr->second));
-        itr = itr2;
-      }
-      std::pair<std::pair<Unit, std::map<Unit, std::set<int> > >, graph_type*> output
-        (std::make_pair(std::make_pair((std::numeric_limits<Unit>::max)(), std::map<Unit, std::set<int> >()), &graph));
-      typename boolean_op_45<Unit>::template Scan45<CountTouch, touch_45_output_functor> scanline;
-      for(typename TSD::iterator itr = tsd_.begin(); itr != tsd_.end(); ) {
-        typename TSD::iterator itr2 = itr;
-        ++itr2;
-        while(itr2 != tsd_.end() && itr2->first.x() == itr->first.x()) {
-          ++itr2;
-        }
-        scanline.scan(output, itr, itr2);
-        itr = itr2;
-      }
-      process_previous_x(output);
-    }
-
-    template <typename iT>
-    static void populateTouchSetData(TouchSetData& tsd, iT begin, iT end, int nodeCount) {
-      for( ; begin != end; ++begin) {
-        Vertex45Compact vertex;
-        vertex.first = typename Vertex45Compact::first_type(begin->pt.x() * 2, begin->pt.y() * 2);
-        tsd.push_back(vertex);
-        for(unsigned int i = 0; i < 4; ++i) {
-          if(begin->count[i]) {
-            tsd.back().second[i][nodeCount] += begin->count[i];
-          }
-        }
-      }
-    }
-    
-  };
-
-  //ConnectivityExtraction computes the graph of connectivity between rectangle, polygon and
-  //polygon set graph nodes where an edge is created whenever the geometry in two nodes overlap
-  template <typename coordinate_type>
-  class connectivity_extraction_45 {
-  private:
-    typedef typename coordinate_traits<coordinate_type>::manhattan_area_type big_coord;
-    typedef typename polygon_45_touch<big_coord>::TouchSetData tsd;
-    tsd tsd_;
-    unsigned int nodeCount_;
-  public:
-    inline connectivity_extraction_45() : tsd_(), nodeCount_(0) {}
-    inline connectivity_extraction_45(const connectivity_extraction_45& that) : tsd_(that.tsd_),
-                                                                          nodeCount_(that.nodeCount_) {}
-    inline connectivity_extraction_45& operator=(const connectivity_extraction_45& that) { 
-      tsd_ = that.tsd_; 
-      nodeCount_ = that.nodeCount_; {}
-      return *this;
-    }
-    
-    //insert a polygon set graph node, the value returned is the id of the graph node
-    inline unsigned int insert(const polygon_45_set_data<coordinate_type>& ps) {
-      ps.clean();
-      polygon_45_touch<big_coord>::populateTouchSetData(tsd_, ps.begin(), ps.end(), nodeCount_);
-      return nodeCount_++;
-    }
-    template <class GeoObjT>
-    inline unsigned int insert(const GeoObjT& geoObj) {
-      polygon_45_set_data<coordinate_type> ps;
-      ps.insert(geoObj);
-      return insert(ps);
-    }
-    
-    //extract connectivity and store the edges in the graph
-    //graph must be indexable by graph node id and the indexed value must be a std::set of
-    //graph node id
-    template <class GraphT>
-    inline void extract(GraphT& graph) {
-      polygon_45_touch<big_coord>::performTouch(graph, tsd_);
-    }
-  };
-}
-}
-#endif 
Modified: sandbox/gtl/boost/polygon/polygon_45_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_45_with_holes_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_45_with_holes_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,10 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_45_WITH_HOLES_DATA_HPP
-#define GTL_POLYGON_45_WITH_HOLES_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_45_WITH_HOLES_DATA_HPP
+#define BOOST_POLYGON_POLYGON_45_WITH_HOLES_DATA_HPP
+#include "isotropy.hpp"
+#include "polygon_45_data.hpp"
 namespace boost { namespace polygon{
 struct polygon_45_with_holes_concept;
 template <typename T>
@@ -63,6 +65,9 @@
     return *this;
   }
 
+  template <typename T2>
+  inline polygon_45_with_holes_data& operator=(const T2& rvalue);
+
   // get begin iterator, returns a pointer to a const coordinate_type
   inline const iterator_type begin() const {
     return self_.begin();
Modified: sandbox/gtl/boost/polygon/polygon_90_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_90_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_90_DATA_HPP
-#define GTL_POLYGON_90_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_90_DATA_HPP
+#define BOOST_POLYGON_POLYGON_90_DATA_HPP
 namespace boost { namespace polygon{
 struct polygon_90_concept;
 template <typename T>
Modified: sandbox/gtl/boost/polygon/polygon_90_set_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_set_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_90_set_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,10 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_90_SET_CONCEPT_HPP
-#define GTL_POLYGON_90_SET_CONCEPT_HPP
+#ifndef BOOST_POLYGON_POLYGON_90_SET_CONCEPT_HPP
+#define BOOST_POLYGON_POLYGON_90_SET_CONCEPT_HPP
+#include "polygon_90_set_data.hpp"
+#include "polygon_90_set_traits.hpp"
 namespace boost { namespace polygon{
 
   template <typename polygon_set_type>
@@ -536,6 +538,9 @@
     assign(polygon_set, polys);
     return polygon_set;
   }
+
+
 }
 }
+#include "detail/polygon_90_set_view.hpp"
 #endif
Modified: sandbox/gtl/boost/polygon/polygon_90_set_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_set_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_90_set_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,27 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_90_SET_DATA_HPP
-#define GTL_POLYGON_90_SET_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_90_SET_DATA_HPP
+#define BOOST_POLYGON_POLYGON_90_SET_DATA_HPP
+#include "isotropy.hpp"
+#include "point_concept.hpp"
+#include "point_3d_concept.hpp"
+#include "transform.hpp"
+#include "interval_concept.hpp"
+#include "rectangle_concept.hpp"
+#include "detail/iterator_points_to_compact.hpp"
+#include "detail/iterator_compact_to_points.hpp"
+#include "polygon_traits.hpp"
+
+//manhattan boolean algorithms
+#include "detail/boolean_op.hpp"
+#include "detail/polygon_formation.hpp"
+#include "detail/rectangle_formation.hpp"
+#include "detail/max_cover.hpp"
+#include "detail/property_merge.hpp"
+#include "detail/polygon_90_touch.hpp"
+#include "detail/iterator_geometry_to_set.hpp"
+
 namespace boost { namespace polygon{
   template <typename ltype, typename rtype, typename op_type>
   class polygon_90_set_view;
Modified: sandbox/gtl/boost/polygon/polygon_90_set_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_set_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_90_set_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_90_SET_TRAITS_HPP
-#define GTL_POLYGON_90_SET_TRAITS_HPP
+#ifndef BOOST_POLYGON_POLYGON_90_SET_TRAITS_HPP
+#define BOOST_POLYGON_POLYGON_90_SET_TRAITS_HPP
 namespace boost { namespace polygon{
 
   struct polygon_90_set_concept {};
Deleted: sandbox/gtl/boost/polygon/polygon_90_set_view.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,438 +0,0 @@
-/*
-  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 GTL_POLYGON_90_SET_VIEW_HPP
-#define GTL_POLYGON_90_SET_VIEW_HPP
-namespace boost { namespace polygon{
-  struct operator_provides_storage {};
-  struct operator_requires_copy {};
-
-  template <typename value_type, typename arg_type>
-  inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient);
-
-  template <typename ltype, typename rtype, typename op_type>
-  class polygon_90_set_view;
-
-  template <typename ltype, typename rtype, typename op_type>
-  struct polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> > {
-    typedef typename polygon_90_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
-    typedef typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
-    typedef typename polygon_90_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
-
-    static inline iterator_type begin(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set); 
-    static inline iterator_type end(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
-
-    static inline orientation_2d orient(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
-
-    static inline bool clean(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
-
-    static inline bool sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set);
-  };
-
-  template <typename value_type, typename ltype, typename rtype, typename op_type>
-  struct compute_90_set_value {
-    static
-    void value(value_type& output_, const ltype& lvalue_, const rtype& rvalue_, orientation_2d orient_) {
-      value_type linput_(orient_);
-      value_type rinput_(orient_);
-      insert_into_view_arg(linput_, lvalue_, orient_);
-      insert_into_view_arg(rinput_, rvalue_, orient_);
-      output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
-                                   rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
-    }
-  };
-
-  template <typename value_type, typename lcoord, typename rcoord, typename op_type>
-  struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, polygon_90_set_data<rcoord>, op_type> {
-    static
-    void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
-               const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
-      lvalue_.sort();
-      rvalue_.sort();
-      output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
-                                   rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); 
-    }
-  };
-
-  template <typename value_type, typename lcoord, typename rtype, typename op_type>
-  struct compute_90_set_value<value_type, polygon_90_set_data<lcoord>, rtype, op_type> {
-    static
-    void value(value_type& output_, const polygon_90_set_data<lcoord>& lvalue_,
-               const rtype& rvalue_, orientation_2d orient_) {
-      value_type rinput_(orient_);
-      lvalue_.sort();
-      insert_into_view_arg(rinput_, rvalue_, orient_);
-      output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
-                                   rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
-    }
-  };
-
-  template <typename value_type, typename ltype, typename rcoord, typename op_type>
-  struct compute_90_set_value<value_type, ltype, polygon_90_set_data<rcoord>, op_type> {
-    static
-    void value(value_type& output_, const ltype& lvalue_,
-               const polygon_90_set_data<rcoord>& rvalue_, orientation_2d orient_) {
-      value_type linput_(orient_);
-      insert_into_view_arg(linput_, lvalue_, orient_);
-      rvalue_.sort();
-      output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
-                                   rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>()); 
-    }
-  };
-
-  template <typename ltype, typename rtype, typename op_type>
-  class polygon_90_set_view {
-  public:
-    typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_90_set_data<coordinate_type> value_type;
-    typedef typename value_type::iterator_type iterator_type;
-    typedef polygon_90_set_view operator_arg_type;
-  private:
-    const ltype& lvalue_;
-    const rtype& rvalue_;
-    orientation_2d orient_;
-    op_type op_;
-    mutable value_type output_;
-    mutable bool evaluated_;
-  public:
-    polygon_90_set_view(const ltype& lvalue,
-                     const rtype& rvalue,
-                     orientation_2d orient,
-                     op_type op) :
-      lvalue_(lvalue), rvalue_(rvalue), orient_(orient), op_(op), output_(orient), evaluated_(false) {}
-
-    // get iterator to begin vertex data
-  private:
-    const value_type& value() const {
-      if(!evaluated_) {
-        evaluated_ = true;
-        compute_90_set_value<value_type, ltype, rtype, op_type>::value(output_, lvalue_, rvalue_, orient_);
-      }
-      return output_;
-    }
-  public:
-    iterator_type begin() const { return value().begin(); }
-    iterator_type end() const { return value().end(); }
-
-    orientation_2d orient() const { return orient_; }
-    bool dirty() const { return false; } //result of a boolean is clean
-    bool sorted() const { return true; } //result of a boolean is sorted
-
-//     template <typename input_iterator_type>
-//     void set(input_iterator_type input_begin, input_iterator_type input_end, 
-//              orientation_2d orient) const {
-//       orient_ = orient;
-//       output_.clear();
-//       output_.insert(output_.end(), input_begin, input_end);
-//       std::sort(output_.begin(), output_.end());
-//     }
-    void sort() const {} //is always sorted
-  };
-
-  template <typename ltype, typename rtype, typename op_type>
-  struct geometry_concept<polygon_90_set_view<ltype, rtype, op_type> > {
-    typedef polygon_90_set_concept type;
-  };
-
-  template <typename ltype, typename rtype, typename op_type>
-  typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-  begin(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
-    return polygon_set.begin();
-  }
-  template <typename ltype, typename rtype, typename op_type>
-  typename polygon_90_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-  end(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) {
-    return polygon_set.end();
-  }
-//   template <typename ltype, typename rtype, typename op_type>
-//   template <typename input_iterator_type>
-//   void polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-//   set(polygon_90_set_view<ltype, rtype, op_type>& polygon_set, 
-//       input_iterator_type input_begin, input_iterator_type input_end,
-//       orientation_2d orient) {
-//     polygon_set.set(input_begin, input_end, orient);
-//   }
-  template <typename ltype, typename rtype, typename op_type>
-  orientation_2d polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-  orient(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
-    return polygon_set.orient(); }
-  template <typename ltype, typename rtype, typename op_type>
-  bool polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-  clean(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
-    return true; }
-  template <typename ltype, typename rtype, typename op_type>
-  bool polygon_90_set_traits<polygon_90_set_view<ltype, rtype, op_type> >::
-  sorted(const polygon_90_set_view<ltype, rtype, op_type>& polygon_set) { 
-    return true; }
-
-  template <typename value_type, typename arg_type>
-  inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient) {
-    typedef typename polygon_90_set_traits<arg_type>::iterator_type literator;
-    literator itr1, itr2;
-    itr1 = polygon_90_set_traits<arg_type>::begin(arg);
-    itr2 = polygon_90_set_traits<arg_type>::end(arg);
-    dest.insert(itr1, itr2, orient);
-    dest.sort();
-  }
-  
-  template <typename T>
-  template <typename ltype, typename rtype, typename op_type>
-  inline polygon_90_set_data<T>& polygon_90_set_data<T>::operator=(const polygon_90_set_view<ltype, rtype, op_type>& that) {
-    set(that.begin(), that.end(), that.orient());
-    dirty_ = false;
-    unsorted_ = false;
-    return *this;
-  }
-  
-  template <typename T>
-  template <typename ltype, typename rtype, typename op_type>
-  inline polygon_90_set_data<T>::polygon_90_set_data(const polygon_90_set_view<ltype, rtype, op_type>& that) :
-    orient_(that.orient()), data_(that.begin(), that.end()), dirty_(false), unsorted_(false) {}
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  struct self_assign_operator_lvalue {
-    typedef geometry_type_1& type;
-  };
-    
-  template <typename type_1, typename type_2>
-  struct by_value_binary_operator {
-    typedef type_1 type;
-  };
-    
-  template <typename geometry_type_1, typename geometry_type_2, typename op_type>
-  geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
-    typedef geometry_type_1 ltype;
-    typedef geometry_type_2 rtype;
-    typedef typename polygon_90_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_90_set_data<coordinate_type> value_type;
-    orientation_2d orient_ = polygon_90_set_traits<ltype>::orient(lvalue_);
-    value_type linput_(orient_);
-    value_type rinput_(orient_);
-    value_type output_(orient_);
-    insert_into_view_arg(linput_, lvalue_, orient_);
-    insert_into_view_arg(rinput_, rvalue_, orient_);
-    output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
-                                 rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>()); 
-    polygon_90_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end(), orient_);
-    return lvalue_;
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< 
-    typename is_polygon_90_set_type<geometry_type_1>::type,
-    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
-                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
-  operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryOr());
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< 
-    typename gtl_and< 
-      typename is_polygon_90_set_type<geometry_type_1>
-#ifdef __ICC 
-      ::type
-#endif
-      ::type,
-      typename is_polygon_90_set_type<geometry_type_2>::type>
-#ifdef __ICC 
-    ::type
-#endif
-    ::type,
-    polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> >::type
-  operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryOr> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryOr());
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< 
-    typename is_polygon_90_set_type<geometry_type_1>::type,
-    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
-                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
-  operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryAnd());
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_if<typename gtl_and< 
-    typename is_polygon_90_set_type<geometry_type_1>::type,
-    typename is_polygon_90_set_type<geometry_type_2>::type>::type>::type,
-                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> >::type
-  operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryAnd());
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< 
-    typename is_polygon_90_set_type<geometry_type_1>::type,
-    typename is_polygon_90_set_type<geometry_type_2>::type>::type,
-                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor> >::type
-  operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryXor> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryXor());
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< 
-    typename is_polygon_90_set_type<geometry_type_1>
-#ifdef __ICC 
-  ::type
-#endif
-::type,
-    typename is_polygon_90_set_type<geometry_type_2>::type>
-#ifdef __ICC 
-  ::type
-#endif
-::type,
-                       polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot> >::type
-  operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return polygon_90_set_view<geometry_type_1, geometry_type_2, boolean_op::BinaryNot> 
-      (lvalue, rvalue, 
-       polygon_90_set_traits<geometry_type_1>::orient(lvalue),
-       boolean_op::BinaryNot());
-  }
-  
-  template <typename coordinate_type_1, typename geometry_type_2>
-  typename enable_if< typename is_polygon_90_set_type<geometry_type_2>::type,
-                       polygon_90_set_data<coordinate_type_1> >::type &
-  operator+=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
-    lvalue.insert(polygon_90_set_traits<geometry_type_2>::begin(rvalue), polygon_90_set_traits<geometry_type_2>::end(rvalue),
-                  polygon_90_set_traits<geometry_type_2>::orient(rvalue));
-    return lvalue;
-  }
-  
-  //
-  template <typename coordinate_type_1, typename geometry_type_2>
-  typename enable_if< typename is_polygon_90_set_type<geometry_type_2>::type, 
-                       polygon_90_set_data<coordinate_type_1> >::type &
-  operator|=(polygon_90_set_data<coordinate_type_1>& lvalue, const geometry_type_2& rvalue) {
-    return lvalue += rvalue;
-  }
-
-  //normal self assignment boolean operations
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator+=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator|=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryOr>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator*=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
-  }
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator&=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryAnd>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator^=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryXor>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename geometry_type_2>
-  typename enable_if< typename gtl_and< typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-                                         typename is_polygon_90_set_type<geometry_type_2>::type>::type, 
-                       geometry_type_1>::type &
-  operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
-    return self_assignment_boolean_op<geometry_type_1, geometry_type_2, boolean_op::BinaryNot>(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and<
-    typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
-                       geometry_type_1>::type &
-  operator+=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    return resize(lvalue, rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and<
-    typename is_mutable_polygon_90_set_type<geometry_type_1>::type, 
-    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>::type,
-                       geometry_type_1>::type &
-  operator-=(geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    return resize(lvalue, -rvalue);
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and<
-    typename is_mutable_polygon_90_set_type<geometry_type_1>
-#ifdef __ICC 
-  ::type
-#endif
-::type, 
-    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type,
-                       geometry_type_1>::type
-  operator+(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    geometry_type_1 retval(lvalue);
-    retval += rvalue;
-    return retval;
-  }
-
-  template <typename geometry_type_1, typename coordinate_type_1>
-  typename enable_if< typename gtl_and<
-    typename is_mutable_polygon_90_set_type<geometry_type_1>
-#ifdef __ICC 
-  ::type
-#endif
-::type, 
-    typename gtl_same_type<typename geometry_concept<coordinate_type_1>::type, coordinate_concept>::type>
-#ifdef __ICC 
-  ::type
-#endif
-  ::type,
-                       geometry_type_1>::type
-  operator-(const geometry_type_1& lvalue, coordinate_type_1 rvalue) {
-    geometry_type_1 retval(lvalue);
-    retval -= rvalue;
-    return retval;
-  }
-}
-}
-#endif
-
Deleted: sandbox/gtl/boost/polygon/polygon_90_touch.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_touch.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,418 +0,0 @@
-/*
-  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 GTL_POLYGON_90_TOUCH_HPP
-#define GTL_POLYGON_90_TOUCH_HPP
-namespace boost { namespace polygon{
-
-  template <typename Unit>
-  struct touch_90_operation {
-    typedef interval_data<Unit> Interval;
-
-    class TouchScanEvent {
-    private:
-      typedef std::map<Unit, std::set<int> > EventData;
-      EventData eventData_;
-    public:
-
-      // The TouchScanEvent::iterator is a lazy algorithm that accumulates
-      // polygon ids in a set as it is incremented through the
-      // scan event data structure.
-      // The iterator provides a forward iterator semantic only.
-      class iterator {
-      private:
-        typename EventData::const_iterator itr_;
-        std::pair<Interval, std::set<int> > ivlIds_;
-        bool incremented_;
-      public:
-        inline iterator() : itr_(), ivlIds_(), incremented_(false) {}
-        inline iterator(typename EventData::const_iterator itr, 
-                        Unit prevPos, Unit curPos, const std::set<int>& ivlIds) : itr_(itr), ivlIds_(), incremented_(false) {
-          ivlIds_.second = ivlIds;
-          ivlIds_.first = Interval(prevPos, curPos);
-        }
-        inline iterator(const iterator& that) : itr_(), ivlIds_(), incremented_(false) { (*this) = that; }
-        inline iterator& operator=(const iterator& that) {
-          itr_ = that.itr_;
-          ivlIds_.first = that.ivlIds_.first;
-          ivlIds_.second = that.ivlIds_.second;
-          incremented_ = that.incremented_;
-          return *this;
-        };
-        inline bool operator==(const iterator& that) { return itr_ == that.itr_; }
-        inline bool operator!=(const iterator& that) { return itr_ != that.itr_; }
-        inline iterator& operator++() {
-          //std::cout << "increment\n";
-          //std::cout << "state\n";
-          //for(std::set<int>::iterator itr = ivlIds_.second.begin(); itr != ivlIds_.second.end(); ++itr) {
-          //   std::cout << (*itr) << " ";
-          //} std::cout << std::endl;
-          //std::cout << "update\n";
-          for(std::set<int>::const_iterator itr = (*itr_).second.begin();
-              itr != (*itr_).second.end(); ++itr) {
-            //std::cout << (*itr) <<  " ";
-            std::set<int>::iterator lb = ivlIds_.second.find(*itr);
-            if(lb != ivlIds_.second.end()) {
-              ivlIds_.second.erase(lb);
-            } else {
-              ivlIds_.second.insert(*itr);
-            }
-          } 
-          //std::cout << std::endl;
-          //std::cout << "new state\n";
-          //for(std::set<int>::iterator itr = ivlIds_.second.begin(); itr != ivlIds_.second.end(); ++itr) {
-          //   std::cout << (*itr) << " ";
-          //} std::cout << std::endl;
-          ++itr_;
-          //ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
-          incremented_ = true;
-          return *this;
-        }
-        inline const iterator operator++(int){
-          iterator tmpItr(*this);
-          ++(*this);
-          return tmpItr;
-        }
-        inline std::pair<Interval, std::set<int> >& operator*() { 
-          if(incremented_) ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
-          incremented_ = false;
-          if(ivlIds_.second.empty())(++(*this));
-          if(incremented_) ivlIds_.first = Interval(ivlIds_.first.get(HIGH), itr_->first);
-          incremented_ = false;
-          return ivlIds_; }
-      };
-
-      inline TouchScanEvent() : eventData_() {}
-      template<class iT>
-      inline TouchScanEvent(iT begin, iT end) : eventData_() {
-        for( ; begin != end; ++begin){
-          insert(*begin);
-        }
-      }
-      inline TouchScanEvent(const TouchScanEvent& that) : eventData_(that.eventData_) {}
-      inline TouchScanEvent& operator=(const TouchScanEvent& that){
-        eventData_ = that.eventData_;
-        return *this;
-      }
-   
-      //Insert an interval polygon id into the EventData
-      inline void insert(const std::pair<Interval, int>& intervalId){
-        insert(intervalId.first.low(), intervalId.second);
-        insert(intervalId.first.high(), intervalId.second);
-      }
-   
-      //Insert an position and polygon id into EventData
-      inline void insert(Unit pos, int id) {
-        typename EventData::iterator lb = eventData_.lower_bound(pos);
-        if(lb != eventData_.end() && lb->first == pos) {
-          std::set<int>& mr (lb->second);
-          std::set<int>::iterator mri = mr.find(id);
-          if(mri == mr.end()) {
-            mr.insert(id);
-          } else {
-            mr.erase(id);
-          }
-        } else {
-          lb = eventData_.insert(lb, std::pair<Unit, std::set<int> >(pos, std::set<int>()));
-          (*lb).second.insert(id);
-        }
-      }
-   
-      //merge this scan event with that by inserting its data
-      inline void insert(const TouchScanEvent& that){
-        typename EventData::const_iterator itr;
-        for(itr = that.eventData_.begin(); itr != that.eventData_.end(); ++itr) {
-          eventData_[(*itr).first].insert(itr->second.begin(), itr->second.end());
-        }
-      }
-   
-      //Get the begin iterator over event data
-      inline iterator begin() const { 
-        //std::cout << "begin\n";
-        if(eventData_.empty()) return end();
-        typename EventData::const_iterator itr = eventData_.begin();
-        Unit pos = itr->first;
-        const std::set<int>& idr = itr->second;
-        ++itr;
-        return iterator(itr, pos, itr->first, idr);
-      }
-   
-      //Get the end iterator over event data
-      inline iterator end() const { return iterator(eventData_.end(), 0, 0, std::set<int>()); }
-   
-      inline void clear() { eventData_.clear(); }
-   
-      inline Interval extents() const { 
-        if(eventData_.empty()) return Interval();
-        return Interval((*(eventData_.begin())).first, (*(eventData_.rbegin())).first);
-      }
-    };
-   
-    //declaration of a map of scan events by coordinate value used to store all the
-    //polygon data for a single layer input into the scanline algorithm
-    typedef std::pair<std::map<Unit, TouchScanEvent>, std::map<Unit, TouchScanEvent> > TouchSetData;
-
-    class TouchOp {
-    public:
-      typedef std::map<Unit, std::set<int> > ScanData;
-      typedef std::pair<Unit, std::set<int> > ElementType;
-    protected:
-      ScanData scanData_;
-      typename ScanData::iterator nextItr_;
-    public:
-      inline TouchOp () : scanData_(), nextItr_() { nextItr_ = scanData_.end(); }
-      inline TouchOp (const TouchOp& that) : scanData_(that.scanData_), nextItr_() { nextItr_ = scanData_.begin(); }
-      inline TouchOp& operator=(const TouchOp& that); 
-   
-      //moves scanline forward
-      inline void advanceScan() { nextItr_ = scanData_.begin(); }
-
-      //proceses the given interval and std::set<int> data
-      //the output data structre is a graph, the indicies in the vector correspond to graph nodes,
-      //the integers in the set are vector indicies and are the nodes with which that node shares an edge
-      template <typename graphT>
-      inline void processInterval(graphT& outputContainer, Interval ivl, const std::set<int>& ids, bool leadingEdge) {
-        //print();
-        typename ScanData::iterator lowItr = lookup_(ivl.low());
-        typename ScanData::iterator highItr = lookup_(ivl.high());
-        //std::cout << "Interval: " << ivl << std::endl;
-        //for(std::set<int>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
-        //   std::cout << (*itr) << " ";
-        //std::cout << std::endl;
-        //add interval to scan data if it is past the end
-        if(lowItr == scanData_.end()) {
-          //std::cout << "case0" << std::endl;
-          lowItr = insert_(ivl.low(), ids);
-          evaluateBorder_(outputContainer, ids, ids);
-          highItr = insert_(ivl.high(), std::set<int>());
-          return;
-        }
-        //ensure that highItr points to the end of the ivl
-        if(highItr == scanData_.end() || (*highItr).first > ivl.high()) {
-          //std::cout << "case1" << std::endl;
-          //std::cout << highItr->first << std::endl;
-          std::set<int> value = std::set<int>();
-          if(highItr != scanData_.begin()) {
-            --highItr;
-            //std::cout << highItr->first << std::endl;
-            //std::cout << "high set size " << highItr->second.size() << std::endl;
-            value = highItr->second;
-          }
-          nextItr_ = highItr;
-          highItr = insert_(ivl.high(), value);
-        } else {
-          //evaluate border with next higher interval
-          //std::cout << "case1a" << std::endl;
-          if(leadingEdge)evaluateBorder_(outputContainer, highItr->second, ids);
-        }
-        //split the low interval if needed
-        if(lowItr->first > ivl.low()) {
-          //std::cout << "case2" << std::endl;
-          if(lowItr != scanData_.begin()) {
-            //std::cout << "case3" << std::endl;
-            --lowItr;
-            nextItr_ = lowItr;
-            //std::cout << lowItr->first << " " << lowItr->second.size() << std::endl;
-            lowItr = insert_(ivl.low(), lowItr->second);
-          } else {
-            //std::cout << "case4" << std::endl;
-            nextItr_ = lowItr;
-            lowItr = insert_(ivl.low(), std::set<int>());
-          }
-        } else {
-          //evaluate border with next higher interval
-          //std::cout << "case2a" << std::endl;
-          typename ScanData::iterator nextLowerItr = lowItr;
-          if(leadingEdge && nextLowerItr != scanData_.begin()){
-            --nextLowerItr;
-            evaluateBorder_(outputContainer, nextLowerItr->second, ids);
-          }
-        }
-        //std::cout << "low: " << lowItr->first << " high: " << highItr->first << std::endl;
-        //print();
-        //process scan data intersecting interval
-        for(typename ScanData::iterator itr = lowItr; itr != highItr; ){
-          //std::cout << "case5" << std::endl;
-          //std::cout << itr->first << std::endl;
-          std::set<int>& beforeIds = itr->second;
-          ++itr;
-          evaluateInterval_(outputContainer, beforeIds, ids, leadingEdge);
-        }
-        //print();
-        //merge the bottom interval with the one below if they have the same count
-        if(lowItr != scanData_.begin()){
-          //std::cout << "case6" << std::endl;
-          typename ScanData::iterator belowLowItr = lowItr;
-          --belowLowItr;
-          if(belowLowItr->second == lowItr->second) {
-            //std::cout << "case7" << std::endl;
-            scanData_.erase(lowItr);
-          }
-        } 
-        //merge the top interval with the one above if they have the same count
-        if(highItr != scanData_.begin()) {
-          //std::cout << "case8" << std::endl;
-          typename ScanData::iterator beforeHighItr = highItr;
-          --beforeHighItr;
-          if(beforeHighItr->second == highItr->second) {
-            //std::cout << "case9" << std::endl;
-            scanData_.erase(highItr);
-            highItr = beforeHighItr;
-            ++highItr;
-          }
-        }
-        //print();
-        nextItr_ = highItr;
-      }
-
-      inline void print() const {
-        for(typename ScanData::const_iterator itr = scanData_.begin(); itr != scanData_.end(); ++itr) {
-          std::cout << itr->first << ": ";
-          for(std::set<int>::const_iterator sitr = itr->second.begin();
-              sitr != itr->second.end(); ++sitr){
-            std::cout << *sitr << " ";
-          }
-          std::cout << std::endl;
-        }
-      }
-   
-    private:
-      inline typename ScanData::iterator lookup_(Unit pos){
-        if(nextItr_ != scanData_.end() && nextItr_->first >= pos) {
-          return nextItr_;
-        }
-        return nextItr_ = scanData_.lower_bound(pos);
-      }
-
-      inline typename ScanData::iterator insert_(Unit pos, const std::set<int>& ids){
-        //std::cout << "inserting " << ids.size() << " ids at: " << pos << std::endl;
-        return nextItr_ = scanData_.insert(nextItr_, std::pair<Unit, std::set<int> >(pos, ids));
-      }
-
-      template <typename graphT>
-      inline void evaluateInterval_(graphT& outputContainer, std::set<int>& ids, 
-                                    const std::set<int>& changingIds, bool leadingEdge) {
-        for(std::set<int>::const_iterator ciditr = changingIds.begin(); ciditr != changingIds.end(); ++ciditr){
-          //std::cout << "evaluateInterval " << (*ciditr) << std::endl;
-          evaluateId_(outputContainer, ids, *ciditr, leadingEdge);
-        }
-      }
-      template <typename graphT>
-      inline void evaluateBorder_(graphT& outputContainer, const std::set<int>& ids, const std::set<int>& changingIds) {
-        for(std::set<int>::const_iterator ciditr = changingIds.begin(); ciditr != changingIds.end(); ++ciditr){
-          //std::cout << "evaluateBorder " << (*ciditr) << std::endl;
-          evaluateBorderId_(outputContainer, ids, *ciditr);
-        }
-      }
-      template <typename graphT>
-      inline void evaluateBorderId_(graphT& outputContainer, const std::set<int>& ids, int changingId) {
-        for(std::set<int>::const_iterator scanItr = ids.begin(); scanItr != ids.end(); ++scanItr) {
-          //std::cout << "create edge: " << changingId << " " << *scanItr << std::endl;
-          if(changingId != *scanItr){
-            outputContainer[changingId].insert(*scanItr);
-            outputContainer[*scanItr].insert(changingId);
-          }
-        }
-      }
-      template <typename graphT>
-      inline void evaluateId_(graphT& outputContainer, std::set<int>& ids, int changingId, bool leadingEdge) {
-        //std::cout << "changingId: " << changingId << std::endl;
-        //for( std::set<int>::iterator itr = ids.begin(); itr != ids.end(); ++itr){
-        //   std::cout << *itr << " ";
-        //}std::cout << std::endl;
-        std::set<int>::iterator lb = ids.lower_bound(changingId);
-        if(lb == ids.end() || (*lb) != changingId) {
-          if(leadingEdge) {
-            //std::cout << "insert\n";
-            //insert and add to output
-            for(std::set<int>::iterator scanItr = ids.begin(); scanItr != ids.end(); ++scanItr) {
-              //std::cout << "create edge: " << changingId << " " << *scanItr << std::endl;
-              if(changingId != *scanItr){
-                outputContainer[changingId].insert(*scanItr);
-                outputContainer[*scanItr].insert(changingId);
-              }
-            }
-            ids.insert(changingId);
-          }
-        } else {
-          if(!leadingEdge){
-            //std::cout << "erase\n";
-            ids.erase(lb);
-          }
-        }
-      }
-    };
-
-    template <typename graphT>
-    static inline void processEvent(graphT& outputContainer, TouchOp& op, const TouchScanEvent& data, bool leadingEdge) {
-      for(typename TouchScanEvent::iterator itr = data.begin(); itr != data.end(); ++itr) {
-        //std::cout << "processInterval" << std::endl;
-        op.processInterval(outputContainer, (*itr).first, (*itr).second, leadingEdge);
-      }
-    }
-
-    template <typename graphT>
-    static inline void performTouch(graphT& outputContainer, const TouchSetData& data) {
-      typename std::map<Unit, TouchScanEvent>::const_iterator leftItr = data.first.begin();
-      typename std::map<Unit, TouchScanEvent>::const_iterator rightItr = data.second.begin();
-      typename std::map<Unit, TouchScanEvent>::const_iterator leftEnd = data.first.end();
-      typename std::map<Unit, TouchScanEvent>::const_iterator rightEnd = data.second.end();
-      TouchOp op;
-      while(leftItr != leftEnd || rightItr != rightEnd) {
-        //std::cout << "loop" << std::endl;
-        op.advanceScan();
-        //rightItr cannont be at end if leftItr is not at end
-        if(leftItr != leftEnd && rightItr != rightEnd &&
-           leftItr->first <= rightItr->first) {
-          //std::cout << "case1" << std::endl;
-          //std::cout << leftItr ->first << std::endl;
-          processEvent(outputContainer, op, leftItr->second, true);
-          ++leftItr;
-        } else {
-          //std::cout << "case2" << std::endl;
-          //std::cout << rightItr ->first << std::endl;
-          processEvent(outputContainer, op, rightItr->second, false);
-          ++rightItr;
-        }
-      }
-    }
-
-    template <class iT>
-    static inline void populateTouchSetData(TouchSetData& data, iT beginData, iT endData, int id) {
-      Unit prevPos = ((std::numeric_limits<Unit>::max)());
-      Unit prevY = prevPos;
-      int count = 0;
-      for(iT itr = beginData; itr != endData; ++itr) {
-        Unit pos = (*itr).first;
-        if(pos != prevPos) {
-          prevPos = pos;
-          prevY = (*itr).second.first;
-          count = (*itr).second.second;
-          continue;
-        }
-        Unit y = (*itr).second.first;
-        if(count != 0 && y != prevY) {
-          std::pair<Interval, int> element(Interval(prevY, y), id);
-          if(count > 0) {
-            data.first[pos].insert(element);
-          } else {
-            data.second[pos].insert(element);
-          }
-        }
-        prevY = y;
-        count += (*itr).second.second;
-      }
-    }
-
-    static inline void populateTouchSetData(TouchSetData& data, const std::vector<std::pair<Unit, std::pair<Unit, int> > >& inputData, int id) {
-      populateTouchSetData(data, inputData.begin(), inputData.end(), id);
-    }
-
-  };
-}
-}
-#endif
Modified: sandbox/gtl/boost/polygon/polygon_90_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_90_with_holes_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_90_with_holes_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,9 +5,11 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_90_WITH_HOLES_DATA_HPP
-#define GTL_POLYGON_90_WITH_HOLES_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP
+#define BOOST_POLYGON_POLYGON_90_WITH_HOLES_DATA_HPP
 namespace boost { namespace polygon{
+#include "isotropy.hpp"
+#include "polygon_90_data.hpp"
 struct polygon_90_with_holes_concept;
 template <typename T>
 class polygon_90_with_holes_data {
@@ -63,6 +65,9 @@
     return *this;
   }
 
+  template <typename T2>
+  inline polygon_90_with_holes_data& operator=(const T2& rvalue);
+
   // get begin iterator, returns a pointer to a const coordinate_type
   inline const iterator_type begin() const {
     return self_.begin();
Deleted: sandbox/gtl/boost/polygon/polygon_arbitrary_formation.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_arbitrary_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,1937 +0,0 @@
-/*
-    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 GTL_POLYGON_ARBITRARY_FORMATION_HPP
-#define GTL_POLYGON_ARBITRARY_FORMATION_HPP
-namespace boost { namespace polygon{
-  template <typename T, typename T2>
-  struct PolyLineArbitraryByConcept {};
-
-  template <typename T>
-  class poly_line_arbitrary_polygon_data;
-  template <typename T>
-  class poly_line_arbitrary_hole_data;
-
-  template <typename Unit>
-  struct scanline_base {
-
-    typedef point_data<Unit> Point;
-    typedef std::pair<Point, Point> half_edge;
-
-    class less_point : public std::binary_function<Point, Point, bool> {
-    public:
-      inline less_point() {}
-      inline bool operator () (const Point& pt1, const Point& pt2) const {
-        if(pt1.get(HORIZONTAL) < pt2.get(HORIZONTAL)) return true;
-        if(pt1.get(HORIZONTAL) == pt2.get(HORIZONTAL)) {
-          if(pt1.get(VERTICAL) < pt2.get(VERTICAL)) return true;
-        }
-        return false;
-      }
-    };
-
-    static inline bool 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 area_type>
-    static inline Unit compute_intercept(const area_type& dy2,
-                                         const area_type& dx1,
-                                         const area_type& dx2) {
-      //intercept = dy2 * dx1 / dx2
-      //return (Unit)(((area_type)dy2 * (area_type)dx1) / (area_type)dx2);
-      area_type dx1_q = dx1 / dx2;
-      area_type dx1_r = dx1 % dx2;
-      return dx1_q * dy2 + (dy2 * dx1_r)/dx2;
-    }
-
-    template <typename area_type>
-    static inline bool equal_slope(area_type dx1, area_type dy1, area_type dx2, area_type dy2) {
-      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
-      unsigned_product_type cross_1 = (unsigned_product_type)(dx2 < 0 ? -dx2 :dx2) * (unsigned_product_type)(dy1 < 0 ? -dy1 : dy1);
-      unsigned_product_type cross_2 = (unsigned_product_type)(dx1 < 0 ? -dx1 :dx1) * (unsigned_product_type)(dy2 < 0 ? -dy2 : dy2);
-      int dx1_sign = dx1 < 0 ? -1 : 1;
-      int dx2_sign = dx2 < 0 ? -1 : 1;
-      int dy1_sign = dy1 < 0 ? -1 : 1;
-      int dy2_sign = dy2 < 0 ? -1 : 1;
-      int cross_1_sign = dx2_sign * dy1_sign;
-      int cross_2_sign = dx1_sign * dy2_sign;
-      return cross_1 == cross_2 && (cross_1_sign == cross_2_sign || cross_1 == 0);
-    }
-
-    static inline bool equal_slope(const Unit& x, const Unit& y,
-                                   const Point& pt1, const Point& pt2) {
-      const Point* pts[2] = {&pt1, &pt2};
-      typedef typename coordinate_traits<Unit>::manhattan_area_type at;
-      at dy2 = (at)pts[1]->get(VERTICAL) - (at)y;
-      at dy1 = (at)pts[0]->get(VERTICAL) - (at)y;
-      at dx2 = (at)pts[1]->get(HORIZONTAL) - (at)x;
-      at dx1 = (at)pts[0]->get(HORIZONTAL) - (at)x;
-      return equal_slope(dx1, dy1, dx2, dy2);
-    }
-
-    template <typename area_type>
-    static inline bool less_slope(area_type dx1, area_type dy1, area_type dx2, area_type dy2) {
-      //reflext x and y slopes to right hand side half plane
-      if(dx1 < 0) {
-        dy1 *= -1;
-        dx1 *= -1;
-      } else if(dx1 == 0) {
-        //if the first slope is vertical the first cannot be less
-        return false;
-      }
-      if(dx2 < 0) {
-        dy2 *= -1;
-        dx2 *= -1;
-      } else if(dx2 == 0) {
-        //if the second slope is vertical the first is always less unless it is also vertical, in which case they are equal 
-        return dx1 != 0;
-      }
-      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
-      unsigned_product_type cross_1 = (unsigned_product_type)(dx2 < 0 ? -dx2 :dx2) * (unsigned_product_type)(dy1 < 0 ? -dy1 : dy1);
-      unsigned_product_type cross_2 = (unsigned_product_type)(dx1 < 0 ? -dx1 :dx1) * (unsigned_product_type)(dy2 < 0 ? -dy2 : dy2);
-      int dx1_sign = dx1 < 0 ? -1 : 1;
-      int dx2_sign = dx2 < 0 ? -1 : 1;
-      int dy1_sign = dy1 < 0 ? -1 : 1;
-      int dy2_sign = dy2 < 0 ? -1 : 1;
-      int cross_1_sign = dx2_sign * dy1_sign;
-      int cross_2_sign = dx1_sign * dy2_sign;
-      if(cross_1_sign < cross_2_sign) return true;
-      if(cross_2_sign < cross_1_sign) return false;
-      if(cross_1_sign == -1) return cross_2 < cross_1;
-      return cross_1 < cross_2;
-    }
-
-    static inline bool less_slope(const Unit& x, const Unit& y,
-                                  const Point& pt1, const Point& pt2) {
-      const Point* pts[2] = {&pt1, &pt2};
-      //compute y value on edge from pt_ to pts[1] at the x value of pts[0]
-      typedef typename coordinate_traits<Unit>::manhattan_area_type at;
-      at dy2 = (at)pts[1]->get(VERTICAL) - (at)y;
-      at dy1 = (at)pts[0]->get(VERTICAL) - (at)y;
-      at dx2 = (at)pts[1]->get(HORIZONTAL) - (at)x;
-      at dx1 = (at)pts[0]->get(HORIZONTAL) - (at)x;
-      return less_slope(dx1, dy1, dx2, dy2);
-    }
-
-    //return -1 below, 0 on and 1 above line
-    //assumes point is on x interval of segment
-    static inline int on_above_or_below(Point pt, const half_edge& he) {
-      if(pt == he.first || pt == he.second) return 0;
-      if(equal_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), he.first, he.second)) return 0;
-      bool less_result = less_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), he.first, he.second);
-      int retval = less_result ? -1 : 1;
-      less_point lp;
-      if(lp(he.second, he.first)) retval *= -1;
-      if(!between(pt, he.first, he.second)) retval *= -1;
-      return retval;
-    }
-
-    //returns true is the segment intersects the integer grid square with lower
-    //left corner at point
-    static inline bool intersects_grid(Point pt, const half_edge& he) {
-      if(pt == he.second) return true;
-      if(pt == he.first) return true;
-      rectangle_data<Unit> rect1;
-      set_points(rect1, he.first, he.second);
-      if(contains(rect1, pt, true)) {
-        if(is_vertical(he) || is_horizontal(he)) return true;
-      } else {
-        return false; //can't intersect a grid not within bounding box
-      }
-      Unit x = pt.get(HORIZONTAL);
-      Unit y = pt.get(VERTICAL);
-      if(equal_slope(x, y, he.first, he.second) &&
-         between(pt, he.first, he.second)) return true;
-      Point pt01(pt.get(HORIZONTAL), pt.get(VERTICAL) + 1);
-      Point pt10(pt.get(HORIZONTAL) + 1, pt.get(VERTICAL));
-      Point pt11(pt.get(HORIZONTAL) + 1, pt.get(VERTICAL) + 1);
-//       if(pt01 == he.first) return true;
-//       if(pt10 == he.first) return true;
-//       if(pt11 == he.first) return true;
-//       if(pt01 == he.second) return true;
-//       if(pt10 == he.second) return true;
-//       if(pt11 == he.second) return true;
-      //check non-integer intersections
-      half_edge widget1(pt, pt11);
-      //intersects but not just at pt11
-      if(intersects(widget1, he) && on_above_or_below(pt11, he)) return true;
-      half_edge widget2(pt01, pt10);
-      //intersects but not just at pt01 or 10
-      if(intersects(widget2, he) && on_above_or_below(pt01, he) && on_above_or_below(pt10, he)) return true;
-      return false;
-    }
-
-    static inline typename high_precision_type<Unit>::type evalAtXforY(Unit xIn, Point pt, Point other_pt) { 
-      //y = (x - x1)dy/dx + y1
-      //y = (xIn - pt.x)*(other_pt.y-pt.y)/(other_pt.x-pt.x) + pt.y
-      //assert pt.x != other_pt.x
-      Unit x1 = pt.get(HORIZONTAL);
-      Unit y1 = pt.get(VERTICAL);
-      typedef typename high_precision_type<Unit>::type high_precision;
-      high_precision dx1 = (high_precision)xIn - (high_precision)pt.get(HORIZONTAL);
-      if(dx1 == high_precision(0)) return (high_precision)(pt.get(VERTICAL)); 
-      high_precision dx = (high_precision)(other_pt.get(HORIZONTAL)) - (high_precision)x1;
-      high_precision dy = (high_precision)(other_pt.get(VERTICAL)) - (high_precision)y1;
-      high_precision y = (((high_precision)dx1) * (high_precision)dy / (high_precision)dx + (high_precision)y1);
-      return y;
-    }
-  
-
-    static inline bool is_vertical(const half_edge& he) {
-      return he.first.get(HORIZONTAL) == he.second.get(HORIZONTAL);
-    }
-      
-    static inline bool is_horizontal(const half_edge& he) {
-      return he.first.get(VERTICAL) == he.second.get(VERTICAL);
-    }
-
-    static inline bool is_45_degree(const half_edge& he) {
-      return euclidean_distance(he.first, he.second, HORIZONTAL) == euclidean_distance(he.first, he.second, VERTICAL);
-    }
-
-    //scanline comparator functor
-    class less_half_edge : public std::binary_function<half_edge, half_edge, bool> {
-    private:
-      Unit *x_; //x value at which to apply comparison
-      int *justBefore_;
-    public:
-      inline less_half_edge() : x_(0), justBefore_(0) {}
-      inline less_half_edge(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
-      inline less_half_edge(const less_half_edge& that) : x_(that.x_), justBefore_(that.justBefore_) {}
-      inline less_half_edge& operator=(const less_half_edge& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
-      inline bool operator () (const half_edge& elm1, const half_edge& elm2) const {
-        //Unit y1 = evalAtXforY(*x_ + !*justBefore_, elm1.first, elm1.second);
-        //Unit y2 = evalAtXforY(*x_ + !*justBefore_, elm2.first, elm2.second);
-        typedef typename high_precision_type<Unit>::type high_precision;
-        high_precision y1 = evalAtXforY(*x_, elm1.first, elm1.second);
-        high_precision y2 = evalAtXforY(*x_, elm2.first, elm2.second);
-        if(y1 < y2) return true;
-        if(y1 == y2) {
-          //if justBefore is true we invert the result of the comparison of slopes
-          bool result = less_slope(elm1.second.get(HORIZONTAL) - elm1.first.get(HORIZONTAL),
-                                   elm1.second.get(VERTICAL) - elm1.first.get(VERTICAL),
-                                   elm2.second.get(HORIZONTAL) - elm2.first.get(HORIZONTAL),
-                                   elm2.second.get(VERTICAL) - elm2.first.get(VERTICAL));
-          return (*justBefore_) ^ result;
-        }
-        return false;
-      }
-    };
-
-    template <typename unsigned_product_type>
-    static inline void unsigned_mod(unsigned_product_type& result, int& result_sign, unsigned_product_type a, int a_sign, unsigned_product_type b, int b_sign) {
-      result = a % b;
-      result_sign = a_sign;
-    }
-
-    template <typename unsigned_product_type>
-    static inline void unsigned_add(unsigned_product_type& result, int& result_sign, unsigned_product_type a, int a_sign, unsigned_product_type b, int b_sign) {
-      int switcher = 0;
-      if(a_sign < 0) switcher += 1; 
-      if(b_sign < 0) switcher += 2; 
-      if(a < b) switcher += 4;
-      switch (switcher) {
-      case 0: //both positive
-        result = a + b;
-        result_sign = 1;
-        break;
-      case 1: //a is negative
-        result = a - b;
-        result_sign = -1;
-        break;
-      case 2: //b is negative
-        result = a - b;
-        result_sign = 1;
-        break;
-      case 3: //both negative
-        result = a + b;
-        result_sign = -1;
-        break;
-      case 4: //both positive
-        result = a + b;
-        result_sign = 1;
-        break;
-      case 5: //a is negative
-        result = b - a;
-        result_sign = 1;
-        break;
-      case 6: //b is negative
-        result = b - a;
-        result_sign = -1;
-        break;
-      case 7: //both negative
-        result = b + a;
-        result_sign = -1;
-        break;
-      };
-    }
-
-    //slower but more overflow protected way to compute coordinate of intersection
-    template <typename product_type>
-    static inline Unit compute_x_intercept(product_type x11,
-                                           product_type x21,
-                                           product_type y11,
-                                           product_type y21,
-                                           product_type dy1,
-                                           product_type dy2,
-                                           product_type dx1,
-                                           product_type dx2) {
-      // x = (x11 * dy1 * dx2 - x21 * dy2 * dx1 + y21 * dx1 * dx2 - y11 * dx1 * dx2) / (dy1 * dx2 - dy2 * dx1);
-      typedef typename coordinate_traits<Unit>::unsigned_area_type unsigned_product_type;
-      unsigned_product_type udy1 = dy1 < 0 ? -dy1 : dy1;
-      int dy1sign = dy1 < 0 ? -1 : 1;
-      unsigned_product_type udy2 = dy2 < 0 ? -dy2 : dy2;
-      int dy2sign = dy2 < 0 ? -1 : 1;
-      unsigned_product_type udx1 = dx1 < 0 ? -dx1 : dx1;
-      int dx1sign = dx1 < 0 ? -1 : 1;
-      unsigned_product_type udx2 = dx2 < 0 ? -dx2 : dx2;
-      int dx2sign = dx2 < 0 ? -1 : 1;
-      unsigned_product_type u_dy1dx2 = udy1 * udx2;
-      unsigned_product_type u_dy2dx1 = udy2 * udx1;
-      unsigned_product_type u_dx1dx2 = udx1 * udx2;
-      int dy1dx2sign = dy1sign * dx2sign;
-      int dy2dx1sign = dy2sign * dx1sign;
-      int dx1dx2sign = dx1sign * dx2sign;
-      unsigned_product_type u_den = 0;;
-      int den_sign = 0;;
-      unsigned_add(u_den, den_sign, u_dy1dx2, dy1dx2sign, u_dy2dx1, -dy2dx1sign);
-      product_type dy1dx2_q = u_dy1dx2 / u_den;
-      product_type dy2dx1_q = u_dy2dx1 / u_den;
-      product_type dx1dx2_q = u_dx1dx2 / u_den;
-      dy1dx2_q *= dy1dx2sign * den_sign;
-      dy2dx1_q *= dy2dx1sign * den_sign;
-      dx1dx2_q *= dx1dx2sign * den_sign;
-      unsigned_product_type u_dy1dx2_r = 0;;
-      unsigned_product_type u_dy2dx1_r = 0;;
-      unsigned_product_type u_dx1dx2_r = 0;;
-      int dy1dx2_r_sign = 0;
-      int dy2dx1_r_sign = 0;
-      int dx1dx2_r_sign = 0;
-      unsigned_mod(u_dy1dx2_r, dy1dx2_r_sign, u_dy1dx2, dy1dx2sign, u_den, den_sign);
-      unsigned_mod(u_dy2dx1_r, dy2dx1_r_sign, u_dy2dx1, dy2dx1sign, u_den, den_sign);
-      unsigned_mod(u_dx1dx2_r, dx1dx2_r_sign, u_dx1dx2, dx1dx2sign, u_den, den_sign);
-      product_type dy1dx2_r = u_dy1dx2_r;
-      product_type dy2dx1_r = u_dy2dx1_r;
-      product_type dx1dx2_r = u_dx1dx2_r;
-      dy1dx2_r *= dy1dx2_r_sign;
-      dy2dx1_r *= dy2dx1_r_sign;
-      dx1dx2_r *= dx1dx2_r_sign;
-      product_type q = x11 * dy1dx2_q - x21 * dy2dx1_q + (y21 - y11) * dx1dx2_q;
-      product_type r = x11 * dy1dx2_r - x21 * dy2dx1_r + (y21 - y11) * dx1dx2_r;
-      unsigned_product_type ur = 0;
-      int rsign = 0;;
-      if(r < 0) { ur = -r; rsign = -1; } else { ur = r; rsign = 1; }
-      //this operation performs only one truncation
-      ur /= u_den;
-      rsign *= den_sign;
-      r = ur;
-      r *= rsign;
-      return q + r;
-    }
-
-    static inline bool compute_intersection(Point& intersection, const half_edge& he1, const half_edge& he2) {
-      typedef typename high_precision_type<Unit>::type high_precision;
-      typedef rectangle_data<Unit> Rectangle;
-      Rectangle rect1, rect2;
-      set_points(rect1, he1.first, he1.second);
-      set_points(rect2, he2.first, he2.second);
-      if(!::boost::polygon::intersects(rect1, rect2, true)) return false;
-      if(is_vertical(he1)) {
-        if(is_vertical(he2)) return false;
-        high_precision y_high = evalAtXforY(he1.first.get(HORIZONTAL), he2.first, he2.second);
-        Unit y = (Unit)y_high;
-        if(y_high < (high_precision)y) --y;
-        if(contains(rect1.get(VERTICAL), y, true)) {
-          intersection = Point(he1.first.get(HORIZONTAL), y);
-          return true;
-        } else {
-          return false;
-        }
-      } else if(is_vertical(he2)) {
-        high_precision y_high = evalAtXforY(he2.first.get(HORIZONTAL), he1.first, he1.second);
-        Unit y = (Unit)y_high;
-        if(y_high < (high_precision)y) --y;
-        if(contains(rect2.get(VERTICAL), y, true)) {
-          intersection = Point(he2.first.get(HORIZONTAL), y);
-          return true;
-        } else {
-          return false;
-        }
-      }
-      //the bounding boxes of the two line segments intersect, so we check closer to find the intersection point
-      high_precision dy2 = (high_precision)(he2.second.get(VERTICAL)) - 
-        (high_precision)(he2.first.get(VERTICAL));
-      high_precision dy1 = (high_precision)(he1.second.get(VERTICAL)) - 
-        (high_precision)(he1.first.get(VERTICAL));
-      high_precision dx2 = (high_precision)(he2.second.get(HORIZONTAL)) - 
-        (high_precision)(he2.first.get(HORIZONTAL));
-      high_precision dx1 = (high_precision)(he1.second.get(HORIZONTAL)) - 
-        (high_precision)(he1.first.get(HORIZONTAL));
-      if(equal_slope(dx1, dy1, dx2, dy2)) return false;
-      //the line segments have different slopes
-      //we can assume that the line segments are not vertical because such an intersection is handled elsewhere
-      high_precision x11 = (high_precision)(he1.first.get(HORIZONTAL));
-      high_precision x21 = (high_precision)(he2.first.get(HORIZONTAL));
-      high_precision y11 = (high_precision)(he1.first.get(VERTICAL));
-      high_precision y21 = (high_precision)(he2.first.get(VERTICAL));
-      //Unit exp_x = ((at)x11 * (at)dy1 * (at)dx2 - (at)x21 * (at)dy2 * (at)dx1 + (at)y21 * (at)dx1 * (at)dx2 - (at)y11 * (at)dx1 * (at)dx2) / ((at)dy1 * (at)dx2 - (at)dy2 * (at)dx1);
-      //Unit exp_y = ((at)y11 * (at)dx1 * (at)dy2 - (at)y21 * (at)dx2 * (at)dy1 + (at)x21 * (at)dy1 * (at)dy2 - (at)x11 * (at)dy1 * (at)dy2) / ((at)dx1 * (at)dy2 - (at)dx2 * (at)dy1);
-      high_precision x_num = (x11 * dy1 * dx2 - x21 * dy2 * dx1 + y21 * dx1 * dx2 - y11 * dx1 * dx2); 
-      high_precision x_den = (dy1 * dx2 - dy2 * dx1);
-      high_precision y_num = (y11 * dx1 * dy2 - y21 * dx2 * dy1 + x21 * dy1 * dy2 - x11 * dy1 * dy2);
-      high_precision y_den = (dx1 * dy2 - dx2 * dy1);
-      high_precision x = x_num / x_den;
-      high_precision y = y_num / y_den;
-      //std::cout << "cross1 " << dy1 << " " << dx2 << " " << dy1 * dx2 << std::endl;
-      //std::cout << "cross2 " << dy2 << " " << dx1 << " " << dy2 * dx1 << std::endl;
-      //Unit exp_x = compute_x_intercept<at>(x11, x21, y11, y21, dy1, dy2, dx1, dx2);
-      //Unit exp_y = compute_x_intercept<at>(y11, y21, x11, x21, dx1, dx2, dy1, dy2);
-      Unit x_unit = (Unit)x;
-      Unit y_unit = (Unit)y;
-      //truncate downward if it went up due to negative number
-      if(x < (high_precision)x_unit) --x_unit;
-      if(y < (high_precision)y_unit) --y_unit;
-      //if(x != exp_x || y != exp_y)
-      //  std::cout << exp_x << " " << exp_y << " " << x << " " << y << std::endl;
-      //Unit y1 = evalAtXforY(exp_x, he1.first, he1.second);
-      //Unit y2 = evalAtXforY(exp_x, he2.first, he2.second);
-      //std::cout << exp_x << " " << exp_y << " " << y1 << " " << y2 << std::endl;
-      Point result(x_unit, y_unit);
-      if(!contains(rect1, result, true)) return false;
-      if(!contains(rect2, result, true)) return false;
-      intersection = result;
-      return true;
-    }
-
-    static inline bool intersects(const half_edge& he1, const half_edge& he2) {
-      typedef rectangle_data<Unit> Rectangle;
-      Rectangle rect1, rect2;
-      set_points(rect1, he1.first, he1.second);
-      set_points(rect2, he2.first, he2.second);
-      if(::boost::polygon::intersects(rect1, rect2, false)) {
-        if(he1.first == he2.first) {
-          if(he1.second != he2.second && equal_slope(he1.first.get(HORIZONTAL), he1.first.get(VERTICAL),
-                                                     he1.second, he2.second)) {
-            return true;
-          } else {
-            return false;
-          }
-        }
-        if(he1.first == he2.second) {
-          if(he1.second != he2.first && equal_slope(he1.first.get(HORIZONTAL), he1.first.get(VERTICAL),
-                                                    he1.second, he2.first)) {
-            return true;
-          } else {
-            return false;
-          }
-        }
-        if(he1.second == he2.first) {
-          if(he1.first != he2.second && equal_slope(he1.second.get(HORIZONTAL), he1.second.get(VERTICAL),
-                                                    he1.first, he2.second)) {
-            return true;
-          } else {
-            return false;
-          }
-        }
-        if(he1.second == he2.second) {
-          if(he1.first != he2.first && equal_slope(he1.second.get(HORIZONTAL), he1.second.get(VERTICAL),
-                                                   he1.first, he2.first)) {
-            return true;
-          } else {
-            return false;
-          }
-        }
-        int oab1 = on_above_or_below(he1.first, he2);
-        if(oab1 == 0 && between(he1.first, he2.first, he2.second)) return true; 
-        int oab2 = on_above_or_below(he1.second, he2);
-        if(oab2 == 0 && between(he1.second, he2.first, he2.second)) return true; 
-        if(oab1 == oab2 && oab1 != 0) return false; //both points of he1 are on same side of he2
-        int oab3 = on_above_or_below(he2.first, he1);
-        if(oab3 == 0 && between(he2.first, he1.first, he1.second)) return true; 
-        int oab4 = on_above_or_below(he2.second, he1);
-        if(oab4 == 0 && between(he2.second, he1.first, he1.second)) return true; 
-        if(oab3 == oab4) return false; //both points of he2 are on same side of he1
-        return true; //they must cross
-      }
-      if(is_vertical(he1) && is_vertical(he2) && he1.first.get(HORIZONTAL) == he2.first.get(HORIZONTAL))
-        return ::boost::polygon::intersects(rect1.get(VERTICAL), rect2.get(VERTICAL), false) &&
-          rect1.get(VERTICAL) != rect2.get(VERTICAL);
-      if(is_horizontal(he1) && is_horizontal(he2) && he1.first.get(VERTICAL) == he2.first.get(VERTICAL))
-        return ::boost::polygon::intersects(rect1.get(HORIZONTAL), rect2.get(HORIZONTAL), false) &&
-          rect1.get(HORIZONTAL) != rect2.get(HORIZONTAL);
-      return false;
-    }
-
-    class vertex_half_edge {
-    public:
-      typedef typename high_precision_type<Unit>::type high_precision;
-      Point pt;
-      Point other_pt; // 1, 0 or -1
-      int count; //dxdydTheta
-      inline vertex_half_edge() {}
-      inline vertex_half_edge(const Point& point, const Point& other_point, int countIn) : pt(point), other_pt(other_point), count(countIn) {}
-      inline vertex_half_edge(const vertex_half_edge& vertex) : pt(vertex.pt), other_pt(vertex.other_pt), count(vertex.count) {}
-      inline vertex_half_edge& operator=(const vertex_half_edge& vertex){ 
-        pt = vertex.pt; other_pt = vertex.other_pt; count = vertex.count; return *this; }
-      inline vertex_half_edge(const std::pair<Point, Point>& vertex) {}
-      inline vertex_half_edge& operator=(const std::pair<Point, Point>& vertex){ return *this; }
-      inline bool operator==(const vertex_half_edge& vertex) const {
-        return pt == vertex.pt && other_pt == vertex.other_pt && count == vertex.count; }
-      inline bool operator!=(const vertex_half_edge& vertex) const { return !((*this) == vertex); }
-      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
-      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
-      inline bool operator<(const vertex_half_edge& vertex) const {
-        if(pt.get(HORIZONTAL) < vertex.pt.get(HORIZONTAL)) return true;
-        if(pt.get(HORIZONTAL) == vertex.pt.get(HORIZONTAL)) {
-          if(pt.get(VERTICAL) < vertex.pt.get(VERTICAL)) return true;
-          if(pt.get(VERTICAL) == vertex.pt.get(VERTICAL)) { return less_slope(pt.get(HORIZONTAL), pt.get(VERTICAL),
-                                                                              other_pt, vertex.other_pt);
-          }
-        }
-        return false;
-      }
-      inline bool operator>(const vertex_half_edge& vertex) const { return vertex < (*this); }
-      inline bool operator<=(const vertex_half_edge& vertex) const { return !((*this) > vertex); }
-      inline bool operator>=(const vertex_half_edge& vertex) const { return !((*this) < vertex); }
-      inline high_precision evalAtX(Unit xIn) const { return evalAtXforY(xIn, pt, other_pt); }
-      inline bool is_vertical() const {
-        return pt.get(HORIZONTAL) == other_pt.get(HORIZONTAL);
-      }
-      inline bool is_begin() const {
-        return pt.get(HORIZONTAL) < other_pt.get(HORIZONTAL) ||
-          (pt.get(HORIZONTAL) == other_pt.get(HORIZONTAL) &&
-           (pt.get(VERTICAL) < other_pt.get(VERTICAL)));
-      }
-    };
-
-    //when scanning Vertex45 for polygon formation we need a scanline comparator functor
-    class less_vertex_half_edge : public std::binary_function<vertex_half_edge, vertex_half_edge, bool> {
-    private:
-      Unit *x_; //x value at which to apply comparison
-      int *justBefore_;
-    public:
-      inline less_vertex_half_edge() : x_(0), justBefore_(0) {}
-      inline less_vertex_half_edge(Unit *x, int *justBefore) : x_(x), justBefore_(justBefore) {}
-      inline less_vertex_half_edge(const less_vertex_half_edge& that) : x_(that.x_), justBefore_(that.justBefore_) {}
-      inline less_vertex_half_edge& operator=(const less_vertex_half_edge& that) { x_ = that.x_; justBefore_ = that.justBefore_; return *this; }
-      inline bool operator () (const vertex_half_edge& elm1, const vertex_half_edge& elm2) const {
-        typedef typename high_precision_type<Unit>::type high_precision;
-        high_precision y1 = elm1.evalAtX(*x_);
-        high_precision y2 = elm2.evalAtX(*x_);
-        if(y1 < y2) return true;
-        if(y1 == y2) {
-          //if justBefore is true we invert the result of the comparison of slopes
-          bool result = less_slope(elm1.other_pt.get(HORIZONTAL) - elm1.pt.get(HORIZONTAL),
-                                   elm1.other_pt.get(VERTICAL) - elm1.pt.get(VERTICAL),
-                                   elm2.other_pt.get(HORIZONTAL) - elm2.pt.get(HORIZONTAL),
-                                   elm2.other_pt.get(VERTICAL) - elm2.pt.get(VERTICAL));
-          return (*justBefore_) ^ result;
-        }
-        return false;
-      }
-    };
-
-  };
-
-  template <typename Unit>
-  class polygon_arbitrary_formation : public scanline_base<Unit> {
-  public:
-    typedef typename scanline_base<Unit>::Point Point;
-    typedef typename scanline_base<Unit>::half_edge half_edge;
-    typedef typename scanline_base<Unit>::vertex_half_edge vertex_half_edge;
-    typedef typename scanline_base<Unit>::less_vertex_half_edge less_vertex_half_edge;
-    
-    class poly_line_arbitrary {
-    public:
-      typedef typename std::list<Point>::const_iterator iterator;
-
-      // default constructor of point does not initialize x and y
-      inline poly_line_arbitrary() : points() {} //do nothing default constructor
-
-      // initialize a polygon from x,y values, it is assumed that the first is an x
-      // and that the input is a well behaved polygon
-      template<class iT>
-      inline poly_line_arbitrary& set(iT inputBegin, iT inputEnd) {
-        points.clear();  //just in case there was some old data there
-        while(inputBegin != inputEnd) {
-          points.insert(points.end(), *inputBegin);
-          ++inputBegin;
-        }
-        return *this;
-      }
-
-      // copy constructor (since we have dynamic memory)
-      inline poly_line_arbitrary(const poly_line_arbitrary& that) : points(that.points) {}
-  
-      // assignment operator (since we have dynamic memory do a deep copy)
-      inline poly_line_arbitrary& operator=(const poly_line_arbitrary& that) {
-        points = that.points;
-        return *this;
-      }
-
-      // get begin iterator, returns a pointer to a const Unit
-      inline iterator begin() const { return points.begin(); }
-
-      // get end iterator, returns a pointer to a const Unit
-      inline iterator end() const { return points.end(); }
-
-      inline std::size_t size() const { return points.size(); }
-
-      //public data member
-      std::list<Point> points; 
-    };
-
-    class active_tail_arbitrary {
-    private:
-      //data
-      poly_line_arbitrary* tailp_; 
-      active_tail_arbitrary *otherTailp_;
-      std::list<active_tail_arbitrary*> holesList_;
-      bool head_;
-    public:
-   
-      /**
-       * @brief iterator over coordinates of the figure
-       */
-      typedef typename poly_line_arbitrary::iterator iterator;
-   
-      /**
-       * @brief iterator over holes contained within the figure
-       */
-      typedef typename std::list<active_tail_arbitrary*>::const_iterator iteratorHoles;
-   
-      //default constructor
-      inline active_tail_arbitrary() : tailp_(), otherTailp_(), holesList_(), head_() {}
-   
-      //constructor
-      inline active_tail_arbitrary(const vertex_half_edge& vertex, active_tail_arbitrary* otherTailp = 0) : tailp_(), otherTailp_(), holesList_(), head_() {
-        tailp_ = new poly_line_arbitrary;
-        tailp_->points.push_back(vertex.pt);
-        bool headArray[4] = {false, true, true, true};
-        bool inverted = vertex.count == -1;
-        head_ = (!vertex.is_vertical) ^ inverted;
-        otherTailp_ = otherTailp;
-      }
-
-      inline active_tail_arbitrary(Point point, active_tail_arbitrary* otherTailp, bool head = true) :
-        tailp_(), otherTailp_(), holesList_(), head_() {
-        tailp_ = new poly_line_arbitrary;
-        tailp_->points.push_back(point);
-        head_ = head;
-        otherTailp_ = otherTailp;
-      
-      }
-      inline active_tail_arbitrary(active_tail_arbitrary* otherTailp) :
-        tailp_(), otherTailp_(), holesList_(), head_() {
-        tailp_ = otherTailp->tailp_;
-        otherTailp_ = otherTailp;
-      }
-
-      //copy constructor
-      inline active_tail_arbitrary(const active_tail_arbitrary& that) :
-        tailp_(), otherTailp_(), holesList_(), head_() { (*this) = that; }
-
-      //destructor
-      inline ~active_tail_arbitrary() {
-        destroyContents();
-      }
-
-      //assignment operator
-      inline active_tail_arbitrary& operator=(const active_tail_arbitrary& that) {
-        tailp_ = new poly_line_arbitrary(*(that.tailp_));
-        head_ = that.head_;
-        otherTailp_ = that.otherTailp_;
-        holesList_ = that.holesList_;
-        return *this;
-      }
-
-      //equivalence operator
-      inline bool operator==(const active_tail_arbitrary& b) const {
-        return tailp_ == b.tailp_ && head_ == b.head_;
-      }
-
-      /**
-       * @brief get the pointer to the polyline that this is an active tail of
-       */
-      inline poly_line_arbitrary* getTail() const { return tailp_; }
-
-      /**
-       * @brief get the pointer to the polyline at the other end of the chain
-       */
-      inline poly_line_arbitrary* getOtherTail() const { return otherTailp_->tailp_; }
-
-      /**
-       * @brief get the pointer to the activetail at the other end of the chain
-       */
-      inline active_tail_arbitrary* getOtherActiveTail() const { return otherTailp_; }
-   
-      /**
-       * @brief test if another active tail is the other end of the chain
-       */
-      inline bool isOtherTail(const active_tail_arbitrary& b) const { return &b == otherTailp_; }
-
-      /**
-       * @brief update this end of chain pointer to new polyline
-       */
-      inline active_tail_arbitrary& updateTail(poly_line_arbitrary* newTail) { tailp_ = newTail; return *this; }
-
-      inline bool join(active_tail_arbitrary* tail) {
-        if(tail == otherTailp_) {
-          //std::cout << "joining to other tail!\n";
-          return false;
-        }
-        if(tail->head_ == head_) {
-          //std::cout << "joining head to head!\n";
-          return false;
-        }
-        if(!tailp_) {
-          //std::cout << "joining empty tail!\n";
-          return false;
-        }
-        if(!(otherTailp_->head_)) {
-          otherTailp_->copyHoles(*tail);
-          otherTailp_->copyHoles(*this);
-        } else {
-          tail->otherTailp_->copyHoles(*this);
-          tail->otherTailp_->copyHoles(*tail);
-        }
-        poly_line_arbitrary* tail1 = tailp_;
-        poly_line_arbitrary* tail2 = tail->tailp_;
-        if(head_) std::swap(tail1, tail2);
-        typename std::list<point_data<Unit> >::reverse_iterator riter = tail1->points.rbegin();
-        typename std::list<point_data<Unit> >::iterator iter = tail2->points.begin();
-        if(*riter == *iter) {
-          tail1->points.pop_back(); //remove duplicate point
-        }
-        tail1->points.splice(tail1->points.end(), tail2->points);
-        delete tail2;
-        otherTailp_->tailp_ = tail1;
-        tail->otherTailp_->tailp_ = tail1;
-        otherTailp_->otherTailp_ = tail->otherTailp_;
-        tail->otherTailp_->otherTailp_ = otherTailp_;
-        tailp_ = 0;
-        tail->tailp_ = 0;
-        tail->otherTailp_ = 0;
-        otherTailp_ = 0;
-        return true;
-      }
-
-      /**
-       * @brief associate a hole to this active tail by the specified policy
-       */
-      inline active_tail_arbitrary* addHole(active_tail_arbitrary* hole) {
-        holesList_.push_back(hole);
-        copyHoles(*hole);
-        copyHoles(*(hole->otherTailp_));
-        return this;
-      }
-
-      /**
-       * @brief get the list of holes
-       */
-      inline const std::list<active_tail_arbitrary*>& getHoles() const { return holesList_; }
-
-      /**
-       * @brief copy holes from that to this
-       */
-      inline void copyHoles(active_tail_arbitrary& that) { holesList_.splice(holesList_.end(), that.holesList_); }
-
-      /**
-       * @brief find out if solid to right
-       */
-      inline bool solidToRight() const { return !head_; }
-      inline bool solidToLeft() const { return head_; }
-
-      /**
-       * @brief get vertex
-       */
-      inline Point getPoint() const {
-        if(head_) return tailp_->points.front();
-        return tailp_->points.back();
-      }
-
-      /**
-       * @brief add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
-       */
-      inline void pushPoint(Point point) {
-        if(head_) {
-          //if(tailp_->points.size() < 2) {
-          //   tailp_->points.push_front(point);
-          //   return;
-          //}
-          typename std::list<Point>::iterator iter = tailp_->points.begin();
-          if(iter == tailp_->points.end()) {
-            tailp_->points.push_front(point);
-            return;
-          }
-          ++iter;
-          if(iter == tailp_->points.end()) {
-            tailp_->points.push_front(point);
-            return;
-          }
-          --iter;
-          if(*iter != point) {
-            tailp_->points.push_front(point);
-          }
-          return;
-        }
-        //if(tailp_->points.size() < 2) {
-        //   tailp_->points.push_back(point);
-        //   return;
-        //}
-        typename std::list<Point>::reverse_iterator iter = tailp_->points.rbegin();
-        if(iter == tailp_->points.rend()) {
-          tailp_->points.push_back(point);
-          return;
-        }
-        ++iter;
-        if(iter == tailp_->points.rend()) {
-          tailp_->points.push_back(point);
-          return;
-        }
-        --iter;
-        if(*iter != point) {
-          tailp_->points.push_back(point);
-        }
-      }
-
-      /**
-       * @brief joins the two chains that the two active tail tails are ends of
-       * checks for closure of figure and writes out polygons appropriately
-       * returns a handle to a hole if one is closed
-       */
-      template <class cT>
-      static inline active_tail_arbitrary* joinChains(Point point, active_tail_arbitrary* at1, active_tail_arbitrary* at2, bool solid, 
-                                                      cT& output) {
-        if(at1->otherTailp_ == at2) {
-          //if(at2->otherTailp_ != at1) std::cout << "half closed error\n";
-          //we are closing a figure
-          at1->pushPoint(point);
-          at2->pushPoint(point);
-          if(solid) {
-            //we are closing a solid figure, write to output
-            //std::cout << "test1\n";
-            at1->copyHoles(*(at1->otherTailp_));
-            typename PolyLineArbitraryByConcept<Unit, typename geometry_concept<typename cT::value_type>::type>::type polyData(at1);
-            //poly_line_arbitrary_polygon_data polyData(at1);
-            //std::cout << "test2\n";
-            //std::cout << poly << std::endl;
-            //std::cout << "test3\n";
-            typedef typename cT::value_type result_type;
-            typedef typename geometry_concept<result_type>::type result_concept;
-            output.push_back(result_type());
-            assign(output.back(), polyData);
-            //std::cout << "test4\n";
-            //std::cout << "delete " << at1->otherTailp_ << std::endl;
-            //at1->print();
-            //at1->otherTailp_->print();
-            delete at1->otherTailp_;
-            //at1->print();
-            //at1->otherTailp_->print();
-            //std::cout << "test5\n";
-            //std::cout << "delete " << at1 << std::endl;
-            delete at1;
-            //std::cout << "test6\n";
-            return 0;
-          } else {
-            //we are closing a hole, return the tail end active tail of the figure
-            return at1;
-          }
-        }
-        //we are not closing a figure
-        at1->pushPoint(point);
-        at1->join(at2);
-        delete at1;
-        delete at2;
-        return 0;
-      }
-
-      inline void destroyContents() {
-        if(otherTailp_) {
-          //std::cout << "delete p " << tailp_ << std::endl;
-          if(tailp_) delete tailp_;
-          tailp_ = 0;
-          otherTailp_->otherTailp_ = 0;
-          otherTailp_->tailp_ = 0;
-          otherTailp_ = 0;
-        }
-        for(typename std::list<active_tail_arbitrary*>::iterator itr = holesList_.begin(); itr != holesList_.end(); ++itr) {
-          //std::cout << "delete p " << (*itr) << std::endl;
-          if(*itr) {
-            if((*itr)->otherTailp_) {
-              delete (*itr)->otherTailp_;
-              (*itr)->otherTailp_ = 0;
-            }
-            delete (*itr);
-          }
-          (*itr) = 0;
-        }
-        holesList_.clear();
-      }
-
-      inline void print() {
-        std::cout << this << " " << tailp_ << " " << otherTailp_ << " " << holesList_.size() << " " << head_ << std::endl;
-      }
-
-      static inline std::pair<active_tail_arbitrary*, active_tail_arbitrary*> createActiveTailsAsPair(Point point, bool solid, 
-                                                                                                      active_tail_arbitrary* phole, bool fractureHoles) {
-        active_tail_arbitrary* at1 = 0;
-        active_tail_arbitrary* at2 = 0;
-        if(phole && fractureHoles) {
-          //std::cout << "adding hole\n";
-          at1 = phole;
-          //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
-          at2 = at1->getOtherActiveTail();
-          at2->pushPoint(point);
-          at1->pushPoint(point);
-        } else {
-          at1 = new active_tail_arbitrary(point, at2, solid);
-          at2 = new active_tail_arbitrary(at1);
-          at1->otherTailp_ = at2;
-          at2->head_ = !solid;
-          if(phole) 
-            at2->addHole(phole); //assert fractureHoles == false
-        }
-        return std::pair<active_tail_arbitrary*, active_tail_arbitrary*>(at1, at2);
-      }
-
-    };
-
-
-    typedef std::vector<std::pair<Point, int> > vertex_arbitrary_count;
-
-    class less_half_edge_count : public std::binary_function<vertex_half_edge, vertex_half_edge, bool> {
-    private:
-      Point pt_;
-    public:
-      inline less_half_edge_count() : pt_() {}
-      inline less_half_edge_count(Point point) : pt_(point) {}
-      inline bool operator () (const std::pair<Point, int>& elm1, const std::pair<Point, int>& elm2) const {
-        return less_slope(pt_.get(HORIZONTAL), pt_.get(VERTICAL), elm1.first, elm2.first);
-      }
-    };
-
-    static inline void sort_vertex_arbitrary_count(vertex_arbitrary_count& count, const Point& pt) {
-      less_half_edge_count lfec(pt);
-      std::sort(count.begin(), count.end(), lfec);
-    }
-
-    typedef std::vector<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*> > incoming_count;
-
-    class less_incoming_count : public std::binary_function<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>, 
-                                                            std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>, bool> {
-    private:
-      Point pt_;
-    public:
-      inline less_incoming_count() : pt_() {}
-      inline less_incoming_count(Point point) : pt_(point) {}
-      inline bool operator () (const std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>& elm1, 
-                               const std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>& elm2) const {
-        Unit dx1 = elm1.first.first.first.get(HORIZONTAL) - elm1.first.first.second.get(HORIZONTAL);
-        Unit dx2 = elm2.first.first.first.get(HORIZONTAL) - elm2.first.first.second.get(HORIZONTAL);
-        Unit dy1 = elm1.first.first.first.get(VERTICAL) - elm1.first.first.second.get(VERTICAL);
-        Unit dy2 = elm2.first.first.first.get(VERTICAL) - elm2.first.first.second.get(VERTICAL);
-        return less_slope(dx1, dy1, dx2, dy2);
-      }
-    };
-
-    static inline void sort_incoming_count(incoming_count& count, const Point& pt) {
-      less_incoming_count lfec(pt);
-      std::sort(count.begin(), count.end(), lfec);
-    }
-
-    static inline void compact_vertex_arbitrary_count(const Point& pt, vertex_arbitrary_count &count) {
-      if(count.empty()) return;
-      vertex_arbitrary_count tmp;
-      tmp.reserve(count.size());
-      tmp.push_back(count[0]);
-      //merge duplicates
-      for(unsigned int i = 1; i < count.size(); ++i) {
-        if(!equal_slope(pt.get(HORIZONTAL), pt.get(VERTICAL), tmp[i-1].first, count[i].first)) {
-          tmp.push_back(count[i]);
-        } else {
-          tmp.back().second += count[i].second;
-        }
-      }
-      count.clear();
-      count.swap(tmp);
-    }
-
-    // inline std::ostream& operator<< (std::ostream& o, const vertex_arbitrary_count& c) {
-//       for(unsinged int i = 0; i < c.size(); ++i) {
-//         o << c[i].first << " " << c[i].second << " ";
-//       }
-//       return o;
-//     }
-
-    class vertex_arbitrary_compact {
-    public:
-      Point pt;
-      vertex_arbitrary_count count;
-      inline vertex_arbitrary_compact() : pt(), count() {}
-      inline vertex_arbitrary_compact(const Point& point, const Point& other_point, int countIn) : pt(point), count() {
-        count.push_back(std::pair<Point, int>(other_point, countIn));
-      }
-      inline vertex_arbitrary_compact(const vertex_half_edge& vertex) : pt(vertex.pt), count() {
-        count.push_back(std::pair<Point, int>(vertex.other_pt, vertex.count));
-      }
-      inline vertex_arbitrary_compact(const vertex_arbitrary_compact& vertex) : pt(vertex.pt), count(vertex.count) {}
-      inline vertex_arbitrary_compact& operator=(const vertex_arbitrary_compact& vertex){ 
-        pt = vertex.pt; count = vertex.count; return *this; }
-      //inline vertex_arbitrary_compact(const std::pair<Point, Point>& vertex) {}
-      inline vertex_arbitrary_compact& operator=(const std::pair<Point, Point>& vertex){ return *this; }
-      inline bool operator==(const vertex_arbitrary_compact& vertex) const {
-        return pt == vertex.pt && count == vertex.count; }
-      inline bool operator!=(const vertex_arbitrary_compact& vertex) const { return !((*this) == vertex); }
-      inline bool operator==(const std::pair<Point, Point>& vertex) const { return false; }
-      inline bool operator!=(const std::pair<Point, Point>& vertex) const { return !((*this) == vertex); }
-      inline bool operator<(const vertex_arbitrary_compact& vertex) const {
-        if(pt.get(HORIZONTAL) < vertex.pt.get(HORIZONTAL)) return true;
-        if(pt.get(HORIZONTAL) == vertex.pt.get(HORIZONTAL)) {
-          return pt.get(VERTICAL) < vertex.pt.get(VERTICAL);
-        }
-        return false;
-      }
-      inline bool operator>(const vertex_arbitrary_compact& vertex) const { return vertex < (*this); }
-      inline bool operator<=(const vertex_arbitrary_compact& vertex) const { return !((*this) > vertex); }
-      inline bool operator>=(const vertex_arbitrary_compact& vertex) const { return !((*this) < vertex); }
-      inline bool have_vertex_half_edge(int index) const { return count[index]; }
-      inline vertex_half_edge operator[](int index) const { return vertex_half_edge(pt, count[index]); }
-      };
-
-//     inline std::ostream& operator<< (std::ostream& o, const vertex_arbitrary_compact& c) {
-//       o << c.pt << ", " << c.count;
-//       return o;
-//     }
-
-  private:
-    //definitions
-    typedef std::map<vertex_half_edge, active_tail_arbitrary*, less_vertex_half_edge> scanline_data;
-    typedef typename scanline_data::iterator iterator;
-    typedef typename scanline_data::const_iterator const_iterator;
-   
-    //data
-    scanline_data scanData_;
-    Unit x_;
-    int justBefore_;
-    int fractureHoles_; 
-  public:
-    inline polygon_arbitrary_formation() : 
-      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) {
-      less_vertex_half_edge lessElm(&x_, &justBefore_);
-      scanData_ = scanline_data(lessElm);
-    }
-    inline polygon_arbitrary_formation(bool fractureHoles = false) : 
-      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(fractureHoles) {
-      less_vertex_half_edge lessElm(&x_, &justBefore_);
-      scanData_ = scanline_data(lessElm);
-    }
-    inline polygon_arbitrary_formation(const polygon_arbitrary_formation& that) : 
-      scanData_(), x_((std::numeric_limits<Unit>::min)()), justBefore_(false), fractureHoles_(0) { (*this) = that; }
-    inline polygon_arbitrary_formation& operator=(const polygon_arbitrary_formation& that) {
-      x_ = that.x_;
-      justBefore_ = that.justBefore_;
-      fractureHoles_ = that.fractureHoles_;
-      less_vertex_half_edge lessElm(&x_, &justBefore_);
-      scanData_ = scanline_data(lessElm);
-      for(const_iterator itr = that.scanData_.begin(); itr != that.scanData_.end(); ++itr){
-        scanData_.insert(scanData_.end(), *itr);
-      }
-      return *this;
-    }
-   
-    //cT is an output container of Polygon45 or Polygon45WithHoles
-    //iT is an iterator over vertex_half_edge elements
-    //inputBegin - inputEnd is a range of sorted iT that represents
-    //one or more scanline stops worth of data
-    template <class cT, class iT>
-    void scan(cT& output, iT inputBegin, iT inputEnd) {
-      //std::cout << "1\n";
-      while(inputBegin != inputEnd) {
-        //std::cout << "2\n";
-        x_ = (*inputBegin).pt.get(HORIZONTAL);
-        //std::cout << "SCAN FORMATION " << x_ << std::endl;
-        //std::cout << "x_ = " << x_ << std::endl;
-        //std::cout << "scan line size: " << scanData_.size() << std::endl;
-        inputBegin = processEvent_(output, inputBegin, inputEnd);
-      }
-      //std::cout << "scan line size: " << scanData_.size() << std::endl;
-    }
-
-  private:
-    //functions
-    template <class cT, class cT2>
-    inline std::pair<std::pair<Point, int>, active_tail_arbitrary*> processPoint_(cT& output, cT2& elements, Point point, 
-                                                                                  incoming_count& counts_from_scanline, vertex_arbitrary_count& incoming_count) { 
-      //std::cout << "\nAT POINT: " <<  point << std::endl;
-      //join any closing solid corners
-      std::vector<int> counts;
-      std::vector<int> incoming;
-      std::vector<active_tail_arbitrary*> tails;
-      counts.reserve(counts_from_scanline.size());
-      tails.reserve(counts_from_scanline.size());
-      incoming.reserve(incoming_count.size());
-      for(unsigned int i = 0; i < counts_from_scanline.size(); ++i) {
-        counts.push_back(counts_from_scanline[i].first.second);
-        tails.push_back(counts_from_scanline[i].second);
-      }
-      for(unsigned int i = 0; i < incoming_count.size(); ++i) {
-        incoming.push_back(incoming_count[i].second);
-        if(incoming_count[i].first < point) {
-          incoming.back() = 0;
-        }
-      }
-        
-      active_tail_arbitrary* returnValue = 0;
-      std::pair<Point, int> returnCount(Point(0, 0), 0);
-      int i_size_less_1 = (int)(incoming.size()) -1;
-      int c_size_less_1 = (int)(counts.size()) -1;
-      int i_size = incoming.size();
-      int c_size = counts.size();
-
-      bool have_vertical_tail_from_below = false;
-      if(c_size &&
-         is_vertical(counts_from_scanline.back().first.first)) {
-        have_vertical_tail_from_below = true;
-      }
-      //assert size = size_less_1 + 1
-      //std::cout << tails.size() << " " << incoming.size() << " " << counts_from_scanline.size() << " " << incoming_count.size() << std::endl;
-      //         for(unsigned int i = 0; i < counts.size(); ++i) {
-      //           std::cout << counts_from_scanline[i].first.first.first.get(HORIZONTAL) << ",";
-      //           std::cout << counts_from_scanline[i].first.first.first.get(VERTICAL) << " ";
-      //           std::cout << counts_from_scanline[i].first.first.second.get(HORIZONTAL) << ",";
-      //           std::cout << counts_from_scanline[i].first.first.second.get(VERTICAL) << ":";
-      //           std::cout << counts_from_scanline[i].first.second << " ";
-      //         } std::cout << std::endl;
-      //         print(incoming_count);
-      {
-        for(int i = 0; i < c_size_less_1; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] == -1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < c_size; ++j) {
-              //std::cout << j << std::endl;
-              if(counts[j]) {
-                if(counts[j] == 1) {
-                  //std::cout << "case1: " << i << " " << j << std::endl;
-                  //if a figure is closed it will be written out by this function to output
-                  active_tail_arbitrary::joinChains(point, tails[i], tails[j], true, output); 
-                  counts[i] = 0;
-                  counts[j] = 0;
-                  tails[i] = 0;
-                  tails[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-      }
-      //find any pairs of incoming edges that need to create pair for leading solid
-      //std::cout << "checking case2\n";
-      {
-        for(int i = 0; i < i_size_less_1; ++i) {
-          //std::cout << i << std::endl;
-          if(incoming[i] == 1) {
-            //std::cout << "fixed i\n";
-            for(int j = i + 1; j < i_size; ++j) {
-              //std::cout << j << std::endl;
-              if(incoming[j]) {
-                //std::cout << incoming[j] << std::endl;
-                if(incoming[j] == -1) {
-                  //std::cout << "case2: " << i << " " << j << std::endl;
-                  //std::cout << "creating active tail pair\n";
-                  std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair = 
-                    active_tail_arbitrary::createActiveTailsAsPair(point, true, 0, fractureHoles_);
-                  //tailPair.first->print();
-                  //tailPair.second->print();
-                  if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
-                    //vertical active tail becomes return value
-                    returnValue = tailPair.first;
-                    returnCount.first = point;
-                    returnCount.second = 1;
-                  } else {
-                    //std::cout << "new element " << j-1 << " " << -1 << std::endl;
-                    //std::cout << point << " " <<  incoming_count[j].first << std::endl;
-                    elements.push_back(std::pair<vertex_half_edge, 
-                                       active_tail_arbitrary*>(vertex_half_edge(point,
-                                                                                incoming_count[j].first, -1), tailPair.first));
-                  }
-                  //std::cout << "new element " << i-1 << " " << 1 << std::endl;
-                  //std::cout << point << " " <<  incoming_count[i].first << std::endl;
-                  elements.push_back(std::pair<vertex_half_edge, 
-                                     active_tail_arbitrary*>(vertex_half_edge(point,
-                                                                              incoming_count[i].first, 1), tailPair.second));
-                  incoming[i] = 0;
-                  incoming[j] = 0;
-                }
-                break;
-              }
-            }
-          }
-        }
-      }
-      //find any active tail that needs to pass through to an incoming edge
-      //we expect to find no more than two pass through
-
-      //find pass through with solid on top
-      {
-        //std::cout << "checking case 3\n";
-        for(int i = 0; i < c_size; ++i) {
-          //std::cout << i << std::endl;
-          if(counts[i] != 0) {
-            if(counts[i] == 1) {
-              //std::cout << "fixed i\n";
-              for(int j = i_size_less_1; j >= 0; --j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == 1) {
-                    //std::cout << "case3: " << i << " " << j << std::endl;
-                    //tails[i]->print();
-                    //pass through solid on top
-                    tails[i]->pushPoint(point);
-                    //std::cout << "after push\n";
-                    if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
-                      returnValue = tails[i];
-                      returnCount.first = point;
-                      returnCount.second = -1;
-                    } else {
-                      elements.push_back(std::pair<vertex_half_edge, 
-                                         active_tail_arbitrary*>(vertex_half_edge(point, 
-                                                                                  incoming_count[j].first, incoming[j]), tails[i]));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-      }
-      //std::cout << "checking case 4\n";
-      //find pass through with solid on bottom
-      {
-        for(int i = c_size_less_1; i >= 0; --i) {
-          //std::cout << "i = " << i << " with count " << counts[i] << std::endl;
-          if(counts[i] != 0) {
-            if(counts[i] == -1) {
-              for(int j = 0; j < i_size; ++j) {
-                if(incoming[j] != 0) {
-                  if(incoming[j] == -1) {
-                    //std::cout << "case4: " << i << " " << j << std::endl;
-                    //pass through solid on bottom
-                    tails[i]->pushPoint(point);
-                    if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
-                      returnValue = tails[i];
-                      returnCount.first = point;
-                      returnCount.second = 1;
-                    } else {
-                      //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                      //std::cout << point << " " <<  incoming_count[j].first << std::endl;
-                      elements.push_back(std::pair<vertex_half_edge,
-                                         active_tail_arbitrary*>(vertex_half_edge(point,
-                                                                                  incoming_count[j].first, incoming[j]), tails[i]));
-                    }
-                    tails[i] = 0;
-                    counts[i] = 0;
-                    incoming[j] = 0;
-                  }
-                  break;
-                }
-              }
-            }
-            break;
-          }
-        }
-      }
-      //find the end of a hole or the beginning of a hole
-
-      //find end of a hole
-      {
-        for(int i = 0; i < c_size_less_1; ++i) {
-          if(counts[i] != 0) {
-            for(int j = i+1; j < c_size; ++j) {
-              if(counts[j] != 0) {
-                //std::cout << "case5: " << i << " " << j << std::endl;
-                //we are ending a hole and may potentially close a figure and have to handle the hole
-                returnValue = active_tail_arbitrary::joinChains(point, tails[i], tails[j], false, output);
-                if(returnValue) returnCount.first = point;
-                //std::cout << returnValue << std::endl;
-                tails[i] = 0;
-                tails[j] = 0;
-                counts[i] = 0;
-                counts[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        } 
-      }
-      //find beginning of a hole
-      {
-        for(int i = 0; i < i_size_less_1; ++i) {
-          if(incoming[i] != 0) {
-            for(int j = i+1; j < i_size; ++j) {
-              if(incoming[j] != 0) {
-                //std::cout << "case6: " << i << " " << j << std::endl;
-                //we are beginning a empty space
-                active_tail_arbitrary* holep = 0;
-                //if(c_size && counts[c_size_less_1] == 0 && 
-                //   counts_from_scanline[c_size_less_1].first.first.first.get(HORIZONTAL) == point.get(HORIZONTAL)) 
-                if(have_vertical_tail_from_below) {
-                  holep = tails[c_size_less_1];
-                  tails[c_size_less_1] = 0;
-                  have_vertical_tail_from_below = false;
-                }
-                std::pair<active_tail_arbitrary*, active_tail_arbitrary*> tailPair = 
-                  active_tail_arbitrary::createActiveTailsAsPair(point, false, holep, fractureHoles_);
-                if(j == i_size_less_1 && incoming_count[j].first.get(HORIZONTAL) == point.get(HORIZONTAL)) {
-                  //std::cout << "vertical element " << point << std::endl;
-                  returnValue = tailPair.first;
-                  returnCount.first = point;
-                  //returnCount = incoming_count[j];
-                  returnCount.second = -1;
-                } else {
-                  //std::cout << "new element " << j-1 << " " << incoming[j] << std::endl;
-                  //std::cout << point << " " <<  incoming_count[j].first << std::endl;
-                  elements.push_back(std::pair<vertex_half_edge, 
-                                     active_tail_arbitrary*>(vertex_half_edge(point,
-                                                                              incoming_count[j].first, incoming[j]), tailPair.first));
-                }
-                //std::cout << "new element " << i-1 << " " << incoming[i] << std::endl;
-                //std::cout << point << " " <<  incoming_count[i].first << std::endl;
-                elements.push_back(std::pair<vertex_half_edge, 
-                                   active_tail_arbitrary*>(vertex_half_edge(point,
-                                                                            incoming_count[i].first, incoming[i]), tailPair.second));
-                incoming[i] = 0;
-                incoming[j] = 0;
-                break;
-              }
-            }
-            break;
-          }
-        }
-      }
-      if(have_vertical_tail_from_below) {
-        if(tails.back()) {
-          tails.back()->pushPoint(point);
-          returnValue = tails.back();
-          returnCount.first = point;
-          returnCount.second = counts.back();
-        }
-      }
-      //assert that tails, counts and incoming are all null
-      return std::pair<std::pair<Point, int>, active_tail_arbitrary*>(returnCount, returnValue);
-    }
-
-    static inline void print(const vertex_arbitrary_count& count) {
-      for(unsigned i = 0; i < count.size(); ++i) {
-        std::cout << count[i].first.get(HORIZONTAL) << ",";
-        std::cout << count[i].first.get(VERTICAL) << ":";
-        std::cout << count[i].second << " ";
-      } std::cout << std::endl;
-    }
-
-    static inline void print(const scanline_data& data) {
-      for(typename scanline_data::const_iterator itr = data.begin(); itr != data.end(); ++itr){
-        std::cout << itr->first.pt << ", " << itr->first.other_pt << "; ";
-      } std::cout << std::endl;
-    }
-
-    template <class cT, class iT>
-    inline iT processEvent_(cT& output, iT inputBegin, iT inputEnd) {
-      typedef typename high_precision_type<Unit>::type high_precision;
-      //std::cout << "processEvent_\n";
-      justBefore_ = true;
-      //collect up all elements from the tree that are at the y
-      //values of events in the input queue
-      //create vector of new elements to add into tree
-      active_tail_arbitrary* verticalTail = 0;
-      std::pair<Point, int> verticalCount(Point(0, 0), 0);
-      iT currentIter = inputBegin;
-      std::vector<iterator> elementIters;
-      std::vector<std::pair<vertex_half_edge, active_tail_arbitrary*> > elements;
-      while(currentIter != inputEnd && currentIter->pt.get(HORIZONTAL) == x_) {
-        //std::cout << "loop\n";
-        Unit currentY = (*currentIter).pt.get(VERTICAL);
-        //std::cout << "current Y " << currentY << std::endl;
-        //std::cout << "scanline size " << scanData_.size() << std::endl;
-        //print(scanData_);
-        iterator iter = lookUp_(currentY);
-        //std::cout << "found element in scanline " << (iter != scanData_.end()) << std::endl;
-        //int counts[4] = {0, 0, 0, 0};
-        incoming_count counts_from_scanline;
-        //std::cout << "finding elements in tree\n";
-        //if(iter != scanData_.end())
-        //  std::cout << "first iter y is " << iter->first.evalAtX(x_) << std::endl;
-        while(iter != scanData_.end() &&
-              iter->first.evalAtX(x_) == (high_precision)currentY) {
-          //std::cout << "loop2\n";
-          elementIters.push_back(iter);
-          counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
-                                         (std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(iter->first.pt,
-                                                                                                          iter->first.other_pt), 
-                                                                                  iter->first.count),
-                                          iter->second));
-          ++iter;
-        }
-        Point currentPoint(x_, currentY);
-        //std::cout << "counts_from_scanline size " << counts_from_scanline.size() << std::endl;
-        sort_incoming_count(counts_from_scanline, currentPoint);
-
-        vertex_arbitrary_count incoming;
-        //std::cout << "aggregating\n";
-        do {
-          //std::cout << "loop3\n";
-          const vertex_half_edge& elem = *currentIter;
-          incoming.push_back(std::pair<Point, int>(elem.other_pt, elem.count));
-          ++currentIter;
-        } while(currentIter != inputEnd && currentIter->pt.get(VERTICAL) == currentY &&
-                currentIter->pt.get(HORIZONTAL) == x_);
-        //print(incoming);
-        sort_vertex_arbitrary_count(incoming, currentPoint);
-        //std::cout << currentPoint.get(HORIZONTAL) << "," << currentPoint.get(VERTICAL) << std::endl;
-        //print(incoming);
-        //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
-        //compact_vertex_arbitrary_count(currentPoint, incoming);
-        vertex_arbitrary_count tmp;
-        tmp.reserve(incoming.size());
-        for(unsigned int i = 0; i < incoming.size(); ++i) {
-          if(currentPoint < incoming[i].first) {
-            tmp.push_back(incoming[i]);
-          }
-        }
-        incoming.swap(tmp);
-        //std::cout << "incoming counts from input size " << incoming.size() << std::endl;
-        //now counts_from_scanline has the data from the left and
-        //incoming has the data from the right at this point
-        //cancel out any end points
-        if(verticalTail) {
-          //std::cout << "adding vertical tail to counts from scanline\n";
-          //std::cout << -verticalCount.second << std::endl;
-          counts_from_scanline.push_back(std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*>
-                                         (std::pair<std::pair<Point, Point>, int>(std::pair<Point, Point>(verticalCount.first, 
-                                                                                                          currentPoint), 
-                                                                                  -verticalCount.second),
-                                          verticalTail));
-        }
-        if(!incoming.empty() && incoming.back().first.get(HORIZONTAL) == x_) {
-          //std::cout << "inverted vertical event\n";
-          incoming.back().second *= -1;
-        }
-        //std::cout << "calling processPoint_\n";
-        std::pair<std::pair<Point, int>, active_tail_arbitrary*> result = processPoint_(output, elements, Point(x_, currentY), counts_from_scanline, incoming);
-        verticalCount = result.first;
-        verticalTail = result.second;
-        //if(verticalTail) {
-        //  std::cout << "have vertical tail\n";
-        //  std::cout << verticalCount.second << std::endl;
-        //}
-        if(verticalTail && !(verticalCount.second)) {
-          //we got a hole out of the point we just processed
-          //iter is still at the next y element above the current y value in the tree
-          //std::cout << "checking whether ot handle hole\n";
-          if(currentIter == inputEnd || 
-             currentIter->pt.get(HORIZONTAL) != x_ ||
-             (high_precision)(currentIter->pt.get(VERTICAL)) >= iter->first.evalAtX(x_)) {
-            //std::cout << "handle hole here\n";
-            if(fractureHoles_) {
-              //std::cout << "fracture hole here\n";
-              //we need to handle the hole now and not at the next input vertex
-              active_tail_arbitrary* at = iter->second;
-              high_precision precise_y = iter->first.evalAtX(x_);
-              Unit fracture_y = (Unit)(precise_y);
-              if(precise_y < fracture_y) --fracture_y;
-              Point point(x_, fracture_y);
-              verticalTail->getOtherActiveTail()->pushPoint(point);
-              iter->second = verticalTail->getOtherActiveTail();
-              at->pushPoint(point);
-              verticalTail->join(at);
-              delete at;
-              delete verticalTail;
-              verticalTail = 0;
-            } else {
-              //std::cout << "push hole onto list\n";
-              iter->second->addHole(verticalTail);
-              verticalTail = 0;
-            }
-          }
-        }
-      }
-      //std::cout << "erasing\n";
-      //erase all elements from the tree
-      for(typename std::vector<iterator>::iterator iter = elementIters.begin();
-          iter != elementIters.end(); ++iter) {
-        //std::cout << "erasing loop\n";
-        scanData_.erase(*iter);
-      }
-      //switch comparison tie breaking policy
-      justBefore_ = false;
-      //add new elements into tree
-      //std::cout << "inserting\n";
-      for(typename std::vector<std::pair<vertex_half_edge, active_tail_arbitrary*> >::iterator iter = elements.begin();
-          iter != elements.end(); ++iter) {
-        //std::cout << "inserting loop\n";
-        scanData_.insert(scanData_.end(), *iter);
-      }
-      //std::cout << "end processEvent\n";
-      return currentIter;
-    }
-   
-    inline iterator lookUp_(Unit y){
-      //if just before then we need to look from 1 not -1
-      //std::cout << "just before " << justBefore_ << std::endl;
-      return scanData_.lower_bound(vertex_half_edge(Point(x_, y), Point(x_, y+1), 0));
-    }
-      
-  public: //test functions
-      
-    static inline bool testPolygonArbitraryFormationRect() {
-      std::cout << "testing polygon formation\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(10, 10), -1));
-      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 10), -1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(0, 10), 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationP1() {
-      std::cout << "testing polygon formation P1\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 10), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(10, 20), -1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 20), -1));
-      data.push_back(vertex_half_edge(Point(10, 20), Point(10, 10), 1));
-      data.push_back(vertex_half_edge(Point(10, 20), Point(0, 10), 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationP2() {
-      std::cout << "testing polygon formation P2\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(-3, 1), Point(2, -4), 1));
-      data.push_back(vertex_half_edge(Point(-3, 1), Point(-2, 2), -1));
-      data.push_back(vertex_half_edge(Point(-2, 2), Point(2, 4), -1));
-      data.push_back(vertex_half_edge(Point(-2, 2), Point(-3, 1), 1));
-      data.push_back(vertex_half_edge(Point(2, -4), Point(-3, 1), -1));
-      data.push_back(vertex_half_edge(Point(2, -4), Point(2, 4), -1));
-      data.push_back(vertex_half_edge(Point(2, 4), Point(-2, 2), 1));
-      data.push_back(vertex_half_edge(Point(2, 4), Point(2, -4), 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-
-    static inline bool testPolygonArbitraryFormationPolys() {
-      std::cout << "testing polygon formation polys\n";
-      polygon_arbitrary_formation pf(false);
-      std::vector<polygon_with_holes_data<Unit> > polys;
-      polygon_arbitrary_formation pf2(true);
-      std::vector<polygon_with_holes_data<Unit> > polys2;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(100, 1), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(1, 100), -1));
-      data.push_back(vertex_half_edge(Point(1, 100), Point(0, 0), 1));
-      data.push_back(vertex_half_edge(Point(1, 100), Point(101, 101), -1));
-      data.push_back(vertex_half_edge(Point(100, 1), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(100, 1), Point(101, 101), 1));
-      data.push_back(vertex_half_edge(Point(101, 101), Point(100, 1), -1));
-      data.push_back(vertex_half_edge(Point(101, 101), Point(1, 100), 1));
-
-      data.push_back(vertex_half_edge(Point(2, 2), Point(10, 2), -1));
-      data.push_back(vertex_half_edge(Point(2, 2), Point(2, 10), -1));
-      data.push_back(vertex_half_edge(Point(2, 10), Point(2, 2), 1));
-      data.push_back(vertex_half_edge(Point(2, 10), Point(10, 10), 1));
-      data.push_back(vertex_half_edge(Point(10, 2), Point(2, 2), 1));
-      data.push_back(vertex_half_edge(Point(10, 2), Point(10, 10), 1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(10, 2), -1));
-      data.push_back(vertex_half_edge(Point(10, 10), Point(2, 10), -1));
-
-      data.push_back(vertex_half_edge(Point(2, 12), Point(10, 12), -1));
-      data.push_back(vertex_half_edge(Point(2, 12), Point(2, 22), -1));
-      data.push_back(vertex_half_edge(Point(2, 22), Point(2, 12), 1));
-      data.push_back(vertex_half_edge(Point(2, 22), Point(10, 22), 1));
-      data.push_back(vertex_half_edge(Point(10, 12), Point(2, 12), 1));
-      data.push_back(vertex_half_edge(Point(10, 12), Point(10, 22), 1));
-      data.push_back(vertex_half_edge(Point(10, 22), Point(10, 12), -1));
-      data.push_back(vertex_half_edge(Point(10, 22), Point(2, 22), -1));
-
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      pf2.scan(polys2, data.begin(), data.end());
-      std::cout << "result size: " << polys2.size() << std::endl;
-      for(unsigned int i = 0; i < polys2.size(); ++i) {
-        std::cout << polys2[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationSelfTouch1() {
-      std::cout << "testing polygon formation self touch 1\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
-
-      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(5, 10), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
-
-      data.push_back(vertex_half_edge(Point(5, 10), Point(5, 5), 1));
-      data.push_back(vertex_half_edge(Point(5, 10), Point(0, 10), 1));
-      
-      data.push_back(vertex_half_edge(Point(5, 2), Point(5, 5), -1));
-      data.push_back(vertex_half_edge(Point(5, 2), Point(7, 2), -1));
-      
-      data.push_back(vertex_half_edge(Point(5, 5), Point(5, 10), -1));
-      data.push_back(vertex_half_edge(Point(5, 5), Point(5, 2), 1));
-      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
-      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
-      
-      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
-      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 2), 1));
-      
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationSelfTouch2() {
-      std::cout << "testing polygon formation self touch 2\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
-
-      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(5, 10), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
-
-      data.push_back(vertex_half_edge(Point(5, 10), Point(4, 1), -1));
-      data.push_back(vertex_half_edge(Point(5, 10), Point(0, 10), 1));
-      
-      data.push_back(vertex_half_edge(Point(4, 1), Point(5, 10), 1));
-      data.push_back(vertex_half_edge(Point(4, 1), Point(7, 2), -1));
-      
-      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
-      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
-      
-      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
-      data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
-      
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationSelfTouch3() {
-      std::cout << "testing polygon formation self touch 3\n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(0, 0), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(0, 0), Point(0, 10), 1));
-
-      data.push_back(vertex_half_edge(Point(0, 10), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(0, 10), Point(6, 10), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 0), Point(0, 0), -1));
-      data.push_back(vertex_half_edge(Point(10, 0), Point(10, 5), -1));
-
-      data.push_back(vertex_half_edge(Point(10, 5), Point(10, 0), 1));
-      data.push_back(vertex_half_edge(Point(10, 5), Point(5, 5), 1));
-
-      data.push_back(vertex_half_edge(Point(6, 10), Point(4, 1), -1));
-      data.push_back(vertex_half_edge(Point(6, 10), Point(0, 10), 1));
-      
-      data.push_back(vertex_half_edge(Point(4, 1), Point(6, 10), 1));
-      data.push_back(vertex_half_edge(Point(4, 1), Point(7, 2), -1));
-      
-      data.push_back(vertex_half_edge(Point(5, 5), Point(10, 5), -1));
-      data.push_back(vertex_half_edge(Point(5, 5), Point(7, 2), 1));
-      
-      data.push_back(vertex_half_edge(Point(7, 2), Point(5, 5), -1));
-      data.push_back(vertex_half_edge(Point(7, 2), Point(4, 1), 1));
-      
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testPolygonArbitraryFormationColinear() {
-      std::cout << "testing polygon formation colinear 3\n";
-      std::cout << "Polygon Set Data { <-3 2, -2 2>:1 <-3 2, -1 4>:-1 <-2 2, 0 2>:1 <-1 4, 0 2>:-1 } \n";
-      polygon_arbitrary_formation pf(true);
-      std::vector<polygon_data<Unit> > polys;
-      std::vector<vertex_half_edge> data;
-      data.push_back(vertex_half_edge(Point(-3, 2), Point(-2, 2), 1));
-      data.push_back(vertex_half_edge(Point(-2, 2), Point(-3, 2), -1));
-
-      data.push_back(vertex_half_edge(Point(-3, 2), Point(-1, 4), -1));
-      data.push_back(vertex_half_edge(Point(-1, 4), Point(-3, 2), 1));
-
-      data.push_back(vertex_half_edge(Point(-2, 2), Point(0, 2), 1));
-      data.push_back(vertex_half_edge(Point(0, 2), Point(-2, 2), -1));
-
-      data.push_back(vertex_half_edge(Point(-1, 4), Point(0, 2), -1));
-      data.push_back(vertex_half_edge(Point(0, 2), Point(-1, 4), 1));
-      std::sort(data.begin(), data.end());
-      pf.scan(polys, data.begin(), data.end());
-      std::cout << "result size: " << polys.size() << std::endl;
-      for(unsigned int i = 0; i < polys.size(); ++i) {
-        std::cout << polys[i] << std::endl;
-      }
-      std::cout << "done testing polygon formation\n";
-      return true;
-    }
-
-    static inline bool testSegmentIntersection() {
-      std::cout << "testing segment intersection\n";
-      half_edge he1, he2;
-      he1.first = Point(0, 0);
-      he1.second = Point(10, 10);
-      he2.first = Point(0, 0);
-      he2.second = Point(10, 20);
-      Point result;
-      bool b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(0, 0)) return false;
-      he1.first = Point(0, 10);
-      b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(5, 10)) return false;
-      he1.first = Point(0, 11);
-      b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(5, 10)) return false;
-      he1.first = Point(0, 0);
-      he1.second = Point(1, 9);
-      he2.first = Point(0, 9);
-      he2.second = Point(1, 0);
-      b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(0, 4)) return false;
-
-      he1.first = Point(0, -10);
-      he1.second = Point(1, -1);
-      he2.first = Point(0, -1);
-      he2.second = Point(1, -10);
-      b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(0, -5)) return false;
-      he1.first = Point((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)()-1);
-      he1.second = Point((std::numeric_limits<int>::min)(), (std::numeric_limits<int>::max)());
-      //he1.second = Point(0, (std::numeric_limits<int>::max)());
-      he2.first = Point((std::numeric_limits<int>::max)()-1, (std::numeric_limits<int>::max)());
-      he2.second = Point((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::min)());
-      //he2.second = Point((std::numeric_limits<int>::max)(), 0);
-      b = compute_intersection(result, he1, he2);
-      //b is false because of overflow error
-      he1.first = Point(1000, 2000);
-      he1.second = Point(1010, 2010);
-      he2.first = Point(1000, 2000);
-      he2.second = Point(1010, 2020);
-      b = compute_intersection(result, he1, he2);
-      if(!b || result != Point(1000, 2000)) return false;
-
-      return b;
-    }
-  
-  };
-
-  template <typename Unit>
-  class poly_line_arbitrary_hole_data {
-  private:
-    typedef typename polygon_arbitrary_formation<Unit>::active_tail_arbitrary active_tail_arbitrary;
-    active_tail_arbitrary* p_;
-  public:
-    typedef point_data<Unit> Point;
-    typedef Point point_type;
-    typedef Unit coordinate_type;
-    typedef typename active_tail_arbitrary::iterator iterator_type;
-    //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
-    
-    typedef iterator_type iterator;
-    inline poly_line_arbitrary_hole_data() : p_(0) {}
-    inline poly_line_arbitrary_hole_data(active_tail_arbitrary* p) : p_(p) {}
-    //use default copy and assign
-    inline iterator begin() const { return p_->getTail()->begin(); }
-    inline iterator end() const { return p_->getTail()->end(); }
-    //inline compact_iterator_type begin_compact() const { return compact_iterator_type(begin()); }
-    //inline compact_iterator_type end_compact() const { return compact_iterator_type(end()); }
-    inline unsigned int size() const { return 0; }
-    template<class iT>
-    inline poly_line_arbitrary_hole_data& set(iT inputBegin, iT inputEnd) {
-      //assert this is not called
-      return *this;
-    }
-    template<class iT>
-    inline poly_line_arbitrary_hole_data& set_compact(iT inputBegin, iT inputEnd) {
-      //assert this is not called
-      return *this;
-    }
-  };
-
-  template <typename Unit>
-  class poly_line_arbitrary_polygon_data {
-  private:
-    typedef typename polygon_arbitrary_formation<Unit>::active_tail_arbitrary active_tail_arbitrary;
-    active_tail_arbitrary* p_;
-  public:
-    typedef point_data<Unit> Point;
-    typedef Point point_type;
-    typedef Unit coordinate_type;
-    typedef typename active_tail_arbitrary::iterator iterator_type;
-    //typedef iterator_points_to_compact<iterator_type, Point> compact_iterator_type;
-    typedef typename coordinate_traits<Unit>::coordinate_distance area_type;
-
-    class iterator_holes_type {
-    private:
-      typedef poly_line_arbitrary_hole_data<Unit> holeType;
-      mutable holeType hole_;
-      typename active_tail_arbitrary::iteratorHoles itr_;
-        
-    public:
-      typedef std::forward_iterator_tag iterator_category;
-      typedef holeType value_type;
-      typedef std::ptrdiff_t difference_type;
-      typedef const holeType* pointer; //immutable
-      typedef const holeType& reference; //immutable
-      inline iterator_holes_type() : hole_(), itr_() {}
-      inline iterator_holes_type(typename active_tail_arbitrary::iteratorHoles itr) : hole_(), itr_(itr) {}
-      inline iterator_holes_type(const iterator_holes_type& that) : hole_(that.hole_), itr_(that.itr_) {} 
-      inline iterator_holes_type& operator=(const iterator_holes_type& that) {
-        itr_ = that.itr_;
-        return *this;
-      }
-      inline bool operator==(const iterator_holes_type& that) { return itr_ == that.itr_; }
-      inline bool operator!=(const iterator_holes_type& that) { return itr_ != that.itr_; }
-      inline iterator_holes_type& operator++() {
-        ++itr_;
-        return *this;
-      }
-      inline const iterator_holes_type operator++(int) {
-        iterator_holes_type tmp = *this;
-        ++(*this);
-        return tmp;
-      }
-      inline reference operator*() {
-        hole_ = holeType(*itr_);
-        return hole_;
-      }
-    };
-
-    typedef poly_line_arbitrary_hole_data<Unit> hole_type;
-
-    inline poly_line_arbitrary_polygon_data() : p_(0) {}
-    inline poly_line_arbitrary_polygon_data(active_tail_arbitrary* p) : p_(p) {}
-    //use default copy and assign
-    inline iterator_type begin() const { return p_->getTail()->begin(); }
-    inline iterator_type end() const { return p_->getTail()->end(); }
-    //inline compact_iterator_type begin_compact() const { return p_->getTail()->begin(); }
-    //inline compact_iterator_type end_compact() const { return p_->getTail()->end(); }
-    inline iterator_holes_type begin_holes() const { return iterator_holes_type(p_->getHoles().begin()); }
-    inline iterator_holes_type end_holes() const { return iterator_holes_type(p_->getHoles().end()); }
-    inline active_tail_arbitrary* yield() { return p_; }
-    //stub out these four required functions that will not be used but are needed for the interface
-    inline unsigned int size_holes() const { return 0; }
-    inline unsigned int size() const { return 0; }
-    template<class iT>
-    inline poly_line_arbitrary_polygon_data& set(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-    template<class iT>
-    inline poly_line_arbitrary_polygon_data& set_compact(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-    template<class iT>
-    inline poly_line_arbitrary_polygon_data& set_holes(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-  };
-    
-  template <typename T>
-  struct PolyLineArbitraryByConcept<T, polygon_with_holes_concept> { typedef poly_line_arbitrary_polygon_data<T> type; };
-  template <typename T>
-  struct PolyLineArbitraryByConcept<T, polygon_concept> { typedef poly_line_arbitrary_hole_data<T> type; };
-
-  template <typename T>
-  struct geometry_concept<poly_line_arbitrary_polygon_data<T> > { typedef polygon_45_with_holes_concept type; };
-  template <typename T>
-  struct geometry_concept<poly_line_arbitrary_hole_data<T> > { typedef polygon_45_concept type; };
-}
-}
-#endif
Modified: sandbox/gtl/boost/polygon/polygon_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,30 +5,75 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_DATA_HPP
-#define GTL_POLYGON_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_DATA_HPP
+#define BOOST_POLYGON_POLYGON_DATA_HPP
 namespace boost { namespace polygon{
-  struct polygon_concept;
-  template <typename T>
-  class polygon_data : public polygon_45_data<T> {
-  public:
-    typedef polygon_concept geometry_type;
-    
-    inline polygon_data() : polygon_45_data<T>() {} //do nothing default constructor
+struct polygon_concept;
+template <typename T>
+class polygon_data {
+public:
+  typedef polygon_concept geometry_type;
+  typedef T coordinate_type;
+  typedef typename std::vector<point_data<coordinate_type> >::const_iterator iterator_type;
+  typedef typename coordinate_traits<T>::coordinate_distance area_type;
+  typedef point_data<T> point_type;
+
+  inline polygon_data() : coords_() {} //do nothing default constructor
+
+  template<class iT>
+  inline polygon_data(iT input_begin, iT input_end) : coords_(input_begin, input_end) {}
 
-    template<class iT>
-    inline polygon_data(iT input_begin, iT input_end) : polygon_45_data<T>(input_begin, input_end) {}  
+  template<class iT>
+  inline polygon_data& set(iT input_begin, iT input_end) {
+    coords_.clear();  //just in case there was some old data there
+    coords_.insert(coords_.end(), input_begin, input_end);
+    return *this;
+  }
 
-    // copy constructor (since we have dynamic memory)
-    inline polygon_data(const polygon_data& that) : polygon_45_data<T>(that.coords_.begin(), that.coords_.end()) {}
+  // copy constructor (since we have dynamic memory)
+  inline polygon_data(const polygon_data& that) : coords_(that.coords_) {}
   
-    // assignment operator (since we have dynamic memory do a deep copy)
-    inline polygon_data& operator=(const polygon_data& that) {
-      this->coords_ = that.coords_;
-      return *this;
+  // assignment operator (since we have dynamic memory do a deep copy)
+  inline polygon_data& operator=(const polygon_data& that) {
+    coords_ = that.coords_;
+    return *this;
+  }
+
+  template <typename T2>
+  inline polygon_data& operator=(const T2& rvalue);
+
+  inline bool operator==(const polygon_data& that) const {
+    if(coords_.size() != that.coords_.size()) return false;
+    for(unsigned int i = 0; i < coords_.size(); ++i) {
+      if(coords_[i] != that.coords_[i]) return false;
     }
-  };
-  
+    return true;
+  }
+
+  inline bool operator!=(const polygon_data& that) const { return !((*this) == that); }
+
+  // get begin iterator, returns a pointer to a const Unit
+  inline iterator_type begin() const { return coords_.begin(); }
+
+  // get end iterator, returns a pointer to a const Unit
+  inline iterator_type end() const { return coords_.end(); }
+
+  inline std::size_t size() const { return coords_.size(); }
+
+private:
+  std::vector<point_data<coordinate_type> > coords_; 
+};
+  template <typename T>
+  std::ostream& operator<<(std::ostream& o, const polygon_data<T>& poly) {
+    o << "Polygon { ";
+    for(typename polygon_data<T>::iterator_type itr = poly.begin(); 
+        itr != poly.end(); ++itr) {
+      if(itr != poly.begin()) o << ", ";
+      o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
+    } 
+    o << " } ";
+    return o;
+  } 
 }
 }
 #endif
Deleted: sandbox/gtl/boost/polygon/polygon_formation.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,1807 +0,0 @@
-/*
-    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 GTL_POLYGON_FORMATION_HPP
-#define GTL_POLYGON_FORMATION_HPP
-namespace boost { namespace polygon{
-
-namespace polygon_formation {
-
-  /*
-   * End has two states, HEAD and TAIL as is represented by a bool
-   */
-  typedef bool End;
-
-  /*
-   * HEAD End is represented as false because it is the lesser state
-   */
-  const End HEAD = false;
-
-  /*
-   * TAIL End is represented by true because TAIL comes after head and 1 after 0
-   */
-  const End TAIL = true;
-   
-  /*
-   * 2D turning direction, left and right sides (is a boolean value since it has two states.)
-   */
-  typedef bool Side;
-   
-  /*
-   * LEFT Side is 0 because we inuitively think left to right; left < right
-   */
-  const Side LEFT = false;
-   
-  /*
-   * RIGHT Side is 1 so that right > left
-   */
-  const Side RIGHT = true;
-
-  /*
-   * The PolyLine class is data storage and services for building and representing partial polygons.  
-   * As the polyline is added to it extends its storage to accomodate the data.
-   * PolyLines can be joined head-to-head/head-to-tail when it is determined that two polylines are
-   * part of the same polygon.
-   * PolyLines keep state information about what orientation their incomplete head and tail geometry have,
-   * which side of the polyline is solid and whether the polyline is joined head-to-head and tail-to-head.
-   * PolyLines have nothing whatsoever to do with holes.
-   * It may be valuable to collect a histogram of PolyLine lengths used by an algorithm on its typical data
-   * sets and tune the allocation of the initial vector of coordinate data to be greater than or equal to
-   * the mean, median, mode, or mean plus some number of standard deviation, or just generally large enough
-   * to prevent too much unnecesary reallocations, but not too big that it wastes a lot of memory and degrades cache
-   * performance.
-   */
-  template <typename Unit>
-  class PolyLine {
-  private:
-    //data
-     
-    /*
-     * ptdata_ a vector of coordiantes
-     * if VERTICAL_HEAD, first coordiante is an X
-     * else first coordinate is a Y
-     */
-    std::vector<Unit> ptdata_;
-   
-    /*
-     * head and tail points to other polylines before and after this in a chain
-     */
-    PolyLine* headp_;
-    PolyLine* tailp_;
-   
-    /*
-     * state bitmask
-     * bit zero is orientation, 0 H, 1 V
-     * bit 1 is head connectivity, 0 for head, 1 for tail
-     * bit 2 is tail connectivity, 0 for head, 1 for tail
-     * bit 3 is solid to left of PolyLine when 1, right when 0
-     */
-    int state_;
-   
-  public:
-    /*
-     * default constructor (for preallocation)
-     */
-    PolyLine();
-   
-    /*
-     * constructor that takes the orientation, coordiante and side to which there is solid
-     */
-    PolyLine(orientation_2d orient, Unit coord, Side side);
-   
-    //copy constructor
-    PolyLine(const PolyLine& pline);
-   
-    //destructor
-    ~PolyLine();
-   
-    //assignment operator
-    PolyLine& operator=(const PolyLine& that);
-
-    //equivalence operator
-    bool operator==(const PolyLine& b) const;
-
-    /*
-     * valid PolyLine (only default constructed polylines are invalid.)
-     */
-    bool isValid() const;
-
-    /*
-     * Orientation of Head
-     */
-    orientation_2d headOrient() const;
-
-    /*
-     * returns true if first coordinate is an X value (first segment is vertical)
-     */
-    bool verticalHead() const; 
-
-    /*
-     * returns the orientation_2d fo the tail
-     */
-    orientation_2d tailOrient() const;
-      
-    /*
-     * returns true if last coordinate is an X value (last segment is vertical)
-     */
-    bool verticalTail() const;
-     
-    /*
-     * retrun true if PolyLine has odd number of coordiantes
-     */
-    bool oddLength() const;
-
-    /*
-     * retrun the End of the other polyline that the specified end of this polyline is connected to
-     */
-    End endConnectivity(End end) const;
-
-    /*
-     * retrun true if the head of this polyline is connect to the tail of a polyline
-     */
-    bool headToTail() const;
-    /*
-     * retrun true if the head of this polyline is connect to the head of a polyline
-     */
-    bool headToHead() const;
-
-    /*
-     * retrun true if the tail of this polyline is connect to the tail of a polyline
-     */
-    bool tailToTail() const;
-    /*
-     * retrun true if the tail of this polyline is connect to the head of a polyline
-     */
-    bool tailToHead() const;
-     
-    /*
-     * retrun the side on which there is solid for this polyline
-     */
-    Side solidSide() const;
-
-    /*
-     * retrun true if there is solid to the right of this polyline
-     */
-    bool solidToRight() const;
-
-    /*
-     * returns true if the polyline tail is not connected
-     */
-    bool active() const;
-
-    /*
-     * adds a coordinate value to the end of the polyline changing the tail orientation
-     */
-    PolyLine& pushCoordinate(Unit coord);
-       
-    /*
-     * removes a coordinate value at the end of the polyline changing the tail orientation
-     */
-    PolyLine& popCoordinate();
-      
-    /*
-     * extends the tail of the polyline to include the point, changing orientation if needed
-     */
-    PolyLine& pushPoint(const point_data<Unit>& point);
-
-    /*
-     * changes the last coordinate of the tail of the polyline by the amount of the delta
-     */
-    PolyLine& extendTail(Unit delta);
-
-    /*
-     * join thisEnd of this polyline to that polyline's end
-     */
-    PolyLine& joinTo(End thisEnd, PolyLine& that, End end);
-
-    /*
-     * join an end of this polyline to the tail of that polyline
-     */
-    PolyLine& joinToTail(PolyLine& that, End end);
-
-    /*
-     * join an end of this polyline to the head of that polyline
-     */
-    PolyLine& joinToHead(PolyLine& that, End end);
-
-    /*
-     * join the head of this polyline to the head of that polyline
-     */
-    //join this to that in the given way
-    PolyLine& joinHeadToHead(PolyLine& that);
-
-    /*
-     * join the head of this polyline to the tail of that polyline
-     */
-    PolyLine& joinHeadToTail(PolyLine& that);
-
-    /*
-     * join the tail of this polyline to the head of that polyline
-     */
-    PolyLine& joinTailToHead(PolyLine& that);
-
-    /*
-     * join the tail of this polyline to the tail of that polyline
-     */
-    PolyLine& joinTailToTail(PolyLine& that);
-
-    /*
-     * dissconnect the tail at the end of the polygon
-     */
-    PolyLine& disconnectTails();
-
-    /*
-     * get the coordinate at one end of this polyline, by default the tail end
-     */
-    Unit getEndCoord(End end = TAIL) const;
-
-    /*
-     * get the point on the polyline at the given index (polylines have the same number of coordinates as points
-     */
-    point_data<Unit> getPoint(unsigned int index) const;
-
-    /*
-     * get the point on one end of the polyline, by default the tail
-     */
-    point_data<Unit> getEndPoint(End end = TAIL) const;
-
-    /*
-     * get the orientation of a segment by index
-     */
-    orientation_2d segmentOrient(unsigned int index = 0) const;
-
-    /*
-     * get a coordinate by index using the square bracket operator
-     */
-    Unit operator[] (unsigned int index) const;
-
-    /*
-     * get the number of segments/points/coordinates in the polyline
-     */
-    unsigned int numSegments() const;
-
-    /*
-     * get the pointer to the next polyline at one end of this
-     */
-    PolyLine* next(End end) const;
-
-    /*
-     * write out coordinates of this and all attached polylines to a single vector
-     */
-    PolyLine* writeOut(std::vector<Unit>& outVec, End startEnd = TAIL) const;
-
-  private:
-    //methods
-    PolyLine& joinTo_(End thisEnd, PolyLine& that, End end);
-  };
-
-  //forward declaration
-  template<bool orientT, typename Unit>
-  class PolyLinePolygonData;
-
-  //forward declaration
-  template<bool orientT, typename Unit>
-  class PolyLinePolygonWithHolesData;
-
-  /*
-   * ActiveTail represents an edge of an incomplete polygon.
-   *
-   * An ActiveTail object is the active tail end of a polyline object, which may (should) be the attached to
-   * a chain of polyline objects through a pointer.  The ActiveTail class provides an abstraction between
-   * and algorithm that builds polygons and the PolyLine data representation of incomplete polygons that are
-   * being built.  It does this by providing an iterface to access the information about the last edge at the
-   * tail of the PolyLine it is associated with.  To a polygon constructing algorithm, an ActiveTail is a floating
-   * edge of an incomplete polygon and has an orientation and coordinate value, as well as knowing which side of
-   * that edge is supposed to be solid or space.  Any incomplete polygon will have two active tails.  Active tails
-   * may be joined together to merge two incomplete polygons into a larger incomplete polygon.  If two active tails
-   * that are to be merged are the oppositve ends of the same incomplete polygon that indicates that the polygon
-   * has been closed and is complete.  The active tail keeps a pointer to the other active tail of its incomplete 
-   * polygon so that it is easy to check this condition.  These pointers are updated when active tails are joined.
-   * The active tail also keeps a list of pointers to active tail objects that serve as handles to closed holes.  In
-   * this way a hole can be associated to another incomplete polygon, which will eventually be its enclosing shell,
-   * or reassociate the hole to another incomplete polygon in the case that it become a hole itself.  Alternately,
-   * the active tail may add a filiment to stitch a hole into a shell and "fracture" the hole out of the interior
-   * of a polygon.  The active tail maintains a static output buffer to temporarily write polygon data to when
-   * it outputs a figure so that outputting a polygon does not require the allocation of a temporary buffer.  This
-   * static buffer should be destroyed whenever the program determines that it won't need it anymore and would prefer to
-   * release the memory it has allocated back to the system.
-   */
-  template <typename Unit>
-  class ActiveTail {
-  private:
-    //data
-    PolyLine<Unit>* tailp_; 
-    ActiveTail *otherTailp_;
-    std::list<ActiveTail*> holesList_;
-  public:
-
-    /*
-     * iterator over coordinates of the figure
-     */
-    class iterator {
-    private:
-      const PolyLine<Unit>* pLine_;
-      const PolyLine<Unit>* pLineEnd_;
-      unsigned int index_;
-      unsigned int indexEnd_;
-      End startEnd_;
-    public:
-      inline iterator() : pLine_(), pLineEnd_(), index_(), indexEnd_(), startEnd_() {}
-      inline iterator(const ActiveTail* at, bool isHole, orientation_2d orient) : 
-        pLine_(), pLineEnd_(), index_(), indexEnd_(), startEnd_() {
-        //if it is a hole and orientation is vertical or it is not a hole and orientation is horizontal
-        //we want to use this active tail, otherwise we want to use the other active tail
-        startEnd_ = TAIL;
-        if(!isHole ^ (orient == HORIZONTAL)) {
-          //switch winding direction
-          at = at->getOtherActiveTail();
-        }
-        //now we have the right winding direction
-        //if it is horizontal we need to skip the first element
-        pLine_ = at->getTail();
-        index_ = at->getTail()->numSegments() - 1;
-        if((at->getOrient() == HORIZONTAL) ^ (orient == HORIZONTAL)) {
-          pLineEnd_ = at->getTail();
-          indexEnd_ = pLineEnd_->numSegments() - 1;
-          if(index_ == 0) {
-            pLine_ = at->getTail()->next(HEAD);
-            if(at->getTail()->endConnectivity(HEAD) == TAIL) {
-              index_ = pLine_->numSegments() -1;
-            } else {
-              startEnd_ = HEAD;
-              index_ = 0;
-            }
-          } else { --index_; }
-        } else {
-          pLineEnd_ = at->getOtherActiveTail()->getTail();
-          indexEnd_ = pLineEnd_->numSegments() - 1;
-        }
-        at->getTail()->joinTailToTail(*(at->getOtherActiveTail()->getTail()));
-      }
-      //use bitwise copy and assign provided by the compiler
-      inline iterator& operator++() {
-        if(pLine_ == pLineEnd_ && index_ == indexEnd_) {
-          pLine_ = 0;
-          index_ = 0;
-          return *this;
-        }
-        if(startEnd_ == HEAD) {
-          ++index_;
-          if(index_ == pLine_->numSegments()) {
-            End end = pLine_->endConnectivity(TAIL);
-            pLine_ = pLine_->next(TAIL);
-            if(end == TAIL) {
-              startEnd_ = TAIL;
-              index_ = pLine_->numSegments() -1;
-            } else {
-              index_ = 0;
-            }
-          }
-        } else {
-          if(index_ == 0) {
-            End end = pLine_->endConnectivity(HEAD);
-            pLine_ = pLine_->next(HEAD);
-            if(end == TAIL) {
-              index_ = pLine_->numSegments() -1;
-            } else {
-              startEnd_ = HEAD;
-              index_ = 0;
-            }
-          } else {
-            --index_;
-          }
-        }
-        return *this;
-      }
-      inline const iterator operator++(int) {
-        iterator tmp(*this);
-        ++(*this);
-        return tmp;
-      }
-      inline bool operator==(const iterator& that) const {
-        return pLine_ == that.pLine_ && index_ == that.index_;
-      }
-      inline bool operator!=(const iterator& that) const {
-        return pLine_ != that.pLine_ || index_ != that.index_;
-      }
-      inline Unit operator*() { return (*pLine_)[index_]; }
-    };
-
-    /*
-     * iterator over holes contained within the figure
-     */
-    typedef typename std::list<ActiveTail*>::const_iterator iteratorHoles;
-
-    //default constructor
-    ActiveTail();
-
-    //constructor
-    ActiveTail(orientation_2d orient, Unit coord, Side solidToRight, ActiveTail* otherTailp);
-
-    //constructor
-    ActiveTail(PolyLine<Unit>* active, ActiveTail* otherTailp);
-
-    //copy constructor
-    ActiveTail(const ActiveTail& that);
-
-    //destructor
-    ~ActiveTail();
-
-    //assignment operator
-    ActiveTail& operator=(const ActiveTail& that);
-
-    //equivalence operator
-    bool operator==(const ActiveTail& b) const;
-
-    /*
-     * comparison operators, ActiveTail objects are sortable by geometry
-     */
-    bool operator<(const ActiveTail& b) const;
-    bool operator<=(const ActiveTail& b) const;
-    bool operator>(const ActiveTail& b) const;
-    bool operator>=(const ActiveTail& b) const;
-
-    /*
-     * get the pointer to the polyline that this is an active tail of
-     */
-    PolyLine<Unit>* getTail() const;
-
-    /*
-     * get the pointer to the polyline at the other end of the chain
-     */
-    PolyLine<Unit>* getOtherTail() const;
-
-    /*
-     * get the pointer to the activetail at the other end of the chain
-     */
-    ActiveTail* getOtherActiveTail() const;
-
-    /*
-     * test if another active tail is the other end of the chain
-     */
-    bool isOtherTail(const ActiveTail& b);
-
-    /*
-     * update this end of chain pointer to new polyline
-     */
-    ActiveTail& updateTail(PolyLine<Unit>* newTail);
-
-    /*
-     * associate a hole to this active tail by the specified policy
-     */
-    ActiveTail* addHole(ActiveTail* hole, bool fractureHoles);
-
-    /*
-     * get the list of holes
-     */
-    const std::list<ActiveTail*>& getHoles() const;
-
-    /*
-     * copy holes from that to this
-     */
-    void copyHoles(ActiveTail& that);
-
-    /*
-     * find out if solid to right
-     */
-    bool solidToRight() const;
-
-    /*
-     * get coordinate (getCoord and getCoordinate are aliases for eachother)
-     */
-    Unit getCoord() const;
-    Unit getCoordinate() const;
-
-    /*
-     * get the tail orientation
-     */
-    orientation_2d getOrient() const;
-
-    /*
-     * add a coordinate to the polygon at this active tail end, properly handle degenerate edges by removing redundant coordinate
-     */
-    void pushCoordinate(Unit coord);
-
-    /*
-     * write the figure that this active tail points to out to the temp buffer
-     */
-    void writeOutFigure(std::vector<Unit>& outVec, bool isHole = false) const;
-
-    /*
-     * write the figure that this active tail points to out through iterators
-     */
-    void writeOutFigureItrs(iterator& beginOut, iterator& endOut, bool isHole = false, orientation_2d orient = VERTICAL) const;
-    iterator begin(bool isHole, orientation_2d orient) const;
-    iterator end() const;
-
-    /*
-     * write the holes that this active tail points to out through iterators
-     */
-    void writeOutFigureHoleItrs(iteratorHoles& beginOut, iteratorHoles& endOut) const;
-    iteratorHoles beginHoles() const;
-    iteratorHoles endHoles() const;
-
-    /*
-     * joins the two chains that the two active tail tails are ends of
-     * checks for closure of figure and writes out polygons appropriately
-     * returns a handle to a hole if one is closed
-     */
-    static ActiveTail* joinChains(ActiveTail* at1, ActiveTail* at2, bool solid, std::vector<Unit>& outBufferTmp);
-    template <typename PolygonT>
-    static ActiveTail* joinChains(ActiveTail* at1, ActiveTail* at2, bool solid, typename std::vector<PolygonT>& outBufferTmp);
-
-    /*
-     * deallocate temp buffer
-     */
-    static void destroyOutBuffer();
-
-    /*
-     * deallocate all polygon data this active tail points to (deep delete, call only from one of a pair of active tails)
-     */
-    void destroyContents();
-  };
-
-  /* allocate a polyline object */
-  template <typename Unit>
-  PolyLine<Unit>* createPolyLine(orientation_2d orient, Unit coord, Side side);
-
-  /* deallocate a polyline object */
-  template <typename Unit>
-  void destroyPolyLine(PolyLine<Unit>* pLine);
-
-  /* allocate an activetail object */
-  template <typename Unit>
-  ActiveTail<Unit>* createActiveTail();
-
-  /* deallocate an activetail object */
-  template <typename Unit>
-  void destroyActiveTail(ActiveTail<Unit>* aTail);
-     
-  template<bool orientT, typename Unit>
-  class PolyLineHoleData {
-  private:
-    ActiveTail<Unit>* p_;
-  public:
-    typedef Unit coordinate_type;
-    typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
-    typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
-    inline PolyLineHoleData() : p_(0) {}
-    inline PolyLineHoleData(ActiveTail<Unit>* p) : p_(p) {}
-    //use default copy and assign
-    inline compact_iterator_type begin_compact() const { return p_->begin(true, (orientT ? VERTICAL : HORIZONTAL)); }
-    inline compact_iterator_type end_compact() const { return p_->end(); }
-    inline iterator_type begin() const { return iterator_type(begin_compact(), end_compact()); }
-    inline iterator_type end() const { return iterator_type(end_compact(), end_compact()); }
-    inline unsigned int size() const { return 0; }
-    inline ActiveTail<Unit>* yield() { return p_; }
-    template<class iT>
-    inline PolyLineHoleData& set(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-    template<class iT>
-    inline PolyLineHoleData& set_compact(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-   
-  };
-
-  template<bool orientT, typename Unit>
-  class PolyLinePolygonWithHolesData {
-  private:
-    ActiveTail<Unit>* p_;
-  public:
-    typedef Unit coordinate_type;
-    typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
-    typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
-    typedef PolyLineHoleData<orientT, Unit> hole_type;
-    typedef typename coordinate_traits<Unit>::area_type area_type;
-    class iteratorHoles {
-    private:
-      typename ActiveTail<Unit>::iteratorHoles itr_;
-    public:
-      inline iteratorHoles() : itr_() {}
-      inline iteratorHoles(typename ActiveTail<Unit>::iteratorHoles itr) : itr_(itr) {}
-      //use bitwise copy and assign provided by the compiler
-      inline iteratorHoles& operator++() {
-        ++itr_;
-        return *this;
-      }
-      inline const iteratorHoles operator++(int) {
-        iteratorHoles tmp(*this);
-        ++(*this);
-        return tmp;
-      }
-      inline bool operator==(const iteratorHoles& that) const {
-        return itr_ == that.itr_;
-      }
-      inline bool operator!=(const iteratorHoles& that) const {
-        return itr_ != that.itr_;
-      }
-      inline PolyLineHoleData<orientT, Unit> operator*() { return PolyLineHoleData<orientT, Unit>(*itr_);}
-    };
-    typedef iteratorHoles iterator_holes_type;
-
-    inline PolyLinePolygonWithHolesData() : p_(0) {}
-    inline PolyLinePolygonWithHolesData(ActiveTail<Unit>* p) : p_(p) {}
-    //use default copy and assign
-    inline compact_iterator_type begin_compact() const { return p_->begin(false, (orientT ? VERTICAL : HORIZONTAL)); }
-    inline compact_iterator_type end_compact() const { return p_->end(); }
-    inline iterator_type begin() const { return iterator_type(begin_compact(), end_compact()); }
-    inline iterator_type end() const { return iterator_type(end_compact(), end_compact()); }
-    inline iteratorHoles begin_holes() const { return iteratorHoles(p_->beginHoles()); }
-    inline iteratorHoles end_holes() const { return iteratorHoles(p_->endHoles()); }
-    inline ActiveTail<Unit>* yield() { return p_; }
-    //stub out these four required functions that will not be used but are needed for the interface
-    inline unsigned int size_holes() const { return 0; }
-    inline unsigned int size() const { return 0; }
-    template<class iT>
-    inline PolyLinePolygonWithHolesData& set(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-    template<class iT>
-    inline PolyLinePolygonWithHolesData& set_compact(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-   
-    // initialize a polygon from x,y values, it is assumed that the first is an x
-    // and that the input is a well behaved polygon
-    template<class iT>
-    inline PolyLinePolygonWithHolesData& set_holes(iT inputBegin, iT inputEnd) {
-      return *this;
-    }
-  };
-
-
-  template <bool orientT, typename Unit, typename polygon_concept_type>
-  struct PolyLineType { };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_90_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_45_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_with_holes_concept> { typedef PolyLinePolygonWithHolesData<orientT, Unit> type; };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_90_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_45_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
-  template <bool orientT, typename Unit>
-  struct PolyLineType<orientT, Unit, polygon_concept> { typedef PolyLineHoleData<orientT, Unit> type; };
-
-  template <bool orientT, typename Unit, typename polygon_concept_type>
-  class ScanLineToPolygonItrs {
-  private:
-    std::map<Unit, ActiveTail<Unit>*> tailMap_;
-    typedef typename PolyLineType<orientT, Unit, polygon_concept_type>::type PolyLinePolygonData;
-    std::vector<PolyLinePolygonData> outputPolygons_;
-    bool fractureHoles_;
-  public:
-    typedef typename std::vector<PolyLinePolygonData>::iterator iterator; 
-    inline ScanLineToPolygonItrs() : tailMap_(), outputPolygons_(), fractureHoles_(false)  {}
-    /* construct a scanline with the proper offsets, protocol and options */
-    inline ScanLineToPolygonItrs(bool fractureHoles) : tailMap_(), outputPolygons_(), fractureHoles_(fractureHoles) {}
-   
-    ~ScanLineToPolygonItrs() { clearOutput_(); }
-   
-    /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
-    void processEdges(iterator& beginOutput, iterator& endOutput, 
-                      Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
-                      std::vector<interval_data<Unit> >& rightEdges);
-   
-  private:
-    void clearOutput_();
-  };
-
-  /*
-   * ScanLine does all the work of stitching together polygons from incoming vertical edges
-   */
-//   template <typename Unit, typename polygon_concept_type>
-//   class ScanLineToPolygons {
-//   private:
-//     ScanLineToPolygonItrs<true, Unit> scanline_;
-//   public:
-//     inline ScanLineToPolygons() : scanline_() {}
-//     /* construct a scanline with the proper offsets, protocol and options */
-//     inline ScanLineToPolygons(bool fractureHoles) : scanline_(fractureHoles) {}
-   
-//     /* process all vertical edges, left and right, at a unique x coordinate, edges must be sorted low to high */
-//     inline void processEdges(std::vector<Unit>& outBufferTmp, Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
-//                              std::vector<interval_data<Unit> >& rightEdges) {
-//       typename ScanLineToPolygonItrs<true, Unit>::iterator itr, endItr;
-//       scanline_.processEdges(itr, endItr, currentX, leftEdges, rightEdges);
-//       //copy data into outBufferTmp
-//       while(itr != endItr) {
-//         typename PolyLinePolygonData<true, Unit>::iterator pditr;
-//         outBufferTmp.push_back(0);
-//         unsigned int sizeIndex = outBufferTmp.size() - 1;
-//         int count = 0;
-//         for(pditr = (*itr).begin(); pditr != (*itr).end(); ++pditr) {
-//           outBufferTmp.push_back(*pditr);
-//           ++count;
-//         }
-//         outBufferTmp[sizeIndex] = count;
-//         typename PolyLinePolygonData<true, Unit>::iteratorHoles pdHoleItr;
-//         for(pdHoleItr = (*itr).beginHoles(); pdHoleItr != (*itr).endHoles(); ++pdHoleItr) {
-//           outBufferTmp.push_back(0);
-//           unsigned int sizeIndex2 = outBufferTmp.size() - 1;
-//           int count2 = 0;
-//           for(pditr = (*pdHoleItr).begin(); pditr != (*pdHoleItr).end(); ++pditr) {
-//             outBufferTmp.push_back(*pditr);
-//             ++count2;
-//           }
-//           outBufferTmp[sizeIndex2] = -count;
-//         }
-//         ++itr;
-//       }
-//     }
-//   };
-
-  const int VERTICAL_HEAD = 1, HEAD_TO_TAIL = 2, TAIL_TO_TAIL = 4, SOLID_TO_RIGHT = 8;
-
-  //EVERY FUNCTION in this DEF file should be explicitly defined as inline
-
-  //microsoft compiler improperly warns whenever you cast an integer to bool
-  //call this function on an integer to convert it to bool without a warning
-  template <class T>
-  inline bool to_bool(const T& val) { return val != 0; }
-
-  //default constructor (for preallocation)
-  template <typename Unit>
-  inline PolyLine<Unit>::PolyLine() : ptdata_() ,headp_(0), tailp_(0), state_(-1) {}
-
-  //constructor
-  template <typename Unit>
-  inline PolyLine<Unit>::PolyLine(orientation_2d orient, Unit coord, Side side) : 
-    ptdata_(1, coord),
-    headp_(0),
-    tailp_(0),
-    state_(orient.to_int() +
-           (side << 3)) {}
-
-  //copy constructor
-  template <typename Unit>
-  inline PolyLine<Unit>::PolyLine(const PolyLine<Unit>& pline) : ptdata_(pline.ptdata_),
-                                                     headp_(pline.headp_),
-                                                     tailp_(pline.tailp_),
-                                                     state_(pline.state_) {}
-
-  //destructor
-  template <typename Unit>
-  inline PolyLine<Unit>::~PolyLine() {
-    //clear out data just in case it is read later
-    headp_ = tailp_ = 0;
-    state_ = 0;
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::operator=(const PolyLine<Unit>& that) {
-    if(!(this == &that)) {
-      headp_ = that.headp_;
-      tailp_ = that.tailp_;
-      ptdata_ = that.ptdata_;
-      state_ = that.state_;
-    }
-    return *this;
-  }
-
-  template <typename Unit>
-  inline bool PolyLine<Unit>::operator==(const PolyLine<Unit>& b) const {
-    return this == &b || (state_ == b.state_ &&
-                          headp_ == b.headp_ &&
-                          tailp_ == b.tailp_);
-  }
-
-  //valid PolyLine
-  template <typename Unit>
-  inline bool PolyLine<Unit>::isValid() const { 
-    return state_ > -1; }
-
-  //first coordinate is an X value
-  //first segment is vertical
-  template <typename Unit>
-  inline bool PolyLine<Unit>::verticalHead() const {
-    return state_ & VERTICAL_HEAD;
-  }
-
-  //retrun true is PolyLine has odd number of coordiantes
-  template <typename Unit>
-  inline bool PolyLine<Unit>::oddLength() const {
-    return to_bool((ptdata_.size()-1) % 2);
-  }
-
-  //last coordiante is an X value
-  //last segment is vertical
-  template <typename Unit>
-  inline bool PolyLine<Unit>::verticalTail() const {
-    return to_bool(verticalHead() ^ oddLength());
-  }
-     
-  template <typename Unit>
-  inline orientation_2d PolyLine<Unit>::tailOrient() const {
-    return (verticalTail() ? VERTICAL : HORIZONTAL);
-  }
-
-  template <typename Unit>
-  inline orientation_2d PolyLine<Unit>::headOrient() const {
-    return (verticalHead() ? VERTICAL : HORIZONTAL);
-  }
-
-  template <typename Unit>
-  inline End PolyLine<Unit>::endConnectivity(End end) const {
-    //Tail should be defined as true
-    if(end) { return tailToTail(); }
-    return headToTail();
-  }
-
-  template <typename Unit>
-  inline bool PolyLine<Unit>::headToTail() const {
-    return to_bool(state_ & HEAD_TO_TAIL);
-  }
-
-  template <typename Unit>
-  inline bool PolyLine<Unit>::headToHead() const {
-    return to_bool(!headToTail());
-  }
-
-  template <typename Unit>
-  inline bool PolyLine<Unit>::tailToHead() const {
-    return to_bool(!tailToTail());
-  }
-     
-  template <typename Unit>
-  inline bool PolyLine<Unit>::tailToTail() const {
-    return to_bool(state_ & TAIL_TO_TAIL);
-  }
-
-  template <typename Unit>
-  inline Side PolyLine<Unit>::solidSide() const { 
-    return solidToRight(); }
-      
-  template <typename Unit>
-  inline bool PolyLine<Unit>::solidToRight() const {
-    return to_bool(state_ & SOLID_TO_RIGHT) != 0;
-  }
-
-  template <typename Unit>
-  inline bool PolyLine<Unit>::active() const {
-    return !to_bool(tailp_);
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::pushCoordinate(Unit coord) {
-    ptdata_.push_back(coord);
-    return *this;
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::popCoordinate() {
-    ptdata_.pop_back();
-    return *this;
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::pushPoint(const point_data<Unit>& point) {
-    point_data<Unit> endPt = getEndPoint();
-    //vertical is true, horizontal is false
-    if((tailOrient().to_int() ? point.get(VERTICAL) == endPt.get(VERTICAL) : point.get(HORIZONTAL) == endPt.get(HORIZONTAL))) {
-      //we were pushing a colinear segment
-      return popCoordinate();
-    }
-    return pushCoordinate(tailOrient().to_int() ? point.get(VERTICAL) : point.get(HORIZONTAL));
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::extendTail(Unit delta) {
-    ptdata_.back() += delta;
-    return *this;
-  }
-
-  //private member function that creates a link from this PolyLine to that
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinTo_(End thisEnd, PolyLine<Unit>& that, End end) {
-    if(thisEnd){
-      tailp_ = &that;
-      state_ &= ~TAIL_TO_TAIL; //clear any previous state_ of bit (for safety)
-      state_ |= (end << 2); //place bit into mask
-    } else {
-      headp_ = &that;
-      state_ &= ~HEAD_TO_TAIL; //clear any previous state_ of bit (for safety)
-      state_ |= (end << 1); //place bit into mask
-    }
-    return *this;
-  }
-
-  //join two PolyLines (both ways of the association)
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinTo(End thisEnd, PolyLine<Unit>& that, End end) {
-    joinTo_(thisEnd, that, end);
-    that.joinTo_(end, *this, thisEnd);
-    return *this;
-  }
-
-  //convenience functions for joining PolyLines
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinToTail(PolyLine<Unit>& that, End end) {
-    return joinTo(TAIL, that, end);
-  }
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinToHead(PolyLine<Unit>& that, End end) {
-    return joinTo(HEAD, that, end);
-  }
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinHeadToHead(PolyLine<Unit>& that) {
-    return joinToHead(that, HEAD);
-  }
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinHeadToTail(PolyLine<Unit>& that) {
-    return joinToHead(that, TAIL);
-  }
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinTailToHead(PolyLine<Unit>& that) {
-    return joinToTail(that, HEAD);
-  }
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::joinTailToTail(PolyLine<Unit>& that) {
-    return joinToTail(that, TAIL);
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>& PolyLine<Unit>::disconnectTails() {
-    next(TAIL)->state_ &= !TAIL_TO_TAIL;
-    next(TAIL)->tailp_ = 0;
-    state_ &= !TAIL_TO_TAIL;
-    tailp_ = 0;
-    return *this;
-  }
-
-  template <typename Unit>
-  inline Unit PolyLine<Unit>::getEndCoord(End end) const {
-    if(end)
-      return ptdata_.back();
-    return ptdata_.front();
-  }
-
-  template <typename Unit>
-  inline orientation_2d PolyLine<Unit>::segmentOrient(unsigned int index) const {
-    return (to_bool((unsigned int)verticalHead() ^ (index % 2)) ? VERTICAL : HORIZONTAL);
-  }
-
-  template <typename Unit>
-  inline point_data<Unit> PolyLine<Unit>::getPoint(unsigned int index) const {
-    //assert(isValid() && headp_->isValid()) ("PolyLine: headp_ must be valid");
-    point_data<Unit> pt;
-    pt.set(HORIZONTAL, ptdata_[index]);
-    pt.set(VERTICAL, ptdata_[index]);
-    Unit prevCoord;
-    if(index == 0) {
-      prevCoord = headp_->getEndCoord(headToTail());
-    } else {
-      prevCoord = ptdata_[index-1];
-    }
-    pt.set(segmentOrient(index), prevCoord);
-    return pt;
-  }
-
-  template <typename Unit>
-  inline point_data<Unit> PolyLine<Unit>::getEndPoint(End end) const {
-    return getPoint((end ? numSegments() - 1 : (unsigned int)0));
-  }
-
-  template <typename Unit>
-  inline Unit PolyLine<Unit>::operator[] (unsigned int index) const {
-    //assert(ptdata_.size() > index) ("PolyLine: out of bounds index");
-    return ptdata_[index];
-  }
-
-  template <typename Unit>
-  inline unsigned int PolyLine<Unit>::numSegments() const {
-    return ptdata_.size();
-  }
-
-  template <typename Unit>
-  inline PolyLine<Unit>* PolyLine<Unit>::next(End end) const {
-    return (end ? tailp_ : headp_);
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>::ActiveTail() : tailp_(0), otherTailp_(0), holesList_() {}
-
-  template <typename Unit>
-  inline ActiveTail<Unit>::ActiveTail(orientation_2d orient, Unit coord, Side solidToRight, ActiveTail* otherTailp) : 
-    tailp_(0), otherTailp_(0), holesList_() {
-    tailp_ = createPolyLine(orient, coord, solidToRight);
-    otherTailp_ = otherTailp;
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>::ActiveTail(PolyLine<Unit>* active, ActiveTail<Unit>* otherTailp) : 
-    tailp_(active), otherTailp_(otherTailp), holesList_() {}
-
-  //copy constructor
-  template <typename Unit>
-  inline ActiveTail<Unit>::ActiveTail(const ActiveTail<Unit>& that) : tailp_(that.tailp_), otherTailp_(that.otherTailp_), holesList_() {}
-
-  //destructor
-  template <typename Unit>
-  inline ActiveTail<Unit>::~ActiveTail() { 
-    //clear them in case the memory is read later
-    tailp_ = 0; otherTailp_ = 0; 
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>& ActiveTail<Unit>::operator=(const ActiveTail<Unit>& that) {
-    //self assignment is safe in this case
-    tailp_ = that.tailp_;
-    otherTailp_ = that.otherTailp_;
-    return *this;
-  }
-
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::operator==(const ActiveTail<Unit>& b) const {
-    return tailp_ == b.tailp_ && otherTailp_ == b.otherTailp_;
-  }
-
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::operator<(const ActiveTail<Unit>& b) const {
-    return tailp_->getEndPoint().get(VERTICAL) < b.tailp_->getEndPoint().get(VERTICAL);
-  }
-
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::operator<=(const ActiveTail<Unit>& b) const { 
-    return !(*this > b); }
-   
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::operator>(const ActiveTail<Unit>& b) const { 
-    return b < (*this); }
-   
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::operator>=(const ActiveTail<Unit>& b) const { 
-    return !(*this < b); }
-
-  template <typename Unit>
-  inline PolyLine<Unit>* ActiveTail<Unit>::getTail() const { 
-    return tailp_; }
-
-  template <typename Unit>
-  inline PolyLine<Unit>* ActiveTail<Unit>::getOtherTail() const { 
-    return otherTailp_->tailp_; }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>* ActiveTail<Unit>::getOtherActiveTail() const { 
-    return otherTailp_; }
-
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::isOtherTail(const ActiveTail<Unit>& b) {
-    //       assert( (tailp_ == b.getOtherTail() && getOtherTail() == b.tailp_) ||
-    //                     (tailp_ != b.getOtherTail() && getOtherTail() != b.tailp_)) 
-    //         ("ActiveTail: Active tails out of sync");
-    return otherTailp_ == &b;
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>& ActiveTail<Unit>::updateTail(PolyLine<Unit>* newTail) {
-    tailp_ = newTail;
-    return *this;
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>* ActiveTail<Unit>::addHole(ActiveTail<Unit>* hole, bool fractureHoles) {
-    if(!fractureHoles){
-      holesList_.push_back(hole);
-      copyHoles(*hole);
-      copyHoles(*(hole->getOtherActiveTail()));
-      return this;
-    }
-    ActiveTail<Unit>* h, *v;
-    ActiveTail<Unit>* other = hole->getOtherActiveTail();
-    if(other->getOrient() == VERTICAL) {
-      //assert that hole.getOrient() == HORIZONTAL
-      //this case should never happen
-      h = hole;  
-      v = other;
-    } else {
-      //assert that hole.getOrient() == VERTICAL
-      h = other;
-      v = hole;
-    }
-    h->pushCoordinate(v->getCoordinate());
-    //assert that h->getOrient() == VERTICAL
-    //v->pushCoordinate(getCoordinate());
-    //assert that v->getOrient() == VERTICAL
-    //I can't close a figure by adding a hole, so pass zero for xMin and yMin
-    std::vector<Unit> tmpVec;
-    ActiveTail<Unit>::joinChains(this, h, false, tmpVec);
-    return v;
-  }
-
-  template <typename Unit>
-  inline const std::list<ActiveTail<Unit>*>& ActiveTail<Unit>::getHoles() const {
-    return holesList_;
-  }
-
-  template <typename Unit>
-  inline void ActiveTail<Unit>::copyHoles(ActiveTail<Unit>& that) {
-    holesList_.splice(holesList_.end(), that.holesList_); //splice the two lists together
-  }
-
-  template <typename Unit>
-  inline bool ActiveTail<Unit>::solidToRight() const { 
-    return getTail()->solidToRight(); }
-
-  template <typename Unit>
-  inline Unit ActiveTail<Unit>::getCoord() const { 
-    return getTail()->getEndCoord(); }
- 
-  template <typename Unit>
-  inline Unit ActiveTail<Unit>::getCoordinate() const { 
-    return getCoord(); } 
-
-  template <typename Unit>
-  inline orientation_2d ActiveTail<Unit>::getOrient() const { 
-    return getTail()->tailOrient(); }
-
-  template <typename Unit>
-  inline void ActiveTail<Unit>::pushCoordinate(Unit coord) { 
-    //appropriately handle any co-linear polyline segments by calling push point internally
-    point_data<Unit> p;
-    p.set(HORIZONTAL, coord);
-    p.set(VERTICAL, coord);
-    //if we are vertical assign the last coordinate (an X) to p.x, else to p.y
-    p.set(getOrient().get_perpendicular(), getCoordinate());
-    tailp_->pushPoint(p);
-  }
-
-
-  //global utility functions
-  template <typename Unit>
-  inline PolyLine<Unit>* createPolyLine(orientation_2d orient, Unit coord, Side side) {
-    return new PolyLine<Unit>(orient, coord, side);
-  }
-
-  template <typename Unit>
-  inline void destroyPolyLine(PolyLine<Unit>* pLine) {
-    delete pLine;
-  }
-
-  template <typename Unit>
-  inline ActiveTail<Unit>* createActiveTail() {
-    //consider replacing system allocator with ActiveTail memory pool
-    return new ActiveTail<Unit>();
-  }
-
-  template <typename Unit>
-  inline void destroyActiveTail(ActiveTail<Unit>* aTail) {
-    delete aTail;
-  }
-
-
-  //no recursion, to prevent max recursion depth errors
-  template <typename Unit>
-  inline void ActiveTail<Unit>::destroyContents() {
-    tailp_->disconnectTails();
-    PolyLine<Unit>* nextPolyLinep = tailp_->next(HEAD);
-    End end = tailp_->endConnectivity(HEAD);
-    destroyPolyLine(tailp_);
-    while(nextPolyLinep) {
-      End nextEnd = nextPolyLinep->endConnectivity(!end); //get the direction of next polyLine
-      PolyLine<Unit>* nextNextPolyLinep = nextPolyLinep->next(!end); //get the next polyline
-      destroyPolyLine(nextPolyLinep); //destroy the current polyline
-      end = nextEnd;
-      nextPolyLinep = nextNextPolyLinep;
-    }
-  }
-
-  template <typename Unit>
-  inline typename ActiveTail<Unit>::iterator ActiveTail<Unit>::begin(bool isHole, orientation_2d orient) const {
-    return iterator(this, isHole, orient);
-  }
-
-  template <typename Unit>
-  inline typename ActiveTail<Unit>::iterator ActiveTail<Unit>::end() const {
-    return iterator();
-  }
-
-  template <typename Unit>
-  inline typename ActiveTail<Unit>::iteratorHoles ActiveTail<Unit>::beginHoles() const {
-    return holesList_.begin();
-  }
-
-  template <typename Unit>
-  inline typename ActiveTail<Unit>::iteratorHoles ActiveTail<Unit>::endHoles() const {
-    return holesList_.end();
-  }
-
-  template <typename Unit>
-  inline void ActiveTail<Unit>::writeOutFigureItrs(iterator& beginOut, iterator& endOut, bool isHole, orientation_2d orient) const {
-    beginOut = begin(isHole, orient);
-    endOut = end();
-  }
-
-  template <typename Unit>
-  inline void ActiveTail<Unit>::writeOutFigureHoleItrs(iteratorHoles& beginOut, iteratorHoles& endOut) const {
-    beginOut = beginHoles();
-    endOut = endHoles();
-  }
-
-  template <typename Unit>
-  inline void ActiveTail<Unit>::writeOutFigure(std::vector<Unit>& outVec, bool isHole) const {
-    //we start writing out the polyLine that this active tail points to at its tail
-    unsigned int size = outVec.size();
-    outVec.push_back(0); //place holder for size
-    PolyLine<Unit>* nextPolyLinep = 0;
-    if(!isHole){
-      nextPolyLinep = otherTailp_->tailp_->writeOut(outVec);
-    } else {
-      nextPolyLinep = tailp_->writeOut(outVec);
-    }
-    Unit firsty = outVec[size + 1];
-    if((getOrient() == HORIZONTAL) ^ !isHole) {
-      //our first coordinate is a y value, so we need to rotate it to the end
-      typename std::vector<Unit>::iterator tmpItr = outVec.begin();
-      tmpItr += size; 
-      outVec.erase(++tmpItr); //erase the 2nd element
-    }
-    End startEnd = tailp_->endConnectivity(HEAD);
-    if(isHole) startEnd = otherTailp_->tailp_->endConnectivity(HEAD);
-    while(nextPolyLinep) {
-      bool nextStartEnd = nextPolyLinep->endConnectivity(!startEnd);
-      nextPolyLinep = nextPolyLinep->writeOut(outVec, startEnd); 
-      startEnd = nextStartEnd;
-    }      
-    if((getOrient() == HORIZONTAL) ^ !isHole) {
-      //we want to push the y value onto the end since we ought to have ended with an x
-      outVec.push_back(firsty); //should never be executed because we want first value to be an x
-    }
-    //the vector contains the coordinates of the linked list of PolyLines in the correct order
-    //first element is supposed to be the size
-    outVec[size] = outVec.size() - 1 - size;  //number of coordinates in vector
-    //assert outVec[size] % 2 == 0 //it should be even
-    //make the size negative for holes
-    outVec[size] *= (isHole ? -1 : 1);
-  }
-
-  //no recursion to prevent max recursion depth errors
-  template <typename Unit>
-  inline PolyLine<Unit>* PolyLine<Unit>::writeOut(std::vector<Unit>& outVec, End startEnd) const {
-    if(startEnd == HEAD){
-      //forward order
-      outVec.insert(outVec.end(), ptdata_.begin(), ptdata_.end());
-      return tailp_;
-    }else{
-      //reverse order
-      //do not reserve because we expect outVec to be large enough already
-      for(int i = ptdata_.size() - 1; i >= 0; --i){
-        outVec.push_back(ptdata_[i]);
-      }
-      //NT didn't know about this version of the API....
-      //outVec.insert(outVec.end(), ptdata_.rbegin(), ptdata_.rend());
-      return headp_;
-    }
-  }
-
-  //solid indicates if it was joined by a solit or a space
-  template <typename Unit>
-  inline ActiveTail<Unit>* ActiveTail<Unit>::joinChains(ActiveTail<Unit>* at1, ActiveTail<Unit>* at2, bool solid, std::vector<Unit>& outBufferTmp) 
-  {
-    //checks to see if we closed a figure
-    if(at1->isOtherTail(*at2)){
-      //value of solid tells us if we closed solid or hole
-      //and output the solid or handle the hole appropriately
-      //if the hole needs to fracture across horizontal partition boundary we need to notify
-      //the calling context to do so
-      if(solid) {
-        //the chains are being joined because there is solid to the right
-        //this means that if the figure is closed at this point it must be a hole
-        //because otherwise it would have to have another vertex to the right of this one
-        //and would not be closed at this point
-        return at1;
-      } else {    
-        //assert pG != 0
-        //the figure that was closed is a shell
-        at1->writeOutFigure(outBufferTmp);
-        //process holes of the polygon
-        at1->copyHoles(*at2); //there should not be holes on at2, but if there are, copy them over
-        const std::list<ActiveTail<Unit>*>& holes = at1->getHoles();
-        for(typename std::list<ActiveTail<Unit>*>::const_iterator litr = holes.begin(); litr != holes.end(); ++litr) {
-          (*litr)->writeOutFigure(outBufferTmp, true);
-          //delete the hole
-          (*litr)->destroyContents();
-          destroyActiveTail((*litr)->getOtherActiveTail());
-          destroyActiveTail((*litr));
-        }
-        //delete the polygon
-        at1->destroyContents();
-        //at2 contents are the same as at1, so it should not destroy them
-        destroyActiveTail(at1);
-        destroyActiveTail(at2);
-      }
-      return 0;
-    }
-    //join the two partial polygons into one large partial polygon
-    at1->getTail()->joinTailToTail(*(at2->getTail()));
-    *(at1->getOtherActiveTail()) = ActiveTail(at1->getOtherTail(), at2->getOtherActiveTail());
-    *(at2->getOtherActiveTail()) = ActiveTail(at2->getOtherTail(), at1->getOtherActiveTail());
-    at1->getOtherActiveTail()->copyHoles(*at1);
-    at1->getOtherActiveTail()->copyHoles(*at2);
-    destroyActiveTail(at1);
-    destroyActiveTail(at2);
-    return 0;
-  }
-
-  //solid indicates if it was joined by a solit or a space
-  template <typename Unit>
-  template <typename PolygonT>
-  inline ActiveTail<Unit>* ActiveTail<Unit>::joinChains(ActiveTail<Unit>* at1, ActiveTail<Unit>* at2, bool solid, 
-                                                        std::vector<PolygonT>& outBufferTmp) {
-    //checks to see if we closed a figure
-    if(at1->isOtherTail(*at2)){
-      //value of solid tells us if we closed solid or hole
-      //and output the solid or handle the hole appropriately
-      //if the hole needs to fracture across horizontal partition boundary we need to notify
-      //the calling context to do so
-      if(solid) {
-        //the chains are being joined because there is solid to the right
-        //this means that if the figure is closed at this point it must be a hole
-        //because otherwise it would have to have another vertex to the right of this one
-        //and would not be closed at this point
-        return at1;
-      } else {    
-        //assert pG != 0
-        //the figure that was closed is a shell
-        outBufferTmp.push_back(at1);
-        at1->copyHoles(*at2); //there should not be holes on at2, but if there are, copy them over
-      }
-      return 0;
-    }
-    //join the two partial polygons into one large partial polygon
-    at1->getTail()->joinTailToTail(*(at2->getTail()));
-    *(at1->getOtherActiveTail()) = ActiveTail<Unit>(at1->getOtherTail(), at2->getOtherActiveTail());
-    *(at2->getOtherActiveTail()) = ActiveTail<Unit>(at2->getOtherTail(), at1->getOtherActiveTail());
-    at1->getOtherActiveTail()->copyHoles(*at1);
-    at1->getOtherActiveTail()->copyHoles(*at2);
-    destroyActiveTail(at1);
-    destroyActiveTail(at2);
-    return 0;
-  }
-
-  template <class TKey, class T> inline typename std::map<TKey, T>::iterator findAtNext(std::map<TKey, T>& theMap, 
-                                                                                        typename std::map<TKey, T>::iterator pos, const TKey& key) 
-  {
-    if(pos == theMap.end()) return theMap.find(key);
-    //if they match the mapItr is pointing to the correct position
-    if(pos->first < key) {
-      return theMap.find(key);
-    }
-    if(pos->first > key) {
-      return theMap.end();
-    } 
-    //else they are equal and no need to do anything to the iterator
-    return pos;
-  }
-
-  // createActiveTailsAsPair is called in these two end cases of geometry
-  // 1. lower left concave corner
-  //         ###| 
-  //         ###|
-  //         ###|### 
-  //         ###|###
-  // 2. lower left convex corner
-  //            |###          
-  //            |###         
-  //            |            
-  //            |     
-  // In case 1 there may be a hole propigated up from the bottom.  If the fracture option is enabled
-  // the two active tails that form the filament fracture line edges can become the new active tail pair
-  // by pushing x and y onto them.  Otherwise the hole simply needs to be associated to one of the new active tails
-  // with add hole
-  template <typename Unit>
-  inline std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> createActiveTailsAsPair(Unit x, Unit y, bool solid, ActiveTail<Unit>* phole, bool fractureHoles) {
-    ActiveTail<Unit>* at1 = 0;
-    ActiveTail<Unit>* at2 = 0;
-    if(!phole || !fractureHoles){
-      at1 = createActiveTail<Unit>();
-      at2 = createActiveTail<Unit>();
-      (*at1) = ActiveTail<Unit>(VERTICAL, x, solid, at2);
-      (*at2) = ActiveTail<Unit>(HORIZONTAL, y, !solid, at1);
-      //provide a function through activeTail class to provide this
-      at1->getTail()->joinHeadToHead(*(at2->getTail()));
-      if(phole) 
-        at1->addHole(phole, fractureHoles); //assert fractureHoles == false
-      return std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*>(at1, at2);
-    }
-    //assert phole is not null
-    //assert fractureHoles is true
-    if(phole->getOrient() == VERTICAL) {
-      at2 = phole;
-    } else {
-      at2 = phole->getOtherActiveTail(); //should never be executed since orientation is expected to be vertical
-    }
-    //assert solid == false, we should be creating a corner with solid below and to the left if there was a hole
-    at1 = at2->getOtherActiveTail();
-    //assert at1 is horizontal
-    at1->pushCoordinate(x);
-    //assert at2 is vertical
-    at2->pushCoordinate(y);
-    return std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*>(at1, at2);
-  }
- 
-  //Process edges connects vertical input edges (right or left edges of figures) to horizontal edges stored as member
-  //data of the scanline object.  It also creates now horizontal edges as needed to construct figures from edge data.
-  //
-  //There are only 12 geometric end cases where the scanline intersects a horizontal edge and even fewer unique 
-  //actions to take:
-  // 1. Solid on both sides of the vertical partition after the current position and space on both sides before
-  //         ###|###          
-  //         ###|###         
-  //            |            
-  //            |            
-  //    This case does not need to be handled because there is no vertical edge at the current x coordinate.
-  //
-  // 2. Solid on both sides of the vertical partition before the current position and space on both sides after
-  //            |            
-  //            |            
-  //         ###|###          
-  //         ###|###         
-  //    This case does not need to be handled because there is no vertical edge at the current x coordinate.
-  //
-  // 3. Solid on the left of the vertical partition after the current position and space elsewhere
-  //         ###|          
-  //         ###|         
-  //            |            
-  //            |     
-  //    The horizontal edge from the left is found and turns upward because of the vertical right edge to become
-  //    the currently active vertical edge.
-  //
-  // 4. Solid on the left of the vertical partion before the current position and space elsewhere
-  //            |            
-  //            |            
-  //         ###| 
-  //         ###|
-  //    The horizontal edge from the left is found and joined to the currently active vertical edge.
-  //
-  // 5. Solid to the right above and below and solid to the left above current position.
-  //         ###|###          
-  //         ###|###         
-  //            |###            
-  //            |###            
-  //    The horizontal edge from the left is found and joined to the currently active vertical edge,
-  //    potentially closing a hole.
-  //
-  // 6. Solid on the left of the vertical partion before the current position and solid to the right above and below
-  //            |###
-  //            |###            
-  //         ###|### 
-  //         ###|###
-  //    The horizontal edge from the left is found and turns upward because of the vertical right edge to become
-  //    the currently active vertical edge.
-  //
-  // 7. Solid on the right of the vertical partition after the current position and space elsewhere
-  //            |###          
-  //            |###         
-  //            |            
-  //            |     
-  //    Create two new ActiveTails, one is added to the horizontal edges and the other becomes the vertical currentTail
-  //
-  // 8. Solid on the right of the vertical partion before the current position and space elsewhere
-  //            |            
-  //            |            
-  //            |### 
-  //            |###
-  //    The currentTail vertical edge turns right and is added to the horizontal edges data
-  //
-  // 9. Solid to the right above and solid to the left above and below current position.
-  //         ###|###          
-  //         ###|###         
-  //         ###| 
-  //         ###|
-  //    The currentTail vertical edge turns right and is added to the horizontal edges data
-  //
-  // 10. Solid on the left of the vertical partion above and below the current position and solid to the right below
-  //         ###| 
-  //         ###|
-  //         ###|### 
-  //         ###|###
-  //    Create two new ActiveTails, one is added to the horizontal edges data and the other becomes the vertical currentTail
-  //
-  // 11. Solid to the right above and solid to the left below current position.
-  //            |### 
-  //            |###
-  //         ###| 
-  //         ###|
-  //    The currentTail vertical edge joins the horizontal edge from the left (may close a polygon)
-  //    Create two new ActiveTails, one is added to the horizontal edges data and the other becomes the vertical currentTail
-  //
-  // 12. Solid on the left of the vertical partion above the current position and solid to the right below
-  //         ###| 
-  //         ###|
-  //            |### 
-  //            |###
-  //    The currentTail vertical edge turns right and is added to the horizontal edges data.
-  //    The horizontal edge from the left turns upward and becomes the currentTail vertical edge
-  //
-  template <bool orientT, typename Unit, typename polygon_concept_type>
-  inline void ScanLineToPolygonItrs<orientT, Unit, polygon_concept_type>::
-  processEdges(iterator& beginOutput, iterator& endOutput, 
-               Unit currentX, std::vector<interval_data<Unit> >& leftEdges, 
-               std::vector<interval_data<Unit> >& rightEdges) {
-    clearOutput_();
-    typename std::map<Unit, ActiveTail<Unit>*>::iterator nextMapItr = tailMap_.begin();
-    //foreach edge
-    unsigned int leftIndex = 0;
-    unsigned int rightIndex = 0;
-    bool bottomAlreadyProcessed = false;
-    ActiveTail<Unit>* currentTail = 0;
-    const Unit UnitMax = (std::numeric_limits<Unit>::max)();
-    while(leftIndex < leftEdges.size() || rightIndex < rightEdges.size()) {
-      interval_data<Unit>  edges[2] = {interval_data<Unit> (UnitMax, UnitMax), interval_data<Unit> (UnitMax, UnitMax)};
-      bool haveNextEdge = true;
-      if(leftIndex < leftEdges.size())
-        edges[0] = leftEdges[leftIndex];
-      else
-        haveNextEdge = false;
-      if(rightIndex < rightEdges.size())
-        edges[1] = rightEdges[rightIndex];
-      else
-        haveNextEdge = false;
-      bool trailingEdge = edges[1].get(LOW) < edges[0].get(LOW);
-      interval_data<Unit> & edge = edges[trailingEdge];
-      interval_data<Unit> & nextEdge = edges[!trailingEdge];
-      //process this edge
-      if(!bottomAlreadyProcessed) {
-        //assert currentTail = 0 
-
-        //process the bottom end of this edge
-        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(LOW));
-        if(thisMapItr != tailMap_.end()) {
-          //there is an edge in the map at the low end of this edge
-          //it needs to turn upward and become the current tail
-          ActiveTail<Unit>* tail = thisMapItr->second;
-          if(currentTail) {
-            //stitch currentTail into this tail
-            currentTail = tail->addHole(currentTail, fractureHoles_);
-            if(!fractureHoles_)
-              currentTail->pushCoordinate(currentX);
-          } else {
-            currentTail = tail;
-            currentTail->pushCoordinate(currentX);
-          }
-          //assert currentTail->getOrient() == VERTICAL
-          nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
-          ++nextMapItr;
-          //remove thisMapItr from the map
-          tailMap_.erase(thisMapItr);
-        } else {
-          //there is no edge in the map at the low end of this edge
-          //we need to create one and another one to be the current vertical tail
-          //if this is a trailing edge then there is space to the right of the vertical edge
-          //so pass the inverse of trailingEdge to indicate solid to the right
-          std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> tailPair = 
-            createActiveTailsAsPair(currentX, edge.get(LOW), !trailingEdge, currentTail, fractureHoles_);
-          currentTail = tailPair.first;
-          tailMap_.insert(nextMapItr, std::pair<Unit, ActiveTail<Unit>*>(edge.get(LOW), tailPair.second));
-          // leave nextMapItr unchanged
-        }
-
-      }
-      if(haveNextEdge && edge.get(HIGH) == nextEdge.get(LOW)) {
-        //the top of this edge is equal to the bottom of the next edge, process them both
-        bottomAlreadyProcessed = true;
-        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(HIGH));
-        if(thisMapItr == tailMap_.end()) //assert this should never happen
-          return;
-        if(trailingEdge) {
-          //geometry at this position
-          //   |##
-          //   |##
-          // -----
-          // ##|
-          // ##|
-          //current tail should join thisMapItr tail
-          ActiveTail<Unit>* tail = thisMapItr->second;
-          //pass false because they are being joined because space is to the right and it will close a solid figure
-          ActiveTail<Unit>::joinChains(currentTail, tail, false, outputPolygons_);
-          //two new tails are created, the vertical becomes current tail, the horizontal becomes thisMapItr tail
-          //pass true becuase they are created at the lower left corner of some solid
-          //pass null because there is no hole pointer possible
-          std::pair<ActiveTail<Unit>*, ActiveTail<Unit>*> tailPair = 
-            createActiveTailsAsPair<Unit>(currentX, edge.get(HIGH), true, 0, fractureHoles_);
-          currentTail = tailPair.first;
-          thisMapItr->second = tailPair.second;
-        } else {
-          //geometry at this position
-          // ##|
-          // ##|
-          // -----
-          //   |##
-          //   |##
-          //current tail should turn right
-          currentTail->pushCoordinate(edge.get(HIGH));
-          //thisMapItr tail should turn up
-          thisMapItr->second->pushCoordinate(currentX);
-          //thisMapItr tail becomes current tail and current tail becomes thisMapItr tail
-          std::swap(currentTail, thisMapItr->second);
-        }
-        nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
-        ++nextMapItr;
-      } else {
-        //there is a gap between the top of this edge and the bottom of the next, process the top of this edge
-        bottomAlreadyProcessed = false;
-        //process the top of this edge
-        typename std::map<Unit, ActiveTail<Unit>*>::iterator thisMapItr = findAtNext(tailMap_, nextMapItr, edge.get(HIGH));
-        if(thisMapItr != tailMap_.end()) {
-          //thisMapItr is pointing to a horizontal edge in the map at the top of this vertical edge
-          //we need to join them and potentially close a figure
-          //assert currentTail != 0
-          ActiveTail<Unit>* tail = thisMapItr->second;
-          //pass the opositve of trailing edge to mean that they are joined because of solid to the right
-          currentTail = ActiveTail<Unit>::joinChains(currentTail, tail, !trailingEdge, outputPolygons_);
-          nextMapItr = thisMapItr; //set nextMapItr to the next position after this one
-          ++nextMapItr;
-          if(currentTail) {
-            Unit nextItrY = UnitMax;
-            if(nextMapItr != tailMap_.end()) {
-              nextItrY = nextMapItr->first;
-            }
-            //for it to be a hole this must have been a left edge
-            Unit leftY = UnitMax;
-            if(leftIndex + 1 < leftEdges.size())
-              leftY = leftEdges[leftIndex+1].get(LOW);
-            Unit rightY = nextEdge.get(LOW);
-            if(!haveNextEdge || (nextItrY < leftY && nextItrY < rightY)) {
-              //we need to add it to the next edge above it in the map
-              tail = nextMapItr->second;
-              tail = tail->addHole(currentTail, fractureHoles_);
-              if(fractureHoles_) {
-                //some small additional work stitching in the filament
-                tail->pushCoordinate(nextItrY);
-                nextMapItr->second = tail;
-              }
-              //set current tail to null
-              currentTail = 0;
-            }
-          }  
-          //delete thisMapItr from the map
-          tailMap_.erase(thisMapItr);
-        } else {
-          //currentTail must turn right and be added into the map
-          currentTail->pushCoordinate(edge.get(HIGH));
-          //assert currentTail->getOrient() == HORIZONTAL
-          tailMap_.insert(nextMapItr, std::pair<Unit, ActiveTail<Unit>*>(edge.get(HIGH), currentTail));
-          //set currentTail to null
-          currentTail = 0;
-          //leave nextMapItr unchanged, it is still next
-        }
-      }
- 
-      //increment index
-      leftIndex += !trailingEdge;
-      rightIndex += trailingEdge;
-    } //end while
-    beginOutput = outputPolygons_.begin();
-    endOutput = outputPolygons_.end();
-  } //end function
-
-  template<bool orientT, typename Unit, typename polygon_concept_type>
-  inline void ScanLineToPolygonItrs<orientT, Unit, polygon_concept_type>::clearOutput_() {
-    for(unsigned int i = 0; i < outputPolygons_.size(); ++i) {
-      ActiveTail<Unit>* at1 = outputPolygons_[i].yield();
-      const std::list<ActiveTail<Unit>*>& holes = at1->getHoles();
-      for(typename std::list<ActiveTail<Unit>*>::const_iterator litr = holes.begin(); litr != holes.end(); ++litr) {
-        //delete the hole
-        (*litr)->destroyContents();
-        destroyActiveTail((*litr)->getOtherActiveTail());
-        destroyActiveTail((*litr));
-      }
-      //delete the polygon
-      at1->destroyContents();
-      //at2 contents are the same as at1, so it should not destroy them
-      destroyActiveTail((at1)->getOtherActiveTail());
-      destroyActiveTail(at1);
-    }
-    outputPolygons_.clear();
-  }
-
-} //polygon_formation namespace
-
-  template <bool orientT, typename Unit>
-  struct geometry_concept<polygon_formation::PolyLinePolygonWithHolesData<orientT, Unit> > {
-    typedef polygon_90_with_holes_concept type;
-  };
-
-  template <bool orientT, typename Unit>
-  struct geometry_concept<polygon_formation::PolyLineHoleData<orientT, Unit> > {
-    typedef polygon_90_concept type;
-  };
-
-  //public API to access polygon formation algorithm
-  template <typename output_container, typename iterator_type, typename concept_type>
-  unsigned int get_polygons(output_container& container, iterator_type begin, iterator_type end,
-                    orientation_2d orient, bool fracture_holes, concept_type tag) {
-    typedef typename output_container::value_type polygon_type;
-    typedef typename iterator_type::value_type::first_type coordinate_type;
-    polygon_type poly;
-    unsigned int countPolygons = 0;
-    typedef typename geometry_concept<polygon_type>::type polygon_concept_type;
-    polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type> scanlineToPolygonItrsV(fracture_holes);
-    polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type> scanlineToPolygonItrsH(fracture_holes);
-    std::vector<interval_data<coordinate_type> > leftEdges;
-    std::vector<interval_data<coordinate_type> > rightEdges;
-    coordinate_type prevPos = (std::numeric_limits<coordinate_type>::max)();
-    coordinate_type prevY = (std::numeric_limits<coordinate_type>::max)();
-    int count = 0;
-    for(iterator_type itr = begin;
-        itr != end; ++ itr) {
-      coordinate_type pos = (*itr).first;
-      if(pos != prevPos) {
-        if(orient == VERTICAL) {
-          typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
-          scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
-          for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
-            ++countPolygons;
-            assign(poly, *itrPoly);
-            container.insert(container.end(), poly);
-          }
-        } else {
-          typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
-          scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
-          for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
-            ++countPolygons;
-            assign(poly, *itrPoly);
-            container.insert(container.end(), poly);
-          }
-        }
-        leftEdges.clear();
-        rightEdges.clear();
-        prevPos = pos;
-        prevY = (*itr).second.first;
-        count = (*itr).second.second;
-        continue;
-      }
-      coordinate_type y = (*itr).second.first;
-      if(count != 0 && y != prevY) {
-        std::pair<interval_data<coordinate_type>, int> element(interval_data<coordinate_type>(prevY, y), count);
-        if(element.second == 1) {
-          if(leftEdges.size() && leftEdges.back().high() == element.first.low()) {
-            encompass(leftEdges.back(), element.first);
-          } else {
-            leftEdges.push_back(element.first);
-          }
-        } else {
-          if(rightEdges.size() && rightEdges.back().high() == element.first.low()) {
-            encompass(rightEdges.back(), element.first);
-          } else {
-            rightEdges.push_back(element.first);
-          }
-        }
-
-      }
-      prevY = y;
-      count += (*itr).second.second;
-    }
-    if(orient == VERTICAL) {
-      typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
-      scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
-      for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
-        ++countPolygons;
-        assign(poly, *itrPoly);
-        container.insert(container.end(), poly);
-      }
-    } else {
-      typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type, polygon_concept_type>::iterator itrPoly, itrPolyEnd;
-      scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
-      for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
-        ++countPolygons;
-        assign(poly, *itrPoly);
-        container.insert(container.end(), poly);
-      }
-    }
-    return countPolygons;
-  }
-
-}
-}
-#endif
-
Modified: sandbox/gtl/boost/polygon/polygon_set_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_set_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_set_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,9 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_SET_CONCEPT_HPP
-#define GTL_POLYGON_SET_CONCEPT_HPP
+#ifndef BOOST_POLYGON_POLYGON_SET_CONCEPT_HPP
+#define BOOST_POLYGON_POLYGON_SET_CONCEPT_HPP
+#include "polygon_set_data.hpp"
 namespace boost { namespace polygon{
 
   template <typename T, typename T2>
@@ -230,15 +231,15 @@
   
   template <typename geometry_type_1, typename geometry_type_2>
   typename enable_if< typename gtl_and_3 < typename is_any_polygon_set_type<geometry_type_1>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, typename is_any_polygon_set_type<geometry_type_2>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, polygon_set_view<geometry_type_1, geometry_type_2, 0> >::type 
@@ -271,15 +272,15 @@
   
   template <typename geometry_type_1, typename geometry_type_2>
   typename enable_if< typename gtl_and_3 < typename is_any_polygon_set_type<geometry_type_1>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, typename is_any_polygon_set_type<geometry_type_2>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, typename is_either_polygon_set_type<geometry_type_1, geometry_type_2>::type>
-#ifdef __ICC 
+#ifdef BOOST_POLYGON_ICC 
   ::type
 #endif
   ::type, polygon_set_view<geometry_type_1, geometry_type_2, 3> >::type 
@@ -337,6 +338,91 @@
   operator-=(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
     return self_assignment_boolean_op<geometry_type_1, geometry_type_2, 3>(lvalue, rvalue);
   }
+
+  template <typename T>
+  struct view_of<polygon_45_set_concept, T> {
+    typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
+    T* tp;
+    std::vector<polygon_45_with_holes_data<coordinate_type> > polys;
+    view_of(const T& obj) : tp(), polys() {
+      std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
+      assign(gpolys, obj);
+      for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
+          itr != gpolys.end(); ++itr) {
+        polys.push_back(polygon_45_with_holes_data<coordinate_type>());
+        assign(polys.back(), view_as<polygon_45_with_holes_concept>(*itr));
+      }
+    }
+    view_of(T& obj) : tp(&obj), polys() {
+      std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
+      assign(gpolys, obj);
+      for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
+          itr != gpolys.end(); ++itr) {
+        polys.push_back(polygon_45_with_holes_data<coordinate_type>());
+        assign(polys.back(), view_as<polygon_45_with_holes_concept>(*itr));
+      }
+    }
+
+    typedef typename std::vector<polygon_45_with_holes_data<coordinate_type> >::const_iterator iterator_type;
+    typedef view_of operator_arg_type;
+
+    inline iterator_type begin() const {
+      return polys.begin();
+    }
+
+    inline iterator_type end() const {
+      return polys.end();
+    }
+
+    inline orientation_2d orient() const { return HORIZONTAL; }
+
+    inline bool clean() const { return false; }
+
+    inline bool sorted() const { return false; }
+
+    inline T& get() { return *tp; }
+  };
+
+  template <typename T>
+  struct polygon_45_set_traits<view_of<polygon_45_set_concept, T> > {
+    typedef typename view_of<polygon_45_set_concept, T>::coordinate_type coordinate_type;
+    typedef typename view_of<polygon_45_set_concept, T>::iterator_type iterator_type;
+    typedef view_of<polygon_45_set_concept, T> operator_arg_type;
+
+    static inline iterator_type begin(const view_of<polygon_45_set_concept, T>& polygon_set) {
+      return polygon_set.begin();
+    }
+
+    static inline iterator_type end(const view_of<polygon_45_set_concept, T>& polygon_set) {
+      return polygon_set.end();
+    }
+
+    static inline orientation_2d orient(const view_of<polygon_45_set_concept, T>& polygon_set) { 
+      return polygon_set.orient(); }
+
+    static inline bool clean(const view_of<polygon_45_set_concept, T>& polygon_set) { 
+      return polygon_set.clean(); }
+
+    static inline bool sorted(const view_of<polygon_45_set_concept, T>& polygon_set) { 
+      return polygon_set.sorted(); }
+
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_45_set_concept, T> > {
+    typedef polygon_45_set_concept type;
+  };
+
+  template <typename T>
+  struct get_coordinate_type<view_of<polygon_45_set_concept, T>, polygon_45_set_concept> {
+    typedef typename view_of<polygon_45_set_concept, T>::coordinate_type type;
+  };
+  template <typename T>
+  struct get_iterator_type_2<view_of<polygon_45_set_concept, T>, polygon_45_set_concept> {
+    typedef typename view_of<polygon_45_set_concept, T>::iterator_type type;
+    static type begin(const view_of<polygon_45_set_concept, T>& t) { return t.begin(); }
+    static type end(const view_of<polygon_45_set_concept, T>& t) { return t.end(); }
+  };
 }
 }
 #endif
Modified: sandbox/gtl/boost/polygon/polygon_set_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_set_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_set_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,11 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_SET_DATA_HPP
-#define GTL_POLYGON_SET_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_SET_DATA_HPP
+#define BOOST_POLYGON_POLYGON_SET_DATA_HPP
+#include "polygon_45_set_data.hpp"
+#include "polygon_45_set_concept.hpp"
+#include "detail/polygon_arbitrary_formation.hpp"
 namespace boost { namespace polygon{
 
   //foward declare view
@@ -137,6 +140,13 @@
       insert(polys.begin(), polys.end());
     }
 
+    template <typename coordinate_type_2>
+    inline void insert(const polygon_90_set_data<coordinate_type_2>& ps) {
+      std::vector<polygon_90_with_holes_data<coordinate_type_2> > polys;
+      assign(polys, ps);
+      insert(polys.begin(), polys.end());
+    }
+
     template <typename polygon_type>
     inline void insert(const polygon_type& polygon_object, bool is_hole, polygon_45_concept tag) {
       insert(polygon_object, is_hole, polygon_concept()); }
@@ -423,5 +433,10 @@
   };
 }
 }
+#include "detail/scan_arbitrary.hpp"
+#include "polygon_set_traits.hpp"
+#include "detail/polygon_set_view.hpp"
+
+#include "polygon_set_concept.hpp"
 #endif
 
Modified: sandbox/gtl/boost/polygon/polygon_set_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_set_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_set_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_SET_TRAITS_HPP
-#define GTL_POLYGON_SET_TRAITS_HPP
+#ifndef BOOST_POLYGON_POLYGON_SET_TRAITS_HPP
+#define BOOST_POLYGON_POLYGON_SET_TRAITS_HPP
 namespace boost { namespace polygon{
 
   struct polygon_set_concept {};
Deleted: sandbox/gtl/boost/polygon/polygon_set_view.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_set_view.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,201 +0,0 @@
-/*
-  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 GTL_POLYGON_SET_VIEW_HPP
-#define GTL_POLYGON_SET_VIEW_HPP
-namespace boost { namespace polygon{
-  
-  
-  template <typename coordinate_type>
-  inline void polygon_set_data<coordinate_type>::clean() const {
-    if(dirty_) {
-      polygon_45_set_data<coordinate_type> tmp;
-      if(downcast(tmp) ) {
-        tmp.clean();
-        data_.clear();
-        is_45_ = true;
-        polygon_set_data<coordinate_type> tmp2;
-        tmp2.insert(tmp);
-        data_.swap(tmp2.data_);
-        dirty_ = false;
-        sort();
-      } else {
-        sort();
-        arbitrary_boolean_op<coordinate_type> abo;
-        polygon_set_data<coordinate_type> tmp2;
-        abo.execute(tmp2, begin(), end(), end(), end(), 0);
-        data_.swap(tmp2.data_);
-        is_45_ = tmp2.is_45_;
-        dirty_ = false;
-      }
-    }
-  }
-
-  template <>
-  inline void polygon_set_data<double>::clean() const {
-    if(dirty_) {
-      sort();
-      arbitrary_boolean_op<double> abo;
-      polygon_set_data<double> tmp2;
-      abo.execute(tmp2, begin(), end(), end(), end(), 0);
-      data_.swap(tmp2.data_);
-      is_45_ = tmp2.is_45_;
-      dirty_ = false;
-    }
-  }
-
-  template <typename value_type, typename arg_type>
-  inline void insert_into_view_arg(value_type& dest, const arg_type& arg);
-
-  template <typename ltype, typename rtype, int op_type>
-  class polygon_set_view;
-
-  template <typename ltype, typename rtype, int op_type>
-  struct polygon_set_traits<polygon_set_view<ltype, rtype, op_type> > {
-    typedef typename polygon_set_view<ltype, rtype, op_type>::coordinate_type coordinate_type;
-    typedef typename polygon_set_view<ltype, rtype, op_type>::iterator_type iterator_type;
-    typedef typename polygon_set_view<ltype, rtype, op_type>::operator_arg_type operator_arg_type;
-
-    static inline iterator_type begin(const polygon_set_view<ltype, rtype, op_type>& polygon_set); 
-    static inline iterator_type end(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
-
-    static inline bool clean(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
-
-    static inline bool sort(const polygon_set_view<ltype, rtype, op_type>& polygon_set);
-  };
-
-  template <typename value_type, typename geometry_type_1, typename geometry_type_2, int op_type>
-  void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_,
-                          double coord) {
-    typedef geometry_type_1 ltype;
-    typedef geometry_type_2 rtype;
-    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
-    value_type linput_;
-    value_type rinput_;
-    insert_into_view_arg(linput_, lvalue_);
-    insert_into_view_arg(rinput_, rvalue_);
-    arbitrary_boolean_op<coordinate_type> abo;
-    abo.execute(output_, linput_.begin(), linput_.end(),
-                rinput_.begin(), rinput_.end(), op_type);
-  }
-
-  template <typename value_type, typename geometry_type_1, typename geometry_type_2, int op_type>
-  void execute_boolean_op(value_type& output_, const geometry_type_1& lvalue_, const geometry_type_2& rvalue_,
-                          int coord) {
-    typedef geometry_type_1 ltype;
-    typedef geometry_type_2 rtype;
-    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
-    value_type linput_;
-    value_type rinput_;
-    insert_into_view_arg(linput_, lvalue_);
-    insert_into_view_arg(rinput_, rvalue_);
-    polygon_45_set_data<coordinate_type> l45, r45, o45;
-    if(linput_.downcast(l45) && rinput_.downcast(r45)) {
-      //the op codes are screwed up between 45 and arbitrary
-      if(op_type < 2)
-        l45.template applyAdaptiveBoolean_<op_type>(o45, r45);
-      else if(op_type == 2)
-        l45.template applyAdaptiveBoolean_<3>(o45, r45);
-      else
-        l45.template applyAdaptiveBoolean_<2>(o45, r45);
-      output_.insert(o45);
-    } else {
-      arbitrary_boolean_op<coordinate_type> abo;
-      abo.execute(output_, linput_.begin(), linput_.end(),
-                  rinput_.begin(), rinput_.end(), op_type);
-    }
-  }
-
-  template <typename ltype, typename rtype, int op_type>
-  class polygon_set_view {
-  public:
-    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_set_data<coordinate_type> value_type;
-    typedef typename value_type::iterator_type iterator_type;
-    typedef polygon_set_view operator_arg_type;
-  private:
-    const ltype& lvalue_;
-    const rtype& rvalue_;
-    mutable value_type output_;
-    mutable bool evaluated_;
-  public:
-    polygon_set_view(const ltype& lvalue,
-                     const rtype& rvalue ) :
-      lvalue_(lvalue), rvalue_(rvalue), output_(), evaluated_(false) {}
-
-    // get iterator to begin vertex data
-  public:
-    const value_type& value() const {
-      if(!evaluated_) {
-        evaluated_ = true;
-        execute_boolean_op<value_type, ltype, rtype, op_type>(output_, lvalue_, rvalue_, coordinate_type());
-      }
-      return output_;
-    }
-  public:
-    iterator_type begin() const { return value().begin(); }
-    iterator_type end() const { return value().end(); }
-
-    bool dirty() const { return false; } //result of a boolean is clean
-    bool sorted() const { return true; } //result of a boolean is sorted
-
-    void sort() const {} //is always sorted
-  };
-
-  template <typename ltype, typename rtype, int op_type>
-  typename polygon_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
-  begin(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
-    return polygon_set.begin();
-  }
-  template <typename ltype, typename rtype, int op_type>
-  typename polygon_set_view<ltype, rtype, op_type>::iterator_type 
-  polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
-  end(const polygon_set_view<ltype, rtype, op_type>& polygon_set) {
-    return polygon_set.end();
-  }
-  template <typename ltype, typename rtype, int op_type>
-  bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
-  clean(const polygon_set_view<ltype, rtype, op_type>& polygon_set) { 
-    return true; }
-  template <typename ltype, typename rtype, int op_type>
-  bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type> >::
-  sort(const polygon_set_view<ltype, rtype, op_type>& polygon_set) { 
-    return true; }
-
-  template <typename value_type, typename arg_type>
-  inline void insert_into_view_arg(value_type& dest, const arg_type& arg) {
-    typedef typename polygon_set_traits<arg_type>::iterator_type literator;
-    literator itr1, itr2;
-    itr1 = polygon_set_traits<arg_type>::begin(arg);
-    itr2 = polygon_set_traits<arg_type>::end(arg);
-    dest.insert(itr1, itr2);
-  }
-  
-  template <typename geometry_type_1, typename geometry_type_2, int op_type>
-  geometry_type_1& self_assignment_boolean_op(geometry_type_1& lvalue_, const geometry_type_2& rvalue_) {
-    typedef geometry_type_1 ltype;
-    typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
-    typedef polygon_set_data<coordinate_type> value_type;
-    value_type output_;
-    execute_boolean_op<value_type, geometry_type_1, geometry_type_2, op_type>(output_, lvalue_, rvalue_, coordinate_type());
-    polygon_set_mutable_traits<geometry_type_1>::set(lvalue_, output_.begin(), output_.end());
-    return lvalue_;
-  }
-
-  // copy constructor
-  template <typename coordinate_type>
-  template <typename ltype, typename rtype, int op_type> 
-  polygon_set_data<coordinate_type>::polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that) :
-    data_(that.value().data_), dirty_(that.value().dirty_), unsorted_(that.value().unsorted_), is_45_(that.value().is_45_) {}
-
-  template <typename ltype, typename rtype, int op_type>
-  struct geometry_concept<polygon_set_view<ltype, rtype, op_type> > { typedef polygon_set_concept type; };
-}
-}
-#endif
-
Modified: sandbox/gtl/boost/polygon/polygon_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_TRAITS_HPP
-#define GTL_POLYGON_TRAITS_HPP
+#ifndef BOOST_POLYGON_POLYGON_TRAITS_HPP
+#define BOOST_POLYGON_POLYGON_TRAITS_HPP
 namespace boost { namespace polygon{
 
   template <typename T, typename enable = gtl_yes>
@@ -190,8 +190,16 @@
 #include "rectangle_concept.hpp"
 
 //algorithms needed by polygon types
-#include "iterator_points_to_compact.hpp"
-#include "iterator_compact_to_points.hpp"
+#include "detail/iterator_points_to_compact.hpp"
+#include "detail/iterator_compact_to_points.hpp"
+
+//polygons
+#include "polygon_45_data.hpp"
+#include "polygon_data.hpp"
+#include "polygon_90_data.hpp"
+#include "polygon_90_with_holes_data.hpp"
+#include "polygon_45_with_holes_data.hpp"
+#include "polygon_with_holes_data.hpp"
 
 namespace boost { namespace polygon{
   struct polygon_concept {};
@@ -919,11 +927,11 @@
     while (begin_range != end_range) {
       area_type x1 = (area_type)x(previous);
       area_type x2 = (area_type)x(*begin_range);
-#ifdef __ICC
+#ifdef BOOST_POLYGON_ICC
 #pragma warning (disable:1572)
 #endif
       if(x1 != x2) {
-#ifdef __ICC
+#ifdef BOOST_POLYGON_ICC
 #pragma warning (default:1572)
 #endif
         // do trapezoid area accumulation
@@ -1317,6 +1325,34 @@
     return *this;
   }
 
+  template <class T>
+  template <class T2>
+  polygon_data<T>& polygon_data<T>::operator=(const T2& rvalue) {
+    assign(*this, rvalue);
+    return *this;
+  }
+
+  template <class T>
+  template <class T2>
+  polygon_90_with_holes_data<T>& polygon_90_with_holes_data<T>::operator=(const T2& rvalue) {
+    assign(*this, rvalue);
+    return *this;
+  }
+
+  template <class T>
+  template <class T2>
+  polygon_45_with_holes_data<T>& polygon_45_with_holes_data<T>::operator=(const T2& rvalue) {
+    assign(*this, rvalue);
+    return *this;
+  }
+
+  template <class T>
+  template <class T2>
+  polygon_with_holes_data<T>& polygon_with_holes_data<T>::operator=(const T2& rvalue) {
+    assign(*this, rvalue);
+    return *this;
+  }
+
   template <typename T>
   struct geometry_concept<polygon_data<T> > {
     typedef polygon_concept type;
@@ -1374,7 +1410,268 @@
     static inline iterator_holes_type end_holes(const hole_type& t) { return &t; }
     static inline unsigned int size_holes(const hole_type& t) { return 0; }
   };
+
+  template <typename T>
+  struct view_of<rectangle_concept, T> {
+    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+    typedef interval_data<coordinate_type> interval_type;
+    rectangle_data<coordinate_type> rect;
+    view_of(const T& obj) : rect() {
+      point_data<coordinate_type> pts[2];
+      typename polygon_traits<T>::iterator_type itr = 
+        begin_points(obj), itre = end_points(obj);
+      if(itr == itre) return;
+      assign(pts[0], *itr);
+      ++itr;
+      if(itr == itre) return;
+      ++itr;
+      if(itr == itre) return;
+      assign(pts[1], *itr);
+      set_points(rect, pts[0], pts[1]);
+    }
+    inline interval_type get(orientation_2d orient) const {
+      return rect.get(orient); }
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<rectangle_concept, T> > {
+    typedef rectangle_concept type;
+  };
                                                          
+  template <typename T>
+  struct view_of<polygon_45_concept, T> {
+    const T* t;
+    view_of(const T& obj) : t(&obj) {}
+    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+    typedef typename polygon_traits<T>::iterator_type iterator_type;
+    typedef typename polygon_traits<T>::point_type point_type;
+
+    /// Get the begin iterator
+    inline iterator_type begin() const {
+      return polygon_traits<T>::begin_points(*t);
+    }
+  
+    /// Get the end iterator
+    inline iterator_type end() const {
+      return polygon_traits<T>::end_points(*t);
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size() const {
+      return polygon_traits<T>::size(*t);
+    }
+  
+    /// Get the winding direction of the polygon
+    inline winding_direction winding() const {
+      return polygon_traits<T>::winding(*t);
+    }
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_45_concept, T> > {
+    typedef polygon_45_concept type;
+  };
+  
+  template <typename T>
+  struct view_of<polygon_90_concept, T> {
+    const T* t;
+    view_of(const T& obj) : t(&obj) {}
+    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+    typedef typename polygon_traits<T>::iterator_type iterator_type;
+    typedef typename polygon_traits<T>::point_type point_type;
+    typedef iterator_points_to_compact<iterator_type, point_type> compact_iterator_type;
+
+    /// Get the begin iterator
+    inline compact_iterator_type begin_compact() const {
+      return compact_iterator_type(polygon_traits<T>::begin_points(*t),
+                                   polygon_traits<T>::end_points(*t));
+    }
+  
+    /// Get the end iterator
+    inline compact_iterator_type end_compact() const {
+      return compact_iterator_type(polygon_traits<T>::end_points(*t),
+                                   polygon_traits<T>::end_points(*t));
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size() const {
+      return polygon_traits<T>::size(*t);
+    }
+  
+    /// Get the winding direction of the polygon
+    inline winding_direction winding() const {
+      return polygon_traits<T>::winding(*t);
+    }
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_90_concept, T> > {
+    typedef polygon_90_concept type;
+  };
+
+  template <typename T>
+  struct view_of<polygon_45_with_holes_concept, T> {
+    const T* t;
+    view_of(const T& obj) : t(&obj) {}
+    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+    typedef typename polygon_traits<T>::iterator_type iterator_type;
+    typedef typename polygon_traits<T>::point_type point_type;
+    typedef view_of<polygon_45_concept, typename polygon_with_holes_traits<T>::hole_type> hole_type;
+    struct iterator_holes_type {
+      typedef std::forward_iterator_tag iterator_category;
+      typedef hole_type value_type;
+      typedef std::ptrdiff_t difference_type;
+      typedef const hole_type* pointer; //immutable
+      typedef const hole_type& reference; //immutable
+      typedef typename polygon_with_holes_traits<T>::iterator_holes_type iht;
+      iht internal_itr;
+      iterator_holes_type() : internal_itr() {}
+      iterator_holes_type(iht iht_in) : internal_itr(iht_in) {}
+      inline iterator_holes_type& operator++() {
+        ++internal_itr;
+        return *this;
+      }
+      inline const iterator_holes_type operator++(int) {
+        iterator_holes_type tmp(*this);
+        ++(*this);
+        return tmp;
+      }
+      inline bool operator==(const iterator_holes_type& that) const {
+        return (internal_itr == that.internal_itr);
+      }
+      inline bool operator!=(const iterator_holes_type& that) const {
+        return (internal_itr != that.internal_itr);
+      }
+      inline value_type operator*() const { 
+        return view_as<polygon_45_concept>(*internal_itr);
+      }
+    };
+      
+    /// Get the begin iterator
+    inline iterator_type begin() const {
+      return polygon_traits<T>::begin_points(*t);
+    }
+  
+    /// Get the end iterator
+    inline iterator_type end() const {
+      return polygon_traits<T>::end_points(*t);
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size() const {
+      return polygon_traits<T>::size(*t);
+    }
+  
+    /// Get the winding direction of the polygon
+    inline winding_direction winding() const {
+      return polygon_traits<T>::winding(*t);
+    }
+
+    /// Get the begin iterator
+    inline iterator_holes_type begin_holes() const {
+      return polygon_with_holes_traits<T>::begin_holes(*t);
+    }
+  
+    /// Get the end iterator
+    inline iterator_holes_type end_holes() const {
+      return polygon_with_holes_traits<T>::end_holes(*t);
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size_holes() const {
+      return polygon_with_holes_traits<T>::size_holes(*t);
+    }
+  
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_45_with_holes_concept, T> > {
+    typedef polygon_45_with_holes_concept type;
+  };
+  
+  template <typename T>
+  struct view_of<polygon_90_with_holes_concept, T> {
+    const T* t;
+    view_of(const T& obj) : t(&obj) {}
+    typedef typename polygon_traits<T>::coordinate_type coordinate_type;
+    typedef typename polygon_traits<T>::iterator_type iterator_type;
+    typedef typename polygon_traits<T>::point_type point_type;
+    typedef iterator_points_to_compact<iterator_type, point_type> compact_iterator_type;
+    typedef view_of<polygon_90_concept, typename polygon_with_holes_traits<T>::hole_type> hole_type;
+    struct iterator_holes_type {
+      typedef std::forward_iterator_tag iterator_category;
+      typedef hole_type value_type;
+      typedef std::ptrdiff_t difference_type;
+      typedef const hole_type* pointer; //immutable
+      typedef const hole_type& reference; //immutable
+      typedef typename polygon_with_holes_traits<T>::iterator_holes_type iht;
+      iht internal_itr;
+      iterator_holes_type() : internal_itr() {}
+      iterator_holes_type(iht iht_in) : internal_itr(iht_in) {}
+      inline iterator_holes_type& operator++() {
+        ++internal_itr;
+        return *this;
+      }
+      inline const iterator_holes_type operator++(int) {
+        iterator_holes_type tmp(*this);
+        ++(*this);
+        return tmp;
+      }
+      inline bool operator==(const iterator_holes_type& that) const {
+        return (internal_itr == that.internal_itr);
+      }
+      inline bool operator!=(const iterator_holes_type& that) const {
+        return (internal_itr != that.internal_itr);
+      }
+      inline value_type operator*() const { 
+        return view_as<polygon_90_concept>(*internal_itr);
+      }
+    };
+      
+    /// Get the begin iterator
+    inline compact_iterator_type begin_compact() const {
+      return compact_iterator_type(polygon_traits<T>::begin_points(*t),
+                                   polygon_traits<T>::end_points(*t));
+    }
+  
+    /// Get the end iterator
+    inline compact_iterator_type end_compact() const {
+      return compact_iterator_type(polygon_traits<T>::end_points(*t),
+                                   polygon_traits<T>::end_points(*t));
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size() const {
+      return polygon_traits<T>::size(*t);
+    }
+  
+    /// Get the winding direction of the polygon
+    inline winding_direction winding() const {
+      return polygon_traits<T>::winding(*t);
+    }
+
+    /// Get the begin iterator
+    inline iterator_holes_type begin_holes() const {
+      return polygon_with_holes_traits<T>::begin_holes(*t);
+    }
+  
+    /// Get the end iterator
+    inline iterator_holes_type end_holes() const {
+      return polygon_with_holes_traits<T>::end_holes(*t);
+    }
+  
+    /// Get the number of sides of the polygon
+    inline unsigned int size_holes() const {
+      return polygon_with_holes_traits<T>::size_holes(*t);
+    }
+  
+  };
+
+  template <typename T>
+  struct geometry_concept<view_of<polygon_90_with_holes_concept, T> > {
+    typedef polygon_90_with_holes_concept type;
+  };
+
 }
 }
 
Modified: sandbox/gtl/boost/polygon/polygon_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/polygon_with_holes_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/polygon_with_holes_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,15 +5,100 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_POLYGON_WITH_HOLES_DATA_HPP
-#define GTL_POLYGON_WITH_HOLES_DATA_HPP
+#ifndef BOOST_POLYGON_POLYGON_WITH_HOLES_DATA_HPP
+#define BOOST_POLYGON_POLYGON_WITH_HOLES_DATA_HPP
+#include "isotropy.hpp"
+#include "polygon_data.hpp"
 namespace boost { namespace polygon{
   struct polygon_with_holes_concept;
   template <typename T>
-  class polygon_with_holes_data : public polygon_45_with_holes_data<T> {
-  public:
-    typedef polygon_with_holes_concept geometry_type;
-    //inherits everything
+  class polygon_with_holes_data {
+public:
+  typedef polygon_with_holes_concept geometry_type;
+  typedef T coordinate_type;
+  typedef typename polygon_data<T>::iterator_type iterator_type;
+  typedef typename std::list<polygon_data<coordinate_type> >::const_iterator iterator_holes_type;
+  typedef polygon_data<coordinate_type> hole_type; 
+  typedef typename coordinate_traits<T>::coordinate_distance area_type;
+  typedef point_data<T> point_type;
+
+  // default constructor of point does not initialize x and y
+  inline polygon_with_holes_data() : self_(), holes_() {} //do nothing default constructor
+
+  template<class iT>
+  inline polygon_with_holes_data(iT input_begin, iT input_end) : self_(), holes_() {
+    set(input_begin, input_end);
+  }
+
+  template<class iT, typename hiT>
+  inline polygon_with_holes_data(iT input_begin, iT input_end, hiT holes_begin, hiT holes_end) : self_(), holes_() {
+    set(input_begin, input_end);
+    set_holes(holes_begin, holes_end);
+  }
+
+  template<class iT>
+  inline polygon_with_holes_data& set(iT input_begin, iT input_end) {
+    self_.set(input_begin, input_end);
+    return *this;
+  }
+
+  // initialize a polygon from x,y values, it is assumed that the first is an x
+  // and that the input is a well behaved polygon
+  template<class iT>
+  inline polygon_with_holes_data& set_holes(iT input_begin, iT input_end) {
+    holes_.clear();  //just in case there was some old data there
+    for( ; input_begin != input_end; ++ input_begin) {
+       holes_.push_back(hole_type());
+       holes_.back().set((*input_begin).begin(), (*input_begin).end());
+    }
+    return *this;
+  }
+
+  // copy constructor (since we have dynamic memory)
+  inline polygon_with_holes_data(const polygon_with_holes_data& that) : self_(that.self_), 
+                                                                  holes_(that.holes_) {}
+  
+  // assignment operator (since we have dynamic memory do a deep copy)
+  inline polygon_with_holes_data& operator=(const polygon_with_holes_data& that) {
+    self_ = that.self_;
+    holes_ = that.holes_;
+    return *this;
+  }
+
+  template <typename T2>
+  inline polygon_with_holes_data& operator=(const T2& rvalue);
+
+  // get begin iterator, returns a pointer to a const coordinate_type
+  inline const iterator_type begin() const {
+    return self_.begin();
+  }
+
+  // get end iterator, returns a pointer to a const coordinate_type
+  inline const iterator_type end() const {
+    return self_.end();
+  }
+
+  inline unsigned int size() const {
+    return self_.size();
+  } 
+
+  // get begin iterator, returns a pointer to a const polygon
+  inline const iterator_holes_type begin_holes() const {
+    return holes_.begin();
+  }
+
+  // get end iterator, returns a pointer to a const polygon
+  inline const iterator_holes_type end_holes() const {
+    return holes_.end();
+  }
+
+  inline unsigned int size_holes() const {
+    return holes_.size();
+  }
+
+private:
+  polygon_data<coordinate_type> self_;
+  std::list<hole_type> holes_; 
   };
   
   template <typename T>
@@ -46,6 +131,21 @@
     o << " } } ";
     return o;
   }
+  template <typename T>
+  std::ostream& operator<<(std::ostream& o, const polygon_with_holes_data<T>& poly) {
+    o << "Polygon With Holes { ";
+    for(typename polygon_with_holes_data<T>::iterator_type itr = poly.begin(); 
+        itr != poly.end(); ++itr) {
+      if(itr != poly.begin()) o << ", ";
+      o << (*itr).get(HORIZONTAL) << " " << (*itr).get(VERTICAL);
+    } o << " { ";
+    for(typename polygon_with_holes_data<T>::iterator_holes_type itr = poly.begin_holes();
+        itr != poly.end_holes(); ++itr) {
+      o << (*itr);
+    }
+    o << " } } ";
+    return o;
+  }
 }
 }
 #endif
Deleted: sandbox/gtl/boost/polygon/property_merge.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/property_merge.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,588 +0,0 @@
-/*
-  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 GTL_PROPERTY_MERGE_HPP
-#define GTL_PROPERTY_MERGE_HPP
-namespace boost { namespace polygon{
-
-template <typename coordinate_type>
-class property_merge_point {
-private:
-  coordinate_type x_, y_;
-public:
-  inline property_merge_point() : x_(), y_() {}
-  inline property_merge_point(coordinate_type x, coordinate_type y) : x_(x), y_(y) {}
-  //use builtin assign and copy
-  inline bool operator==(const property_merge_point& that) const { return x_ == that.x_ && y_ == that.y_; }
-  inline bool operator!=(const property_merge_point& that) const { return !((*this) == that); }
-  inline bool operator<(const property_merge_point& that) const {
-    if(x_ < that.x_) return true;
-    if(x_ > that.x_) return false;
-    return y_ < that.y_;
-  }
-  inline coordinate_type x() const { return x_; }
-  inline coordinate_type y() const { return y_; }
-  inline void x(coordinate_type value) { x_ = value; }
-  inline void y(coordinate_type value) { y_ = value; }
-};
-
-template <typename coordinate_type>
-class property_merge_interval {
-private:
-  coordinate_type low_, high_;
-public:
-  inline property_merge_interval() : low_(), high_() {}
-  inline property_merge_interval(coordinate_type low, coordinate_type high) : low_(low), high_(high) {}
-  //use builtin assign and copy
-  inline bool operator==(const property_merge_interval& that) const { return low_ == that.low_ && high_ == that.high_; }
-  inline bool operator!=(const property_merge_interval& that) const { return !((*this) == that); }
-  inline bool operator<(const property_merge_interval& that) const {
-    if(low_ < that.low_) return true;
-    if(low_ > that.low_) return false;
-    return high_ < that.high_;
-  }
-  inline coordinate_type low() const { return low_; }
-  inline coordinate_type high() const { return high_; }
-  inline void low(coordinate_type value) { low_ = value; }
-  inline void high(coordinate_type value) { high_ = value; }
-};
-
-template <typename coordinate_type, typename property_type, typename polygon_set_type, typename keytype = std::set<property_type> >
-class merge_scanline {
-public:
-  //definitions
-
-  typedef keytype property_set;
-  typedef std::vector<std::pair<property_type, int> > property_map;
-  typedef std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > vertex_property;
-  typedef std::pair<property_merge_point<coordinate_type>, property_map> vertex_data;
-  typedef std::vector<vertex_property> property_merge_data;
-  //typedef std::map<property_set, polygon_set_type> Result;
-  typedef std::map<coordinate_type, property_map> scanline_type;
-  typedef typename scanline_type::iterator scanline_iterator;
-  typedef std::pair<property_merge_interval<coordinate_type>, std::pair<property_set, property_set> > edge_property;
-  typedef std::vector<edge_property> edge_property_vector;
-
-  //static public member functions
-
-  template <typename iT, typename orientation_2d_type>
-  static inline void 
-  populate_property_merge_data(property_merge_data& pmd, iT input_begin, iT input_end, 
-                               const property_type& property, orientation_2d_type orient) {
-    for( ; input_begin != input_end; ++input_begin) {
-      std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > element;
-      if(orient == HORIZONTAL)
-        element.first = property_merge_point<coordinate_type>((*input_begin).second.first, (*input_begin).first);
-      else
-        element.first = property_merge_point<coordinate_type>((*input_begin).first, (*input_begin).second.first);
-      element.second.first = property;
-      element.second.second = (*input_begin).second.second;
-      pmd.push_back(element);
-    }
-  }
-
-  //public member functions
-
-  merge_scanline() : output(), scanline(), currentVertex(), tmpVector(), previousY(), countFromBelow(), scanlinePosition() {}
-  merge_scanline(const merge_scanline& that) :
-    output(that.output),
-    scanline(that.scanline),
-    currentVertex(that.currentVertex),
-    tmpVector(that.tmpVector),
-    previousY(that.previousY),
-    countFromBelow(that.countFromBelow),
-    scanlinePosition(that.scanlinePosition)
-  {}
-  merge_scanline& operator=(const merge_scanline& that) {
-    output = that.output;
-    scanline = that.scanline;
-    currentVertex = that.currentVertex;
-    tmpVector = that.tmpVector;
-    previousY = that.previousY;
-    countFromBelow = that.countFromBelow;
-    scanlinePosition = that.scanlinePosition;
-    return *this;
-  }
-
-  template <typename result_type>
-  inline void perform_merge(result_type& result, property_merge_data& data) {
-    if(data.empty()) return;
-    //sort
-    std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>());
-    //scanline
-    bool firstIteration = true;
-    scanlinePosition = scanline.end();
-    for(unsigned int i = 0; i < data.size(); ++i) {
-      if(firstIteration) {
-        mergeProperty(currentVertex.second, data[i].second);
-        currentVertex.first = data[i].first;
-        firstIteration = false;
-      } else {
-        if(data[i].first != currentVertex.first) {
-          if(data[i].first.x() != currentVertex.first.x()) {
-            processVertex(output);
-            //std::cout << scanline.size() << " ";
-            countFromBelow.clear(); //should already be clear
-            writeOutput(currentVertex.first.x(), result, output);
-            currentVertex.second.clear();
-            mergeProperty(currentVertex.second, data[i].second);
-            currentVertex.first = data[i].first;
-            //std::cout << assertRedundant(scanline) << "/" << scanline.size() << " ";
-          } else {
-            processVertex(output);
-            currentVertex.second.clear();
-            mergeProperty(currentVertex.second, data[i].second);
-            currentVertex.first = data[i].first;
-          }
-        } else {
-          mergeProperty(currentVertex.second, data[i].second);
-        }
-      }
-    }
-    processVertex(output);
-    writeOutput(currentVertex.first.x(), result, output);
-    //std::cout << assertRedundant(scanline) << "/" << scanline.size() << "\n";
-    //std::cout << scanline.size() << "\n";
-  }
-
-private:
-  //private supporting types
-
-  template <class T>
-  class less_vertex_data {
-  public:
-    less_vertex_data() {}
-    bool operator()(const T& lvalue, const T& rvalue) {
-      if(lvalue.first.x() < rvalue.first.x()) return true;
-      if(lvalue.first.x() > rvalue.first.x()) return false;
-      if(lvalue.first.y() < rvalue.first.y()) return true;
-      return false;
-    }
-  };
-
-  template <typename T>
-  struct lessPropertyCount {
-    lessPropertyCount() {}
-    bool operator()(const T& a, const T& b) {
-      return a.first < b.first;
-    }
-  };
-
-  //private static member functions
-
-  static inline void mergeProperty(property_map& lvalue, std::pair<property_type, int>& rvalue) {
-    typename property_map::iterator itr = std::lower_bound(lvalue.begin(), lvalue.end(), rvalue, 
-                                                          lessPropertyCount<std::pair<property_type, int> >());
-    if(itr == lvalue.end() ||
-       (*itr).first != rvalue.first) {
-      lvalue.insert(itr, rvalue);
-    } else {
-      (*itr).second += rvalue.second;
-      if((*itr).second == 0)
-        lvalue.erase(itr);
-    }
-//     if(assertSorted(lvalue)) {
-//       std::cout << "in mergeProperty\n";
-//       exit(0);
-//     }
-  }
-
-  static inline bool assertSorted(property_map& pset) {
-    bool result = false;
-    for(unsigned int i = 1; i < pset.size(); ++i) {
-      if(pset[i] < pset[i-1]) {
-        std::cout << "Out of Order Error ";
-        result = true;
-      }
-      if(pset[i].first == pset[i-1].first) {
-        std::cout << "Duplicate Property Error ";
-        result = true;
-      }
-      if(pset[0].second == 0 || pset[1].second == 0) {
-        std::cout << "Empty Property Error ";
-        result = true;
-      }
-    }
-    return result;
-  }
-
-  static inline void setProperty(property_set& pset, property_map& pmap) {
-    for(typename property_map::iterator itr = pmap.begin(); itr != pmap.end(); ++itr) {
-      if((*itr).second > 0) {
-        pset.insert(pset.end(), (*itr).first);
-      }
-    }
-  }
-
-  //private data members
-
-  edge_property_vector output;
-  scanline_type scanline;
-  vertex_data currentVertex;
-  property_map tmpVector;
-  coordinate_type previousY;
-  property_map countFromBelow;
-  scanline_iterator scanlinePosition;
-
-  //private member functions
-
-  inline void mergeCount(property_map& lvalue, property_map& rvalue) {
-    typename property_map::iterator litr = lvalue.begin();
-    typename property_map::iterator ritr = rvalue.begin();
-    tmpVector.clear();
-    while(litr != lvalue.end() && ritr != rvalue.end()) {
-      if((*litr).first <= (*ritr).first) {
-        if(!tmpVector.empty() &&
-           (*litr).first == tmpVector.back().first) {
-          tmpVector.back().second += (*litr).second;
-        } else {
-          tmpVector.push_back(*litr);
-        }
-        ++litr;
-      } else if((*ritr).first <= (*litr).first) {
-        if(!tmpVector.empty() &&
-           (*ritr).first == tmpVector.back().first) {
-          tmpVector.back().second += (*ritr).second;
-        } else {
-          tmpVector.push_back(*ritr);
-        }
-        ++ritr;
-      }
-    }
-    while(litr != lvalue.end()) {
-      if(!tmpVector.empty() &&
-         (*litr).first == tmpVector.back().first) {
-        tmpVector.back().second += (*litr).second;
-      } else {
-        tmpVector.push_back(*litr);
-      }
-      ++litr;
-    }
-    while(ritr != rvalue.end()) {
-      if(!tmpVector.empty() &&
-         (*ritr).first == tmpVector.back().first) {
-        tmpVector.back().second += (*ritr).second;
-      } else {
-        tmpVector.push_back(*ritr);
-      }
-      ++ritr;
-    }
-    lvalue.clear();
-    for(unsigned int i = 0; i < tmpVector.size(); ++i) {
-      if(tmpVector[i].second != 0) {
-        lvalue.push_back(tmpVector[i]);
-      }
-    }
-//     if(assertSorted(lvalue)) {
-//       std::cout << "in mergeCount\n";
-//       exit(0);
-//     }
-  }
-
-  inline void processVertex(edge_property_vector& output) {
-    if(!countFromBelow.empty()) {
-      //we are processing an interval of change in scanline state between
-      //previous vertex position and current vertex position where 
-      //count from below represents the change on the interval
-      //foreach scanline element from previous to current we
-      //write the interval on the scanline that is changing
-      //the old value and the new value to output
-      property_merge_interval<coordinate_type> currentInterval(previousY, currentVertex.first.y());
-      coordinate_type currentY = currentInterval.low();
-      if(scanlinePosition == scanline.end() ||
-         (*scanlinePosition).first != previousY) {
-        scanlinePosition = scanline.lower_bound(previousY);
-      }
-      scanline_iterator previousScanlinePosition = scanlinePosition;
-      ++scanlinePosition;
-      while(scanlinePosition != scanline.end()) {
-        coordinate_type elementY = (*scanlinePosition).first;
-        if(elementY <= currentInterval.high()) {
-          property_map& countOnLeft = (*previousScanlinePosition).second;
-          edge_property element;
-          output.push_back(element);
-          output.back().first = property_merge_interval<coordinate_type>((*previousScanlinePosition).first, elementY);
-          setProperty(output.back().second.first, countOnLeft);
-          mergeCount(countOnLeft, countFromBelow);
-          setProperty(output.back().second.second, countOnLeft);
-          if(output.back().second.first == output.back().second.second) {
-            output.pop_back(); //it was an internal vertical edge, not to be output
-          }
-          else if(output.size() > 1) {
-            edge_property& secondToLast = output[output.size()-2];
-            if(secondToLast.first.high() == output.back().first.low() &&
-               secondToLast.second.first == output.back().second.first &&
-               secondToLast.second.second == output.back().second.second) {
-              //merge output onto previous output because properties are
-              //identical on both sides implying an internal horizontal edge
-              secondToLast.first.high(output.back().first.high());
-              output.pop_back();
-            }
-          }
-          if(previousScanlinePosition == scanline.begin()) {
-            if(countOnLeft.empty()) {
-              scanline.erase(previousScanlinePosition);
-            }
-          } else {
-            scanline_iterator tmpitr = previousScanlinePosition;
-            --tmpitr;
-            if((*tmpitr).second == (*previousScanlinePosition).second)
-              scanline.erase(previousScanlinePosition);
-          }
-             
-        } else if(currentY < currentInterval.high()){
-          //elementY > currentInterval.high()
-          //split the interval between previous and current scanline elements
-          std::pair<coordinate_type, property_map> elementScan;
-          elementScan.first = currentInterval.high();
-          elementScan.second = (*previousScanlinePosition).second;
-          scanlinePosition = scanline.insert(scanlinePosition, elementScan);
-          continue;
-        } else {
-          break;
-        }
-        previousScanlinePosition = scanlinePosition;
-        currentY = previousY = elementY;
-        ++scanlinePosition;
-        if(scanlinePosition == scanline.end() &&
-           currentY < currentInterval.high()) {
-          //insert a new element for top of range
-          std::pair<coordinate_type, property_map> elementScan;
-          elementScan.first = currentInterval.high();
-          scanlinePosition = scanline.insert(scanline.end(), elementScan);
-        } 
-      }
-      if(scanlinePosition == scanline.end() &&
-         currentY < currentInterval.high()) {
-        //handle case where we iterated to end of the scanline
-        //we need to insert an element into the scanline at currentY
-        //with property value coming from below
-        //and another one at currentInterval.high() with empty property value
-        mergeCount(scanline[currentY], countFromBelow);
-        std::pair<coordinate_type, property_map> elementScan;
-        elementScan.first = currentInterval.high();
-        scanline.insert(scanline.end(), elementScan);
-
-        edge_property element;
-        output.push_back(element);
-        output.back().first = property_merge_interval<coordinate_type>(currentY, currentInterval.high());
-        setProperty(output.back().second.second, countFromBelow);
-        mergeCount(countFromBelow, currentVertex.second);
-      } else {
-        mergeCount(countFromBelow, currentVertex.second);
-        if(countFromBelow.empty()) {
-          if(previousScanlinePosition == scanline.begin()) {
-            if((*previousScanlinePosition).second.empty()) {
-              scanline.erase(previousScanlinePosition);
-              //previousScanlinePosition = scanline.end();
-              //std::cout << "ERASE_A ";
-            }
-          } else {
-            scanline_iterator tmpitr = previousScanlinePosition;
-            --tmpitr;
-            if((*tmpitr).second == (*previousScanlinePosition).second) {
-              scanline.erase(previousScanlinePosition);
-              //previousScanlinePosition = scanline.end();
-              //std::cout << "ERASE_B ";
-            }
-          }
-        }
-      }
-    } else {
-      //count from below is empty, we are starting a new interval of change
-      countFromBelow = currentVertex.second;
-      scanlinePosition = scanline.lower_bound(currentVertex.first.y());
-      if(scanlinePosition != scanline.end()) {
-        if((*scanlinePosition).first != currentVertex.first.y()) {
-          if(scanlinePosition != scanline.begin()) {
-            //decrement to get the lower position of the first interval this vertex intersects
-            --scanlinePosition;
-            //insert a new element into the scanline for the incoming vertex
-            property_map& countOnLeft = (*scanlinePosition).second;
-            std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
-            scanlinePosition = scanline.insert(scanlinePosition, element);
-          } else {
-            property_map countOnLeft;
-            std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
-            scanlinePosition = scanline.insert(scanlinePosition, element);
-          }
-        }
-      } else {
-        property_map countOnLeft;
-        std::pair<coordinate_type, property_map> element(currentVertex.first.y(), countOnLeft);
-        scanlinePosition = scanline.insert(scanlinePosition, element);
-      }
-    }
-    previousY = currentVertex.first.y();
-  }
-
-  template <typename T>
-  inline int assertRedundant(T& t) {
-    if(t.empty()) return 0;
-    int count = 0; 
-    typename T::iterator itr = t.begin();
-    if((*itr).second.empty())
-      ++count;
-    typename T::iterator itr2 = itr;
-    ++itr2;
-    while(itr2 != t.end()) {
-      if((*itr).second == (*itr2).second)
-        ++count;
-      itr = itr2;
-      ++itr2;
-    }
-    return count;
-  }
-
-  template <typename T>
-  inline void performExtract(T& result, property_merge_data& data) {
-    if(data.empty()) return;
-    //sort
-    std::sort(data.begin(), data.end(), less_vertex_data<vertex_property>());
-    
-    //scanline
-    bool firstIteration = true;
-    scanlinePosition = scanline.end();
-    for(unsigned int i = 0; i < data.size(); ++i) {
-      if(firstIteration) {
-        mergeProperty(currentVertex.second, data[i].second);
-        currentVertex.first = data[i].first;
-        firstIteration = false;
-      } else {
-        if(data[i].first != currentVertex.first) {
-          if(data[i].first.x() != currentVertex.first.x()) {
-            processVertex(output);
-            //std::cout << scanline.size() << " ";
-            countFromBelow.clear(); //should already be clear
-            writeGraph(currentVertex.first.x(), result, output, scanline);
-            currentVertex.second.clear();
-            mergeProperty(currentVertex.second, data[i].second);
-            currentVertex.first = data[i].first;
-          } else {
-            processVertex(output);
-            currentVertex.second.clear();
-            mergeProperty(currentVertex.second, data[i].second);
-            currentVertex.first = data[i].first;
-          }
-        } else {
-          mergeProperty(currentVertex.second, data[i].second);
-        }
-      }
-    }
-    processVertex(output);
-    writeGraph(currentVertex.first.x(), result, output, scanline);
-    //std::cout << scanline.size() << "\n";
-  }
-
-  template <typename T>
-  inline void insertEdges(T& graph, property_set& p1, property_set& p2) {
-    for(typename property_set::iterator itr = p1.begin(); itr != p1.end(); ++itr) {
-      for(typename property_set::iterator itr2 = p2.begin(); itr2 != p2.end(); ++itr2) {
-        if(*itr != *itr2) {
-          graph[*itr].insert(*itr2);
-          graph[*itr2].insert(*itr);
-        }
-      }
-    }
-  }
-
-  template <typename T>
-  inline void propertySetAbove(coordinate_type y, property_set& ps, T& scanline) {
-    ps.clear();
-    typename T::iterator itr = scanline.find(y);
-    if(itr != scanline.end())
-      setProperty(ps, (*itr).second);
-  }
-
-  template <typename T>
-  inline void propertySetBelow(coordinate_type y, property_set& ps, T& scanline) {
-    ps.clear();
-    typename T::iterator itr = scanline.find(y);
-    if(itr != scanline.begin()) {
-      --itr;
-      setProperty(ps, (*itr).second);
-    }
-  }
-
-  template <typename T, typename T2>
-  inline void writeGraph(coordinate_type x, T& graph, edge_property_vector& output, T2& scanline) {
-    if(output.empty()) return;
-    edge_property* previousEdgeP = &(output[0]);
-    bool firstIteration = true;
-    property_set ps;
-    for(unsigned int i = 0; i < output.size(); ++i) {
-      edge_property& previousEdge = *previousEdgeP;
-      edge_property& edge = output[i];
-      if(previousEdge.first.high() == edge.first.low()) {
-        //horizontal edge
-        insertEdges(graph, edge.second.first, previousEdge.second.first);
-        //corner 1
-        insertEdges(graph, edge.second.first, previousEdge.second.second);
-        //other horizontal edge
-        insertEdges(graph, edge.second.second, previousEdge.second.second);
-        //corner 2
-        insertEdges(graph, edge.second.second, previousEdge.second.first);
-      } else {
-        if(!firstIteration){
-          //look up regions above previous edge 
-          propertySetAbove(previousEdge.first.high(), ps, scanline);
-          insertEdges(graph, ps, previousEdge.second.first);
-          insertEdges(graph, ps, previousEdge.second.second);
-        }
-        //look up regions below current edge in the scanline
-        propertySetBelow(edge.first.high(), ps, scanline);
-        insertEdges(graph, ps, edge.second.first);
-        insertEdges(graph, ps, edge.second.second);
-      }
-      firstIteration = false;
-      //vertical edge
-      insertEdges(graph, edge.second.second, edge.second.first);
-      //shared region to left
-      insertEdges(graph, edge.second.second, edge.second.second);
-      //shared region to right
-      insertEdges(graph, edge.second.first, edge.second.first);
-      previousEdgeP = &(output[i]);
-    }
-    edge_property& previousEdge = *previousEdgeP;
-    propertySetAbove(previousEdge.first.high(), ps, scanline);
-    insertEdges(graph, ps, previousEdge.second.first);
-    insertEdges(graph, ps, previousEdge.second.second);
-    output.clear();
-  }
-
-  template <typename Result>
-  inline void writeOutput(coordinate_type x, Result& result, edge_property_vector& output) {
-    for(unsigned int i = 0; i < output.size(); ++i) {
-      edge_property& edge = output[i];
-      //edge.second.first is the property set on the left of the edge
-      if(!edge.second.first.empty()) {
-        typename Result::iterator itr = result.find(edge.second.first);
-        if(itr == result.end()) {
-          std::pair<property_set, polygon_set_type> element(edge.second.first, polygon_set_type(VERTICAL));
-          itr = result.insert(result.end(), element);
-        }
-        std::pair<interval_data<coordinate_type>, int> element2(interval_data<coordinate_type>(edge.first.low(), edge.first.high()), -1); //right edge of figure
-        (*itr).second.insert(x, element2);
-      }
-      if(!edge.second.second.empty()) {
-        //edge.second.second is the property set on the right of the edge
-        typename Result::iterator itr = result.find(edge.second.second);
-        if(itr == result.end()) {
-          std::pair<property_set, polygon_set_type> element(edge.second.second, polygon_set_type(VERTICAL));
-          itr = result.insert(result.end(), element);
-        }
-        std::pair<interval_data<coordinate_type>, int> element3(interval_data<coordinate_type>(edge.first.low(), edge.first.high()), 1); //left edge of figure
-        (*itr).second.insert(x, element3);
-      }
-    }
-    output.clear();
-  }
-};
-
-}
-}
-#endif
Modified: sandbox/gtl/boost/polygon/rectangle_concept.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/rectangle_concept.hpp	(original)
+++ sandbox/gtl/boost/polygon/rectangle_concept.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_RECTANGLE_CONCEPT_HPP
-#define GTL_RECTANGLE_CONCEPT_HPP
+#ifndef BOOST_POLYGON_RECTANGLE_CONCEPT_HPP
+#define BOOST_POLYGON_RECTANGLE_CONCEPT_HPP
 
 #include "isotropy.hpp"
 
Modified: sandbox/gtl/boost/polygon/rectangle_data.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/rectangle_data.hpp	(original)
+++ sandbox/gtl/boost/polygon/rectangle_data.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_RECTANGLE_DATA_HPP
-#define GTL_RECTANGLE_DATA_HPP
+#ifndef BOOST_POLYGON_RECTANGLE_DATA_HPP
+#define BOOST_POLYGON_RECTANGLE_DATA_HPP
 
 #include "isotropy.hpp"
 //interval
Deleted: sandbox/gtl/boost/polygon/rectangle_formation.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/rectangle_formation.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,267 +0,0 @@
-/*
-    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 GTL_RECTANGLE_FORMATION_HPP
-#define GTL_RECTANGLE_FORMATION_HPP
-namespace boost { namespace polygon{
-
-namespace rectangle_formation {
-  template <class T> 
-  class ScanLineToRects {
-  public:
-    typedef T rectangle_type;
-    typedef typename rectangle_traits<T>::coordinate_type coordinate_type;
-    typedef rectangle_data<coordinate_type> scan_rect_type;
-  private:
-    
-    typedef std::set<scan_rect_type, less_rectangle_concept<scan_rect_type, scan_rect_type> > ScanData;
-    ScanData scanData_;
-    bool haveCurrentRect_;
-    scan_rect_type currentRect_;
-    orientation_2d orient_;
-    typename rectangle_traits<T>::coordinate_type currentCoordinate_;
-  public:
-    inline ScanLineToRects() : scanData_(), haveCurrentRect_(), currentRect_(), orient_(), currentCoordinate_() {}
-    
-    inline ScanLineToRects(orientation_2d orient, rectangle_type model) :
-      scanData_(orientation_2d(orient.to_int() ? VERTICAL : HORIZONTAL)),
-      haveCurrentRect_(false), currentRect_(), orient_(orient), currentCoordinate_() {
-      assign(currentRect_, model);
-      currentCoordinate_ = (std::numeric_limits<coordinate_type>::max)();
-    }
-    
-    template <typename CT>
-    inline ScanLineToRects& processEdge(CT& rectangles, const interval_data<coordinate_type>& edge);
-    
-    inline ScanLineToRects& nextMajorCoordinate(coordinate_type currentCoordinate) {
-      if(haveCurrentRect_) {
-        scanData_.insert(scanData_.end(), currentRect_);
-        haveCurrentRect_ = false;
-      }
-      currentCoordinate_ = currentCoordinate;
-      return *this;
-    }
-    
-  };
-
-  template <class CT, class ST, class rectangle_type, typename interval_type, typename coordinate_type> inline CT& 
-  processEdge_(CT& rectangles, ST& scanData, const interval_type& edge, 
-               bool& haveCurrentRect, rectangle_type& currentRect, coordinate_type currentCoordinate, orientation_2d orient) 
-  {
-    typedef typename CT::value_type result_type;
-    bool edgeProcessed = false;
-    if(!scanData.empty()) {
-
-      //process all rectangles in the scanData that touch the edge
-      typename ST::iterator dataIter = scanData.lower_bound(rectangle_type(edge, edge));
-      //decrement beginIter until its low is less than edge's low
-      while((dataIter == scanData.end() || (*dataIter).get(orient).get(LOW) > edge.get(LOW)) && 
-            dataIter != scanData.begin())
-        {
-          --dataIter;
-        }
-      //process each rectangle until the low end of the rectangle 
-      //is greater than the high end of the edge
-      while(dataIter != scanData.end() &&
-            (*dataIter).get(orient).get(LOW) <= edge.get(HIGH)) 
-        {
-          const rectangle_type& rect = *dataIter;
-          //if the rectangle data intersects the edge at all
-          if(rect.get(orient).get(HIGH) >= edge.get(LOW)) {
-            if(contains(rect.get(orient), edge, true)) {
-              //this is a closing edge
-              //we need to write out the intersecting rectangle and
-              //insert between 0 and 2 rectangles into the scanData
-              //write out rectangle
-              rectangle_type tmpRect = rect;
-
-              if(rect.get(orient.get_perpendicular()).get(LOW) < currentCoordinate) {
-                //set the high coordinate perpedicular to slicing orientation
-                //to the current coordinate of the scan event
-                tmpRect.set(orient.get_perpendicular().get_direction(HIGH),
-                            currentCoordinate);
-                result_type result;
-                assign(result, tmpRect);
-                rectangles.insert(rectangles.end(), result);
-              }
-              //erase the rectangle from the scan data
-              typename ST::iterator nextIter = dataIter;
-              ++nextIter;
-              scanData.erase(dataIter);
-              if(tmpRect.get(orient).get(LOW) < edge.get(LOW)) {
-                //insert a rectangle for the overhang of the bottom
-                //of the rectangle back into scan data
-                rectangle_type lowRect(tmpRect);
-                lowRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
-                                                                currentCoordinate));
-                lowRect.set(orient.get_direction(HIGH), edge.get(LOW));
-                scanData.insert(nextIter, lowRect);
-              }
-              if(tmpRect.get(orient).get(HIGH) > edge.get(HIGH)) {
-                //insert a rectangle for the overhang of the top
-                //of the rectangle back into scan data
-                rectangle_type highRect(tmpRect);
-                highRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
-                                                                 currentCoordinate));
-                highRect.set(orient.get_direction(LOW), edge.get(HIGH));
-                scanData.insert(nextIter, highRect);
-              }
-              //we are done with this edge
-              edgeProcessed = true;                 
-              break;
-            } else {
-              //it must be an opening edge
-              //assert that rect does not overlap the edge but only touches
-              //write out rectangle
-              rectangle_type tmpRect = rect;
-              //set the high coordinate perpedicular to slicing orientation
-              //to the current coordinate of the scan event
-              if(tmpRect.get(orient.get_perpendicular().get_direction(LOW)) < currentCoordinate) {
-                tmpRect.set(orient.get_perpendicular().get_direction(HIGH),
-                            currentCoordinate);
-                result_type result;
-                assign(result, tmpRect);
-                rectangles.insert(rectangles.end(), result);
-              }
-              //erase the rectangle from the scan data
-              typename ST::iterator nextIter = dataIter;
-              ++nextIter;
-              scanData.erase(dataIter);
-              dataIter = nextIter;
-              if(haveCurrentRect) {
-                if(currentRect.get(orient).get(HIGH) >= edge.get(LOW)){
-                  if(!edgeProcessed && currentRect.get(orient.get_direction(HIGH)) > edge.get(LOW)){
-                    rectangle_type tmpRect2(currentRect);
-                    tmpRect2.set(orient.get_direction(HIGH), edge.get(LOW));
-                    scanData.insert(nextIter, tmpRect2);
-                    if(currentRect.get(orient.get_direction(HIGH)) > edge.get(HIGH)) {
-                      currentRect.set(orient, interval_data<coordinate_type>(edge.get(HIGH), currentRect.get(orient.get_direction(HIGH))));
-                    } else {
-                      haveCurrentRect = false;
-                    }
-                  } else {
-                    //extend the top of current rect
-                    currentRect.set(orient.get_direction(HIGH), 
-                                    (std::max)(edge.get(HIGH), 
-                                               tmpRect.get(orient.get_direction(HIGH))));
-                  }
-                } else {
-                  //insert current rect into the scanData
-                  scanData.insert(nextIter, currentRect);
-                  //create a new current rect
-                  currentRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
-                                                                      currentCoordinate));
-                  currentRect.set(orient, interval_data<coordinate_type>((std::min)(tmpRect.get(orient).get(LOW), 
-                                                       edge.get(LOW)),
-                                                                         (std::max)(tmpRect.get(orient).get(HIGH),
-                                                       edge.get(HIGH))));
-                }
-              } else {
-                haveCurrentRect = true;
-                currentRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
-                                                                    currentCoordinate));
-                currentRect.set(orient, interval_data<coordinate_type>((std::min)(tmpRect.get(orient).get(LOW), 
-                                                     edge.get(LOW)),
-                                                                       (std::max)(tmpRect.get(orient).get(HIGH),
-                                                     edge.get(HIGH))));
-              }
-              //skip to nextIter position
-              edgeProcessed = true;
-              continue;
-            }
-            //edgeProcessed = true;
-          }
-          ++dataIter;
-        } //end while edge intersects rectangle data 
-
-    }
-    if(!edgeProcessed) {
-      if(haveCurrentRect) {
-        if(currentRect.get(orient.get_perpendicular().get_direction(HIGH)) 
-           == currentCoordinate &&
-           currentRect.get(orient.get_direction(HIGH)) >= edge.get(LOW)) 
-          {
-            if(currentRect.get(orient.get_direction(HIGH)) > edge.get(LOW)){
-              rectangle_type tmpRect(currentRect);
-              tmpRect.set(orient.get_direction(HIGH), edge.get(LOW));
-              scanData.insert(scanData.end(), tmpRect);
-              if(currentRect.get(orient.get_direction(HIGH)) > edge.get(HIGH)) {
-                currentRect.set(orient, 
-                                interval_data<coordinate_type>(edge.get(HIGH), 
-                                         currentRect.get(orient.get_direction(HIGH))));
-                return rectangles;
-              } else {
-                haveCurrentRect = false;
-                return rectangles;
-              }
-            }
-            //extend current rect
-            currentRect.set(orient.get_direction(HIGH), edge.get(HIGH));
-            return rectangles;
-          }
-        scanData.insert(scanData.end(), currentRect);
-        haveCurrentRect = false;
-      } 
-      rectangle_type tmpRect(currentRect);
-      tmpRect.set(orient.get_perpendicular(), interval_data<coordinate_type>(currentCoordinate,
-                                                      currentCoordinate));
-      tmpRect.set(orient, edge);
-      scanData.insert(tmpRect);
-      return rectangles;
-    }
-    return rectangles;
-  
-  }
-
-  template <class T> 
-  template <class CT> 
-  inline 
-  ScanLineToRects<T>& ScanLineToRects<T>::processEdge(CT& rectangles, const interval_data<coordinate_type>& edge) 
-  {
-    processEdge_(rectangles, scanData_, edge, haveCurrentRect_, currentRect_, currentCoordinate_, orient_);
-    return *this;
-  }
-
-
-} //namespace rectangle_formation
-
-  template <typename T, typename T2>
-  struct get_coordinate_type_for_rectangles {
-    typedef typename polygon_traits<T>::coordinate_type type;
-  };
-  template <typename T>
-  struct get_coordinate_type_for_rectangles<T, rectangle_concept> {
-    typedef typename rectangle_traits<T>::coordinate_type type;
-  };
-
-  template <typename output_container, typename iterator_type, typename rectangle_concept>
-  void form_rectangles(output_container& output, iterator_type begin, iterator_type end,
-                       orientation_2d orient, rectangle_concept tag) {
-    typedef typename output_container::value_type rectangle_type;
-    typedef typename get_coordinate_type_for_rectangles<rectangle_type, typename geometry_concept<rectangle_type>::type>::type Unit;
-    rectangle_data<Unit> model;
-    Unit prevPos = (std::numeric_limits<Unit>::max)();
-    rectangle_formation::ScanLineToRects<rectangle_data<Unit> > scanlineToRects(orient, model);
-    for(iterator_type itr = begin;
-        itr != end; ++ itr) {
-      Unit pos = (*itr).first;
-      if(pos != prevPos) {
-        scanlineToRects.nextMajorCoordinate(pos);
-        prevPos = pos;
-      }
-      Unit lowy = (*itr).second.first;
-      iterator_type tmp_itr = itr;
-      ++itr;
-      Unit highy = (*itr).second.first;
-      scanlineToRects.processEdge(output, interval_data<Unit>(lowy, highy));
-      if(abs((*itr).second.second) > 1) itr = tmp_itr; //next edge begins from this vertex
-    }
-  }
-}
-}
-#endif
-
Modified: sandbox/gtl/boost/polygon/rectangle_traits.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/rectangle_traits.hpp	(original)
+++ sandbox/gtl/boost/polygon/rectangle_traits.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,8 +5,8 @@
   Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_RECTANGLE_TRAITS_HPP
-#define GTL_RECTANGLE_TRAITS_HPP
+#ifndef BOOST_POLYGON_RECTANGLE_TRAITS_HPP
+#define BOOST_POLYGON_RECTANGLE_TRAITS_HPP
 namespace boost { namespace polygon{
 
   template <typename T, typename enable = gtl_yes>
Deleted: sandbox/gtl/boost/polygon/scan_arbitrary.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/scan_arbitrary.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,2533 +0,0 @@
-/*
-  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 GTL_SCAN_ARBITRARY_HPP
-#define GTL_SCAN_ARBITRARY_HPP
-#include <fstream>
-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) {
-      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_() { (*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);
-    }
-    
-    //quadratic algorithm to do same work as optimal scan for cross checking
-    //assume sorted input
-    template <typename iT>
-    static inline void validate_scan(std::map<segment_id, std::set<Point> >& intersection_points,
-                                     iT begin, iT end) {
-      std::set<Point> pts;
-      std::vector<std::pair<half_edge, segment_id> > data(begin, end);
-      for(unsigned int i = 0; i < data.size(); ++i) {
-        if(data[i].first.second < data[i].first.first) {
-          std::swap(data[i].first.first, data[i].first.second);
-        }
-      }
-      std::sort(data.begin(), data.end());
-      //find all intersection points
-      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
-          outer != data.end(); ++outer) {
-        const half_edge& he1 = (*outer).first;
-        //its own end points
-        pts.insert(he1.first);
-        pts.insert(he1.second);
-        for(typename std::vector<std::pair<half_edge, segment_id> >::iterator inner = outer;
-            inner != data.end(); ++inner) {
-          const half_edge& he2 = (*inner).first;
-          if(he1 == he2) continue;
-          if((std::min)(he2. first.get(HORIZONTAL),
-                        he2.second.get(HORIZONTAL)) > 
-             (std::max)(he1.second.get(HORIZONTAL),
-                        he1.first.get(HORIZONTAL)))
-            break;
-          Point intersection;
-          if(compute_intersection(intersection, he1, he2)) {
-            //their intersection point
-            pts.insert(intersection);
-          } 
-        }
-      }
-      //find all segments that interact with intersection points
-      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
-          outer != data.end(); ++outer) {
-        const half_edge& he1 = (*outer).first;
-        segment_id id1 = (*outer).second;
-        typedef rectangle_data<Unit> Rectangle;
-        Rectangle rect1;
-        set_points(rect1, he1.first, he1.second);
-        typename std::set<Point>::iterator itr = pts.lower_bound((std::min)(he1.first, he1.second));
-        typename std::set<Point>::iterator itr2 = pts.upper_bound((std::max)(he1.first, he1.second));
-        while(itr != pts.end() && itr != pts.begin() && (*itr).get(HORIZONTAL) >= (std::min)(he1.first.get(HORIZONTAL), he1.second.get(HORIZONTAL))) --itr;
-        while(itr2 != pts.end() && (*itr2).get(HORIZONTAL) <= (std::max)(he1.first.get(HORIZONTAL), he1.second.get(HORIZONTAL))) ++itr2;
-        //itr = pts.begin();
-        //itr2 = pts.end();
-        for( ; itr != itr2; ++itr) {
-          if(intersects_grid(*itr, he1))
-            intersection_points[id1].insert(*itr);
-        }
-      }
-    }
-
-    template <typename iT, typename property_type>
-    static inline void validate_scan(std::vector<std::pair<half_edge, std::pair<property_type, int> > >& output_segments,
-                                     iT begin, iT end) {
-      std::vector<std::pair<property_type, int> > input_properties;
-      std::vector<std::pair<half_edge, int> > input_segments, intermediate_segments;
-      int index = 0;
-      for( ; begin != end; ++begin) {
-        input_properties.push_back((*begin).second);
-        input_segments.push_back(std::make_pair((*begin).first, index++));
-      }
-      validate_scan(intermediate_segments, input_segments.begin(), input_segments.end());
-      for(unsigned int i = 0; i < intermediate_segments.size(); ++i) {
-        output_segments.push_back(std::make_pair(intermediate_segments[i].first,
-                                                 input_properties[intermediate_segments[i].second]));
-        less_point lp;
-        if(lp(output_segments.back().first.first, output_segments.back().first.second) !=
-           lp(input_segments[intermediate_segments[i].second].first.first,
-              input_segments[intermediate_segments[i].second].first.second)) {
-          //edge changed orientation, invert count on edge
-          output_segments.back().second.second *= -1;
-        }
-        if(!is_vertical(input_segments[intermediate_segments[i].second].first) &&
-           is_vertical(output_segments.back().first)) {
-          output_segments.back().second.second *= -1;
-        }
-        if(lp(output_segments.back().first.second, output_segments.back().first.first)) {
-          std::swap(output_segments.back().first.first, output_segments.back().first.second);
-        }
-      }
-    }
-
-    template <typename iT>
-    static inline void validate_scan(std::vector<std::pair<half_edge, int> >& output_segments,
-                                     iT begin, iT end) {
-      std::map<segment_id, std::set<Point> > intersection_points;
-      validate_scan(intersection_points, begin, end);
-      segment_intersections(output_segments, intersection_points, begin, end);
-    }
-
-    //quadratic algorithm to find intersections
-    template <typename iT, typename segment_id>
-    static inline bool verify_scan(std::pair<segment_id, segment_id>& offenders,
-                                   iT begin, iT end) {
-
-      std::vector<std::pair<half_edge, segment_id> > data(begin, end);
-      for(unsigned int i = 0; i < data.size(); ++i) {
-        if(data[i].first.second < data[i].first.first) {
-          std::swap(data[i].first.first, data[i].first.second);
-        }
-      }
-      std::sort(data.begin(), data.end());
-      for(typename std::vector<std::pair<half_edge, segment_id> >::iterator outer = data.begin();
-          outer != data.end(); ++outer) {
-        const half_edge& he1 = (*outer).first;
-        segment_id id1 = (*outer).second;
-        for(typename std::vector<std::pair<half_edge, segment_id> >::iterator inner = outer;
-            inner != data.end(); ++inner) {
-          const half_edge& he2 = (*inner).first;
-          if(he1 == he2) continue;
-          if((std::min)(he2. first.get(HORIZONTAL),
-                        he2.second.get(HORIZONTAL)) > 
-             (std::max)(he1.second.get(HORIZONTAL),
-                        he1.first.get(HORIZONTAL)))
-            break;
-          segment_id id2 = (*inner).second;
-          if(scanline_base<Unit>::intersects(he1, he2)) {
-            offenders.first = id1;
-            offenders.second = id2;
-            return false;
-          }
-        }
-      }
-      return true;
-    }
-
-    class less_point_down_slope : public std::binary_function<Point, Point, bool> {
-    public:
-      inline less_point_down_slope() {}
-      inline bool operator () (const Point& pt1, const Point& pt2) const {
-        if(pt1.get(HORIZONTAL) < pt2.get(HORIZONTAL)) return true;
-        if(pt1.get(HORIZONTAL) == pt2.get(HORIZONTAL)) {
-          if(pt1.get(VERTICAL) > pt2.get(VERTICAL)) return true;
-        }
-        return false;
-      }
-    };
-
-    template <typename iT>
-    static inline void segment_edge(std::vector<std::pair<half_edge, int> >& output_segments,
-                                    const half_edge& he, segment_id id, iT begin, iT end) {
-      iT current = begin;
-      iT next = begin;
-      ++next;
-      while(next != end) {
-        output_segments.push_back(std::make_pair(half_edge(*current, *next), id));
-        current = next;
-        ++next;
-      }
-    }
-
-    template <typename iT>
-    static inline void segment_intersections(std::vector<std::pair<half_edge, int> >& output_segments,
-                                             std::map<segment_id, std::set<Point> >& intersection_points,
-                                             iT begin, iT end) {
-      for(iT iter = begin; iter != end; ++iter) {
-        //less_point lp;
-        const half_edge& he = (*iter).first;
-        //if(lp(he.first, he.second)) {
-        //  //it is the begin event
-          segment_id id = (*iter).second;
-          const std::set<Point>& pts = intersection_points[id];
-          Point hpt(he.first.get(HORIZONTAL)+1, he.first.get(VERTICAL));
-          if(!is_vertical(he) && less_slope(he.first.get(HORIZONTAL), he.first.get(VERTICAL),
-                                            he.second, hpt)) {
-            //slope is below horizontal
-            std::vector<Point> tmpPts;
-            tmpPts.reserve(pts.size());
-            tmpPts.insert(tmpPts.end(), pts.begin(), pts.end());
-            less_point_down_slope lpds;
-            std::sort(tmpPts.begin(), tmpPts.end(), lpds);
-            segment_edge(output_segments, he, id, tmpPts.begin(), tmpPts.end());
-          } else {
-            segment_edge(output_segments, he, id, pts.begin(), pts.end());
-          }
-          //}
-      }
-    }
-
-    //iT iterator over unsorted pair<Point> representing line segments of input
-    //output_segments is populated with fully intersected output line segment half
-    //edges and the index of the input segment that they are assoicated with
-    //duplicate output half edges with different ids will be generated in the case
-    //that parallel input segments intersection
-    //outputs are in sorted order and include both begin and end events for
-    //each segment
-    template <typename iT>
-    inline void scan(std::vector<std::pair<half_edge, int> >& output_segments,
-                     iT begin, iT end) {
-      std::map<segment_id, std::set<Point> > intersection_points;
-      scan(intersection_points, begin, end);
-      segment_intersections(output_segments, intersection_points, begin, end);
-    }
-
-    //iT iterator over sorted sequence of half edge, segment id pairs representing segment begin and end points
-    //intersection points provides a mapping from input segment id (vector index) to the set
-    //of intersection points assocated with that input segment
-    template <typename iT>
-    inline void scan(std::map<segment_id, std::set<Point> >& intersection_points,
-                     iT begin, iT end) {
-      for(iT iter = begin; iter != end; ++iter) {
-        const std::pair<half_edge, int>& elem = *iter;
-        const half_edge& he = elem.first;
-        Unit current_x = he.first.get(HORIZONTAL);
-        if(current_x != x_) {
-          process_scan_event(intersection_points);
-          while(!intersection_queue_.empty() &&
-                (*(intersection_queue_.begin()).get(HORIZONTAL) < current_x)) {
-            x_ = *(intersection_queue_.begin()).get(HORIZONTAL);
-            process_intersections_at_scan_event(intersection_points);
-          }
-          x_ = current_x;
-        }
-        event_edges_.push_back(elem);
-      }
-      process_scan_event(intersection_points);
-    }
-
-    inline iterator lookup(const half_edge& he) {
-      return edge_scanline_.find(he);
-    }
-
-    inline void insert_into_scanline(const half_edge& he, int id) {
-      edge_scanline_[he].insert(id);
-    }
-
-    inline void lookup_and_remove(const half_edge& he, int id) {
-      iterator remove_iter = lookup(he);
-      if(remove_iter == edge_scanline_.end()) {
-        std::cout << "failed to find removal segment in scanline\n";
-        return;
-      }
-      std::set<segment_id>& ids = (*remove_iter).second;
-      std::set<segment_id>::iterator id_iter = ids.find(id);
-      if(id_iter == ids.end()) {
-        std::cout << "failed to find removal segment id in scanline set\n";
-        return;
-      }
-      ids.erase(id_iter);
-      if(ids.empty())
-        edge_scanline_.erase(remove_iter);
-    }
-
-    static inline void update_segments(std::map<segment_id, std::set<Point> >& intersection_points, 
-                                       const std::set<segment_id>& segments, Point pt) {
-      for(std::set<segment_id>::const_iterator itr = segments.begin(); itr != segments.end(); ++itr) {
-        intersection_points[*itr].insert(pt);
-      }
-    }
-
-    inline void process_intersections_at_scan_event(std::map<segment_id, std::set<Point> >& intersection_points) {
-      //there may be additional intersection points at this x location that haven't been
-      //found yet if vertical or near vertical line segments intersect more than
-      //once before the next x location
-      just_before_ = true;
-      std::set<iterator> intersecting_elements;
-      std::set<Unit> intersection_locations;
-      typedef typename std::set<Point>::iterator intersection_iterator;
-      intersection_iterator iter;
-      //first find all secondary intersection locations and all scanline iterators
-      //that are intersecting
-      for(iter = intersection_queue_.begin();
-          iter != intersection_queue_.end() && (*iter).get(HORIZONTAL) == x_; ++iter) {
-        Point pt = *iter;
-        Unit y = pt.get(VERTICAL);
-        intersection_locations.insert(y);
-        //if x_ is max there can be only end events and no sloping edges
-        if(x_ != (std::numeric_limits<Unit>::max)()) {
-          //deal with edges that project to the right of scanline
-          //first find the edges in the scanline adjacent to primary intersectin points
-          //lookup segment in scanline at pt
-          iterator itr = edge_scanline_.lower_bound(half_edge(pt, Point(x_+1, y)));
-          //look above pt in scanline until reaching end or segment that doesn't intersect
-          //1x1 grid upper right of pt
-          //look below pt in scanline until reaching begin or segment that doesn't interset
-          //1x1 grid upper right of pt
-
-          //second find edges in scanline on the y interval of each edge found in the previous
-          //step for x_ to x_ + 1
-
-          //third find overlaps in the y intervals of all found edges to find all
-          //secondary intersection points
-
-        }
-      }
-      //erase the intersection points from the queue
-      intersection_queue_.erase(intersection_queue_.begin(), iter);
-      std::vector<scanline_element> insertion_edges;
-      insertion_edges.reserve(intersecting_elements.size());
-      std::vector<std::pair<Unit, iterator> > sloping_ends;
-      //do all the work of updating the output of all intersecting 
-      for(typename std::set<iterator>::iterator inter_iter = intersecting_elements.begin();
-          inter_iter != intersecting_elements.end(); ++inter_iter) {
-        //if it is horizontal update it now and continue
-        if(is_horizontal((*inter_iter).first)) {
-          update_segments(intersection_points, (*inter_iter).second, Point(x_, (*inter_iter).first.get(VERTICAL)));
-        } else {
-          //if x_ is max there can be only end events and no sloping edges
-          if(x_ != (std::numeric_limits<Unit>::max)()) {
-            //insert its end points into the vector of sloping ends
-            const half_edge& he = (*inter_iter).first;
-            Unit y = evalAtXforY(x_, he.first, he.second);
-            Unit y2 = evalAtXforY(x_+1, he.first, he.second); 
-            if(y2 >= y) y2 +=1; //we round up, in exact case we don't worry about overbite of one
-            else y += 1; //downward sloping round up
-            sloping_ends.push_back(std::make_pair(y, inter_iter));
-            sloping_ends.push_back(std::make_pair(y2, inter_iter));
-          }
-        }
-      }
-        
-      //merge sloping element data
-      std::sort(sloping_ends.begin(), sloping_ends.end());
-      std::map<Unit, std::set<iterator> > sloping_elements;
-      std::set<iterator> merge_elements;
-      for(typename std::vector<std::pair<Unit, iterator> >::iterator slop_iter = sloping_ends.begin();
-          slop_iter = sloping_ends.end(); ++slop_iter) {
-        //merge into sloping elements
-        typename std::set<iterator>::iterator merge_iterator = merge_elements.find((*slop_iter).second);
-        if(merge_iterator = merge_elements.end()) {
-          merge_elements.insert((*slop_iter).second);
-        } else {
-          merge_elements.erase(merge_iterator);
-        }
-        sloping_elements[(*slop_iter).first] = merge_elements;
-      }
-
-      //scan intersection points
-      typename std::map<Unit, std::set<segment_id> >::iterator vertical_iter = vertical_data_.begin();
-      typename std::map<Unit, std::set<iterator> >::iterator sloping_iter = sloping_elements.begin();
-      for(typename std::set<Unit>::iterator position_iter = intersection_locations.begin();
-          position_iter = intersection_locations.end(); ++position_iter) {
-        //look for vertical segments that intersect this point and update them
-        Unit y = *position_iter;
-        Point pt(x_, y);
-        //handle vertical segments
-        if(vertical_iter != vertical_data_.end()) {
-          typename std::map<Unit, std::set<segment_id> >::iterator next_vertical = vertical_iter;
-          for(++next_vertical; next_vertical != vertical_data_.end() &&
-                (*next_vertical).first < y; ++next_vertical) {
-            vertical_iter = next_vertical;
-          }
-          if((*vertical_iter).first < y && !(*vertical_iter).second.empty()) {
-            update_segments(intersection_points, (*vertical_iter).second, pt);
-            ++vertical_iter;
-            if(vertical_iter != vertical_data_.end() && (*vertical_iter).first == y)
-              update_segments(intersection_points, (*vertical_iter).second, pt);
-          }
-        }
-        //handle sloping segments
-        if(sloping_iter != sloping_elements.end()) {
-          typename std::map<Unit, std::set<iterator> >::iterator next_sloping = sloping_iter;
-          for(++next_sloping; next_sloping != sloping_elements.end() &&
-                (*next_sloping).first < y; ++next_sloping) {
-            sloping_iter = next_sloping;
-          }
-          if((*sloping_iter).first < y && !(*sloping_iter).second.empty()) {
-            for(typename std::set<iterator>::iterator element_iter = (*sloping_iter).second.begin();
-                element_iter != (*sloping_iter).second.end(); ++element_iter) {
-              const half_edge& he = (*element_iter).first;
-              if(intersects_grid(pt, he)) {
-                update_segments(intersection_points, (*element_iter).second, pt);
-              }
-            }
-            ++sloping_iter;
-            if(sloping_iter != sloping_elements.end() && (*sloping_iter).first == y &&
-               !(*sloping_iter).second.empty()) {
-              for(typename std::set<iterator>::iterator element_iter = (*sloping_iter).second.begin();
-                  element_iter != (*sloping_iter).second.end(); ++element_iter) {
-                const half_edge& he = (*element_iter).first;
-                if(intersects_grid(pt, he)) {
-                  update_segments(intersection_points, (*element_iter).second, pt);
-                }
-              }
-            }
-          }
-        }
-      }
-
-      //erase and reinsert edges into scanline with check for future intersection
-    }
-
-    inline void process_scan_event(std::map<segment_id, std::set<Point> >& intersection_points) {
-      just_before_ = true;
-
-      //process end events by removing those segments from the scanline 
-      //and insert vertices of all events into intersection queue
-      Point prev_point((std::numeric_limits<Unit>::min)(), (std::numeric_limits<Unit>::min)());
-      less_point lp;
-      std::set<segment_id> vertical_ids;
-      vertical_data_.clear();
-      for(unsigned int i = 0; i < event_edges_.size(); ++i) {
-        segment_id id = event_edges_[i].second;
-        const half_edge& he = event_edges_[i].first;
-        //vertical half edges are handled during intersection processing because
-        //they cannot be inserted into the scanline
-        if(!is_vertical(he)) {
-          if(lp(he.second, he.first)) {
-            //half edge is end event
-            lookup_and_remove(he, id);
-          } else {
-            //half edge is begin event
-            insert_into_scanline(he, id);  
-            //note that they will be immediately removed and reinserted after
-            //handling their intersection (vertex)
-            //an optimization would allow them to be processed specially to avoid the redundant
-            //removal and reinsertion
-          }
-        } else {
-          //common case if you are lucky
-          //update the map of y to set of segment id
-          if(lp(he.second, he.first)) {
-            //half edge is end event
-            std::set<segment_id>::iterator itr = vertical_ids.find(id);
-            if(itr == vertical_ids.end()) {
-              std::cout << "Failed to find end event id in vertical ids\n";
-            } else {
-              vertical_ids.erase(itr);
-              vertical_data_[he.first.get(HORIZONTAL)] = vertical_ids;
-            }
-          } else {
-            //half edge is a begin event
-            vertical_ids.insert(id);
-            vertical_data_[he.first.get(HORIZONTAL)] = vertical_ids;
-          }
-        }
-        //prevent repeated insertion of same vertex into intersection queue
-        if(prev_point != he.first)
-          intersection_queue_.insert(he.first);
-        else
-          prev_point = he.first;
-        // process intersections at scan event
-        process_intersections_at_scan_event(intersection_points);
-      }
-      event_edges_.clear();
-    }
-
-  public:
-    static inline bool test_validate_scan() {
-      std::vector<std::pair<half_edge, segment_id> > input, edges;
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), 0));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 10)), 1));
-      std::pair<segment_id, segment_id> result;
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail1 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.push_back(std::make_pair(half_edge(Point(0, 5), Point(5, 5)), 2));
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.pop_back();
-      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(11, 11)), 3));
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail3 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(10, 11)), 4));
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail4 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.pop_back();
-      input.push_back(std::make_pair(half_edge(Point(1, 2), Point(11, 11)), 5));
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail5 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.push_back(std::make_pair(half_edge(Point(0, 5), Point(0, 11)), 6));
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail6 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.pop_back();
-      for(unsigned int i = 0; i < input.size(); ++i) {
-        std::swap(input[i].first.first, input[i].first.second);
-      }
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail5 2 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      for(unsigned int i = 0; i < input.size(); ++i) {
-        input[i].first.first = Point(input[i].first.first.get(HORIZONTAL) * -1,
-                                     input[i].first.first.get(VERTICAL) * -1);
-        input[i].first.second = Point(input[i].first.second.get(HORIZONTAL) * -1,
-                                     input[i].first.second.get(VERTICAL) * -1);
-      }
-      edges.clear();
-      validate_scan(edges, input.begin(), input.end());
-      std::cout << edges.size() << std::endl;
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail5 3 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(5, 7), Point(7, 6)), 0));
-      input.push_back(std::make_pair(half_edge(Point(2, 4), Point(6, 7)), 1));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 1 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(3, 2), Point(1, 7)), 0));
-      input.push_back(std::make_pair(half_edge(Point(0, 6), Point(7, 4)), 1));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 2 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(6, 6), Point(1, 0)), 0));
-      input.push_back(std::make_pair(half_edge(Point(3, 6), Point(2, 3)), 1));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 3 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(7, 0)), 0));
-      input.push_back(std::make_pair(half_edge(Point(6, 0), Point(2, 0)), 1));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 4 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(-17333131 - -17208131, -10316869 - -10191869), Point(0, 0)), 0));
-      input.push_back(std::make_pair(half_edge(Point(-17291260 - -17208131, -10200000 - -10191869), Point(-17075000 - -17208131, -10200000 - -10191869)), 1));
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 5 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(-17333131, -10316869), Point(-17208131, -10191869)), 0));
-      input.push_back(std::make_pair(half_edge(Point(-17291260, -10200000), Point(-17075000, -10200000)), 1));
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 6 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(-9850009+9853379, -286971+290340), Point(-12777869+9853379, -3214831+290340)), 0));
-      input.push_back(std::make_pair(half_edge(Point(-5223510+9853379, -290340+290340), Point(-9858140+9853379, -290340+290340)), 1));
-      validate_scan(edges, input.begin(), input.end());
-      print(edges);
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 7 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(-9850009, -286971), Point(-12777869, -3214831)), 0));
-      input.push_back(std::make_pair(half_edge(Point(-5223510, -290340), Point(-9858140, -290340)), 1));
-      validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 8 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      //3 3 2 2: 0; 4 2 0 6: 1; 0 3 6 3: 2; 4 1 5 5: 3; 
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(3, 3), Point(2, 2)), 0));
-      input.push_back(std::make_pair(half_edge(Point(4, 2), Point(0, 6)), 1));
-      input.push_back(std::make_pair(half_edge(Point(0, 3), Point(6, 3)), 2));
-      input.push_back(std::make_pair(half_edge(Point(4, 1), Point(5, 5)), 3));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail4 1 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      //5 7 1 3: 0; 4 5 2 1: 1; 2 5 2 1: 2; 4 1 5 3: 3; 
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(5, 7), Point(1, 3)), 0));
-      input.push_back(std::make_pair(half_edge(Point(4, 5), Point(2, 1)), 1));
-      input.push_back(std::make_pair(half_edge(Point(2, 5), Point(2, 1)), 2));
-      input.push_back(std::make_pair(half_edge(Point(4, 1), Point(5, 3)), 3));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail4 2 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      //1 0 -4 -1: 0; 0 0 2 -1: 1; 
-      input.clear();
-      edges.clear();
-      input.push_back(std::make_pair(half_edge(Point(1, 0), Point(-4, -1)), 0));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(2, -1)), 1));
-            validate_scan(edges, input.begin(), input.end());
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "s fail2 5 " << result.first << " " << result.second << "\n";
-        print(input);
-        print(edges);
-        return false;
-      }
-      Unit min_c =0;
-      Unit max_c =0;
-      for(unsigned int outer = 0; outer < 1000; ++outer) {
-        input.clear();
-        for(unsigned int i = 0; i < 4; ++i) {
-          Unit x1 = rand();
-          Unit x2 = rand();
-          Unit y1 = rand();
-          Unit y2 = rand();
-          int neg1 = rand() % 2;
-          if(neg1) x1 *= -1;
-          int neg2 = rand() % 2;
-          if(neg2) x2 *= -1;
-          int neg3 = rand() % 2;
-          if(neg3) y1 *= -1;
-          int neg4 = rand() % 2;
-          if(neg4) y2 *= -1;
-          if(x1 < min_c) min_c = x1;
-          if(x2 < min_c) min_c = x2;
-          if(y1 < min_c) min_c = y1;
-          if(y2 < min_c) min_c = y2;
-          if(x1 > max_c) max_c = x1;
-          if(x2 > max_c) max_c = x2;
-          if(y1 > max_c) max_c = y1;
-          if(y2 > max_c) max_c = y2;
-          Point pt1(x1, y1);
-          Point pt2(x2, y2);
-          if(pt1 != pt2)
-            input.push_back(std::make_pair(half_edge(pt1, pt2), i));
-        }
-        edges.clear();
-        validate_scan(edges, input.begin(), input.end());
-        if(!verify_scan(result, edges.begin(), edges.end())) {
-          std::cout << "s fail9 " << outer << ": " << result.first << " " << result.second << "\n";
-          print(input);
-          print(edges);
-          return false;
-        }
-      }
-      return true;
-    }
-
-    static void print(const std::pair<half_edge, segment_id>& segment) {
-      std::cout << segment.first.first << " " << segment.first.second << ": " << segment.second << "; ";
-    }
-    static void print(const std::vector<std::pair<half_edge, segment_id> >& vec) {
-      for(unsigned int i = 0; i < vec.size(); ++ i) {
-        print(vec[i]);
-      } std::cout << std::endl;
-    }
-
-    static inline bool test_verify_scan() {
-      std::vector<std::pair<half_edge, segment_id> > edges;
-      edges.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), 0));
-      edges.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 10)), 1));
-      std::pair<segment_id, segment_id> result;
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail1\n";
-        return false;
-      }
-      edges.push_back(std::make_pair(half_edge(Point(0, 5), Point(5, 5)), 2));
-      if(verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail2\n";
-        return false;
-      }
-      edges.pop_back();
-      edges.push_back(std::make_pair(half_edge(Point(1, 0), Point(11, 11)), 3));
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail3\n";
-        return false;
-      }
-      edges.push_back(std::make_pair(half_edge(Point(1, 0), Point(10, 11)), 4));
-      if(verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail4\n";
-        return false;
-      }
-      edges.pop_back();
-      edges.push_back(std::make_pair(half_edge(Point(1, 2), Point(11, 11)), 5));
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail5 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      edges.push_back(std::make_pair(half_edge(Point(0, 5), Point(0, 11)), 6));
-      if(verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail6 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      edges.pop_back();
-      for(unsigned int i = 0; i < edges.size(); ++i) {
-        std::swap(edges[i].first.first, edges[i].first.second);
-      }
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail5 2 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      for(unsigned int i = 0; i < edges.size(); ++i) {
-        edges[i].first.first = Point(edges[i].first.first.get(HORIZONTAL) * -1,
-                                     edges[i].first.first.get(VERTICAL) * -1);
-        edges[i].first.second = Point(edges[i].first.second.get(HORIZONTAL) * -1,
-                                     edges[i].first.second.get(VERTICAL) * -1);
-      }
-      if(!verify_scan(result, edges.begin(), edges.end())) {
-        std::cout << "fail5 3 " << result.first << " " << result.second << "\n";
-        return false;
-      }
-      return true;
-    }
-
-  };
-
-  //scanline consumes the "flattened" fully intersected line segments produced by
-  //a pass of line_intersection along with property and count information and performs a 
-  //useful operation like booleans or property merge or connectivity extraction
-  template <typename Unit, typename property_type, typename keytype = std::set<property_type> >
-  class scanline : public scanline_base<Unit> {
-  public:
-    //definitions
-    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;
-
-    typedef keytype property_set;
-    //this is the data type used internally to store the combination of property counts at a given location
-    typedef std::vector<std::pair<property_type, int> > property_map;
-    //this data structure assocates a property and count to a half edge
-    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
-    //this data type is used internally to store the combined property data for a given half edge
-    typedef std::pair<half_edge, property_map> vertex_data;
-    //this data type stores the combination of many half edges
-    typedef std::vector<vertex_property> property_merge_data;
-    //this data structure stores end points of edges in the scanline
-    typedef std::set<Point, less_point> end_point_queue;
-
-    //this is the output data type that is created by the scanline before it is post processed based on content of property sets
-    typedef std::pair<half_edge, std::pair<property_set, property_set> > half_edge_property;
-      
-    //this is the scanline data structure
-    typedef std::map<half_edge, property_map, less_half_edge> scanline_type;
-    typedef std::pair<half_edge, property_map> scanline_element;
-    typedef typename scanline_type::iterator iterator;
-    typedef typename scanline_type::const_iterator const_iterator;
-
-    //data
-    scanline_type scan_data_;
-    std::vector<iterator> removal_set_; //edges to be removed at the current scanline stop
-    std::vector<scanline_element> insertion_set_; //edge to be inserted after current scanline stop
-    end_point_queue end_point_queue_;
-    Unit x_;
-    Unit y_;
-    int just_before_;
-  public:
-    inline scanline() : scan_data_(), removal_set_(), insertion_set_(), end_point_queue_(), 
-                        x_((std::numeric_limits<Unit>::max)()), y_((std::numeric_limits<Unit>::max)()), just_before_(false) {
-      less_half_edge lessElm(&x_, &just_before_);
-      scan_data_ = scanline_type(lessElm);
-    }
-    inline scanline(const scanline& that) : scan_data_(), removal_set_(), insertion_set_(), end_point_queue_(), 
-                                            x_((std::numeric_limits<Unit>::max)()), y_((std::numeric_limits<Unit>::max)()), just_before_(false) {
-      (*this) = that; }
-    inline scanline& operator=(const scanline& that) {
-      x_ = that.x_;
-      y_ = that.y_;
-      just_before_ = that.just_before_;
-      end_point_queue_ = that.end_point_queue_;
-      //I cannot simply copy that.scanline_type to this scanline_type becuase the functor store pointers to other members!
-      less_half_edge lessElm(&x_, &just_before_);
-      scan_data_ = scanline_type(lessElm);
-
-      scan_data_.insert(that.scan_data_.begin(), that.scan_data_.end());
-      return *this;
-    }
-
-    template <typename result_type, typename result_functor>
-    void write_out(result_type& result, result_functor rf, const half_edge& he,
-                   const property_map& pm_left, const property_map& pm_right) {
-      //std::cout << "write out ";
-      //std::cout << he.first << ", " << he.second << std::endl;
-      property_set ps_left, ps_right;
-      set_unique_property(ps_left, pm_left);
-      set_unique_property(ps_right, pm_right);
-      if(ps_left != ps_right) {
-        //std::cout << "!equivalent\n";
-        rf(result, he, ps_left, ps_right);
-      }
-    }
-
-    template <typename result_type, typename result_functor, typename iT>
-    iT handle_input_events(result_type& result, result_functor rf, iT begin, iT end) {
-      typedef typename high_precision_type<Unit>::type high_precision;
-      //for each event
-      property_map vertical_properties_above;
-      property_map vertical_properties_below;
-      half_edge vertical_edge_above;
-      half_edge vertical_edge_below;
-      std::vector<scanline_element> insertion_elements;
-      //current_iter should increase monotonically toward end as we process scanline stop
-      iterator current_iter = scan_data_.begin();
-      just_before_ = true;
-      high_precision y = (high_precision)((std::numeric_limits<Unit>::min)());
-      bool first_iteration = true;
-      //we want to return from inside the loop when we hit end or new x
-      while(true) {
-        if(begin == end || (!first_iteration && (high_precision)(((*begin).first.first.get(VERTICAL)) != y || 
-                                                                 (*begin).first.first.get(HORIZONTAL) != x_))) {
-          //lookup iterator range in scanline for elements coming in from the left
-          //that end at this y
-          Point pt(x_, (Unit)y);
-          //grab the properties coming in from below
-          property_map properties_below;
-          if(current_iter != scan_data_.end()) {
-            //make sure we are looking at element in scanline just below y
-            if(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) != y) {
-              Point e2(pt);
-              if(e2.get(VERTICAL) != (std::numeric_limits<Unit>::max)())
-                e2.set(VERTICAL, e2.get(VERTICAL) + 1);
-              else
-                e2.set(VERTICAL, e2.get(VERTICAL) - 1);
-              half_edge vhe(pt, e2);
-              current_iter = scan_data_.lower_bound(vhe);
-            }
-            if(current_iter != scan_data_.end()) {
-              //get the bottom iterator for elements at this point
-              while(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) >= y && 
-                    current_iter != scan_data_.begin()) {
-                --current_iter;
-              }
-              if(evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) >= y) {
-                properties_below.clear();
-              } else {
-                properties_below = (*current_iter).second;
-                //move back up to y or one past y
-                ++current_iter;
-              }
-            }
-          }
-          std::vector<iterator> edges_from_left;
-          while(current_iter != scan_data_.end() &&
-                evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) == y) {
-            //removal_set_.push_back(current_iter);
-            ++current_iter;
-          }
-          //merge vertical count with count from below
-          if(!vertical_properties_below.empty()) {
-            merge_property_maps(vertical_properties_below, properties_below);
-            //write out vertical edge
-            write_out(result, rf, vertical_edge_below, properties_below, vertical_properties_below);
-          } else {
-            merge_property_maps(vertical_properties_below, properties_below);
-          }
-          //iteratively add intertion element counts to count from below
-          //and write them to insertion set
-          for(unsigned int i = 0; i < insertion_elements.size(); ++i) {
-            if(i == 0) {
-              merge_property_maps(insertion_elements[i].second, vertical_properties_below);
-              write_out(result, rf, insertion_elements[i].first, insertion_elements[i].second, vertical_properties_below);
-            } else {
-              merge_property_maps(insertion_elements[i].second, insertion_elements[i-1].second);
-              write_out(result, rf, insertion_elements[i].first, insertion_elements[i].second, insertion_elements[i-1].second);
-            }
-            insertion_set_.push_back(insertion_elements[i]);
-          }
-          if((begin == end || (*begin).first.first.get(HORIZONTAL) != x_)) {
-            if(vertical_properties_above.empty()) {
-              return begin;
-            } else {
-              y = (high_precision)(vertical_edge_above.second.get(VERTICAL));
-              vertical_properties_below.clear();
-              vertical_properties_above.swap(vertical_properties_below);
-              vertical_edge_below = vertical_edge_above;
-              insertion_elements.clear();
-              continue;
-            }
-          }
-          vertical_properties_below.clear();
-          vertical_properties_above.swap(vertical_properties_below);
-          vertical_edge_below = vertical_edge_above;
-          insertion_elements.clear();
-        }
-        if(begin != end) {
-          const vertex_property& vp = *begin;
-          const half_edge& he = vp.first;
-          y = (high_precision)(he.first.get(VERTICAL));
-          first_iteration = false;
-          if(! vertical_properties_below.empty() &&
-             vertical_edge_below.second.get(VERTICAL) < y) {
-            y = (high_precision)(vertical_edge_below.second.get(VERTICAL));
-            continue;
-          }
-          if(is_vertical(he)) {
-            update_property_map(vertical_properties_above, vp.second);
-            vertical_edge_above = he;
-          } else {
-            if(insertion_elements.empty() ||
-               insertion_elements.back().first != he) {
-              insertion_elements.push_back(scanline_element(he, property_map()));
-            }
-            update_property_map(insertion_elements.back().second, vp.second);
-          }
-          ++begin;
-        }
-      }
-    }
-
-    inline void erase_end_events(typename end_point_queue::iterator epqi) {
-      end_point_queue_.erase(end_point_queue_.begin(), epqi);
-      for(typename std::vector<iterator>::iterator retire_itr = removal_set_.begin();
-          retire_itr != removal_set_.end(); ++retire_itr) {
-        scan_data_.erase(*retire_itr);
-      }
-      removal_set_.clear();
-    }
-
-
-    inline void remove_retired_edges_from_scanline() {
-      just_before_ = true;
-      typename end_point_queue::iterator epqi = end_point_queue_.begin();
-      Unit current_x = x_;
-      Unit previous_x = x_;
-      while(epqi != end_point_queue_.end() &&
-            (*epqi).get(HORIZONTAL) <= current_x) {
-        x_ = (*epqi).get(HORIZONTAL);
-        if(x_ != previous_x) erase_end_events(epqi);
-        previous_x = x_;
-        //lookup elements
-        Point e2(*epqi);
-        if(e2.get(VERTICAL) != (std::numeric_limits<Unit>::max)())
-          e2.set(VERTICAL, e2.get(VERTICAL) + 1);
-        else
-          e2.set(VERTICAL, e2.get(VERTICAL) - 1);
-        half_edge vhe_e(*epqi, e2);
-        iterator current_iter = scan_data_.lower_bound(vhe_e);
-        while(current_iter != scan_data_.end() && (*current_iter).first.second == (*epqi)) {
-          //evalAtXforY(x_, (*current_iter).first.first, (*current_iter).first.second) == (*epqi).get(VERTICAL)) {
-          removal_set_.push_back(current_iter);
-          ++current_iter;
-        }
-        ++epqi;
-      }
-      x_ = current_x;
-      erase_end_events(epqi);
-    }
-
-    inline void insert_new_edges_into_scanline() {
-      just_before_ = false;
-      for(typename std::vector<scanline_element>::iterator insert_itr = insertion_set_.begin();
-          insert_itr != insertion_set_.end(); ++insert_itr) {
-        scan_data_.insert(*insert_itr);
-        end_point_queue_.insert((*insert_itr).first.second);
-      }
-      insertion_set_.clear();
-    }
-
-    //iterator over range of vertex property elements and call result functor
-    //passing edge to be output, the merged data on both sides and the result
-    template <typename result_type, typename result_functor, typename iT>
-    void scan(result_type& result, result_functor rf, iT begin, iT end) {
-      while(begin != end) {
-        x_ = (*begin).first.first.get(HORIZONTAL); //update scanline stop location
-        //print_scanline();
-        --x_;
-        remove_retired_edges_from_scanline();
-        ++x_;
-        begin = handle_input_events(result, rf, begin, end);
-        remove_retired_edges_from_scanline();
-        //print_scanline();
-        insert_new_edges_into_scanline();
-      }
-      //print_scanline();
-      x_ = (std::numeric_limits<Unit>::max)();
-      remove_retired_edges_from_scanline();
-    }
-
-    inline void print_scanline() {
-      std::cout << "scanline at " << x_ << ": ";
-      for(iterator itr = scan_data_.begin(); itr != scan_data_.end(); ++itr) {
-        const scanline_element& se = *itr;
-        const half_edge& he = se.first;
-        const property_map& mp = se.second;
-        std::cout << he.first << ", " << he.second << " ( ";
-        for(unsigned int i = 0; i < mp.size(); ++i) {
-          std::cout << mp[i].first << ":" << mp[i].second << " ";
-        } std::cout << ") ";
-      } std::cout << std::endl;
-    }
-
-    static inline void merge_property_maps(property_map& mp, const property_map& mp2) {
-      property_map newmp;
-      newmp.reserve(mp.size() + mp2.size());
-      unsigned int i = 0;
-      unsigned int j = 0;
-      while(i != mp.size() && j != mp2.size()) {
-        if(mp[i].first < mp2[j].first) {
-          newmp.push_back(mp[i]);
-          ++i;
-        } else if(mp[i].first > mp2[j].first) {
-          newmp.push_back(mp2[j]);
-          ++j;
-        } else {
-          int count = mp[i].second;
-          count += mp2[j].second; 
-          if(count) {
-            newmp.push_back(mp[i]);
-            newmp.back().second = count;
-          }
-          ++i;
-          ++j;
-        }
-      }
-      while(i != mp.size()) {
-        newmp.push_back(mp[i]);
-        ++i;
-      }
-      while(j != mp2.size()) {
-        newmp.push_back(mp2[j]);
-        ++j;
-      }
-      mp.swap(newmp);
-    }
-
-    static inline void update_property_map(property_map& mp, const std::pair<property_type, int>& prop_data) {
-      property_map newmp;
-      newmp.reserve(mp.size() +1);
-      bool consumed = false;
-      for(unsigned int i = 0; i < mp.size(); ++i) {
-        if(!consumed && prop_data.first == mp[i].first) {
-          consumed = true;
-          int count = prop_data.second + mp[i].second;
-          if(count)
-            newmp.push_back(std::make_pair(prop_data.first, count));
-        } else if(!consumed && prop_data.first < mp[i].first) {
-          consumed = true;
-          newmp.push_back(prop_data);
-          newmp.push_back(mp[i]);
-        } else {
-          newmp.push_back(mp[i]);
-        }
-      }
-      if(!consumed) newmp.push_back(prop_data);
-      mp.swap(newmp);
-    }
-
-    static inline void set_unique_property(property_set& unqiue_property, const property_map& property) {
-      unqiue_property.clear();
-      for(typename property_map::const_iterator itr = property.begin(); itr != property.end(); ++itr) {
-        if((*itr).second > 0)
-          unqiue_property.insert(unqiue_property.end(), (*itr).first);
-      }
-    }
-
-    static inline bool common_vertex(const half_edge& he1, const half_edge& he2) {
-      return he1.first == he2.first ||
-        he1.first == he2.second ||
-        he1.second == he2.first ||
-        he1.second == he2.second;
-    }
-
-    typedef typename scanline_base<Unit>::vertex_half_edge vertex_half_edge;
-    template <typename iT>
-    static inline void convert_segments_to_vertex_half_edges(std::vector<vertex_half_edge>& output, iT begin, iT end) {
-      for( ; begin != end; ++begin) {
-        const half_edge& he = (*begin).first;
-        int count = (*begin).second;
-        output.push_back(vertex_half_edge(he.first, he.second, count));
-        output.push_back(vertex_half_edge(he.second, he.first, -count));
-      }
-      std::sort(output.begin(), output.end());
-    }
-
-    class test_functor {
-    public:
-      inline test_functor() {}
-      inline void operator()(std::vector<std::pair<half_edge, std::pair<property_set, property_set> > >& result,
-                             const half_edge& he, const property_set& ps_left, const property_set& ps_right) {
-        result.push_back(std::make_pair(he, std::make_pair(ps_left, ps_right)));
-      }
-    };
-    static inline bool test_scanline() {
-      std::vector<std::pair<half_edge, std::pair<property_set, property_set> > > result;
-      std::vector<std::pair<half_edge, std::pair<property_type, int> > > input;
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
-      scanline sl;
-      test_functor tf;
-      sl.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(0, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(11, 11)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, 1)));
-      scanline sl2;
-      sl2.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(8, 2)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(2, 8)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(2, 8), Point(9, 9)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(8, 2), Point(9, 9)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
-      scanline sl3;
-      sl3.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(8, 2)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 1), Point(2, 8)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(2, 8), Point(9, 9)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(8, 2), Point(9, 9)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
-      scanline sl4;
-      sl4.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
-      scanline sl5;
-      sl5.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(10, 10)), std::make_pair(0, -1)));
-      scanline sl6;
-      sl6.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(10, 0)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(9, 1)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(1, 9)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 0), Point(0, 10)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(10, 10)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(10, 20)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(9, 21)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(1, 29)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 20), Point(0, 30)), std::make_pair(0, 1)));
-      input.push_back(std::make_pair(half_edge(Point(0, 30), Point(10, 30)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 9), Point(10, 10)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(1, 29), Point(10, 30)), std::make_pair(1, -1)));
-      input.push_back(std::make_pair(half_edge(Point(9, 1), Point(10, 10)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(9, 21), Point(10, 30)), std::make_pair(1, 1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 20), Point(10, 30)), std::make_pair(0, -1)));
-      input.push_back(std::make_pair(half_edge(Point(10, 20), Point(10, 30)), std::make_pair(0, -1)));
-      scanline sl7;
-      sl7.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      input.clear();
-      result.clear();
-      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(10, 0)), std::make_pair(0, 1))); //a
-      input.push_back(std::make_pair(half_edge(Point(-1, -1), Point(0, 10)), std::make_pair(0, -1))); //a
-      input.push_back(std::make_pair(half_edge(Point(0, 10), Point(11, 11)), std::make_pair(0, -1))); //a
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(20, 0)), std::make_pair(0, 1))); //b
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, -1))); //b
-      input.push_back(std::make_pair(half_edge(Point(10, 0), Point(11, 11)), std::make_pair(0, 1))); //a
-      input.push_back(std::make_pair(half_edge(Point(11, 11), Point(20, 10)), std::make_pair(0, -1))); //b
-      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(30, 0)), std::make_pair(0, 1))); //c
-      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(20, 10)), std::make_pair(0, -1))); //b
-      input.push_back(std::make_pair(half_edge(Point(20, 0), Point(20, 10)), std::make_pair(0, 1))); //c
-      input.push_back(std::make_pair(half_edge(Point(20, 10), Point(30, 10)), std::make_pair(0, -1))); //c
-      input.push_back(std::make_pair(half_edge(Point(30, 0), Point(30, 10)), std::make_pair(0, -1))); //c
-      scanline sl8;
-      sl8.scan(result, tf, input.begin(), input.end());
-      std::cout << "scanned\n";
-      for(unsigned int i = 0; i < result.size(); ++i) {
-        std::cout << result[i].first.first << ", " << result[i].first.second << "; ";
-      } std::cout << std::endl;
-      return true;
-    }
-
-  };
-
-  template <typename Unit>
-  class merge_output_functor {
-  public:
-    typedef typename scanline_base<Unit>::half_edge half_edge;
-    merge_output_functor() {}
-    template <typename result_type, typename key_type>
-    void operator()(result_type& result, const half_edge& edge, const key_type& left, const key_type& right) {
-      typename std::pair<half_edge, int> elem;
-      elem.first = edge;
-      elem.second = 1;
-      if(edge.second < edge.first) elem.second *= -1;
-      if(scanline_base<Unit>::is_vertical(edge)) elem.second *= -1;
-      if(!left.empty())
-        result[left].insert_clean(elem);
-      elem.second *= -1;
-      if(!right.empty())
-        result[right].insert_clean(elem);
-    }
-  };
-
-  template <typename Unit, typename property_type, typename key_type = std::set<property_type>, 
-            typename output_functor_type = merge_output_functor<Unit> >
-  class property_merge : public scanline_base<Unit> {
-  protected:
-    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;
-
-    //this data structure assocates a property and count to a half edge
-    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
-    //this data type stores the combination of many half edges
-    typedef std::vector<vertex_property> property_merge_data;
-
-    //this is the data type used internally to store the combination of property counts at a given location
-    typedef std::vector<std::pair<property_type, int> > property_map;
-    //this data type is used internally to store the combined property data for a given half edge
-    typedef std::pair<half_edge, property_map> vertex_data;
-
-    property_merge_data pmd;
-
-    template<typename vertex_data_type>
-    class less_vertex_data {
-    public:
-      less_vertex_data() {}
-      bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
-        less_point lp;
-        if(lp(lvalue.first.first, rvalue.first.first)) return true;
-        if(lp(rvalue.first.first, lvalue.first.first)) return false;
-        Unit x = lvalue.first.first.get(HORIZONTAL);
-        int just_before_ = 0;
-        less_half_edge lhe(&x, &just_before_);
-        return lhe(lvalue.first, rvalue.first);
-      }
-    };
-
-
-    inline void sort_property_merge_data() {
-      less_vertex_data<vertex_property> lvd;
-      std::sort(pmd.begin(), pmd.end(), lvd);
-    }
-  public:
-    inline property_merge_data& get_property_merge_data() { return pmd; }
-    inline property_merge() : pmd() {}
-    inline property_merge(const property_merge& pm) : pmd(pm.pmd) {}
-    inline property_merge& operator=(const property_merge& pm) { pmd = pm.pmd; return *this; }
-
-    template <typename polygon_type>
-    void insert(const polygon_type& polygon_object, const property_type& property_value, bool is_hole = false) {
-      insert(polygon_object, property_value, is_hole, typename geometry_concept<polygon_type>::type());
-    }
-
-    //result type should be std::map<std::set<property_type>, polygon_set_type>
-    //or std::map<std::vector<property_type>, polygon_set_type>
-    template <typename result_type>
-    void merge(result_type& result) {
-      //intersect data
-      property_merge_data tmp_pmd;
-      line_intersection<Unit>::validate_scan(tmp_pmd, pmd.begin(), pmd.end());
-      pmd.swap(tmp_pmd);
-      sort_property_merge_data();
-      scanline<Unit, property_type, key_type> sl;
-      output_functor_type mof;
-      sl.scan(result, mof, pmd.begin(), pmd.end());
-    }
-
-    inline bool verify() {
-      std::pair<int, int> offenders;
-      std::vector<std::pair<half_edge, int> > lines;
-      int count = 0;
-      for(unsigned int i = 0; i < pmd.size(); ++i) {
-        lines.push_back(std::make_pair(pmd[i].first, count++));
-      }
-      if(!line_intersection<Unit>::verify_scan(offenders, lines.begin(), lines.end())) {
-        std::cout << "Intersection failed!\n";
-        std::cout << offenders.first << " " << offenders.second << std::endl;
-        return false;
-      }
-      std::vector<Point> pts;
-      for(unsigned int i = 0; i < lines.size(); ++i) {
-        pts.push_back(lines[i].first.first);
-        pts.push_back(lines[i].first.second);
-      }
-      std::sort(pts.begin(), pts.end());
-      for(unsigned int i = 0; i < pts.size(); i+=2) {
-        if(pts[i] != pts[i+1]) {
-          std::cout << "Non-closed figures after line intersection!\n";
-          return false;
-        }
-      }
-      return true;
-    }
-
-    void clear() {*this = property_merge();}
-
-  protected:
-    template <typename polygon_type>
-    void insert(const polygon_type& polygon_object, const property_type& property_value, bool is_hole, 
-                polygon_concept tag) {
-      bool first_iteration = true;
-      bool second_iteration = true;
-      Point first_point;
-      Point second_point;
-      Point previous_previous_point;
-      Point previous_point;
-      Point current_point;
-      direction_1d winding_dir = winding(polygon_object);
-      for(typename polygon_traits<polygon_type>::iterator_type itr = begin_points(polygon_object);
-          itr != end_points(polygon_object); ++itr) {
-        assign(current_point, *itr);
-        if(first_iteration) {
-          first_iteration = false;
-          first_point = previous_point = current_point;
-        } else if(second_iteration) {
-          if(previous_point != current_point) {
-            second_iteration = false;
-            previous_previous_point = previous_point;
-            second_point = previous_point = current_point;
-          }
-        } else {
-          if(previous_point != current_point) {
-            create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
-                          is_hole, property_value);
-            previous_previous_point = previous_point;
-            previous_point = current_point;
-          }
-        }
-      }
-      current_point = first_point;
-      if(!first_iteration && !second_iteration) {
-        if(previous_point != current_point) {
-          create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
-                        is_hole, property_value);
-          previous_previous_point = previous_point;
-          previous_point = current_point;
-        }
-        current_point = second_point;
-        create_vertex(pmd, previous_previous_point, previous_point, current_point, winding_dir,
-                      is_hole, property_value);
-        previous_previous_point = previous_point;
-        previous_point = current_point;
-      }
-    }
-
-    template <typename polygon_with_holes_type>
-    void insert(const polygon_with_holes_type& polygon_with_holes_object, const property_type& property_value, bool is_hole, 
-                polygon_with_holes_concept tag) {
-      insert(polygon_with_holes_object, property_value, is_hole, polygon_concept());
-      for(typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itr = 
-            begin_holes(polygon_with_holes_object);
-          itr != end_holes(polygon_with_holes_object); ++itr) {
-        insert(*itr, property_value, !is_hole, polygon_concept());
-      }
-    }
-
-    template <typename rectangle_type>
-    void insert(const rectangle_type& rectangle_object, const property_type& property_value, bool is_hole, 
-                rectangle_concept tag) {
-      polygon_90_data<Unit> poly;
-      assign(poly, rectangle_object);
-      insert(poly, property_value, is_hole, polygon_concept());
-    }
-
-  public: //change to private when done testing
-
-    static inline void create_vertex(property_merge_data& pmd, 
-                                     const Point& previous_point, 
-                                     const Point& current_point, 
-                                     const Point& next_point, 
-                                     direction_1d winding,
-                                     bool is_hole, const property_type& property) {
-      if(current_point == next_point) return;
-      vertex_property current_vertex;
-      current_vertex.first.first = current_point;
-      current_vertex.first.second = next_point;
-      current_vertex.second.first = property;
-      int multiplier = 1;
-      if(winding == CLOCKWISE) 
-        multiplier = -1;
-      if(is_hole)
-        multiplier *= -1;
-      if(current_point < next_point) {
-        multiplier *= -1;
-        std::swap(current_vertex.first.first, current_vertex.first.second);
-      }
-      current_vertex.second.second = multiplier * (euclidean_distance(next_point, current_point, HORIZONTAL) == 0 ? -1: 1);
-      pmd.push_back(current_vertex);
-      //current_vertex.first.second = previous_point;
-      //current_vertex.second.second *= -1;
-      //pmd.push_back(current_vertex);
-    }
-
-    static inline void sort_vertex_half_edges(vertex_data& vertex) {
-      less_half_edge_pair lessF(vertex.first);
-      std::sort(vertex.second.begin(), vertex.second.end(), lessF);
-    }
-
-    class less_half_edge_pair {
-    private:
-      Point pt_;
-    public:
-      less_half_edge_pair(const Point& pt) : pt_(pt) {}
-      bool operator()(const half_edge& e1, const half_edge& e2) {
-        const Point& pt1 = e1.first;
-        const Point& pt2 = e2.first;
-        if(get(pt1, HORIZONTAL) == 
-           get(pt_, HORIZONTAL)) {
-          //vertical edge is always largest
-          return false;
-        }
-        if(get(pt2, HORIZONTAL) == 
-           get(pt_, HORIZONTAL)) {
-          //if half edge 1 is not vertical its slope is less than that of half edge 2
-          return get(pt1, HORIZONTAL) != get(pt2, HORIZONTAL);
-        }
-        return less_slope(get(pt_, HORIZONTAL),
-                          get(pt_, VERTICAL), pt1, pt2);
-      }
-    };
-
-  public:
-    //test functions
-    static std::ostream& print (std::ostream& o, const property_map& c)
-    {
-      o << "count: {";
-      for(typename property_map::const_iterator itr = c.begin(); itr != c.end(); ++itr) {
-        o << ((*itr).first) << ":" << ((*itr).second) << " ";
-      }
-      return o << "} ";
-    }
-
-
-    static std::ostream& print (std::ostream& o, const half_edge& he)
-    {
-      o << "half edge: (";
-      o << (he.first);
-      return o << ", " << (he.second) << ") ";
-    }
-
-    static std::ostream& print (std::ostream& o, const vertex_property& c)
-    {
-      o << "vertex property: {";
-      print(o, c.first);
-      o << ", " << c.second.first << ":" << c.second.second << " ";
-      return o;
-    }
-
-    static std::ostream& print (std::ostream& o, const std::vector<vertex_property>& hev)
-    {
-      o << "vertex properties: {";
-      for(unsigned int i = 0; i < hev.size(); ++i) {
-        print(o, (hev[i])) << " ";
-      }
-      return o << "} ";
-    }
-
-    static std::ostream& print (std::ostream& o, const std::vector<half_edge>& hev)
-    {
-      o << "half edges: {";
-      for(unsigned int i = 0; i < hev.size(); ++i) {
-        print(o, (hev[i])) << " ";
-      }
-      return o << "} ";
-    }
-
-    static std::ostream& print (std::ostream& o, const vertex_data& v)
-    {
-      return print(o << "vertex: <" << (v.first) << ", ", (v.second)) << "> ";
-    }
-
-    static std::ostream& print (std::ostream& o, const std::vector<vertex_data>& vv)
-    {
-      o << "vertices: {";
-      for(unsigned int i = 0; i < vv.size(); ++i) {
-        print(o, (vv[i])) << " ";
-      }
-      return o << "} ";
-    }
-
-
-
-    static inline bool test_insertion() {
-      property_merge si;
-      rectangle_data<Unit> rect;
-      xl(rect, 0);
-      yl(rect, 1);
-      xh(rect, 10);
-      yh(rect, 11);
-
-      si.insert(rect, 333);
-      print(std::cout, si.pmd) << std::endl;
-      
-      Point pts[4] = {Point(0, 0), Point(10,-3), Point(13, 8), Point(0, 0) };
-      polygon_data<Unit> poly;
-      property_merge si2;
-      poly.set(pts, pts+3);
-      si2.insert(poly, 444);
-      si2.sort_property_merge_data();
-      print(std::cout, si2.pmd) << std::endl;
-      property_merge si3;
-      poly.set(pts, pts+4);
-      si3.insert(poly, 444);
-      si3.sort_property_merge_data();
-      std::cout << (si2.pmd == si3.pmd) << std::endl;
-      std::reverse(pts, pts+4);
-      property_merge si4;
-      poly.set(pts, pts+4);
-      si4.insert(poly, 444);
-      si4.sort_property_merge_data();
-      print(std::cout, si4.pmd) << std::endl;
-      std::cout << (si2.pmd == si4.pmd) << std::endl;
-      std::reverse(pts, pts+3);
-      property_merge si5;
-      poly.set(pts, pts+4);
-      si5.insert(poly, 444);
-      si5.sort_property_merge_data();
-      std::cout << (si2.pmd == si5.pmd) << std::endl;
-      
-      return true;
-    }
-
-    static inline bool test_merge() {
-      property_merge si;
-      rectangle_data<Unit> rect;
-      xl(rect, 0);
-      yl(rect, 1);
-      xh(rect, 10);
-      yh(rect, 11);
-
-      si.insert(rect, 333);
-      std::map<std::set<property_type>, polygon_set_data<Unit> > result;
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      polygon_set_data<Unit> psd = (*(result.begin())).second;
-      std::vector<polygon_data<Unit> > polys;
-      psd.get(polys);
-      if(polys.size() != 1) {
-        std::cout << "fail merge 1\n";
-        return false;
-      }
-      std::cout << (polys[0]) << std::endl;
-      si.clear();
-      std::vector<Point> pts;
-      pts.push_back(Point(0, 0));
-      pts.push_back(Point(10, -10));
-      pts.push_back(Point(10, 10));
-      polygon_data<Unit> poly;
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(5, 0));
-      pts.push_back(Point(-5, -10));
-      pts.push_back(Point(-5, 10));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      psd = (*(result.begin())).second;
-      std::cout << psd << std::endl;
-      polys.clear();
-      psd.get(polys);
-      if(polys.size() != 1) {
-        std::cout << "fail merge 2\n";
-        return false;
-      }
-      //Polygon { -4 -1, 3 3, -2 3 } 
-      //Polygon { 0 -4, -4 -2, -2 1 } 
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(-4, -1));
-      pts.push_back(Point(3, 3));
-      pts.push_back(Point(-2, 3));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(0, -4));
-      pts.push_back(Point(-4, -2));
-      pts.push_back(Point(-2, 1));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      psd = (*(result.begin())).second;
-      std::cout << psd << std::endl;
-      polys.clear();
-      psd.get(polys);
-      if(polys.size() != 1) {
-        std::cout << "fail merge 3\n";
-        return false;
-      }
-      std::cout << "Polygon { -2 2, -2 2, 1 4 } \n";
-      std::cout << "Polygon { 2 4, 2 -4, -3 1 } \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(-2, 2));
-      pts.push_back(Point(-2, 2));
-      pts.push_back(Point(1, 4));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(2, 4));
-      pts.push_back(Point(2, -4));
-      pts.push_back(Point(-3, 1));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      psd = (*(result.begin())).second;
-      std::cout << psd << std::endl;
-      polys.clear();
-      psd.get(polys);
-      if(polys.size() != 1) {
-        std::cout << "fail merge 4\n";
-        return false;
-      }
-      std::cout << (polys[0]) << std::endl;
-      std::cout << "Polygon { -4 0, -2 -3, 3 -4 } \n";
-      std::cout << "Polygon { -1 1, 1 -2, -4 -3 } \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(-4, 0));
-      pts.push_back(Point(-2, -3));
-      pts.push_back(Point(3, -4));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(-1, 1));
-      pts.push_back(Point(1, -2));
-      pts.push_back(Point(-4, -3));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      psd = (*(result.begin())).second;
-      std::cout << psd << std::endl;
-      polys.clear();
-      psd.get(polys);
-      if(polys.size() != 1) {
-        std::cout << "fail merge 5\n";
-        return false;
-      }
-      std::cout << "Polygon { 2 2, -2 0, 0 1 }  \n";
-      std::cout << "Polygon { 4 -2, 3 -1, 2 3 }  \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(2, 2));
-      pts.push_back(Point(-2, 0));
-      pts.push_back(Point(0, 1));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(4, -2));
-      pts.push_back(Point(3, -1));
-      pts.push_back(Point(2, 3));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      if(!result.empty()) {
-        psd = (*(result.begin())).second;
-        std::cout << psd << std::endl;
-        polys.clear();
-        psd.get(polys);
-        if(polys.size() != 1) {
-          std::cout << "fail merge 6\n";
-          return false;
-        }
-        std::cout << (polys[0]) << std::endl;
-      }
-      std::cout << "Polygon { 0 2, 3 -1, 4 1 }  \n";
-      std::cout << "Polygon { -4 3, 3 3, 4 2 }  \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(0, 2));
-      pts.push_back(Point(3, -1));
-      pts.push_back(Point(4, 1));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(-4, 3));
-      pts.push_back(Point(3, 3));
-      pts.push_back(Point(4, 2));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      if(!result.empty()) {
-        psd = (*(result.begin())).second;
-        std::cout << psd << std::endl;
-        polys.clear();
-        psd.get(polys);
-        if(polys.size() == 0) {
-          std::cout << "fail merge 7\n";
-          return false;
-        }
-        std::cout << (polys[0]) << std::endl;
-      }
-std::cout << "Polygon { 1 -2, -1 4, 3 -2 }   \n";
-std::cout << "Polygon { 0 -3, 3 1, -3 -4 }   \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(1, -2));
-      pts.push_back(Point(-1, 4));
-      pts.push_back(Point(3, -2));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(0, -3));
-      pts.push_back(Point(3, 1));
-      pts.push_back(Point(-3, -4));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      if(!result.empty()) {
-        psd = (*(result.begin())).second;
-        std::cout << psd << std::endl;
-        polys.clear();
-        psd.get(polys);
-        if(polys.size() == 0) {
-          std::cout << "fail merge 8\n";
-          return false;
-        }
-        std::cout << (polys[0]) << std::endl;
-      }
-std::cout << "Polygon { 2 2, 3 0, -3 4 }  \n";
-std::cout << "Polygon { -2 -2, 0 0, -1 -1 }  \n";
-      si.clear();
-      pts.clear();
-      pts.push_back(Point(2, 2));
-      pts.push_back(Point(3, 0));
-      pts.push_back(Point(-3, 4));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      pts.clear();
-      pts.push_back(Point(-2, -2));
-      pts.push_back(Point(0, 0));
-      pts.push_back(Point(-1, -1));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      if(!result.empty()) {
-        psd = (*(result.begin())).second;
-        std::cout << psd << std::endl;
-        polys.clear();
-        psd.get(polys);
-        if(polys.size() == 0) {
-          std::cout << "fail merge 9\n";
-          return false;
-        }
-        std::cout << (polys[0]) << std::endl;
-      }
-      si.clear();
-      pts.clear();
-      //5624841,17616200,75000,9125000
-      //pts.push_back(Point(5624841,75000));
-      //pts.push_back(Point(5624841,9125000));
-      //pts.push_back(Point(17616200,9125000));
-      //pts.push_back(Point(17616200,75000));
-pts.push_back(Point(12262940, 6652520 )); pts.push_back(Point(12125750, 6652520 )); pts.push_back(Point(12121272, 6652961 )); pts.push_back(Point(12112981, 6656396 )); pts.push_back(Point(12106636, 6662741 )); pts.push_back(Point(12103201, 6671032 )); pts.push_back(Point(12103201, 6680007 )); pts.push_back(Point(12106636, 6688298 )); 
-pts.push_back(Point(12109500, 6691780 )); pts.push_back(Point(12748600, 7330890 )); pts.push_back(Point(15762600, 7330890 )); pts.push_back(Point(15904620, 7472900 )); pts.push_back(Point(15909200, 7473030 )); pts.push_back(Point(15935830, 7476006 )); pts.push_back(Point(15992796, 7499602 )); pts.push_back(Point(16036397, 7543203 )); 
-pts.push_back(Point(16059993, 7600169 )); pts.push_back(Point(16059993, 7661830 )); pts.push_back(Point(16036397, 7718796 )); pts.push_back(Point(15992796, 7762397 )); pts.push_back(Point(15935830, 7785993 )); pts.push_back(Point(15874169, 7785993 )); pts.push_back(Point(15817203, 7762397 )); pts.push_back(Point(15773602, 7718796 )); 
-pts.push_back(Point(15750006, 7661830 )); pts.push_back(Point(15747030, 7635200 )); pts.push_back(Point(15746900, 7630620 )); pts.push_back(Point(15670220, 7553930 )); pts.push_back(Point(14872950, 7553930 )); pts.push_back(Point(14872950, 7626170 )); 
-pts.push_back(Point(14869973, 7661280 )); pts.push_back(Point(14846377, 7718246 )); pts.push_back(Point(14802776, 7761847 )); pts.push_back(Point(14745810, 7785443 )); pts.push_back(Point(14684149, 7785443 )); pts.push_back(Point(14627183, 7761847 )); pts.push_back(Point(14583582, 7718246 )); 
-pts.push_back(Point(14559986, 7661280 )); pts.push_back(Point(14557070, 7636660 )); pts.push_back(Point(14556670, 7625570 )); pts.push_back(Point(13703330, 7625570 )); pts.push_back(Point(13702930, 7636660 )); pts.push_back(Point(13699993, 7661830 )); pts.push_back(Point(13676397, 7718796 )); 
-pts.push_back(Point(13632796, 7762397 )); pts.push_back(Point(13575830, 7785993 )); pts.push_back(Point(13514169, 7785993 )); pts.push_back(Point(13457203, 7762397 )); pts.push_back(Point(13436270, 7745670 )); pts.push_back(Point(13432940, 7742520 )); pts.push_back(Point(12963760, 7742520 )); 
-pts.push_back(Point(12959272, 7742961 )); pts.push_back(Point(12950981, 7746396 )); pts.push_back(Point(12944636, 7752741 )); pts.push_back(Point(12941201, 7761032 )); pts.push_back(Point(12941201, 7770007 )); pts.push_back(Point(12944636, 7778298 )); pts.push_back(Point(12947490, 7781780 )); 
-pts.push_back(Point(13425330, 8259620 )); pts.push_back(Point(15601330, 8259620 )); pts.push_back(Point(15904620, 8562900 )); pts.push_back(Point(15909200, 8563030 )); pts.push_back(Point(15935830, 8566006 )); pts.push_back(Point(15992796, 8589602 )); pts.push_back(Point(16036397, 8633203 )); 
-pts.push_back(Point(16059993, 8690169 )); pts.push_back(Point(16059993, 8751830 )); pts.push_back(Point(16036397, 8808796 )); pts.push_back(Point(15992796, 8852397 )); pts.push_back(Point(15935830, 8875993 )); pts.push_back(Point(15874169, 8875993 )); pts.push_back(Point(15817203, 8852397 )); pts.push_back(Point(15773602, 8808796 )); 
-pts.push_back(Point(15750006, 8751830 )); pts.push_back(Point(15747030, 8725200 )); pts.push_back(Point(15746900, 8720620 )); pts.push_back(Point(15508950, 8482660 )); pts.push_back(Point(14689890, 8482660 )); pts.push_back(Point(14685412, 8483101 )); pts.push_back(Point(14677121, 8486536 )); 
-pts.push_back(Point(14670776, 8492881 )); pts.push_back(Point(14667341, 8501172 )); pts.push_back(Point(14667341, 8510147 )); pts.push_back(Point(14670776, 8518438 )); pts.push_back(Point(14673630, 8521920 )); pts.push_back(Point(14714620, 8562900 )); pts.push_back(Point(14719200, 8563030 )); pts.push_back(Point(14745830, 8566006 )); 
-pts.push_back(Point(14802796, 8589602 )); pts.push_back(Point(14846397, 8633203 )); pts.push_back(Point(14869993, 8690169 )); pts.push_back(Point(14869993, 8751830 )); pts.push_back(Point(14846397, 8808796 )); pts.push_back(Point(14802796, 8852397 )); pts.push_back(Point(14745830, 8875993 )); pts.push_back(Point(14684169, 8875993 )); 
-pts.push_back(Point(14627203, 8852397 )); pts.push_back(Point(14583602, 8808796 )); pts.push_back(Point(14560006, 8751830 )); pts.push_back(Point(14557030, 8725200 )); pts.push_back(Point(14556900, 8720620 )); pts.push_back(Point(14408270, 8571980 )); pts.push_back(Point(13696320, 8571980 )); pts.push_back(Point(13696320, 8675520 )); 
-pts.push_back(Point(13699963, 8690161 )); pts.push_back(Point(13699963, 8751818 )); pts.push_back(Point(13676368, 8808781 )); pts.push_back(Point(13632771, 8852378 )); pts.push_back(Point(13575808, 8875973 )); pts.push_back(Point(13514151, 8875973 )); pts.push_back(Point(13457188, 8852378 )); pts.push_back(Point(13436270, 8835670 )); pts.push_back(Point(13432940, 8832520 )); 
-pts.push_back(Point(13281760, 8832520 )); pts.push_back(Point(13277272, 8832961 )); pts.push_back(Point(13268981, 8836396 )); pts.push_back(Point(13262636, 8842741 )); pts.push_back(Point(13259201, 8851032 )); pts.push_back(Point(13259201, 8860007 )); pts.push_back(Point(13262636, 8868298 )); pts.push_back(Point(13265500, 8871780 )); 
-pts.push_back(Point(13518710, 9125000 )); pts.push_back(Point(16270720, 9125000 )); pts.push_back(Point(16270720, 8939590 )); pts.push_back(Point(17120780, 8939590 )); pts.push_back(Point(17120780, 9125000 )); pts.push_back(Point(17616200, 9125000 )); pts.push_back(Point(17616200,   75000 )); pts.push_back(Point(16024790,   75000 )); 
-pts.push_back(Point(16021460,   80700 )); pts.push_back(Point(16016397,   88796 )); pts.push_back(Point(15972796,  132397 )); pts.push_back(Point(15915830,  155993 )); pts.push_back(Point(15908730,  157240 )); pts.push_back(Point(15905000,  157800 )); pts.push_back(Point(15516800,  546000 )); pts.push_back(Point(15905000,  934200 )); 
-pts.push_back(Point(15908730,  934760 )); pts.push_back(Point(15915830,  936006 )); pts.push_back(Point(15972796,  959602 )); pts.push_back(Point(16016397, 1003203 )); pts.push_back(Point(16039993, 1060169 )); pts.push_back(Point(16039993, 1121830 )); pts.push_back(Point(16016397, 1178796 )); pts.push_back(Point(15972796, 1222397 )); 
-pts.push_back(Point(15915830, 1245993 )); pts.push_back(Point(15854169, 1245993 )); pts.push_back(Point(15797203, 1222397 )); pts.push_back(Point(15753602, 1178796 )); pts.push_back(Point(15730006, 1121830 )); pts.push_back(Point(15728760, 1114730 )); pts.push_back(Point(15728200, 1111000 )); pts.push_back(Point(15363500,  746300 )); 
-pts.push_back(Point(14602620,  746300 )); pts.push_back(Point(14598142,  746741 )); pts.push_back(Point(14589851,  750176 )); pts.push_back(Point(14583506,  756521 )); pts.push_back(Point(14580071,  764812 )); pts.push_back(Point(14580071,  773787 )); pts.push_back(Point(14583506,  782078 )); pts.push_back(Point(14586360,  785560 )); 
-pts.push_back(Point(14586370,  785560 )); pts.push_back(Point(14735000,  934200 )); pts.push_back(Point(14738730,  934760 )); pts.push_back(Point(14745830,  936006 )); pts.push_back(Point(14802796,  959602 )); pts.push_back(Point(14846397, 1003203 )); pts.push_back(Point(14869993, 1060169 )); 
-pts.push_back(Point(14870450, 1062550 )); pts.push_back(Point(14872170, 1071980 )); pts.push_back(Point(14972780, 1071980 )); pts.push_back(Point(15925000, 2024200 )); pts.push_back(Point(15928730, 2024760 )); pts.push_back(Point(15935830, 2026006 )); pts.push_back(Point(15992796, 2049602 )); 
-pts.push_back(Point(16036397, 2093203 )); pts.push_back(Point(16059993, 2150169 )); pts.push_back(Point(16059993, 2211830 )); pts.push_back(Point(16036397, 2268796 )); pts.push_back(Point(15992796, 2312397 )); pts.push_back(Point(15935830, 2335993 )); pts.push_back(Point(15874169, 2335993 )); 
-pts.push_back(Point(15817203, 2312397 )); pts.push_back(Point(15773602, 2268796 )); pts.push_back(Point(15750006, 2211830 )); pts.push_back(Point(15748760, 2204730 )); pts.push_back(Point(15748200, 2201000 )); pts.push_back(Point(14869220, 1322020 )); pts.push_back(Point(14088350, 1322020 )); 
-pts.push_back(Point(14083862, 1322461 )); pts.push_back(Point(14075571, 1325896 )); pts.push_back(Point(14069226, 1332241 )); pts.push_back(Point(14065791, 1340532 )); pts.push_back(Point(14065791, 1349507 )); pts.push_back(Point(14069226, 1357798 )); pts.push_back(Point(14072080, 1361280 )); 
-pts.push_back(Point(14072090, 1361280 )); pts.push_back(Point(14735000, 2024200 )); pts.push_back(Point(14738730, 2024760 )); pts.push_back(Point(14745830, 2026006 )); pts.push_back(Point(14802796, 2049602 )); pts.push_back(Point(14846397, 2093203 )); pts.push_back(Point(14869993, 2150169 )); 
-pts.push_back(Point(14869993, 2211830 )); pts.push_back(Point(14846397, 2268796 )); pts.push_back(Point(14802796, 2312397 )); pts.push_back(Point(14745830, 2335993 )); pts.push_back(Point(14684169, 2335993 )); pts.push_back(Point(14627203, 2312397 )); pts.push_back(Point(14583602, 2268796 )); pts.push_back(Point(14560006, 2211830 )); 
-pts.push_back(Point(14558760, 2204730 )); pts.push_back(Point(14558200, 2201000 )); pts.push_back(Point(13752220, 1395020 )); pts.push_back(Point(12991340, 1395020 )); pts.push_back(Point(12986862, 1395461 )); pts.push_back(Point(12978571, 1398896 )); pts.push_back(Point(12972226, 1405241 )); 
-pts.push_back(Point(12968791, 1413532 )); pts.push_back(Point(12968791, 1422507 )); pts.push_back(Point(12972226, 1430798 )); pts.push_back(Point(12975080, 1434280 )); pts.push_back(Point(12975090, 1434280 )); pts.push_back(Point(13565000, 2024200 )); pts.push_back(Point(13568730, 2024760 )); pts.push_back(Point(13575830, 2026006 )); 
-pts.push_back(Point(13632796, 2049602 )); pts.push_back(Point(13676397, 2093203 )); pts.push_back(Point(13699993, 2150169 )); pts.push_back(Point(13699993, 2211830 )); pts.push_back(Point(13676397, 2268796 )); pts.push_back(Point(13632796, 2312397 )); pts.push_back(Point(13575830, 2335993 )); 
-pts.push_back(Point(13514169, 2335993 )); pts.push_back(Point(13457203, 2312397 )); pts.push_back(Point(13413602, 2268796 )); pts.push_back(Point(13390006, 2211830 )); pts.push_back(Point(13388760, 2204730 )); pts.push_back(Point(13388200, 2201000 )); pts.push_back(Point(12655220, 1468020 )); 
-pts.push_back(Point(11894340, 1468020 )); pts.push_back(Point(11889862, 1468461 )); pts.push_back(Point(11881571, 1471896 )); pts.push_back(Point(11875226, 1478241 )); pts.push_back(Point(11871791, 1486532 )); pts.push_back(Point(11871791, 1495507 )); 
-pts.push_back(Point(11875226, 1503798 )); pts.push_back(Point(11878090, 1507280 )); pts.push_back(Point(12395000, 2024200 )); pts.push_back(Point(12398730, 2024760 )); pts.push_back(Point(12405830, 2026006 )); pts.push_back(Point(12462796, 2049602 )); pts.push_back(Point(12506397, 2093203 )); 
-pts.push_back(Point(12529993, 2150169 )); pts.push_back(Point(12529993, 2211830 )); pts.push_back(Point(12506397, 2268796 )); pts.push_back(Point(12462796, 2312397 )); pts.push_back(Point(12405830, 2335993 )); pts.push_back(Point(12344169, 2335993 )); 
-pts.push_back(Point(12287203, 2312397 )); pts.push_back(Point(12243602, 2268796 )); pts.push_back(Point(12220006, 2211830 )); pts.push_back(Point(12218760, 2204730 )); pts.push_back(Point(12218200, 2201000 )); pts.push_back(Point(11558220, 1541020 )); 
-pts.push_back(Point(10797340, 1541020 )); pts.push_back(Point(10792862, 1541461 )); pts.push_back(Point(10784571, 1544896 )); pts.push_back(Point(10778226, 1551241 )); pts.push_back(Point(10774791, 1559532 )); pts.push_back(Point(10774791, 1568507 )); pts.push_back(Point(10778226, 1576798 )); pts.push_back(Point(10781080, 1580280 )); 
-pts.push_back(Point(10781090, 1580280 )); pts.push_back(Point(11225000, 2024200 )); pts.push_back(Point(11228730, 2024760 )); pts.push_back(Point(11235830, 2026006 )); pts.push_back(Point(11292796, 2049602 )); pts.push_back(Point(11336397, 2093203 )); pts.push_back(Point(11359993, 2150169 )); 
-pts.push_back(Point(11359993, 2211830 )); pts.push_back(Point(11336397, 2268796 )); pts.push_back(Point(11292796, 2312397 )); pts.push_back(Point(11235830, 2335993 )); pts.push_back(Point(11174169, 2335993 )); pts.push_back(Point(11117203, 2312397 )); pts.push_back(Point(11073602, 2268796 )); pts.push_back(Point(11050006, 2211830 )); 
-pts.push_back(Point(11048760, 2204730 )); pts.push_back(Point(11048200, 2201000 )); pts.push_back(Point(10461220, 1614020 )); pts.push_back(Point( 5647400, 1614020 )); pts.push_back(Point( 5642912, 1614461 )); 
-pts.push_back(Point( 5634621, 1617896 )); pts.push_back(Point( 5628276, 1624241 )); pts.push_back(Point( 5624841, 1632532 )); pts.push_back(Point( 5624841, 1641507 )); pts.push_back(Point( 5628276, 1649798 )); pts.push_back(Point( 5631130, 1653280 )); 
-pts.push_back(Point( 5688490, 1710640 )); pts.push_back(Point( 9722350, 1710640 )); pts.push_back(Point(10034620, 2022900 )); pts.push_back(Point(10039200, 2023030 )); pts.push_back(Point(10065830, 2026006 )); pts.push_back(Point(10122796, 2049602 )); 
-pts.push_back(Point(10166397, 2093203 )); pts.push_back(Point(10189993, 2150169 )); pts.push_back(Point(10189993, 2211830 )); pts.push_back(Point(10166397, 2268796 )); pts.push_back(Point(10158620, 2279450 )); pts.push_back(Point(10158620, 2404900 )); pts.push_back(Point(10548950, 2795240 )); 
-pts.push_back(Point(15586950, 2795240 )); pts.push_back(Point(15904620, 3112900 )); pts.push_back(Point(15909200, 3113030 )); pts.push_back(Point(15935830, 3116006 )); pts.push_back(Point(15992796, 3139602 )); pts.push_back(Point(16036397, 3183203 )); pts.push_back(Point(16059993, 3240169 )); pts.push_back(Point(16059993, 3301830 )); 
-pts.push_back(Point(16036397, 3358796 )); pts.push_back(Point(15992796, 3402397 )); pts.push_back(Point(15935830, 3425993 )); pts.push_back(Point(15874169, 3425993 )); pts.push_back(Point(15817203, 3402397 )); pts.push_back(Point(15773602, 3358796 )); pts.push_back(Point(15750006, 3301830 )); pts.push_back(Point(15747030, 3275200 )); 
-pts.push_back(Point(15746900, 3270620 )); pts.push_back(Point(15494570, 3018280 )); pts.push_back(Point(14675510, 3018280 )); pts.push_back(Point(14671032, 3018721 )); pts.push_back(Point(14662741, 3022156 )); pts.push_back(Point(14656396, 3028501 )); pts.push_back(Point(14652961, 3036792 )); 
-pts.push_back(Point(14652961, 3045767 )); pts.push_back(Point(14656396, 3054058 )); pts.push_back(Point(14659260, 3057540 )); pts.push_back(Point(14714620, 3112900 )); pts.push_back(Point(14719200, 3113030 )); pts.push_back(Point(14745830, 3116006 )); pts.push_back(Point(14802796, 3139602 )); 
-pts.push_back(Point(14846397, 3183203 )); pts.push_back(Point(14869993, 3240169 )); pts.push_back(Point(14869993, 3301830 )); pts.push_back(Point(14846397, 3358796 )); pts.push_back(Point(14802796, 3402397 )); pts.push_back(Point(14745830, 3425993 )); pts.push_back(Point(14684169, 3425993 )); pts.push_back(Point(14627203, 3402397 )); 
-pts.push_back(Point(14583602, 3358796 )); pts.push_back(Point(14560006, 3301830 )); pts.push_back(Point(14557030, 3275200 )); pts.push_back(Point(14556900, 3270620 )); pts.push_back(Point(14370700, 3084410 )); pts.push_back(Point(13702830, 3084410 )); pts.push_back(Point(13702830, 3263160 )); 
-pts.push_back(Point(13700003, 3302210 )); pts.push_back(Point(13676407, 3359176 )); pts.push_back(Point(13632806, 3402777 )); pts.push_back(Point(13575840, 3426373 )); pts.push_back(Point(13514179, 3426373 )); pts.push_back(Point(13457213, 3402777 )); pts.push_back(Point(13413612, 3359176 )); 
-pts.push_back(Point(13390016, 3302210 )); pts.push_back(Point(13387030, 3275200 )); pts.push_back(Point(13386900, 3270620 )); pts.push_back(Point(13266840, 3150550 )); pts.push_back(Point(12532920, 3150550 )); pts.push_back(Point(12532920, 3264990 )); pts.push_back(Point(12529993, 3301820 )); 
-pts.push_back(Point(12506397, 3358786 )); pts.push_back(Point(12462796, 3402387 )); pts.push_back(Point(12405830, 3425983 )); pts.push_back(Point(12344169, 3425983 )); pts.push_back(Point(12287203, 3402387 )); pts.push_back(Point(12243602, 3358786 )); pts.push_back(Point(12220006, 3301820 )); pts.push_back(Point(12217030, 3275200 )); 
-pts.push_back(Point(12216900, 3270620 )); pts.push_back(Point(12157460, 3211170 )); pts.push_back(Point(11362030, 3211170 )); pts.push_back(Point(11360250, 3220520 )); pts.push_back(Point(11359993, 3221830 )); pts.push_back(Point(11336397, 3278796 )); 
-pts.push_back(Point(11292796, 3322397 )); pts.push_back(Point(11235830, 3345993 )); pts.push_back(Point(11174169, 3345993 )); pts.push_back(Point(11117203, 3322397 )); pts.push_back(Point(11096270, 3305670 )); pts.push_back(Point(11092940, 3302520 )); pts.push_back(Point(10680760, 3302520 )); 
-pts.push_back(Point(10676272, 3302961 )); pts.push_back(Point(10667981, 3306396 )); pts.push_back(Point(10661636, 3312741 )); pts.push_back(Point(10658201, 3321032 )); pts.push_back(Point(10658201, 3330007 )); pts.push_back(Point(10661636, 3338298 )); pts.push_back(Point(10664500, 3341780 )); 
-pts.push_back(Point(11264260, 3941550 )); pts.push_back(Point(15643260, 3941550 )); pts.push_back(Point(15904620, 4202900 )); pts.push_back(Point(15909200, 4203030 )); pts.push_back(Point(15935830, 4206006 )); pts.push_back(Point(15992796, 4229602 )); 
-pts.push_back(Point(16036397, 4273203 )); pts.push_back(Point(16059993, 4330169 )); pts.push_back(Point(16059993, 4391830 )); pts.push_back(Point(16036397, 4448796 )); pts.push_back(Point(15992796, 4492397 )); 
-pts.push_back(Point(15935830, 4515993 )); pts.push_back(Point(15874169, 4515993 )); pts.push_back(Point(15817203, 4492397 )); pts.push_back(Point(15773602, 4448796 )); pts.push_back(Point(15750006, 4391830 )); pts.push_back(Point(15747030, 4365200 )); pts.push_back(Point(15746900, 4360620 )); 
-pts.push_back(Point(15550880, 4164590 )); pts.push_back(Point(14825070, 4164590 )); pts.push_back(Point(14825070, 4247610 )); pts.push_back(Point(14846397, 4273213 )); pts.push_back(Point(14869993, 4330179 )); pts.push_back(Point(14869993, 4391840 )); pts.push_back(Point(14846397, 4448806 )); 
-pts.push_back(Point(14802796, 4492407 )); pts.push_back(Point(14745830, 4516003 )); pts.push_back(Point(14684169, 4516003 )); pts.push_back(Point(14627203, 4492407 )); pts.push_back(Point(14583602, 4448806 )); pts.push_back(Point(14560006, 4391840 )); pts.push_back(Point(14557030, 4365200 )); 
-pts.push_back(Point(14556900, 4360620 )); pts.push_back(Point(14432520, 4236230 )); pts.push_back(Point(13702830, 4236230 )); pts.push_back(Point(13702830, 4352930 )); pts.push_back(Point(13699993, 4391750 )); pts.push_back(Point(13676397, 4448716 )); 
-pts.push_back(Point(13632796, 4492317 )); pts.push_back(Point(13575830, 4515913 )); pts.push_back(Point(13514169, 4515913 )); pts.push_back(Point(13457203, 4492317 )); pts.push_back(Point(13413602, 4448716 )); pts.push_back(Point(13390006, 4391750 )); pts.push_back(Point(13387030, 4365200 )); 
-pts.push_back(Point(13386900, 4360620 )); pts.push_back(Point(13334170, 4307880 )); pts.push_back(Point(12532990, 4307880 )); pts.push_back(Point(12532990, 4357550 )); pts.push_back(Point(12529993, 4391760 )); pts.push_back(Point(12506397, 4448726 )); pts.push_back(Point(12462796, 4492327 )); 
-pts.push_back(Point(12405830, 4515923 )); pts.push_back(Point(12344169, 4515923 )); pts.push_back(Point(12287203, 4492327 )); pts.push_back(Point(12243602, 4448726 )); pts.push_back(Point(12220006, 4391760 )); pts.push_back(Point(12217970, 4378710 )); pts.push_back(Point(12216810, 4368500 )); 
-pts.push_back(Point(11363190, 4368500 )); pts.push_back(Point(11362030, 4378710 )); pts.push_back(Point(11359983, 4391828 )); pts.push_back(Point(11336388, 4448791 )); pts.push_back(Point(11292791, 4492388 )); pts.push_back(Point(11235828, 4515983 )); pts.push_back(Point(11174171, 4515983 )); pts.push_back(Point(11117208, 4492388 )); 
-pts.push_back(Point(11096270, 4475670 )); pts.push_back(Point(11092940, 4472520 )); pts.push_back(Point(11057750, 4472520 )); pts.push_back(Point(11053272, 4472961 )); pts.push_back(Point(11044981, 4476396 )); pts.push_back(Point(11038636, 4482741 )); pts.push_back(Point(11035201, 4491032 )); 
-pts.push_back(Point(11035201, 4500007 )); pts.push_back(Point(11038636, 4508298 )); pts.push_back(Point(11041490, 4511780 )); pts.push_back(Point(11573490, 5043780 )); pts.push_back(Point(15655490, 5043780 )); pts.push_back(Point(15904620, 5292900 )); 
-pts.push_back(Point(15909200, 5293030 )); pts.push_back(Point(15935830, 5296006 )); pts.push_back(Point(15992796, 5319602 )); pts.push_back(Point(16036397, 5363203 )); pts.push_back(Point(16059993, 5420169 )); pts.push_back(Point(16059993, 5481830 )); pts.push_back(Point(16036397, 5538796 )); 
-pts.push_back(Point(15992796, 5582397 )); pts.push_back(Point(15935830, 5605993 )); pts.push_back(Point(15874169, 5605993 )); pts.push_back(Point(15817203, 5582397 )); pts.push_back(Point(15773602, 5538796 )); pts.push_back(Point(15750006, 5481830 )); pts.push_back(Point(15747030, 5455200 )); 
-pts.push_back(Point(15746900, 5450620 )); pts.push_back(Point(15563110, 5266820 )); pts.push_back(Point(14857380, 5266820 )); pts.push_back(Point(14857380, 5382430 )); pts.push_back(Point(14869993, 5420179 )); pts.push_back(Point(14869993, 5481840 )); pts.push_back(Point(14846397, 5538806 )); pts.push_back(Point(14802796, 5582407 )); 
-pts.push_back(Point(14745830, 5606003 )); pts.push_back(Point(14684169, 5606003 )); pts.push_back(Point(14627203, 5582407 )); pts.push_back(Point(14583602, 5538806 )); pts.push_back(Point(14560006, 5481840 )); pts.push_back(Point(14557030, 5455200 )); pts.push_back(Point(14556900, 5450620 )); pts.push_back(Point(14444750, 5338460 )); 
-pts.push_back(Point(13702890, 5338460 )); pts.push_back(Point(13702890, 5364400 )); pts.push_back(Point(13699993, 5401800 )); pts.push_back(Point(13676397, 5458766 )); pts.push_back(Point(13632796, 5502367 )); pts.push_back(Point(13575830, 5525963 )); pts.push_back(Point(13514169, 5525963 )); pts.push_back(Point(13457203, 5502367 )); 
-pts.push_back(Point(13413602, 5458766 )); pts.push_back(Point(13390006, 5401800 )); pts.push_back(Point(13389230, 5397620 )); pts.push_back(Point(13387590, 5388060 )); pts.push_back(Point(12532960, 5388060 )); pts.push_back(Point(12532960, 5446220 )); pts.push_back(Point(12529993, 5481820 )); 
-pts.push_back(Point(12506397, 5538786 )); pts.push_back(Point(12462796, 5582387 )); pts.push_back(Point(12405830, 5605983 )); pts.push_back(Point(12344169, 5605983 )); pts.push_back(Point(12287203, 5582387 )); pts.push_back(Point(12266270, 5565670 )); pts.push_back(Point(12262940, 5562520 )); pts.push_back(Point(11737750, 5562520 )); 
-pts.push_back(Point(11733272, 5562961 )); pts.push_back(Point(11724981, 5566396 )); pts.push_back(Point(11718636, 5572741 )); pts.push_back(Point(11715201, 5581032 )); pts.push_back(Point(11715201, 5590007 )); pts.push_back(Point(11718636, 5598298 )); pts.push_back(Point(11721500, 5601780 )); 
-pts.push_back(Point(12287760, 6168050 )); pts.push_back(Point(15689760, 6168050 )); pts.push_back(Point(15904620, 6382900 )); pts.push_back(Point(15909200, 6383030 )); pts.push_back(Point(15935830, 6386006 )); pts.push_back(Point(15992796, 6409602 )); 
-pts.push_back(Point(16036397, 6453203 )); pts.push_back(Point(16059993, 6510169 )); pts.push_back(Point(16059993, 6571830 )); pts.push_back(Point(16036397, 6628796 )); pts.push_back(Point(15992796, 6672397 )); pts.push_back(Point(15935830, 6695993 )); pts.push_back(Point(15874169, 6695993 )); 
-pts.push_back(Point(15817203, 6672397 )); pts.push_back(Point(15773602, 6628796 )); pts.push_back(Point(15750006, 6571830 )); pts.push_back(Point(15747030, 6545200 )); pts.push_back(Point(15746900, 6540620 )); pts.push_back(Point(15597380, 6391090 )); pts.push_back(Point(14858060, 6391090 )); 
-pts.push_back(Point(14858060, 6473860 )); pts.push_back(Point(14869993, 6510179 )); pts.push_back(Point(14869993, 6571840 )); pts.push_back(Point(14846397, 6628806 )); pts.push_back(Point(14802796, 6672407 )); pts.push_back(Point(14745830, 6696003 )); pts.push_back(Point(14684169, 6696003 )); 
-pts.push_back(Point(14627203, 6672407 )); pts.push_back(Point(14583602, 6628806 )); pts.push_back(Point(14560006, 6571840 )); pts.push_back(Point(14557030, 6545200 )); pts.push_back(Point(14556900, 6540620 )); pts.push_back(Point(14479020, 6462730 )); 
-pts.push_back(Point(13702990, 6462730 )); pts.push_back(Point(13702990, 6537170 )); pts.push_back(Point(13700003, 6571840 )); pts.push_back(Point(13676407, 6628806 )); pts.push_back(Point(13632806, 6672407 )); pts.push_back(Point(13575840, 6696003 )); 
-pts.push_back(Point(13514179, 6696003 )); pts.push_back(Point(13457213, 6672407 )); pts.push_back(Point(13413612, 6628806 )); pts.push_back(Point(13390016, 6571840 )); pts.push_back(Point(13387040, 6545550 )); pts.push_back(Point(13386710, 6534380 )); 
-pts.push_back(Point(12533290, 6534380 )); pts.push_back(Point(12532960, 6545550 )); pts.push_back(Point(12529983, 6571828 )); pts.push_back(Point(12506388, 6628791 )); pts.push_back(Point(12462791, 6672388 )); pts.push_back(Point(12405828, 6695983 )); 
-pts.push_back(Point(12344171, 6695983 )); pts.push_back(Point(12287208, 6672388 )); pts.push_back(Point(12266270, 6655670 ));
-      poly.set(pts.begin(), pts.end());
-      si.insert(poly, 444);
-      result.clear();
-      si.merge(result);
-      si.verify();
-      print(std::cout, si.pmd) << std::endl;
-      if(!result.empty()) {
-        psd = (*(result.begin())).second;
-        std::cout << psd << std::endl;
-        std::vector<Point> outpts;
-        for(typename polygon_set_data<Unit>::iterator_type itr = psd.begin();
-            itr != psd.end(); ++itr) {
-          outpts.push_back((*itr).first.first);
-          outpts.push_back((*itr).first.second);
-        }
-        std::sort(outpts.begin(), outpts.end());
-        for(unsigned int i = 0; i < outpts.size(); i+=2) {
-          if(outpts[i] != outpts[i+1]) {
-            std::cout << "Polygon set not a closed figure\n";
-            std::cout << i << std::endl;
-            std::cout << outpts[i] << " " << outpts[i+1] << std::endl;
-            return 0;
-          }
-        }
-        polys.clear();
-        psd.get(polys);
-        if(polys.size() == 0) {
-          std::cout << "fail merge 10\n";
-          return false;
-        }
-        std::cout << (polys[0]) << std::endl;
-      }
-      for(unsigned int i = 0; i < 10; ++i) {
-        std::cout << "random case # " << i << std::endl;
-        si.clear();
-        pts.clear();
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        polygon_data<Unit> poly1;
-        poly1.set(pts.begin(), pts.end());
-        std::cout << poly1 << std::endl;
-        si.insert(poly1, 444);
-        pts.clear();
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        polygon_data<Unit> poly2;
-        poly2.set(pts.begin(), pts.end());
-        std::cout << poly2 << std::endl;
-        si.insert(poly2, 444);
-        result.clear();
-        si.merge(result);
-        print(std::cout, si.pmd) << std::endl;
-        if(!result.empty()) {
-          psd = (*(result.begin())).second;
-          std::cout << psd << std::endl;
-          polys.clear();
-          psd.get(polys);
-          if(polys.size() == 0) {
-            si.clear();
-            si.insert(poly1, 333);
-            result.clear();
-            si.merge(result);
-            psd = (*(result.begin())).second;
-            std::vector<polygon_data<Unit> > polys1;
-            psd.get(polys1);
-            si.clear();
-            si.insert(poly2, 333);
-            result.clear();
-            si.merge(result);
-            psd = (*(result.begin())).second;
-            std::vector<polygon_data<Unit> > polys2;
-            psd.get(polys2);
-            if(!polys1.empty() || !polys2.empty()) {
-              std::cout << "fail random merge " << i << std::endl;
-              return false;
-            }
-          }
-        }
-        if(!polys.empty())
-          std::cout << polys.size() << ": " << (polys[0]) << std::endl;
-      }
-      return true;
-    }
-
-    static inline bool check_rectangle_trio(rectangle_data<Unit> rect1, rectangle_data<Unit> rect2, rectangle_data<Unit> rect3) {
-        property_merge si;
-        std::map<std::set<property_type>, polygon_set_data<Unit> > result;
-        std::vector<polygon_data<Unit> > polys;
-        property_merge_90<property_type, Unit> si90;
-        std::map<std::set<property_type>, polygon_90_set_data<Unit> > result90;
-        std::vector<polygon_data<Unit> > polys90;
-        si.insert(rect1, 111);
-        si90.insert(rect1, 111);
-        std::cout << rect1 << std::endl;
-        si.insert(rect2, 222);
-        si90.insert(rect2, 222);
-        std::cout << rect2 << std::endl;
-        si.insert(rect3, 333);
-        si90.insert(rect3, 333);
-        std::cout << rect3 << std::endl;
-        si.merge(result);
-        si90.merge(result90);
-        if(result.size() != result90.size()) {
-          std::cout << "merge failed with size mismatch\n";
-          return 0;
-        }
-        typename std::map<std::set<property_type>, polygon_90_set_data<Unit> >::iterator itr90 = result90.begin();
-        for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
-            itr != result.end(); ++itr) {
-          for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
-              set_itr != (*itr).first.end(); ++set_itr) {
-            std::cout << (*set_itr) << " ";
-          } std::cout << ") \n";
-          polygon_set_data<Unit> psd = (*itr).second;
-          polygon_90_set_data<Unit> psd90 = (*itr90).second;
-          polys.clear();
-          polys90.clear();
-          psd.get(polys);
-          psd90.get(polys90);
-          if(polys.size() != polys90.size()) {
-            std::cout << "merge failed with polygon count mismatch\n";
-            std::cout << psd << std::endl;
-            for(unsigned int j = 0; j < polys.size(); ++j) {
-              std::cout << polys[j] << std::endl;
-            }
-            std::cout << "reference\n";
-            for(unsigned int j = 0; j < polys90.size(); ++j) {
-              std::cout << polys90[j] << std::endl;
-            }
-            return 0;
-          }
-          bool failed = false;
-          for(unsigned int j = 0; j < polys.size(); ++j) {
-            std::cout << polys[j] << std::endl;
-            std::cout << polys90[j] << std::endl;
-#ifdef __ICC
-#pragma warning (disable:1572)
-#endif
-            if(area(polys[j]) != area(polys90[j])) {
-#ifdef __ICC
-#pragma warning (default:1572)
-#endif
-              std::cout << "merge failed with area mismatch\n";
-              failed = true;
-            }
-          }
-          if(failed) return 0;
-          ++itr90;
-        }
-        return true;
-    }
-
-    static inline bool test_manhattan_intersection() {
-      rectangle_data<Unit> rect1, rect2, rect3;
-      set_points(rect1, (Point(-1, 2)), (Point(1, 4)));
-      set_points(rect2, (Point(-1, 2)), (Point(2, 3)));
-      set_points(rect3, (Point(-3, 0)), (Point(4, 2)));
-      if(!check_rectangle_trio(rect1, rect2, rect3)) {
-        return false;
-      }
-      for(unsigned int i = 0; i < 100; ++i) {
-        property_merge si;
-        std::map<std::set<property_type>, polygon_set_data<Unit> > result;
-        std::vector<polygon_data<Unit> > polys;
-        property_merge_90<property_type, Unit> si90;
-        std::map<std::set<property_type>, polygon_90_set_data<Unit> > result90;
-        std::vector<polygon_data<Unit> > polys90;
-        std::cout << "random case # " << i << std::endl;
-        set_points(rect1, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
-        set_points(rect2, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
-        set_points(rect3, (Point(rand()%9-4, rand()%9-4)), (Point(rand()%9-4, rand()%9-4)));
-        if(!check_rectangle_trio(rect1, rect2, rect3)) {
-          return false;
-        }
-      }
-      return true;
-    }
-
-    static inline bool test_intersection() {
-      property_merge si;
-      rectangle_data<Unit> rect;
-      xl(rect, 0);
-      yl(rect, 10);
-      xh(rect, 30);
-      yh(rect, 20);
-      si.insert(rect, 333);
-      xl(rect, 10);
-      yl(rect, 0);
-      xh(rect, 20);
-      yh(rect, 30);
-      si.insert(rect, 444);
-      xl(rect, 15);
-      yl(rect, 0);
-      xh(rect, 25);
-      yh(rect, 30);
-      si.insert(rect, 555);
-      std::map<std::set<property_type>, polygon_set_data<Unit> > result;
-      si.merge(result);
-      print(std::cout, si.pmd) << std::endl;
-      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
-          itr != result.end(); ++itr) {
-        std::cout << "( ";
-        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
-            set_itr != (*itr).first.end(); ++set_itr) {
-          std::cout << (*set_itr) << " ";
-        } std::cout << ") \n";
-        polygon_set_data<Unit> psd = (*itr).second;
-        std::cout << psd << std::endl;
-        std::vector<polygon_data<Unit> > polys;
-        psd.get(polys);
-        for(unsigned int i = 0; i < polys.size(); ++i) {
-          std::cout << polys[i] << std::endl;
-        }
-      }
-      std::vector<Point> pts;
-      std::vector<polygon_data<Unit> > polys;
-      for(unsigned int i = 0; i < 10; ++i) {
-        property_merge si2;
-        std::cout << "random case # " << i << std::endl;
-        si.clear();
-        pts.clear();
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        polygon_data<Unit> poly1;
-        poly1.set(pts.begin(), pts.end());
-        std::cout << poly1 << std::endl;
-        si.insert(poly1, 444);
-        si2.insert(poly1, 333);
-        pts.clear();
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        polygon_data<Unit> poly2;
-        poly2.set(pts.begin(), pts.end());
-        std::cout << poly2 << std::endl;
-        si.insert(poly2, 444);
-        si2.insert(poly2, 444);
-        pts.clear();
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        pts.push_back(Point(rand()%9-4, rand()%9-4));
-        polygon_data<Unit> poly3;
-        poly3.set(pts.begin(), pts.end());
-        std::cout << poly3 << std::endl;
-        si.insert(poly3, 444);
-        si2.insert(poly3, 555);
-        result.clear();
-        std::map<std::set<property_type>, polygon_set_data<Unit> > result2;
-        si.merge(result);
-        si2.merge(result2);
-        std::cout << "merged result\n";
-      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result.begin();
-          itr != result.end(); ++itr) {
-        std::cout << "( ";
-        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
-            set_itr != (*itr).first.end(); ++set_itr) {
-          std::cout << (*set_itr) << " ";
-        } std::cout << ") \n";
-        polygon_set_data<Unit> psd = (*itr).second;
-        std::cout << psd << std::endl;
-        std::vector<polygon_data<Unit> > polys2;
-        psd.get(polys2);
-        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
-          std::cout << polys2[ii] << std::endl;
-        }
-      }
-      std::cout << "intersected pmd\n";
-      print(std::cout, si2.pmd) << std::endl;
-      std::cout << "intersected result\n";
-      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
-          itr != result2.end(); ++itr) {
-        std::cout << "( ";
-        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
-            set_itr != (*itr).first.end(); ++set_itr) {
-          std::cout << (*set_itr) << " ";
-        } std::cout << ") \n";
-        polygon_set_data<Unit> psd = (*itr).second;
-        std::cout << psd << std::endl;
-        std::vector<polygon_data<Unit> > polys2;
-        psd.get(polys2);
-        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
-          std::cout << polys2[ii] << std::endl;
-        }
-      }
-        si.clear();
-        for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
-            itr != result2.end(); ++itr) {
-          polys.clear();
-          (*itr).second.get(polys);
-          for(unsigned int j = 0; j < polys.size(); ++j) {
-            si.insert(polys[j], 444);
-          }
-        }
-        result2.clear();
-        si.merge(result2);
-      std::cout << "remerged result\n";
-      for(typename std::map<std::set<property_type>, polygon_set_data<Unit> >::iterator itr = result2.begin();
-          itr != result2.end(); ++itr) {
-        std::cout << "( ";
-        for(typename std::set<property_type>::const_iterator set_itr = (*itr).first.begin();
-            set_itr != (*itr).first.end(); ++set_itr) {
-          std::cout << (*set_itr) << " ";
-        } std::cout << ") \n";
-        polygon_set_data<Unit> psd = (*itr).second;
-        std::cout << psd << std::endl;
-        std::vector<polygon_data<Unit> > polys2;
-        psd.get(polys2);
-        for(unsigned int ii = 0; ii < polys2.size(); ++ii) {
-          std::cout << polys2[ii] << std::endl;
-        }
-      }
-      std::vector<polygon_data<Unit> > polys2;
-      polys.clear();
-      (*(result.begin())).second.get(polys);
-      (*(result2.begin())).second.get(polys2);
-      if(!(polys == polys2)) {
-          std::cout << "failed intersection check # " << i << std::endl;
-          return false;
-        }
-      }
-      return true;
-    }
-  };
-
-  template <typename Unit>
-  class arbitrary_boolean_op : public scanline_base<Unit> {
-  private:
-    
-    typedef int property_type;
-    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;
-
-    //this data structure assocates a property and count to a half edge
-    typedef std::pair<half_edge, std::pair<property_type, int> > vertex_property;
-    //this data type stores the combination of many half edges
-    typedef std::vector<vertex_property> property_merge_data;
-
-    //this is the data type used internally to store the combination of property counts at a given location
-    typedef std::vector<std::pair<property_type, int> > property_map;
-    //this data type is used internally to store the combined property data for a given half edge
-    typedef std::pair<half_edge, property_map> vertex_data;
-
-    property_merge_data pmd;
-
-    template<typename vertex_data_type>
-    class less_vertex_data {
-    public:
-      less_vertex_data() {}
-      bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
-        less_point lp;
-        if(lp(lvalue.first.first, rvalue.first.first)) return true;
-        if(lp(rvalue.first.first, lvalue.first.first)) return false;
-        Unit x = lvalue.first.first.get(HORIZONTAL);
-        int just_before_ = 0;
-        less_half_edge lhe(&x, &just_before_);
-        return lhe(lvalue.first, rvalue.first);
-      }
-    };
-
-    template <typename result_type, typename key_type, int op_type>
-    class boolean_output_functor {
-    public:
-      boolean_output_functor() {}
-      void operator()(result_type& result, const half_edge& edge, const key_type& left, const key_type& right) {
-        typename std::pair<half_edge, int> elem;
-        elem.first = edge;
-        elem.second = 1;
-        if(edge.second < edge.first) elem.second *= -1;
-        if(is_vertical(edge)) elem.second *= -1;
-        if(op_type == 0) { //OR
-          if(!left.empty() && right.empty()) {
-            result.insert_clean(elem);
-          } else if(!right.empty() && left.empty()) {
-            elem.second *= -1;
-            result.insert_clean(elem);
-          }
-        } else if(op_type == 1) { //AND
-          if(left.size() == 2 && right.size() != 2) {
-            result.insert_clean(elem);
-          } else if(right.size() == 2 && left.size() != 2) {
-            elem.second *= -1;
-            result.insert_clean(elem);
-          }
-        } else if(op_type == 2) { //XOR
-          if(left.size() == 1 && right.size() != 1) {
-            result.insert_clean(elem);
-          } else if(right.size() == 1 && left.size() != 1) {
-            elem.second *= -1;
-            result.insert_clean(elem);
-          }
-        } else { //SUBTRACT
-          if(left.size() == 1) {
-            if((*(left.begin())) == 0) {
-              result.insert_clean(elem);
-            }
-          } 
-          if(right.size() == 1) {
-            if((*(right.begin())) == 0) {
-              elem.second *= -1;
-              result.insert_clean(elem);
-            }
-          }
-        }
-      }
-    };
-
-    inline void sort_property_merge_data() {
-      less_vertex_data<vertex_property> lvd;
-      std::sort(pmd.begin(), pmd.end(), lvd);
-    }
-  public:
-    inline arbitrary_boolean_op() : pmd() {}
-    inline arbitrary_boolean_op(const arbitrary_boolean_op& pm) : pmd(pm.pmd) {}
-    inline arbitrary_boolean_op& operator=(const arbitrary_boolean_op& pm) { pmd = pm.pmd; return *this; }
-
-    enum BOOLEAN_OP_TYPE {
-      BOOLEAN_OR = 0,
-      BOOLEAN_AND = 1,
-      BOOLEAN_XOR = 2, 
-      BOOLEAN_NOT = 3
-    };
-    template <typename result_type, typename iT1, typename iT2>
-    inline void execute(result_type& result, iT1 b1, iT1 e1, iT2 b2, iT2 e2, int op) {
-      //intersect data
-      insert(b1, e1, 0);
-      insert(b2, e2, 1);
-      property_merge_data tmp_pmd;
-      //#define GTL_DEBUG_FILE
-#ifdef GTL_DEBUG_FILE
-      std::fstream debug_file;
-      debug_file.open("gtl_debug.txt", std::ios::out);
-      property_merge<Unit, property_type, std::vector<property_type> >::print(debug_file, pmd);
-      debug_file.close();
-#endif
-      line_intersection<Unit>::validate_scan(tmp_pmd, pmd.begin(), pmd.end());
-      pmd.swap(tmp_pmd);
-      sort_property_merge_data();
-      scanline<Unit, property_type, std::vector<property_type> > sl;
-      if(op == BOOLEAN_OR) {
-        boolean_output_functor<result_type, std::vector<property_type>, 0> bof;
-        sl.scan(result, bof, pmd.begin(), pmd.end());
-      } else if(op == BOOLEAN_AND) {
-        boolean_output_functor<result_type, std::vector<property_type>, 1> bof;
-        sl.scan(result, bof, pmd.begin(), pmd.end());
-      } else if(op == BOOLEAN_XOR) {
-        boolean_output_functor<result_type, std::vector<property_type>, 2> bof;
-        sl.scan(result, bof, pmd.begin(), pmd.end());
-      } else if(op == BOOLEAN_NOT) {
-        boolean_output_functor<result_type, std::vector<property_type>, 3> bof;
-        sl.scan(result, bof, pmd.begin(), pmd.end());
-      } 
-    }
-    
-    inline void clear() {*this = arbitrary_boolean_op();}
-
-  private:
-    template <typename iT>
-    void insert(iT b, iT e, int id) {
-      for(; 
-          b != e; ++b) {
-        pmd.push_back(vertex_property(half_edge((*b).first.first, (*b).first.second), 
-                                      std::pair<property_type, int>(id, (*b).second)));
-      }
-    }
-
-  };
-
-  template <typename Unit>
-  bool test_arbitrary_boolean_op() {
-    polygon_set_data<Unit> psd;
-    rectangle_data<Unit> rect;
-    set_points(rect, point_data<Unit>(0, 0), point_data<Unit>(10, 10));
-    psd.insert(rect);
-    polygon_set_data<Unit> psd2;
-    set_points(rect, point_data<Unit>(5, 5), point_data<Unit>(15, 15));
-    psd2.insert(rect);
-    std::vector<polygon_data<Unit> > pv;
-    pv.clear();
-    arbitrary_boolean_op<Unit> abo;
-    polygon_set_data<Unit> psd3;
-    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_OR);
-    psd3.get(pv);
-    for(unsigned int i = 0; i < pv.size(); ++i) {
-      std::cout << pv[i] << std::endl;
-    }
-    pv.clear();
-    abo.clear();
-    psd3.clear();
-    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_AND);
-    psd3.get(pv);
-    for(unsigned int i = 0; i < pv.size(); ++i) {
-      std::cout << pv[i] << std::endl;
-    }
-    pv.clear();
-    abo.clear();
-    psd3.clear();
-    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_XOR);
-    psd3.get(pv);
-    for(unsigned int i = 0; i < pv.size(); ++i) {
-      std::cout << pv[i] << std::endl;
-    }
-    pv.clear();
-    abo.clear();
-    psd3.clear();
-    abo.execute(psd3, psd.begin(), psd.end(), psd2.begin(), psd2.end(), arbitrary_boolean_op<Unit>::BOOLEAN_NOT);
-    psd3.get(pv);
-    for(unsigned int i = 0; i < pv.size(); ++i) {
-      std::cout << pv[i] << std::endl;
-    }
-    return true;
-  }
-
-}  
-}
-#endif
-
Modified: sandbox/gtl/boost/polygon/transform.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/transform.hpp	(original)
+++ sandbox/gtl/boost/polygon/transform.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
@@ -5,9 +5,10 @@
     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt).
 */
-#ifndef GTL_TRANSFORM_HPP
-#define GTL_TRANSFORM_HPP
-
+#ifndef BOOST_POLYGON_TRANSFORM_HPP
+#define BOOST_POLYGON_TRANSFORM_HPP
+#include "isotropy.hpp"
+#include "point_3d_concept.hpp"
 namespace boost { namespace polygon{
 // Transformation of Coordinate Systems
 // Enum meaning:
@@ -483,5 +484,6 @@
 };
 }
 }
+#include "detail/transform_detail.hpp"
 #endif
 
Deleted: sandbox/gtl/boost/polygon/transform_detail.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/transform_detail.hpp	2009-06-25 13:06:17 EDT (Thu, 25 Jun 2009)
+++ (empty file)
@@ -1,553 +0,0 @@
-/*
-    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 GTL_TRANSFORM_DETAIL_HPP
-#define GTL_TRANSFORM_DETAIL_HPP
-
-namespace boost { namespace polygon{
-  // inline std::ostream& operator<< (std::ostream& o, const axis_transformation& r) {
-  //   o << r.atr_;
-  //   return o;
-  // }
-
-  // inline std::istream& operator>> (std::istream& i, axis_transformation& r) {
-  //   int tmp;
-  //   i >> tmp;
-  //   r = axis_transformation((axis_transformation::ATR)tmp);
-  //   return i;
-  // }
-
-  // template <typename scale_factor_type>
-  // inline std::ostream& operator<< (std::ostream& o, const anisotropic_scale_factor<scale_factor_type>& sc) {
-  //   o << sc.scale_[0] << GTL_SEP << sc.scale_[1] << GTL_SEP << sc.scale_[2];
-  //   return o;
-  // }
-
-  // template <typename scale_factor_type>
-  // inline std::istream& operator>> (std::istream& i, anisotropic_scale_factor<scale_factor_type>& sc) {
-  //   i >> sc.scale_[0] >> sc.scale_[1] >> sc.scale_[2];
-  //   return i;
-  // }
-
-  // template <typename coordinate_type>
-  // inline std::ostream& operator<< (std::ostream& o, const transformation& tr) {
-  //   o << tr.atr_ << GTL_SEP << tr.p_;
-  //   return o;
-  // }
-
-  // template <typename coordinate_type>
-  // inline std::istream& operator>> (std::istream& i, transformation& tr) {
-  //   i >> tr.atr_ >> tr.p_;
-  //   return i;
-  // }
-
-
-  inline axis_transformation::axis_transformation(const orientation_3d& orient) : atr_(NULL_TRANSFORM) {
-    const ATR tmp[3] = {
-      UP_EAST_NORTH, //sort by x, then z, then y
-      EAST_UP_NORTH, //sort by y, then z, then x
-      EAST_NORTH_UP  //sort by z, then y, then x
-    };
-    atr_ = tmp[orient.to_int()];
-  }
-  
-  inline axis_transformation::axis_transformation(const orientation_2d& orient) : atr_(NULL_TRANSFORM) {
-    const ATR tmp[3] = {
-      NORTH_EAST_UP, //sort by z, then x, then y
-      EAST_NORTH_UP  //sort by z, then y, then x
-    };
-    atr_ = tmp[orient.to_int()];
-  }
-  
-  inline axis_transformation::axis_transformation(const direction_3d& dir) : atr_(NULL_TRANSFORM) {
-    const ATR tmp[6] = {
-      DOWN_EAST_NORTH, //sort by -x, then z, then y
-      UP_EAST_NORTH,   //sort by x, then z, then y
-      EAST_DOWN_NORTH, //sort by -y, then z, then x
-      EAST_UP_NORTH,   //sort by y, then z, then x
-      EAST_NORTH_DOWN, //sort by -z, then y, then x
-      EAST_NORTH_UP    //sort by z, then y, then x
-    };
-    atr_ = tmp[dir.to_int()];
-  }
-  
-  inline axis_transformation::axis_transformation(const direction_2d& dir) : atr_(NULL_TRANSFORM) {
-    const ATR tmp[4] = {
-      SOUTH_EAST_UP, //sort by z, then x, then y
-      NORTH_EAST_UP, //sort by z, then x, then y
-      EAST_SOUTH_UP, //sort by z, then y, then x
-      EAST_NORTH_UP  //sort by z, then y, then x
-    };
-    atr_ = tmp[dir.to_int()];
-  }
-  
-  inline axis_transformation& axis_transformation::operator=(const axis_transformation& a) {
-    atr_ = a.atr_;
-    return *this;
-  }
-
-  inline axis_transformation& axis_transformation::operator=(const ATR& atr) {
-    atr_ = atr;
-    return *this;
-  }
-
-  inline bool axis_transformation::operator==(const axis_transformation& a) const {
-    return atr_ == a.atr_;
-  }
-
-  inline bool axis_transformation::operator!=(const axis_transformation& a) const {
-    return !(*this == a);
-  }
-
-  inline bool axis_transformation::operator<(const axis_transformation& a) const {
-    return atr_ < a.atr_;
-  }
-
-  inline axis_transformation& axis_transformation::operator+=(const axis_transformation& a){
-    bool abit5 = a.atr_ & 32;
-    bool abit4 = a.atr_ & 16;
-    bool abit3 = a.atr_ & 8;
-    bool abit2 = a.atr_ & 4;
-    bool abit1 = a.atr_ & 2;
-    bool abit0 = a.atr_ & 1;      
-    bool bit5 = atr_ & 32;
-    bool bit4 = atr_ & 16;
-    bool bit3 = atr_ & 8;
-    bool bit2 = atr_ & 4;
-    bool bit1 = atr_ & 2;
-    bool bit0 = atr_ & 1;      
-    int indexes[2][3] = {
-      {
-        ((int)((bit5 & bit2) | (bit4 & !bit2)) << 1) +
-        (int)(bit2 & !bit5),
-        ((int)((bit4 & bit2) | (bit5 & !bit2)) << 1) +
-        (int)(!bit5 & !bit2),
-        ((int)(!bit4 & !bit5) << 1) +
-        (int)(bit5) 
-      },
-      {
-        ((int)((abit5 & abit2) | (abit4 & !abit2)) << 1) +
-        (int)(abit2 & !abit5),
-        ((int)((abit4 & abit2) | (abit5 & !abit2)) << 1) +
-        (int)(!abit5 & !abit2),
-        ((int)(!abit4 & !abit5) << 1) +
-        (int)(abit5) 
-      }
-    };
-    int zero_bits[2][3] = {
-      {bit0, bit1, bit3},
-      {abit0, abit1, abit3}
-    };
-    int nbit3 = zero_bits[0][2] ^ zero_bits[1][indexes[0][2]];
-    int nbit1 = zero_bits[0][1] ^ zero_bits[1][indexes[0][1]];
-    int nbit0 = zero_bits[0][0] ^ zero_bits[1][indexes[0][0]];
-    indexes[0][0] = indexes[1][indexes[0][0]];
-    indexes[0][1] = indexes[1][indexes[0][1]];
-    indexes[0][2] = indexes[1][indexes[0][2]];
-    int nbit5 = (indexes[0][2] == 1);
-    int nbit4 = (indexes[0][2] == 0);
-    int nbit2 = (!(nbit5 | nbit4) & (bool)(indexes[0][0] & 1)) | //swap xy
-      (nbit5 & ((indexes[0][0] & 2) >> 1)) | //z->y x->z
-      (nbit4 & ((indexes[0][1] & 2) >> 1));  //z->x y->z
-    atr_ = (ATR)((nbit5 << 5) + 
-                 (nbit4 << 4) + 
-                 (nbit3 << 3) + 
-                 (nbit2 << 2) + 
-                 (nbit1 << 1) + nbit0);
-    return *this;
-  }
-  
-  inline axis_transformation axis_transformation::operator+(const axis_transformation& a) const {
-    axis_transformation retval(*this);
-    return retval+=a;
-  }
-  
-  // populate_axis_array writes the three INDIVIDUAL_AXIS values that the
-  // ATR enum value of 'this' represent into axis_array
-  inline void axis_transformation::populate_axis_array(INDIVIDUAL_AXIS axis_array[]) const {
-    bool bit5 = atr_ & 32;
-    bool bit4 = atr_ & 16;
-    bool bit3 = atr_ & 8;
-    bool bit2 = atr_ & 4;
-    bool bit1 = atr_ & 2;
-    bool bit0 = atr_ & 1;      
-    axis_array[2] = 
-      (INDIVIDUAL_AXIS)((((int)(!bit4 & !bit5)) << 2) +
-                        ((int)(bit5) << 1) + 
-                        bit3);
-    axis_array[1] = 
-      (INDIVIDUAL_AXIS)((((int)((bit4 & bit2) | (bit5 & !bit2))) << 2)+
-                        ((int)(!bit5 & !bit2) << 1) + 
-                        bit1);
-    axis_array[0] = 
-      (INDIVIDUAL_AXIS)((((int)((bit5 & bit2) | (bit4 & !bit2))) << 2) +
-                        ((int)(bit2 & !bit5) << 1) + 
-                        bit0);
-  }
-  
-  // combine_axis_arrays concatenates this_array and that_array overwriting
-  // the result into this_array
-  inline void 
-  axis_transformation::combine_axis_arrays (INDIVIDUAL_AXIS this_array[],
-                                            const INDIVIDUAL_AXIS that_array[]){
-    int indexes[3] = {this_array[0] >> 1,
-                      this_array[1] >> 1,
-                      this_array[2] >> 1};
-    int zero_bits[2][3] = {
-      {this_array[0] & 1, this_array[1] & 1, this_array[2] & 1},
-      {that_array[0] & 1, that_array[1] & 1, that_array[2] & 1}
-    };
-    this_array[0] = that_array[indexes[0]];
-    this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] & (int)((int)PZ+(int)PY));
-    this_array[0] = (INDIVIDUAL_AXIS)((int)this_array[0] | 
-                                      ((int)zero_bits[0][0] ^ 
-                                       (int)zero_bits[1][indexes[0]]));
-    this_array[1] = that_array[indexes[1]];
-    this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] & (int)((int)PZ+(int)PY));
-    this_array[1] = (INDIVIDUAL_AXIS)((int)this_array[1] | 
-                                      ((int)zero_bits[0][1] ^ 
-                                       (int)zero_bits[1][indexes[1]]));
-    this_array[2] = that_array[indexes[2]];
-    this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] & (int)((int)PZ+(int)PY));
-    this_array[2] = (INDIVIDUAL_AXIS)((int)this_array[2] | 
-                                      ((int)zero_bits[0][2] ^ 
-                                       (int)zero_bits[1][indexes[2]]));
-  }
-  
-  // write_back_axis_array converts an array of three INDIVIDUAL_AXIS values
-  // to the ATR enum value and sets 'this' to that value
-  inline void axis_transformation::write_back_axis_array(const INDIVIDUAL_AXIS this_array[]) {
-    int bit5 = (bool)((int)this_array[2] & 2);
-    int bit4 = !((bool)((int)this_array[2] & 4) | (bool)((int)this_array[2] & 2));
-    int bit3 = (bool)((int)this_array[2] & 1);
-    //bit 2 is the tricky bit
-    int bit2 = (!(bit5 | bit4) & (bool)((int)this_array[0] & 2)) | //swap xy
-      (bit5 & (((int)this_array[0] & 4) >> 2)) | //z->y x->z
-      (bit4 & (((int)this_array[1] & 4) >> 2));  //z->x y->z
-    int bit1 = ((int)this_array[1] & 1);
-    int bit0 = ((int)this_array[0] & 1);
-    atr_ = ATR((bit5 << 5) + 
-               (bit4 << 4) + 
-               (bit3 << 3) + 
-               (bit2 << 2) + 
-               (bit1 << 1) + bit0);
-  }
-  
-  // behavior is deterministic but undefined in the case where illegal
-  // combinations of directions are passed in. 
-  inline axis_transformation& 
-  axis_transformation::set_directions(const direction_2d& horizontalDir,
-                                      const direction_2d& verticalDir){
-    int bit2 = bool(static_cast<orientation_2d>(horizontalDir).to_int());
-    int bit1 = !(verticalDir.to_int() & 1);
-    int bit0 = !(horizontalDir.to_int() & 1);
-    atr_ = ATR((bit2 << 2) + (bit1 << 1) + bit0);
-    return *this;
-  }
-  
-  // behavior is deterministic but undefined in the case where illegal
-  // combinations of directions are passed in.
-  inline axis_transformation& axis_transformation::set_directions(const direction_3d& horizontalDir,
-                                                                  const direction_3d& verticalDir,
-                                                                  const direction_3d& proximalDir){
-    int this_array[3] = {horizontalDir.to_int(),
-                         verticalDir.to_int(),
-                         proximalDir.to_int()};
-    int bit5 = (bool)(this_array[2] & 2);
-    int bit4 = !((bool)(this_array[2] & 4) | (bool)(this_array[2] & 2));
-    int bit3 = !(bool)(this_array[2] & 1);
-    //bit 2 is the tricky bit
-    int bit2 = (!(bit5 | bit4) & (bool)(this_array[0] & 2)) | //swap xy
-      (bit5 & ((this_array[0] & 4) >> 2)) | //z->y x->z
-      (bit4 & ((this_array[1] & 4) >> 2));  //z->x y->z
-    int bit1 = !(this_array[1] & 1);
-    int bit0 = !(this_array[0] & 1);
-    atr_ = ATR((bit5 << 5) + 
-               (bit4 << 4) + 
-               (bit3 << 3) + 
-               (bit2 << 2) + 
-               (bit1 << 1) + bit0);
-    return *this;
-  }
-  
-  template <typename coordinate_type_2>
-  inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y) const {
-    int bit2 = (bool)(atr_ & 4);
-    int bit1 = (bool)(atr_ & 2);
-    int bit0 = (bool)(atr_ & 1);
-    x *= -((bit0 << 1) - 1);
-    y *= -((bit1 << 1) - 1);    
-    predicated_swap(bit2,x,y);
-  }
-  
-  template <typename coordinate_type_2>
-  inline void axis_transformation::transform(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
-    int bit5 = (bool)(atr_ & 32);
-    int bit4 = (bool)(atr_ & 16);
-    int bit3 = (bool)(atr_ & 8);
-    int bit2 = (bool)(atr_ & 4);
-    int bit1 = (bool)(atr_ & 2);
-    int bit0 = (bool)(atr_ & 1);
-    x *= -((bit0 << 1) - 1);
-    y *= -((bit1 << 1) - 1);    
-    z *= -((bit3 << 1) - 1);
-    predicated_swap(bit2, x, y);
-    predicated_swap(bit5, y, z);
-    predicated_swap(bit4, x, z);
-  }
-  
-  inline axis_transformation& axis_transformation::invert_2d() {
-    int bit2 = (bool)(atr_ & 4);
-    int bit1 = (bool)(atr_ & 2);
-    int bit0 = (bool)(atr_ & 1);
-    //swap bit 0 and bit 1 if bit2 is 1
-    predicated_swap(bit2, bit0, bit1);
-    bit1 = bit1 << 1;
-    atr_ = (ATR)(atr_ & (32+16+8+4)); //mask away bit0 and bit1
-    atr_ = (ATR)(atr_ | bit0 | bit1);
-    return *this;
-  }
-  
-  inline axis_transformation axis_transformation::inverse_2d() const {
-    axis_transformation retval(*this);
-    return retval.invert_2d();
-  }
-  
-  inline axis_transformation& axis_transformation::invert() {
-    int bit5 = (bool)(atr_ & 32);
-    int bit4 = (bool)(atr_ & 16);    
-    int bit3 = (bool)(atr_ & 8);
-    int bit2 = (bool)(atr_ & 4);
-    int bit1 = (bool)(atr_ & 2);
-    int bit0 = (bool)(atr_ & 1);
-    predicated_swap(bit2, bit4, bit5);
-    predicated_swap(bit4, bit0, bit3);
-    predicated_swap(bit5, bit1, bit3);
-    predicated_swap(bit2, bit0, bit1);
-    atr_ = (ATR)((bit5 << 5) + 
-                 (bit4 << 4) + 
-                 (bit3 << 3) + 
-                 (bit2 << 2) + 
-                 (bit1 << 1) + bit0);
-    return *this;
-  }
-  
-  inline axis_transformation axis_transformation::inverse() const {
-    axis_transformation retval(*this);
-    return retval.invert();
-  }
-  
-  template <typename scale_factor_type>
-  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::get(orientation_3d orient) const {
-    return scale_[orient.to_int()];
-  }
-  
-  template <typename scale_factor_type>
-  inline void anisotropic_scale_factor<scale_factor_type>::set(orientation_3d orient, scale_factor_type value) {
-    scale_[orient.to_int()] = value;
-  }
-
-  template <typename scale_factor_type>
-  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::x() const { return scale_[HORIZONTAL]; }
-  template <typename scale_factor_type>
-  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::y() const { return scale_[VERTICAL]; }
-  template <typename scale_factor_type>
-  inline scale_factor_type anisotropic_scale_factor<scale_factor_type>::z() const { return scale_[PROXIMAL]; }
-  template <typename scale_factor_type>
-  inline void anisotropic_scale_factor<scale_factor_type>::x(scale_factor_type value) { scale_[HORIZONTAL] = value; }
-  template <typename scale_factor_type>
-  inline void anisotropic_scale_factor<scale_factor_type>::y(scale_factor_type value) { scale_[VERTICAL] = value; }
-  template <typename scale_factor_type>
-  inline void anisotropic_scale_factor<scale_factor_type>::z(scale_factor_type value) { scale_[PROXIMAL] = value; }
-  
-  //concatenation operator (convolve scale factors)
-  template <typename scale_factor_type>
-  inline anisotropic_scale_factor<scale_factor_type> anisotropic_scale_factor<scale_factor_type>::operator+(const anisotropic_scale_factor<scale_factor_type>& s) const {
-    anisotropic_scale_factor<scale_factor_type> retval(*this);
-    return retval+=s;
-  }
-  
-  //concatenate this with that
-  template <typename scale_factor_type>
-  inline const anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::operator+=(const anisotropic_scale_factor<scale_factor_type>& s){
-    scale_[0] *= s.scale_[0];
-    scale_[1] *= s.scale_[1];
-    scale_[2] *= s.scale_[2];
-    return *this;
-  }
-  
-  //transform
-  template <typename scale_factor_type>
-  inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::transform(axis_transformation atr){
-    direction_3d dirs[3];
-    atr.get_directions(dirs[0],dirs[1],dirs[2]);
-    scale_factor_type tmp[3] = {scale_[0], scale_[1], scale_[2]};
-    for(int i = 0; i < 3; ++i){
-      scale_[orientation_3d(dirs[i]).to_int()] = tmp[i];
-    }
-    return *this;
-  }
-
-  template <typename scale_factor_type>
-  template <typename coordinate_type_2>
-  inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y) const {
-    x = scaling_policy<coordinate_type_2>::round((scale_factor_type)x * get(HORIZONTAL));
-    y = scaling_policy<coordinate_type_2>::round((scale_factor_type)y * get(HORIZONTAL));
-  }
-
-  template <typename scale_factor_type>
-  template <typename coordinate_type_2>
-  inline void anisotropic_scale_factor<scale_factor_type>::scale(coordinate_type_2& x, coordinate_type_2& y, coordinate_type_2& z) const {
-    scale(x, y);
-    z = scaling_policy<coordinate_type_2>::round((scale_factor_type)z * get(HORIZONTAL));
-  }
-
-  template <typename scale_factor_type>
-  inline anisotropic_scale_factor<scale_factor_type>& anisotropic_scale_factor<scale_factor_type>::invert() {
-    x(1/x());
-    y(1/y());
-    z(1/z());
-    return *this;
-  }
-
-
-  template <typename coordinate_type>
-  inline transformation<coordinate_type>::transformation() : atr_(), p_(0, 0, 0) {;}
-
-  template <typename coordinate_type>
-  inline transformation<coordinate_type>::transformation(axis_transformation atr) : atr_(atr), p_(0, 0, 0){;}
-
-  template <typename coordinate_type>
-  inline transformation<coordinate_type>::transformation(axis_transformation::ATR atr) : atr_(atr), p_(0, 0, 0){;}
-
-  template <typename coordinate_type>
-  template <typename point_type>
-  inline transformation<coordinate_type>::transformation(const point_type& p) : atr_(), p_(0, 0, 0) {
-    set_translation(p);
-  }
-
-  template <typename coordinate_type>
-  template <typename point_type>
-  inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& p) :
-    atr_(atr), p_(0, 0, 0) {
-    set_translation(p);
-  }
-
-  template <typename coordinate_type>
-  template <typename point_type>
-  inline transformation<coordinate_type>::transformation(axis_transformation atr, const point_type& referencePt, const point_type& destinationPt) : atr_(), p_(0, 0, 0) {
-    transformation<coordinate_type> tmp(referencePt);
-    transformation<coordinate_type> rotRef(atr);
-    transformation<coordinate_type> tmpInverse = tmp.inverse();
-    point_type decon(referencePt);
-    deconvolve(decon, destinationPt);
-    transformation<coordinate_type> displacement(decon);
-    tmp += rotRef;
-    tmp += tmpInverse;
-    tmp += displacement;
-    (*this) = tmp;
-  }
-
-  template <typename coordinate_type>
-  inline transformation<coordinate_type>::transformation(const transformation<coordinate_type>& tr) : 
-    atr_(tr.atr_), p_(tr.p_) {;}
-  
-  template <typename coordinate_type>
-  inline bool transformation<coordinate_type>::operator==(const transformation<coordinate_type>& tr) const {
-    return atr_ == tr.atr_ && p_ == tr.p_;
-  }
-  
-  template <typename coordinate_type>
-  inline bool transformation<coordinate_type>::operator!=(const transformation<coordinate_type>& tr) const {
-    return !(*this == tr);
-  }
-  
-  template <typename coordinate_type>
-  inline bool transformation<coordinate_type>::operator<(const transformation<coordinate_type>& tr) const {
-    return atr_ < tr.atr_ || atr_ == tr.atr_ && p_ < tr.p_;
-  }
-  
-  template <typename coordinate_type>
-  inline transformation<coordinate_type> transformation<coordinate_type>::operator+(const transformation<coordinate_type>& tr) const {
-    transformation<coordinate_type> retval(*this);
-    return retval+=tr;
-  }
-  
-  template <typename coordinate_type>
-  inline const transformation<coordinate_type>& transformation<coordinate_type>::operator+=(const transformation<coordinate_type>& tr){
-    //apply the inverse transformation of this to the translation point of that
-    //and convolve it with this translation point
-    coordinate_type x, y, z;
-    transformation<coordinate_type> inv = inverse();
-    inv.transform(x, y, z);
-    p_.set(HORIZONTAL, p_.get(HORIZONTAL) + x);
-    p_.set(VERTICAL, p_.get(VERTICAL) + y);
-    p_.set(PROXIMAL, p_.get(PROXIMAL) + z);
-    //concatenate axis transforms
-    atr_ += tr.atr_;
-    return *this;
-  }
-  
-  template <typename coordinate_type>
-  inline void transformation<coordinate_type>::set_axis_transformation(const axis_transformation& atr) {
-    atr_ = atr;
-  }
-  
-  template <typename coordinate_type>
-  template <typename point_type>
-  inline void transformation<coordinate_type>::get_translation(point_type& p) const {
-    assign(p, p_);
-  }
-  
-  template <typename coordinate_type>
-  template <typename point_type>
-  inline void transformation<coordinate_type>::set_translation(const point_type& p) {
-    assign(p_, p);
-  }
-  
-  template <typename coordinate_type>
-  inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y) const {
-    //subtract each component of new origin point
-    y -= p_.get(VERTICAL);
-    x -= p_.get(HORIZONTAL);
-    atr_.transform(x, y);
-  }
-
-  template <typename coordinate_type>
-  inline void transformation<coordinate_type>::transform(coordinate_type& x, coordinate_type& y, coordinate_type& z) const {
-    //subtract each component of new origin point
-    z -= p_.get(PROXIMAL);
-    y -= p_.get(VERTICAL);
-    x -= p_.get(HORIZONTAL);
-    atr_.transform(x,y,z);
-  }
-  
-  // sets the axis_transform portion to its inverse
-  // transforms the tranlastion portion by that inverse axis_transform
-  // multiplies the translation portion by -1 to reverse it
-  template <typename coordinate_type>
-  inline transformation<coordinate_type>& transformation<coordinate_type>::invert() {
-    coordinate_type x = p_.get(HORIZONTAL), y = p_.get(VERTICAL), z = p_.get(PROXIMAL);
-    atr_.transform(x, y, z);
-    x *= -1;
-    y *= -1;
-    z *= -1;
-    p_ = point_3d_data<coordinate_type>(x, y, z);
-    atr_.invert();
-    return *this;
-  }
-  
-  template <typename coordinate_type>
-  inline transformation<coordinate_type> transformation<coordinate_type>::inverse() const {
-    transformation<coordinate_type> retval(*this);
-    return retval.invert();
-  }
-}
-}
-#endif
-
-