Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66485 - in branches/release/boost/polygon: . detail
From: lucanus.j.simonson_at_[hidden]
Date: 2010-11-10 13:07:54


Author: ljsimons
Date: 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
New Revision: 66485
URL: http://svn.boost.org/trac/boost/changeset/66485

Log:
merge from trunk
Text files modified:
   branches/release/boost/polygon/detail/boolean_op_45.hpp | 2
   branches/release/boost/polygon/detail/iterator_geometry_to_set.hpp | 14 ++
   branches/release/boost/polygon/detail/max_cover.hpp | 2
   branches/release/boost/polygon/detail/polygon_45_formation.hpp | 42 ++++----
   branches/release/boost/polygon/detail/polygon_45_set_view.hpp | 2
   branches/release/boost/polygon/detail/polygon_45_touch.hpp | 2
   branches/release/boost/polygon/detail/polygon_90_set_view.hpp | 176 +++++++++++++++++++++++++--------------
   branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp | 68 +++++++++-----
   branches/release/boost/polygon/detail/property_merge.hpp | 6
   branches/release/boost/polygon/detail/property_merge_45.hpp | 2
   branches/release/boost/polygon/detail/scan_arbitrary.hpp | 35 ++++---
   branches/release/boost/polygon/gmp_override.hpp | 2
   branches/release/boost/polygon/interval_concept.hpp | 2
   branches/release/boost/polygon/isotropy.hpp | 12 ++
   branches/release/boost/polygon/polygon.hpp | 1
   branches/release/boost/polygon/polygon_45_set_data.hpp | 14 +-
   branches/release/boost/polygon/polygon_90_set_data.hpp | 94 +++++++++++---------
   branches/release/boost/polygon/polygon_set_data.hpp | 92 ++++++++++----------
   18 files changed, 330 insertions(+), 238 deletions(-)

Modified: branches/release/boost/polygon/detail/boolean_op_45.hpp
==============================================================================
--- branches/release/boost/polygon/detail/boolean_op_45.hpp (original)
+++ branches/release/boost/polygon/detail/boolean_op_45.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -445,7 +445,7 @@
     };
     template <typename S45V>
     static inline void sortScan45Vector(S45V& vec) {
- std::sort(vec.begin(), vec.end(), lessScan45Vertex());
+ gtlsort(vec.begin(), vec.end(), lessScan45Vertex());
     }
 
     template <typename CountType, typename output_functor>

Modified: branches/release/boost/polygon/detail/iterator_geometry_to_set.hpp
==============================================================================
--- branches/release/boost/polygon/detail/iterator_geometry_to_set.hpp (original)
+++ branches/release/boost/polygon/detail/iterator_geometry_to_set.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -253,8 +253,13 @@
             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>();
+ //in this case we have no holes so we just need the iterhib == itrhie, which
+ //is always true if they were default initialized in the initial case or
+ //both point to end of the previous hole processed
+ //no need to explicitly reset them, and it causes an stl debug assertion to use
+ //the default constructed iterator this way
+ //itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept,
+ // typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
         }
       } else {
         ++itrhib;
@@ -266,8 +271,9 @@
               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>();
+ //this is the same case as above
+ //itrhib = itrhie = iterator_geometry_to_set<polygon_90_concept,
+ // typename polygon_with_holes_traits<polygon_with_holes_type>::hole_type>();
           }
         }
       }

Modified: branches/release/boost/polygon/detail/max_cover.hpp
==============================================================================
--- branches/release/boost/polygon/detail/max_cover.hpp (original)
+++ branches/release/boost/polygon/detail/max_cover.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -213,7 +213,7 @@
         Interval rectIvl = nodep->rect.get(orient);
         leadingEdges.push_back(EdgeAssociation(std::pair<Unit, Interval>(leading, rectIvl), nodep));
       }
- std::sort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation());
+ gtlsort(leadingEdges.begin(), leadingEdges.end(), lessEdgeAssociation());
       typename std::vector<EdgeAssociation>::iterator leadingBegin = leadingEdges.begin();
       iT trailingBegin = beginNode;
       while(leadingBegin != leadingEdges.end()) {

Modified: branches/release/boost/polygon/detail/polygon_45_formation.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_45_formation.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_45_formation.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -478,7 +478,7 @@
       ct counts[4];
     };
 
- typedef Vertex45CountT<signed char> Vertex45Count;
+ typedef Vertex45CountT<int> Vertex45Count;
 
 // inline std::ostream& operator<< (std::ostream& o, const Vertex45Count& c) {
 // o << c[0] << ", " << c[1] << ", ";
@@ -904,7 +904,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -928,7 +928,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -953,7 +953,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1018,7 +1018,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1051,7 +1051,7 @@
       stdcout << "scanning\n";
       scan45.scan(result, vertices.begin(), vertices.end());
    
- std::sort(result.begin(), result.end());
+ gtlsort(result.begin(), result.end());
       pf.scan(polys, result.begin(), result.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1123,7 +1123,7 @@
       data.push_back(Vertex45(Point(8, 6), -1, -1));
       data.push_back(Vertex45(Point(8, 6), 1, 1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1195,7 +1195,7 @@
       data.push_back(Vertex45(Point(10, 8), -1, -1));
       data.push_back(Vertex45(Point(10, 8), 1, 1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1239,7 +1239,7 @@
       data.push_back(Vertex45(Point(10, 22), 2, -1));
       data.push_back(Vertex45(Point(10, 22), 0, -1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1668,7 +1668,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1692,7 +1692,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1716,7 +1716,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1742,7 +1742,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1768,7 +1768,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1801,7 +1801,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1835,7 +1835,7 @@
       data.push_back(Vertex45(Point(2, 2), 2, -1));
       data.push_back(Vertex45(Point(2, 2), 0, -1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1899,7 +1899,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1933,7 +1933,7 @@
       stdcout << "scanning\n";
       scan45.scan(result, vertices.begin(), vertices.end());
    
- std::sort(result.begin(), result.end());
+ gtlsort(result.begin(), result.end());
       pf.scan(polys, result.begin(), result.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2005,7 +2005,7 @@
       data.push_back(Vertex45(Point(8, 6), -1, -1));
       data.push_back(Vertex45(Point(8, 6), 1, 1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2077,7 +2077,7 @@
       data.push_back(Vertex45(Point(10, 8), -1, -1));
       data.push_back(Vertex45(Point(10, 8), 1, 1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2121,7 +2121,7 @@
       data.push_back(Vertex45(Point(10, 22), 2, -1));
       data.push_back(Vertex45(Point(10, 22), 0, -1));
 
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {

Modified: branches/release/boost/polygon/detail/polygon_45_set_view.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_45_set_view.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_45_set_view.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -119,7 +119,7 @@
     // orient_ = orient;
     // output_.clear();
     // output_.insert(output_.end(), input_begin, input_end);
- // std::sort(output_.begin(), output_.end());
+ // gtlsort(output_.begin(), output_.end());
     // }
   };
 

Modified: branches/release/boost/polygon/detail/polygon_45_touch.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_45_touch.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_45_touch.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -186,7 +186,7 @@
     template <typename graph_type>
     static void performTouch(graph_type& graph, TouchSetData& tsd) {
       
- std::sort(tsd.begin(), tsd.end(), lessVertex45Compact());
+ gtlsort(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());

Modified: branches/release/boost/polygon/detail/polygon_90_set_view.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_90_set_view.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_90_set_view.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -33,56 +33,91 @@
     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 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_);
+ orientation_2d orient_l = polygon_90_set_traits<ltype>::orient(lvalue_);
+ orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
+ //std::cout << "compute_90_set_value-0 orientations (left, right, out):\t" << orient_l.to_int()
+ // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
+ insert_into_view_arg(linput_, lvalue_, orient_l);
+ insert_into_view_arg(rinput_, rvalue_, orient_r);
+ 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) {
- 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 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_) {
+ orientation_2d orient_l = lvalue_.orient();
+ orientation_2d orient_r = rvalue_.orient();
+ value_type linput_(orient_);
+ value_type rinput_(orient_);
+ //std::cout << "compute_90_set_value-1 orientations (left, right, out):\t" << orient_l.to_int()
+ // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
+ if((orient_ == orient_l) && (orient_== orient_r)){ // assume that most of the time this condition is met
+ lvalue_.sort();
+ rvalue_.sort();
+ output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+ rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
+ }else if((orient_ != orient_l) && (orient_!= orient_r)){ // both the orientations are not equal to input
+ // easier way is to ignore the input orientation and use the input data's orientation, but not done so
+ insert_into_view_arg(linput_, lvalue_, orient_l);
+ insert_into_view_arg(rinput_, rvalue_, orient_r);
+ output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+ rinput_.begin(), rinput_.end(), boolean_op::BinaryCount<op_type>());
+ }else if(orient_ != orient_l){ // left hand side orientation is different
+ insert_into_view_arg(linput_, lvalue_, orient_l);
+ rvalue_.sort();
+ output_.applyBooleanBinaryOp(linput_.begin(), linput_.end(),
+ rvalue_.begin(), rvalue_.end(), boolean_op::BinaryCount<op_type>());
+ } else if(orient_ != orient_r){ // right hand side orientation is different
+ insert_into_view_arg(rinput_, rvalue_, orient_r);
+ lvalue_.sort();
+ output_.applyBooleanBinaryOp(lvalue_.begin(), lvalue_.end(),
+ rinput_.begin(), rinput_.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 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();
+ orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
+ //std::cout << "compute_90_set_value-2 orientations (right, out):\t" << orient_r.to_int()
+ // << "," << orient_.to_int() << std::endl;
+ insert_into_view_arg(rinput_, rvalue_, orient_r);
+ 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 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_);
+ orientation_2d orient_l = polygon_90_set_traits<ltype>::orient(lvalue_);
+ insert_into_view_arg(linput_, lvalue_, orient_l);
+ rvalue_.sort();
+ //std::cout << "compute_90_set_value-3 orientations (left, out):\t" << orient_l.to_int()
+ // << "," << orient_.to_int() << std::endl;
+
+ 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 {
@@ -129,7 +164,7 @@
 // orient_ = orient;
 // output_.clear();
 // output_.insert(output_.end(), input_begin, input_end);
-// std::sort(output_.begin(), output_.end());
+// gtlsort(output_.begin(), output_.end());
 // }
     void sort() const {} //is always sorted
   };
@@ -206,23 +241,34 @@
     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 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_);
+ //BM: rvalue_ data set may have its own orientation for scanline
+ orientation_2d orient_r = polygon_90_set_traits<rtype>::orient(rvalue_);
+ //std::cout << "self-assignment boolean-op (left, right, out):\t" << orient_.to_int()
+ // << "," << orient_r.to_int() << "," << orient_.to_int() << std::endl;
+ value_type linput_(orient_);
+ // BM: the rinput_ set's (that stores the rvalue_ dataset polygons) scanline orientation is *forced*
+ // to be same as linput
+ value_type rinput_(orient_);
+ //BM: The output dataset's scanline orient is set as equal to first input dataset's (lvalue_) orientation
+ value_type output_(orient_);
+ insert_into_view_arg(linput_, lvalue_, orient_);
+ // BM: The last argument orient_r is the user initialized scanline orientation for rvalue_ data set.
+ // But since rinput (see above) is initialized to scanline orientation consistent with the lvalue_
+ // data set, this insertion operation will change the incoming rvalue_ dataset's scanline orientation
+ insert_into_view_arg(rinput_, rvalue_, orient_r);
+ // BM: boolean operation and output uses lvalue_ dataset's scanline orientation.
+ 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_;
+ }
   
   namespace operators {
   struct y_ps90_b : gtl_yes {};

Modified: branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp
==============================================================================
--- branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp (original)
+++ branches/release/boost/polygon/detail/polygon_arbitrary_formation.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -455,6 +455,10 @@
         //truncate downward if it went up due to negative number
         if(x < x_unit) --x_unit;
         if(y < y_unit) --y_unit;
+ if(is_horizontal(he1))
+ y_unit = he1.first.y();
+ if(is_horizontal(he2))
+ y_unit = he2.first.y();
         //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);
@@ -464,11 +468,11 @@
         if(!projected && !contains(rect1, result, true)) return false;
         if(!projected && !contains(rect2, result, true)) return false;
         if(projected) {
- rectangle_data<long double> inf_rect((long double)(std::numeric_limits<Unit>::min)(),
- (long double) (std::numeric_limits<Unit>::min)(),
+ rectangle_data<long double> inf_rect(-(long double)(std::numeric_limits<Unit>::max)(),
+ -(long double) (std::numeric_limits<Unit>::max)(),
                                                (long double)(std::numeric_limits<Unit>::max)(),
                                                (long double) (std::numeric_limits<Unit>::max)() );
- if(contains(inf_rect, intersection, true)) {
+ if(contains(inf_rect, point_data<long double>(x, y), true)) {
             intersection = result;
             return true;
           } else
@@ -477,6 +481,7 @@
         intersection = result;
         return true;
       }
+
       inline bool compute_intersection(Point& intersection, const half_edge& he1, const half_edge& he2,
                                        bool projected = false, bool round_closest = false) {
         if(!projected && !intersects(he1, he2))
@@ -491,6 +496,13 @@
         } else {
           return lazy_success;
         }
+ return compute_exact_intersection(intersection, he1, he2, projected, round_closest);
+ }
+
+ inline bool compute_exact_intersection(Point& intersection, const half_edge& he1, const half_edge& he2,
+ bool projected = false, bool round_closest = false) {
+ if(!projected && !intersects(he1, he2))
+ return false;
         typedef rectangle_data<Unit> Rectangle;
         Rectangle rect1, rect2;
         set_points(rect1, he1.first, he1.second);
@@ -542,6 +554,7 @@
         y_den = (dx1 * dy2 - dx2 * dy1);
         x = x_num / x_den;
         y = y_num / y_den;
+ //std::cout << x << " " << y << std::endl;
         //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);
@@ -555,6 +568,10 @@
         //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(is_horizontal(he1))
+ y_unit = he1.first.y();
+ if(is_horizontal(he2))
+ y_unit = he2.first.y();
         //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);
@@ -564,14 +581,9 @@
         if(!contains(rect1, result, true)) return false;
         if(!contains(rect2, result, true)) return false;
         if(projected) {
- rectangle_data<long double> inf_rect((long double)(std::numeric_limits<Unit>::min)(),
- (long double) (std::numeric_limits<Unit>::min)(),
- (long double)(std::numeric_limits<Unit>::max)(),
- (long double) (std::numeric_limits<Unit>::max)() );
- if(contains(inf_rect, intersection, true)) {
- intersection = result;
- return true;
- } else
+ high_precision b1 = (high_precision) (std::numeric_limits<Unit>::min)();
+ high_precision b2 = (high_precision) (std::numeric_limits<Unit>::max)();
+ if(x > b2 || y > b2 || x < b1 || y < b1)
             return false;
         }
         intersection = result;
@@ -641,6 +653,10 @@
       //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(is_horizontal(he1))
+ y_unit = he1.first.y();
+ if(is_horizontal(he2))
+ y_unit = he2.first.y();
       //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);
@@ -1203,7 +1219,7 @@
 
     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);
+ gtlsort(count.begin(), count.end(), lfec);
     }
 
     typedef std::vector<std::pair<std::pair<std::pair<Point, Point>, int>, active_tail_arbitrary*> > incoming_count;
@@ -1227,7 +1243,7 @@
 
     static inline void sort_incoming_count(incoming_count& count, const Point& pt) {
       less_incoming_count lfec(pt);
- std::sort(count.begin(), count.end(), lfec);
+ gtlsort(count.begin(), count.end(), lfec);
     }
 
     static inline void compact_vertex_arbitrary_count(const Point& pt, vertex_arbitrary_count &count) {
@@ -1798,7 +1814,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1822,7 +1838,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1846,7 +1862,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1892,7 +1908,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1939,7 +1955,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -1979,7 +1995,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2019,7 +2035,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2047,7 +2063,7 @@
 
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2753,7 +2769,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2776,7 +2792,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2799,7 +2815,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2844,7 +2860,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {
@@ -2891,7 +2907,7 @@
       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());
+ gtlsort(data.begin(), data.end());
       pf.scan(polys, data.begin(), data.end());
       stdcout << "result size: " << polys.size() << std::endl;
       for(std::size_t i = 0; i < polys.size(); ++i) {

Modified: branches/release/boost/polygon/detail/property_merge.hpp
==============================================================================
--- branches/release/boost/polygon/detail/property_merge.hpp (original)
+++ branches/release/boost/polygon/detail/property_merge.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -112,7 +112,7 @@
   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>());
+ gtlsort(data.begin(), data.end(), less_vertex_data<vertex_property>());
     //scanline
     bool firstIteration = true;
     scanlinePosition = scanline.end();
@@ -156,7 +156,7 @@
   class less_vertex_data {
   public:
     less_vertex_data() {}
- bool operator()(const T& lvalue, const T& rvalue) {
+ bool operator()(const T& lvalue, const T& rvalue) const {
       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;
@@ -442,7 +442,7 @@
   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>());
+ gtlsort(data.begin(), data.end(), less_vertex_data<vertex_property>());
     
     //scanline
     bool firstIteration = true;

Modified: branches/release/boost/polygon/detail/property_merge_45.hpp
==============================================================================
--- branches/release/boost/polygon/detail/property_merge_45.hpp (original)
+++ branches/release/boost/polygon/detail/property_merge_45.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -111,7 +111,7 @@
     template <typename output_type>
     static void performMerge(output_type& result, MergeSetData& tsd) {
       
- std::sort(tsd.begin(), tsd.end(), lessVertex45Compact());
+ gtlsort(tsd.begin(), tsd.end(), lessVertex45Compact());
       typedef std::vector<std::pair<Point, typename boolean_op_45<Unit>::template Scan45CountT<CountMerge> > > TSD;
       TSD tsd_;
       tsd_.reserve(tsd.size());

Modified: branches/release/boost/polygon/detail/scan_arbitrary.hpp
==============================================================================
--- branches/release/boost/polygon/detail/scan_arbitrary.hpp (original)
+++ branches/release/boost/polygon/detail/scan_arbitrary.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -10,6 +10,7 @@
 #ifdef BOOST_POLYGON_DEBUG_FILE
 #include <fstream>
 #endif
+#include "polygon_sort_adaptor.hpp"
 namespace boost { namespace polygon{
 
   template <typename Unit>
@@ -75,7 +76,7 @@
         ends.push_back(std::make_pair((*itr).first.first.y(), count));
         ends.push_back(std::make_pair((*itr).first.second.y(), -count));
       }
- std::sort(ends.begin(), ends.end());
+ gtlsort(ends.begin(), ends.end());
       histogram.reserve(ends.size());
       histogram.push_back(std::make_pair(ends.front().first, std::make_pair(0, 0)));
       for(typename std::vector<std::pair<Unit, int> >::iterator itr = ends.begin(); itr != ends.end(); ++itr) {
@@ -160,7 +161,7 @@
         }
       }
       typename scanline_base<Unit>::compute_intersection_pack pack_;
- std::sort(data.begin(), data.end());
+ gtlsort(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) {
@@ -191,11 +192,13 @@
             if(pack_.compute_intersection(intersection, he1, he2)) {
               //their intersection point
               pts.push_back(intersection);
+ intersection_points[(*inner).second].insert(intersection);
+ intersection_points[(*outer).second].insert(intersection);
             }
           }
         }
       }
- std::sort(pts.begin(), pts.end());
+ gtlsort(pts.begin(), pts.end());
       typename std::vector<Point>::iterator newend = std::unique(pts.begin(), pts.end());
       typename std::vector<Point>::iterator lfinger = pts.begin();
       //find all segments that interact with intersection points
@@ -286,7 +289,7 @@
           std::swap(data[i].first.first, data[i].first.second);
         }
       }
- std::sort(data.begin(), data.end());
+ gtlsort(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;
@@ -356,7 +359,7 @@
             tmpPts.reserve(pts.size());
             tmpPts.insert(tmpPts.end(), pts.begin(), pts.end());
             less_point_down_slope lpds;
- std::sort(tmpPts.begin(), tmpPts.end(), lpds);
+ gtlsort(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());
@@ -498,7 +501,7 @@
 // }
         
 // //merge sloping element data
-// std::sort(sloping_ends.begin(), sloping_ends.end());
+// gtlsort(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();
@@ -1310,7 +1313,7 @@
         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());
+ gtlsort(output.begin(), output.end());
     }
 
     class test_functor {
@@ -1514,7 +1517,7 @@
     public:
       less_vertex_data() : pack_() {}
       less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
- bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
+ bool operator() (const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
         less_point lp;
         if(lp(lvalue.first.first, rvalue.first.first)) return true;
         if(lp(rvalue.first.first, lvalue.first.first)) return false;
@@ -1528,7 +1531,7 @@
 
     inline void sort_property_merge_data() {
       less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
- std::sort(pmd.begin(), pmd.end(), lvd);
+ gtlsort(pmd.begin(), pmd.end(), lvd);
     }
   public:
     inline property_merge_data& get_property_merge_data() { return pmd; }
@@ -1573,7 +1576,7 @@
         pts.push_back(lines[i].first.first);
         pts.push_back(lines[i].first.second);
       }
- std::sort(pts.begin(), pts.end());
+ gtlsort(pts.begin(), pts.end());
       for(std::size_t i = 0; i < pts.size(); i+=2) {
         if(pts[i] != pts[i+1]) {
           //stdcout << "Non-closed figures after line intersection!\n";
@@ -1683,7 +1686,7 @@
 
     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);
+ gtlsort(vertex.second.begin(), vertex.second.end(), lessF);
     }
 
     class less_half_edge_pair {
@@ -2165,7 +2168,7 @@
           outpts.push_back((*itr).first.first);
           outpts.push_back((*itr).first.second);
         }
- std::sort(outpts.begin(), outpts.end());
+ gtlsort(outpts.begin(), outpts.end());
         for(std::size_t i = 0; i < outpts.size(); i+=2) {
           if(outpts[i] != outpts[i+1]) {
             stdcout << "Polygon set not a closed figure\n";
@@ -2514,7 +2517,7 @@
     public:
       less_vertex_data() : pack_() {}
       less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
- bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
+ bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
         less_point lp;
         if(lp(lvalue.first.first, rvalue.first.first)) return true;
         if(lp(rvalue.first.first, lvalue.first.first)) return false;
@@ -2580,7 +2583,7 @@
 
     inline void sort_property_merge_data() {
       less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
- std::sort(pmd.begin(), pmd.end(), lvd);
+ gtlsort(pmd.begin(), pmd.end(), lvd);
     }
   public:
     inline arbitrary_boolean_op() : pmd(), evalAtXforYPack_() {}
@@ -2732,7 +2735,7 @@
     public:
       less_vertex_data() : pack_() {}
       less_vertex_data(typename scanline_base<Unit>::evalAtXforYPack* pack) : pack_(pack) {}
- bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) {
+ bool operator()(const vertex_data_type& lvalue, const vertex_data_type& rvalue) const {
         less_point lp;
         if(lp(lvalue.first.first, rvalue.first.first)) return true;
         if(lp(rvalue.first.first, lvalue.first.first)) return false;
@@ -2804,7 +2807,7 @@
 
     inline void sort_property_merge_data() {
       less_vertex_data<vertex_property> lvd(&evalAtXforYPack_);
- std::sort(pmd.begin(), pmd.end(), lvd);
+ gtlsort(pmd.begin(), pmd.end(), lvd);
     }
   public:
     inline arbitrary_connectivity_extraction() : pmd(), evalAtXforYPack_() {}

Modified: branches/release/boost/polygon/gmp_override.hpp
==============================================================================
--- branches/release/boost/polygon/gmp_override.hpp (original)
+++ branches/release/boost/polygon/gmp_override.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -125,5 +125,5 @@
 
 }
 }
-
+//==
 #endif

Modified: branches/release/boost/polygon/interval_concept.hpp
==============================================================================
--- branches/release/boost/polygon/interval_concept.hpp (original)
+++ branches/release/boost/polygon/interval_concept.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -471,7 +471,7 @@
     typedef typename interval_traits<interval_type>::coordinate_type Unit;
     Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
     //consider implementing faster sorting of small fixed length range
- std::sort(coords, coords+4);
+ gtlsort(coords, coords+4);
     low(interval, coords[1]);
     high(interval, coords[2]);
     return interval;

Modified: branches/release/boost/polygon/isotropy.hpp
==============================================================================
--- branches/release/boost/polygon/isotropy.hpp (original)
+++ branches/release/boost/polygon/isotropy.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -198,6 +198,16 @@
     typedef double coordinate_distance;
   };
 
+ template <>
+ struct coordinate_traits<long double> {
+ typedef long double coordinate_type;
+ typedef long double area_type;
+ typedef long double manhattan_area_type;
+ typedef long double unsigned_area_type;
+ typedef long double coordinate_difference;
+ typedef long double coordinate_distance;
+ };
+
   template <typename T>
   struct scaling_policy {
     template <typename T2>
@@ -222,6 +232,8 @@
   struct geometry_concept<float> { typedef coordinate_concept type; };
   template <>
   struct geometry_concept<double> { typedef coordinate_concept type; };
+ template <>
+ struct geometry_concept<long double> { typedef coordinate_concept type; };
 
 #ifndef BOOST_POLYGON_NO_DEPS
   struct gtl_no : mpl::bool_<false> {};

Modified: branches/release/boost/polygon/polygon.hpp
==============================================================================
--- branches/release/boost/polygon/polygon.hpp (original)
+++ branches/release/boost/polygon/polygon.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -7,6 +7,7 @@
 */
 #ifndef BOOST_POLYGON_POLYGON_HPP
 #define BOOST_POLYGON_POLYGON_HPP
+#define BOOST_POLYGON_VERSION 014401
 
 #include "isotropy.hpp"
 

Modified: branches/release/boost/polygon/polygon_45_set_data.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_45_set_data.hpp (original)
+++ branches/release/boost/polygon/polygon_45_set_data.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -212,7 +212,7 @@
 
     void sort() const{
       if(unsorted_) {
- std::sort(data_.begin(), data_.end());
+ gtlsort(data_.begin(), data_.end());
         unsorted_ = false;
       }
     }
@@ -1262,7 +1262,7 @@
         //std::cout << "SCAN " << currentX << "\n";
         //scan event
         scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
+ gtlsort(eventOut.begin(), eventOut.end());
         std::size_t ptCount = 0;
         for(std::size_t i = 0; i < eventOut.size(); ++i) {
           if(!result_data.empty() &&
@@ -1333,7 +1333,7 @@
       }
     }
     scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
+ gtlsort(eventOut.begin(), eventOut.end());
 
     std::size_t ptCount = 0;
     for(std::size_t i = 0; i < eventOut.size(); ++i) {
@@ -1385,7 +1385,7 @@
         //std::cout << "SCAN " << currentX << "\n";
         //scan event
         scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
+ gtlsort(eventOut.begin(), eventOut.end());
         std::size_t ptCount = 0;
         for(std::size_t i = 0; i < eventOut.size(); ++i) {
           if(!result_data.empty() &&
@@ -1422,7 +1422,7 @@
       ++iter1;
     }
     scan45.scan(eventOut, eventIn.begin(), eventIn.end());
- std::sort(eventOut.begin(), eventOut.end());
+ gtlsort(eventOut.begin(), eventOut.end());
 
     std::size_t ptCount = 0;
     for(std::size_t i = 0; i < eventOut.size(); ++i) {
@@ -1639,7 +1639,7 @@
               result.error_data_.push_back(ci);
             }
             Data2 new_result_data;
- std::sort(result_data.begin(), result_data.end());
+ gtlsort(result_data.begin(), result_data.end());
             applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
             result_data.swap(new_result_data);
           }
@@ -1749,7 +1749,7 @@
               result.error_data_.push_back(ci);
             }
             Data2 new_result_data;
- std::sort(result_data.begin(), result_data.end());
+ gtlsort(result_data.begin(), result_data.end());
             applyUnary45OpOnVectors<Unit2, 0>(new_result_data, result_data); //OR operation
             result_data.swap(new_result_data);
           }

Modified: branches/release/boost/polygon/polygon_90_set_data.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_90_set_data.hpp (original)
+++ branches/release/boost/polygon/polygon_90_set_data.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -244,37 +244,47 @@
     // get the scanline orientation of the polygon set
     inline orientation_2d orient() const { return orient_; }
 
- polygon_90_set_data<coordinate_type>& operator-=(const polygon_90_set_data& that) {
- sort();
- that.sort();
- value_type data;
- std::swap(data, data_);
- applyBooleanBinaryOp(data.begin(), data.end(),
- that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryNot>());
- return *this;
- }
- polygon_90_set_data<coordinate_type>& operator^=(const polygon_90_set_data& that) {
- sort();
- that.sort();
- value_type data;
- std::swap(data, data_);
- applyBooleanBinaryOp(data.begin(), data.end(),
- that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryXor>());
- return *this;
- }
- polygon_90_set_data<coordinate_type>& operator&=(const polygon_90_set_data& that) {
- sort();
- that.sort();
- value_type data;
- std::swap(data, data_);
- applyBooleanBinaryOp(data.begin(), data.end(),
- that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryAnd>());
- return *this;
- }
- polygon_90_set_data<coordinate_type>& operator|=(const polygon_90_set_data& that) {
- insert(that);
- return *this;
- }
+ // Start BM
+ // The problem: If we have two polygon sets with two different scanline orientations:
+ // I tried changing the orientation of one to coincide with other (If not, resulting boolean operation
+ // produces spurious results).
+ // First I tried copying polygon data from one of the sets into another set with corrected orientation
+ // using one of the copy constructor that takes in orientation (see somewhere above in this file) --> copy constructor throws error
+ // Then I tried another approach:(see below). This approach also fails to produce the desired results when test case is run.
+ // Here is the part that beats me: If I comment out the whole section, I can do all the operations (^=, -=, &= )these commented out
+ // operations perform. So then why do we need them?. Hence, I commented out this whole section.
+ // End BM
+ // polygon_90_set_data<coordinate_type>& operator-=(const polygon_90_set_data& that) {
+ // sort();
+ // that.sort();
+ // value_type data;
+ // std::swap(data, data_);
+ // applyBooleanBinaryOp(data.begin(), data.end(),
+ // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryNot>());
+ // return *this;
+ // }
+ // polygon_90_set_data<coordinate_type>& operator^=(const polygon_90_set_data& that) {
+ // sort();
+ // that.sort();
+ // value_type data;
+ // std::swap(data, data_);
+ // applyBooleanBinaryOp(data.begin(), data.end(),
+ // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryXor>());
+ // return *this;
+ // }
+ // polygon_90_set_data<coordinate_type>& operator&=(const polygon_90_set_data& that) {
+ // sort();
+ // that.sort();
+ // value_type data;
+ // std::swap(data, data_);
+ // applyBooleanBinaryOp(data.begin(), data.end(),
+ // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryAnd>());
+ // return *this;
+ // }
+ // polygon_90_set_data<coordinate_type>& operator|=(const polygon_90_set_data& that) {
+ // insert(that);
+ // return *this;
+ // }
 
     void clean() const {
       sort();
@@ -286,7 +296,7 @@
 
     void sort() const{
       if(unsorted_) {
- std::sort(data_.begin(), data_.end());
+ gtlsort(data_.begin(), data_.end());
         unsorted_ = false;
       }
     }
@@ -439,7 +449,7 @@
 
     static bool remove_colinear_pts(std::vector<point_data<coordinate_type> >& poly) {
       bool found_colinear = true;
- while(found_colinear) {
+ while(found_colinear && poly.size() >= 4) {
         found_colinear = false;
         typename std::vector<point_data<coordinate_type> >::iterator itr = poly.begin();
         itr += poly.size() - 1; //get last element position
@@ -504,9 +514,9 @@
           //polygon_45_data<coordinate_type> testpoly(*itrh);
           if(resize_poly_down((*itrh).coords_, west_bloating, east_bloating, south_bloating, north_bloating)) {
             iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
- begin_input(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
- end_input(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
- insert(begin_input, end_input, orient_);
+ begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
+ end_input2(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
+ insert(begin_input2, end_input2, orient_);
             //polygon_90_set_data<coordinate_type> pstesthole;
             //pstesthole.insert(rect);
             //iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
@@ -569,9 +579,9 @@
             //polygon_45_data<coordinate_type> testpoly(*itrh);
             resize_poly_up((*itrh).coords_, -west_shrinking, -east_shrinking, -south_shrinking, -north_shrinking);
             iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
- begin_input(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
- end_input(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
- insert(begin_input, end_input, orient_);
+ begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
+ end_input2(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
+ insert(begin_input2, end_input2, orient_);
             //polygon_90_set_data<coordinate_type> pstesthole;
             //pstesthole.insert(rect);
             //iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
@@ -638,8 +648,7 @@
         return shrink(0, shrinking, 0, 0);
       if(dir == SOUTH)
         return shrink(0, 0, shrinking, 0);
- if(dir == NORTH)
- return shrink(0, 0, 0, shrinking);
+ return shrink(0, 0, 0, shrinking);
     }
 
     polygon_90_set_data&
@@ -650,8 +659,7 @@
         return bloat(0, shrinking, 0, 0);
       if(dir == SOUTH)
         return bloat(0, 0, shrinking, 0);
- if(dir == NORTH)
- return bloat(0, 0, 0, shrinking);
+ return bloat(0, 0, 0, shrinking);
     }
 
     polygon_90_set_data&

Modified: branches/release/boost/polygon/polygon_set_data.hpp
==============================================================================
--- branches/release/boost/polygon/polygon_set_data.hpp (original)
+++ branches/release/boost/polygon/polygon_set_data.hpp 2010-11-10 13:07:40 EST (Wed, 10 Nov 2010)
@@ -248,7 +248,7 @@
         data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second));
         data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second));
       }
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(container, data.begin(), data.end());
       //std::cout << "DONE FORMING POLYGONS\n";
     }
@@ -321,7 +321,7 @@
 
     void sort() const{
       if(unsorted_) {
- std::sort(data_.begin(), data_.end());
+ gtlsort(data_.begin(), data_.end());
         unsorted_ = false;
       }
     }
@@ -359,24 +359,7 @@
     }
 
     inline polygon_set_data&
- resize(coordinate_type resizing, bool corner_fill_arc = false, unsigned int num_circle_segments=0) {
- if(!corner_fill_arc) {
- if(resizing < 0)
- return shrink(-resizing);
- if(resizing > 0)
- return bloat(-resizing);
- return *this;
- }
- if(resizing == 0) return *this;
- std::list<polygon_with_holes_data<coordinate_type> > pl;
- get(pl);
- clear();
- for(typename std::list<polygon_with_holes_data<coordinate_type> >::iterator itr = pl.begin(); itr != pl.end(); ++itr) {
- insert_with_resize(*itr, resizing, corner_fill_arc, num_circle_segments);
- }
- clean();
- return *this;
- }
+ resize(coordinate_type resizing, bool corner_fill_arc = false, unsigned int num_circle_segments=0);
 
     template <typename transform_type>
     inline polygon_set_data&
@@ -425,37 +408,53 @@
       return *this;
     }
 
- static inline void compute_offset_edge(point_data<coordinate_type>& pt1, point_data<coordinate_type>& pt2,
- const point_data<coordinate_type>& prev_pt,
- const point_data<coordinate_type>& current_pt,
- coordinate_type distance, int multiplier) {
- coordinate_type dx = current_pt.x() - prev_pt.x();
- coordinate_type dy = current_pt.y() - prev_pt.y();
- double ddx = (double)dx;
- double ddy = (double)dy;
- double edge_length = std::sqrt(ddx*ddx + ddy*ddy);
- double dnx = dy;
- double dny = -dx;
- dnx = dnx * (double)distance / edge_length;
- dny = dny * (double)distance / edge_length;
- dnx = std::floor(dnx+0.5);
- dny = std::floor(dny+0.5);
- pt1.x(prev_pt.x() + (coordinate_type)dnx * (coordinate_type)multiplier);
- pt2.x(current_pt.x() + (coordinate_type)dnx * (coordinate_type)multiplier);
- pt1.y(prev_pt.y() + (coordinate_type)dny * (coordinate_type)multiplier);
- pt2.y(current_pt.y() + (coordinate_type)dny * (coordinate_type)multiplier);
+ static inline void compute_offset_edge(point_data<long double>& pt1, point_data<long double>& pt2,
+ const point_data<long double>& prev_pt,
+ const point_data<long double>& current_pt,
+ long double distance, int multiplier) {
+ long double dx = current_pt.x() - prev_pt.x();
+ long double dy = current_pt.y() - prev_pt.y();
+ long double edge_length = std::sqrt(dx*dx + dy*dy);
+ long double dnx = dy;
+ long double dny = -dx;
+ dnx = dnx * (long double)distance / edge_length;
+ dny = dny * (long double)distance / edge_length;
+ pt1.x(prev_pt.x() + (long double)dnx * (long double)multiplier);
+ pt2.x(current_pt.x() + (long double)dnx * (long double)multiplier);
+ pt1.y(prev_pt.y() + (long double)dny * (long double)multiplier);
+ pt2.y(current_pt.y() + (long double)dny * (long double)multiplier);
     }
 
     static inline void modify_pt(point_data<coordinate_type>& pt, const point_data<coordinate_type>& prev_pt,
                                  const point_data<coordinate_type>& current_pt, const point_data<coordinate_type>& next_pt,
                                  coordinate_type distance, coordinate_type multiplier) {
- std::pair<point_data<coordinate_type>, point_data<coordinate_type> > he1(prev_pt, current_pt), he2(current_pt, next_pt);
+ std::pair<point_data<long double>, point_data<long double> > he1, he2;
+ he1.first.x((long double)(prev_pt.x()));
+ he1.first.y((long double)(prev_pt.y()));
+ he1.second.x((long double)(current_pt.x()));
+ he1.second.y((long double)(current_pt.y()));
+ he2.first.x((long double)(current_pt.x()));
+ he2.first.y((long double)(current_pt.y()));
+ he2.second.x((long double)(next_pt.x()));
+ he2.second.y((long double)(next_pt.y()));
       compute_offset_edge(he1.first, he1.second, prev_pt, current_pt, distance, multiplier);
       compute_offset_edge(he2.first, he2.second, current_pt, next_pt, distance, multiplier);
- typename scanline_base<coordinate_type>::compute_intersection_pack pack;
- if(!pack.compute_lazy_intersection(pt, he1, he2, true, true)) {
- pt = he1.second; //colinear offset edges use shared point
+ typename scanline_base<long double>::compute_intersection_pack pack;
+ point_data<long double> rpt;
+ point_data<long double> bisectorpt((he1.second.x()+he2.first.x())/2,
+ (he1.second.y()+he2.first.y())/2);
+ point_data<long double> orig_pt((long double)pt.x(), (long double)pt.y());
+ if(euclidean_distance(bisectorpt, orig_pt) < distance/2) {
+ if(!pack.compute_lazy_intersection(rpt, he1, he2, true, false)) {
+ rpt = he1.second; //colinear offset edges use shared point
+ }
+ } else {
+ if(!pack.compute_lazy_intersection(rpt, he1, std::pair<point_data<long double>, point_data<long double> >(orig_pt, bisectorpt), true, false)) {
+ rpt = he1.second; //colinear offset edges use shared point
+ }
       }
+ pt.x((coordinate_type)(std::floor(rpt.x()+0.5)));
+ pt.y((coordinate_type)(std::floor(rpt.y()+0.5)));
     }
 
     static void resize_poly_up(std::vector<point_data<coordinate_type> >& poly, coordinate_type distance, coordinate_type multiplier) {
@@ -615,7 +614,7 @@
 
       // for all corners
       polygon_set_data<T> sizingSet;
- bool sizing_sign = resizing>0;
+ bool sizing_sign = resizing<0;
       bool prev_concave = true;
       point_data<T> prev_point;
       //int iCtr=0;
@@ -791,7 +790,7 @@
         data.push_back(vertex_half_edge((*itr).first.first, (*itr).first.second, (*itr).second));
         data.push_back(vertex_half_edge((*itr).first.second, (*itr).first.first, -1 * (*itr).second));
       }
- std::sort(data.begin(), data.end());
+ gtlsort(data.begin(), data.end());
       pf.scan(container, data.begin(), data.end());
     }
   };
@@ -911,7 +910,7 @@
       }
       return_points.push_back(round_down<T>(center));
       return_points.push_back(round_down<T>(start));
- int i=0;
+ unsigned int i=0;
       double curr_angle = ps+delta_angle;
       while( curr_angle < pe - 0.01 && i < 2 * num_circle_segments) {
          i++;
@@ -996,5 +995,6 @@
 #include "detail/polygon_set_view.hpp"
 
 #include "polygon_set_concept.hpp"
+#include "detail/minkowski.hpp"
 #endif
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk