$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r78375 - in trunk: boost/polygon boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-05-07 18:10:54
Author: asydorchuk
Date: 2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
New Revision: 78375
URL: http://svn.boost.org/trac/boost/changeset/78375
Log:
Polygon: fixing Boost.Polygon warnings; replacing on_above_or_below with orientation method; updating tests.
Text files modified: 
   trunk/boost/polygon/detail/polygon_set_view.hpp  |    36 +++++++-------                          
   trunk/boost/polygon/polygon.hpp                  |    10 ++--                                    
   trunk/boost/polygon/polygon_set_data.hpp         |    97 +++++++++++++++++++-------------------- 
   trunk/boost/polygon/segment_concept.hpp          |    73 ++++++++++++++++++++++-------           
   trunk/libs/polygon/test/gtl_boost_unit_test.cpp  |    63 -------------------------               
   trunk/libs/polygon/test/polygon_segment_test.cpp |    65 +++++++++++++++++---------              
   6 files changed, 168 insertions(+), 176 deletions(-)
Modified: trunk/boost/polygon/detail/polygon_set_view.hpp
==============================================================================
--- trunk/boost/polygon/detail/polygon_set_view.hpp	(original)
+++ trunk/boost/polygon/detail/polygon_set_view.hpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -20,24 +20,24 @@
       //that vertices be "linearly consistent"
       //therefore it doesn't work to fall back on 45-degree
       //booleans for arbitrary angle polygons
-      if(0) { //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;
-      }
+      //if(0) { //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;
+      //}
     }
   }
 
Modified: trunk/boost/polygon/polygon.hpp
==============================================================================
--- trunk/boost/polygon/polygon.hpp	(original)
+++ trunk/boost/polygon/polygon.hpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -34,6 +34,11 @@
 #include "rectangle_traits.hpp"
 #include "rectangle_concept.hpp"
 
+//segment
+#include "segment_data.hpp"
+#include "segment_traits.hpp"
+#include "segment_concept.hpp"
+
 //algorithms needed by polygon types
 #include "detail/iterator_points_to_compact.hpp"
 #include "detail/iterator_compact_to_points.hpp"
@@ -88,9 +93,4 @@
 
 #include "polygon_set_concept.hpp"
 
-//segment
-#include "segment_data.hpp"
-#include "segment_traits.hpp"
-#include "segment_concept.hpp"
-
 #endif
Modified: trunk/boost/polygon/polygon_set_data.hpp
==============================================================================
--- trunk/boost/polygon/polygon_set_data.hpp	(original)
+++ trunk/boost/polygon/polygon_set_data.hpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -1,6 +1,6 @@
 /*
   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).
@@ -21,7 +21,7 @@
   template <typename T>
   static inline T round_down(double val) {
      T rounded_val = (T)(val);
-     if(val < (double)rounded_val) 
+     if(val < (double)rounded_val)
         --rounded_val;
      return rounded_val;
   }
@@ -56,11 +56,11 @@
     }
 
     // copy constructor
-    inline polygon_set_data(const polygon_set_data& that) : 
+    inline polygon_set_data(const polygon_set_data& that) :
       data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_), is_45_(that.is_45_) {}
 
     // copy constructor
-    template <typename ltype, typename rtype, int op_type> 
+    template <typename ltype, typename rtype, int op_type>
     inline polygon_set_data(const polygon_set_view<ltype, rtype, op_type>& that);
 
     // destructor
@@ -149,10 +149,10 @@
       insert(polygon_object, is_hole, polygon_concept()); }
 
     template <typename polygon_with_holes_type>
-    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, 
+    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
                        polygon_with_holes_concept ) {
       insert(polygon_with_holes_object, is_hole, polygon_concept());
-      for(typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type itr = 
+      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, !is_hole, polygon_concept());
@@ -160,12 +160,12 @@
     }
 
     template <typename polygon_with_holes_type>
-    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, 
+    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
                        polygon_45_with_holes_concept ) {
       insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); }
 
     template <typename polygon_with_holes_type>
-    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole, 
+    inline void insert(const polygon_with_holes_type& polygon_with_holes_object, bool is_hole,
                        polygon_90_with_holes_concept ) {
       insert(polygon_with_holes_object, is_hole, polygon_with_holes_concept()); }
 
@@ -211,7 +211,7 @@
           first_point = previous_point = current_point;
         } else {
           if(previous_point != current_point) {
-            element_type elem(edge_type(previous_point, current_point), 
+            element_type elem(edge_type(previous_point, current_point),
                               ( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier);
             insert_clean(elem);
           }
@@ -221,7 +221,7 @@
       current_point = first_point;
       if(!first_iteration) {
         if(previous_point != current_point) {
-          element_type elem(edge_type(previous_point, current_point), 
+          element_type elem(edge_type(previous_point, current_point),
                             ( previous_point.get(HORIZONTAL) == current_point.get(HORIZONTAL) ? -1 : 1) * multiplier);
           insert_clean(elem);
         }
@@ -269,14 +269,14 @@
       }
     }
 
-    // equivalence operator 
+    // equivalence operator
     inline bool operator==(const polygon_set_data& p) const {
       clean();
       p.clean();
       return data_ == p.data_;
     }
 
-    // inequivalence operator 
+    // inequivalence operator
     inline bool operator!=(const polygon_set_data& p) const {
       return !((*this) == p);
     }
@@ -335,7 +335,7 @@
     }
 
     void set(const value_type& value) {
-      data_ = value; 
+      data_ = value;
       dirty_ = true;
       unsorted_ = true;
     }
@@ -362,7 +362,7 @@
     resize(coordinate_type resizing, bool corner_fill_arc = false, unsigned int num_circle_segments=0);
 
     template <typename transform_type>
-    inline polygon_set_data& 
+    inline polygon_set_data&
     transform(const transform_type& tr) {
       std::vector<polygon_with_holes_data<T> > polys;
       get(polys);
@@ -376,7 +376,7 @@
       return *this;
     }
 
-    inline polygon_set_data& 
+    inline polygon_set_data&
     scale_up(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
       for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) {
         ::boost::polygon::scale_up((*itr).first.first, factor);
@@ -384,8 +384,8 @@
       }
       return *this;
     }
-    
-    inline polygon_set_data& 
+
+    inline polygon_set_data&
     scale_down(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
       for(typename value_type::iterator itr = data_.begin(); itr != data_.end(); ++itr) {
         bool vb = (*itr).first.first.x() == (*itr).first.second.x();
@@ -400,9 +400,9 @@
       dirty_ = true;
       return *this;
     }
-    
+
     template <typename scaling_type>
-    inline polygon_set_data& scale(polygon_set_data& polygon_set, 
+    inline polygon_set_data& scale(polygon_set_data& polygon_set,
                                    const scaling_type& scaling) {
       for(typename value_type::iterator itr = begin(); itr != end(); ++itr) {
         bool vb = (*itr).first.first.x() == (*itr).first.second.x();
@@ -418,7 +418,7 @@
       return *this;
     }
 
-    static inline void compute_offset_edge(point_data<long double>& pt1, point_data<long double>& pt2, 
+    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) {
@@ -449,17 +449,17 @@
       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<long double>::compute_intersection_pack pack;
+      typedef 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)) {
+        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)) {
+        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
         }
       }
@@ -575,8 +575,8 @@
     }
 
     template <typename geometry_type>
-    inline polygon_set_data& 
-    insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole, 
+    inline polygon_set_data&
+    insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole,
                                polygon_with_holes_concept tag) {
       insert_with_resize_dispatch(poly, resizing, corner_fill_arc, num_circle_segments, hole, polygon_concept());
       for(typename polygon_with_holes_traits<geometry_type>::iterator_holes_type itr =
@@ -588,14 +588,14 @@
     }
 
     template <typename geometry_type>
-    inline polygon_set_data& 
-    insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole, 
+    inline polygon_set_data&
+    insert_with_resize_dispatch(const geometry_type& poly, coordinate_type resizing, bool corner_fill_arc, unsigned int num_circle_segments, bool hole,
                           polygon_concept tag) {
 
       if (resizing==0)
          return *this;
 
-      
+
       // one dimensional used to store CCW/CW flag
       //direction_1d wdir = winding(poly);
       // LOW==CLOCKWISE just faster to type
@@ -640,7 +640,7 @@
         point_data<coordinate_type> normal2( third->y()-second->y(), second->x()-third->x());
         double direction = normal1.x()*normal2.y()- normal2.x()*normal1.y();
         bool convex = direction>0;
- 
+
         bool treat_as_concave = !convex;
         if(sizing_sign)
           treat_as_concave = convex;
@@ -653,12 +653,12 @@
         if (prev_concave)
           //TODO missing round_down()
           curr_prev = point_data<T>(first->x()+v.x(),first->y()+v.y());
-        else 
+        else
           curr_prev = prev_point;
 
            // around concave corners - insert rectangle
            // if previous corner is concave it's point info may be ignored
-        if ( treat_as_concave) { 
+        if ( treat_as_concave) {
            std::vector<point_data<T> > pts;
 
            pts.push_back(point_data<T>(second->x()+v.x(),second->y()+v.y()));
@@ -679,13 +679,13 @@
            direction_1d winding;
            winding = convex?COUNTERCLOCKWISE:CLOCKWISE;
            if (make_resizing_vertex_list(pts, curr_prev, prev_concave, *first, *second, *third, resizing
-                                         , num_circle_segments, corner_fill_arc)) 
+                                         , num_circle_segments, corner_fill_arc))
            {
                if (first_pts.size()) {
                   for (int i=0; i<pts.size(); i++) {
                     sizingSet.insert_vertex_sequence(pts[i].begin(),pts[i].end(),winding,false);
                   }
-  
+
                } else {
                   first_pts = pts[0];
                   first_wdir = resize_wdir;
@@ -694,7 +694,7 @@
                   }
                }
                prev_point = curr_prev;
-          
+
            } else {
               treat_as_concave = true;
            }
@@ -717,7 +717,7 @@
           first_pts[first_pts.size()-1]=prev_point;
       }
       sizingSet.insert_vertex_sequence(first_pts.begin(),first_pts.end(),first_wdir,false);
-         
+
       polygon_set_data<coordinate_type> tmp;
 
       //insert original shape
@@ -731,7 +731,7 @@
 
 
     inline polygon_set_data&
-    interact(const polygon_set_data& that); 
+    interact(const polygon_set_data& that);
 
     inline bool downcast(polygon_45_set_data<coordinate_type>& result) const {
       if(!is_45_) return false;
@@ -820,7 +820,7 @@
 //   }
 
   template <typename  T>
-  inline int make_resizing_vertex_list(std::vector<std::vector<point_data< T> > >& return_points, 
+  inline int make_resizing_vertex_list(std::vector<std::vector<point_data< T> > >& return_points,
                        point_data<T>& curr_prev, bool ignore_prev_point,
                        point_data< T> start, point_data<T> middle, point_data< T>  end,
                        double sizing_distance, unsigned int num_circle_segments, bool corner_fill_arc) {
@@ -853,7 +853,7 @@
          int num = make_arc(return_points[return_points.size()-1],mid1_offset,mid2_offset,dmid,sizing_distance,num_circle_segments);
          curr_prev = round_down<T>(mid2_offset);
          return num;
-         
+
       }
 
       std::pair<point_data<double>,point_data<double> > he1(start_offset,mid1_offset);
@@ -891,21 +891,21 @@
   // returnPoints will start with the first point after start
   // returnPoints vector  may be empty
   template <typename  T>
-  inline int  make_arc(std::vector<point_data< T> >& return_points,  
+  inline int  make_arc(std::vector<point_data< T> >& return_points,
                        point_data< double> start, point_data< double>  end,
                        point_data< double> center,  double r, unsigned int num_circle_segments) {
       const double our_pi=3.1415926535897932384626433832795028841971;
 
-      // derive start and end angles 
+      // derive start and end angles
       double ps = atan2(start.y()-center.y(), start.x()-center.x());
       double pe = atan2(end.y()-center.y(), end.x()-center.x());
-      if (ps <  0.0) 
+      if (ps <  0.0)
          ps += 2.0 * our_pi;
-      if (pe <= 0.0) 
+      if (pe <= 0.0)
          pe += 2.0 * our_pi;
-      if (ps >= 2.0 * our_pi) 
+      if (ps >= 2.0 * our_pi)
          ps -= 2.0 * our_pi;
-      while (pe <= ps)  
+      while (pe <= ps)
          pe += 2.0 * our_pi;
       double delta_angle = (2.0 * our_pi) / (double)num_circle_segments;
       if ( start==end) // full circle?
@@ -951,12 +951,12 @@
     inline connectivity_extraction() : ce_(), nodeCount_(0) {}
     inline connectivity_extraction(const connectivity_extraction& that) : ce_(that.ce_),
                                                                           nodeCount_(that.nodeCount_) {}
-    inline connectivity_extraction& operator=(const connectivity_extraction& that) { 
-      ce_ = that.ce_; 
+    inline connectivity_extraction& operator=(const connectivity_extraction& that) {
+      ce_ = that.ce_;
       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_set_data<coordinate_type>& ps) {
       ps.clean();
@@ -969,7 +969,7 @@
       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
@@ -1007,4 +1007,3 @@
 #include "polygon_set_concept.hpp"
 #include "detail/minkowski.hpp"
 #endif
-
Modified: trunk/boost/polygon/segment_concept.hpp
==============================================================================
--- trunk/boost/polygon/segment_concept.hpp	(original)
+++ trunk/boost/polygon/segment_concept.hpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -12,7 +12,6 @@
 #include "segment_data.hpp"
 #include "segment_traits.hpp"
 #include "rectangle_concept.hpp"
-#include "detail/polygon_arbitrary_formation.hpp"
 
 namespace boost { namespace polygon{
   struct segment_concept {};
@@ -296,13 +295,57 @@
     set(segment, HIGH, point);
   }
 
-  struct y_s_on_above_or_below : gtl_yes {};
+  struct y_s_orientation1 : gtl_yes {};
 
-  // -1 for below, 0 for on and 1 for above
+  // -1 for CW, 0 for collinear and 1 for CCW.
+  template <typename Segment1, typename Segment2>
+  typename enable_if<
+    typename gtl_and_3<
+      y_s_orientation1,
+      typename is_segment_concept<
+        typename geometry_concept<Segment1>::type
+      >::type,
+      typename is_segment_concept<
+        typename geometry_concept<Segment2>::type
+      >::type
+    >::type,
+    int
+  >::type
+  orientation(const Segment1& segment1, const Segment2& segment2) {
+    typedef typename coordinate_traits<
+      typename segment_traits<Segment1>::coordinate_type
+    >::manhattan_area_type int_x2;
+    typedef typename coordinate_traits<
+      typename segment_traits<Segment1>::coordinate_type
+    >::unsigned_area_type uint_x2;
+    int_x2 a1 = (int_x2)x(high(segment1)) - (int_x2)x(low(segment1));
+    int_x2 b1 = (int_x2)y(high(segment1)) - (int_x2)y(low(segment1));
+    int_x2 a2 = (int_x2)x(high(segment2)) - (int_x2)x(low(segment2));
+    int_x2 b2 = (int_x2)y(high(segment2)) - (int_x2)y(low(segment2));
+
+    int sign1 = 0;
+    int sign2 = 0;
+    if (a1 && b2)
+      sign1 = ((a1 > 0) ^ (b2 > 0)) ? -1 : 1;
+    if (a2 && b1)
+      sign2 = ((a2 > 0) ^ (b1 > 0)) ? -1 : 1;
+
+    if (sign1 != sign2)
+      return (sign1 < sign2) ? -1 : 1;
+    uint_x2 a3 = (uint_x2)(a1 < 0 ? -a1 : a1) * (uint_x2)(b2 < 0 ? -b2 : b2);
+    uint_x2 b3 = (uint_x2)(b1 < 0 ? -b1 : b1) * (uint_x2)(a2 < 0 ? -a2 : a2);
+    if (a3 == b3)
+      return 0;
+    return ((a3 < b3) ^ (sign1 == 1)) ? 1 : -1; 
+  }
+
+  struct y_s_orientation2 : gtl_yes {};
+
+  // -1 for right, 0 for collinear and 1 for left.
   template <typename Segment, typename Point>
   typename enable_if<
     typename gtl_and_3<
-      y_s_on_above_or_below,
+      y_s_orientation2,
       typename is_segment_concept<
         typename geometry_concept<Segment>::type
       >::type,
@@ -312,15 +355,9 @@
     >::type,
     int
   >::type
-  on_above_or_below(const Segment& segment, const Point& point) {
-    typedef polygon_arbitrary_formation<
-      typename segment_coordinate_type<Segment>::type
-    > paf;
-    typename paf::Point pt, l, h;
-    assign(pt, point);
-    assign(l, low(segment));
-    assign(h, high(segment));
-    return paf::on_above_or_below(pt, typename paf::half_edge(l, h));
+  orientation(const Segment& segment, const Point& point) {
+    Segment segment2 = construct<Segment>(high(segment), point);
+    return orientation(segment, segment2);
   }
 
   struct y_s_contains : gtl_yes {};
@@ -339,7 +376,7 @@
     bool
   >::type
   contains(const Segment& segment, const Point& point, bool consider_touch = true ) {
-    if (on_above_or_below(segment, point))
+    if (orientation(segment, point))
       return false;
     rectangle_data<typename segment_coordinate_type<Segment>::type> rect;
     set_points(rect, low(segment), high(segment));
@@ -594,12 +631,12 @@
     // Check if axis-parallel rectangles containing segments intersect.
     if (!intersects(rect1, rect2, true))
       return false;
-    int or1_1 = on_above_or_below(segment1, low(segment2));
-    int or1_2 = on_above_or_below(segment1, high(segment2));
+    int or1_1 = orientation(segment1, low(segment2));
+    int or1_2 = orientation(segment1, high(segment2));
     if (or1_1 * or1_2 > 0)
       return false;
-    int or2_1 = on_above_or_below(segment2, low(segment1));
-    int or2_2 = on_above_or_below(segment2, high(segment1));
+    int or2_1 = orientation(segment2, low(segment1));
+    int or2_2 = orientation(segment2, high(segment1));
     if (or2_1 * or2_2 > 0)
       return false;
     if (consider_touch || or1_1 && or1_2 || or2_1 && or2_2)
Modified: trunk/libs/polygon/test/gtl_boost_unit_test.cpp
==============================================================================
--- trunk/libs/polygon/test/gtl_boost_unit_test.cpp	(original)
+++ trunk/libs/polygon/test/gtl_boost_unit_test.cpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -3645,69 +3645,6 @@
       }
     }
   }
-  {
-    using namespace gtl;
-    typedef point_data<int> Point;
-    typedef segment_data<int> Segment;
-    Point pt1(0, 0);
-    Point pt2(10, 10);
-    Point pt3(20, 20);
-    Point pt4(20, 0);
-    Segment dls1(pt1, pt2);
-    Segment dls2(pt1, pt3);
-    Segment dls3(pt1, pt4);
-    Segment dls4(pt2, pt1);
-    bool b1 = equivalence(dls1, dls1);
-    bool b2 = equivalence(dls1, dls2);
-    bool b3 = equivalence(dls1, dls3);
-    bool b4 = equivalence(dls1, dls4);
-    if(!b1 || b2 || b3 || b4) {
-      std::cout << "fail1\n";
-      return 1;
-    }
-    low(dls1, pt1);
-    if(!equivalence(low(dls1), pt1)) {
-      std::cout << "fail2\n";
-      return 1;
-    }
-    high(dls1, pt2);
-    assert_s(equivalence(high(dls1), pt2), "fail3");
-    assign(dls1, dls4);
-    assert_s(equivalence(dls1, dls4), "fail4");
-    assert_s(!contains(dls1, dls2), "fail5");
-    assert_s(contains(dls2, dls1), "fail5");
-    assert_s(!contains(dls2, dls1, false), "fail6");
-    assert_s(center(dls1) == Point(5, 5), "center");
-    assert_s(length(dls3) == 20, "length");
-    scale_up(dls3, 10);
-    assert_s(length(dls3) == 200, "length2");
-    scale_down(dls3, 10);
-    assert_s(length(dls3) == 20, "length3");
-    scale(dls3, anisotropic_scale_factor<double>(1.5, 1.5, 1.5));
-    assert_s(length(dls3) == 30, "length4");
-    axis_transformation atr(axis_transformation::WS);
-    transform(dls3, atr);
-    assert_s(equivalence(high(dls3), Point(-30, 0)), "transform");
-    move(dls3, HORIZONTAL, 30);
-    assert_s(equivalence(high(dls3), pt1), "move");
-    convolve(dls3, pt2);
-    assert_s(equivalence(high(dls3), pt2), "convolve");
-    deconvolve(dls3, pt2);
-    assert_s(equivalence(high(dls3), pt1), "deconvolve");
-    assert_s(euclidean_distance(dls3, pt1) == 0.0, "distance1");
-    assert_s(euclidean_distance(dls3, pt2) == 10.0, "distance2");
-    std::cout << euclidean_distance(dls3, Point(5, 5)) << std::endl;
-    std::cout << dls1 << std::endl;
-    std::cout << euclidean_distance(dls1, Point(5, 5)) << std::endl;
-    std::cout << euclidean_distance(dls1, Point(15, 15)) << std::endl;
-    std::cout << euclidean_distance(dls1, Point(5, 6)) << std::endl;
-    std::cout << euclidean_distance(dls1, Point(5, 3)) << std::endl;
-    std::cout << euclidean_distance(dls1, dls3) << std::endl;
-    std::cout << euclidean_distance(dls1, segment_data<int>(Point(2, 0), Point(3, 0))) << std::endl;
-    assert_s(intersects(dls1, dls3), "intersects1");
-    assert_s(!intersects(dls1, segment_data<int>(Point(2, 0), Point(3, 0))), "intersects2");
-    assert_s(abuts(dls1, dls2), "abuts");
-  }
 
   std::cout << "ALL TESTS COMPLETE\n";
   return 0;
Modified: trunk/libs/polygon/test/polygon_segment_test.cpp
==============================================================================
--- trunk/libs/polygon/test/polygon_segment_test.cpp	(original)
+++ trunk/libs/polygon/test/polygon_segment_test.cpp	2012-05-07 18:10:46 EDT (Mon, 07 May 2012)
@@ -164,27 +164,46 @@
   segment_type segment2 = construct<segment_type>(point2, point1);
   segment_type segment3 = construct<segment_type>(point1, point5);
 
-  BOOST_CHECK(on_above_or_below(segment1, point1) == 0);
-  BOOST_CHECK(on_above_or_below(segment1, point2) == 0);
-  BOOST_CHECK(on_above_or_below(segment1, point3) == 0);
-  BOOST_CHECK(on_above_or_below(segment1, point4) == 0);
-  BOOST_CHECK(on_above_or_below(segment1, point5) == 1);
-  BOOST_CHECK(on_above_or_below(segment2, point5) == 1);
-  BOOST_CHECK(on_above_or_below(segment1, point6) == -1);
-  BOOST_CHECK(on_above_or_below(segment2, point6) == -1);
-  BOOST_CHECK(on_above_or_below(segment1, point7) == 1);
-  BOOST_CHECK(on_above_or_below(segment2, point7) == 1);
-  BOOST_CHECK(on_above_or_below(segment1, point8) == 0);
-  BOOST_CHECK(on_above_or_below(segment1, point9) == -1);
-  BOOST_CHECK(on_above_or_below(segment2, point9) == -1);
-  BOOST_CHECK(on_above_or_below(segment3, point6) == -1);
-  BOOST_CHECK(on_above_or_below(segment3, point3) == 1);
+  BOOST_CHECK(orientation(segment1, point1) == 0);
+  BOOST_CHECK(orientation(segment1, point2) == 0);
+  BOOST_CHECK(orientation(segment1, point3) == 0);
+  BOOST_CHECK(orientation(segment1, point4) == 0);
+  BOOST_CHECK(orientation(segment1, point5) == 1);
+  BOOST_CHECK(orientation(segment2, point5) == -1);
+  BOOST_CHECK(orientation(segment1, point6) == -1);
+  BOOST_CHECK(orientation(segment2, point6) == 1);
+  BOOST_CHECK(orientation(segment1, point7) == 1);
+  BOOST_CHECK(orientation(segment2, point7) == -1);
+  BOOST_CHECK(orientation(segment1, point8) == 0);
+  BOOST_CHECK(orientation(segment1, point9) == -1);
+  BOOST_CHECK(orientation(segment2, point9) == 1);
+  BOOST_CHECK(orientation(segment3, point6) == -1);
+  BOOST_CHECK(orientation(segment3, point3) == 1);
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test3, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
+  segment_type segment1 = construct<segment_type>(point_type(0, 0), point_type(1, 2));
+  segment_type segment2 = construct<segment_type>(point_type(0, 0), point_type(2, 4));
+  segment_type segment3 = construct<segment_type>(point_type(0, 0), point_type(2, 3));
+  segment_type segment4 = construct<segment_type>(point_type(0, 0), point_type(2, 5));
+  segment_type segment5 = construct<segment_type>(point_type(0, 2), point_type(2, 0));
+
+  BOOST_CHECK(orientation(segment1, segment2) == 0);
+  BOOST_CHECK(orientation(segment1, segment3) == -1);
+  BOOST_CHECK(orientation(segment3, segment1) == 1);
+  BOOST_CHECK(orientation(segment1, segment4) == 1);
+  BOOST_CHECK(orientation(segment4, segment1) == -1);
+  BOOST_CHECK(orientation(segment1, segment5) == -1);
+  BOOST_CHECK(orientation(segment5, segment1) == 1);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test4, T, test_types) {
+  typedef point_data<T> point_type;
+  typedef Segment<T> segment_type;
+
   point_type point1(1, 2);
   point_type point2(3, 6);
   point_type point3(2, 4);
@@ -201,7 +220,7 @@
   BOOST_CHECK(!contains(segment, point5, true));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test4, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test5, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -221,7 +240,7 @@
   BOOST_CHECK(!contains(segment, point5, true));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test5, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test6, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -258,7 +277,7 @@
   }
 };
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test6, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test7, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -297,7 +316,7 @@
   BOOST_CHECK(high(segment1) == point_type(12, 8));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test7, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test8, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -325,7 +344,7 @@
   BOOST_CHECK(!abuts(segment2, segment4));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test8, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test9, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -349,7 +368,7 @@
   BOOST_CHECK(intersects(segment3, segment5, true));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test9, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test10, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -376,7 +395,7 @@
   BOOST_CHECK(intersects(segment1, segment6, true));
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test10, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test11, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;
 
@@ -392,7 +411,7 @@
   BOOST_CHECK(euclidean_distance(segment1, point_type(8, 3)) == 5.0);
 }
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test11, T, test_types) {
+BOOST_AUTO_TEST_CASE_TEMPLATE(segment_concept_test12, T, test_types) {
   typedef point_data<T> point_type;
   typedef Segment<T> segment_type;