Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81843 - in trunk: boost/polygon libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-12-10 18:13:45


Author: asydorchuk
Date: 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
New Revision: 81843
URL: http://svn.boost.org/trac/boost/changeset/81843

Log:
Polygon: Refactoring data/concept/traits classes for point/segment/interval.

Added:
   trunk/libs/polygon/test/polygon_interval_test.cpp (contents, props changed)
Text files modified:
   trunk/boost/polygon/interval_concept.hpp | 1197 +++++++++++++++++++++------------------
   trunk/boost/polygon/interval_data.hpp | 154 +++-
   trunk/boost/polygon/interval_traits.hpp | 73 +
   trunk/boost/polygon/point_concept.hpp | 14
   trunk/boost/polygon/point_data.hpp | 65 +-
   trunk/boost/polygon/point_traits.hpp | 12
   trunk/boost/polygon/segment_concept.hpp | 12
   trunk/boost/polygon/segment_data.hpp | 12
   trunk/boost/polygon/segment_traits.hpp | 12
   trunk/boost/polygon/transform.hpp | 24
   trunk/libs/polygon/test/Jamfile.v2 | 1
   trunk/libs/polygon/test/polygon_point_test.cpp | 4
   trunk/libs/polygon/test/polygon_segment_test.cpp | 4
   13 files changed, 872 insertions(+), 712 deletions(-)

Modified: trunk/boost/polygon/interval_concept.hpp
==============================================================================
--- trunk/boost/polygon/interval_concept.hpp (original)
+++ trunk/boost/polygon/interval_concept.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,632 +1,731 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_concept.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
 
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-*/
 #ifndef BOOST_POLYGON_INTERVAL_CONCEPT_HPP
 #define BOOST_POLYGON_INTERVAL_CONCEPT_HPP
+
 #include "isotropy.hpp"
-#include "interval_data.hpp"
 #include "interval_traits.hpp"
 
-namespace boost { namespace polygon{
- struct interval_concept {};
+namespace boost {
+namespace polygon {
 
- template <typename T>
- struct is_interval_concept { typedef gtl_no type; };
- template <>
- struct is_interval_concept<interval_concept> { typedef gtl_yes type; };
-
- template <typename T>
- struct is_mutable_interval_concept { typedef gtl_no type; };
- template <>
- struct is_mutable_interval_concept<interval_concept> { typedef gtl_yes type; };
-
- template <typename T, typename CT>
- struct interval_coordinate_type_by_concept { typedef void type; };
- template <typename T>
- struct interval_coordinate_type_by_concept<T, gtl_yes> { typedef typename interval_traits<T>::coordinate_type type; };
-
- template <typename T>
- struct interval_coordinate_type {
- typedef typename interval_coordinate_type_by_concept<
- T, typename is_interval_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- template <typename T, typename CT>
- struct interval_difference_type_by_concept { typedef void type; };
- template <typename T>
- struct interval_difference_type_by_concept<T, gtl_yes> {
- typedef typename coordinate_traits<typename interval_traits<T>::coordinate_type>::coordinate_difference type; };
-
- template <typename T>
- struct interval_difference_type {
- typedef typename interval_difference_type_by_concept<
- T, typename is_interval_concept<typename geometry_concept<T>::type>::type>::type type;
- };
-
- struct y_i_get : gtl_yes {};
-
- template <typename T>
- typename enable_if< typename gtl_and<
- y_i_get,
- typename is_interval_concept<typename geometry_concept<T>::type>::type>::type,
- typename interval_coordinate_type<T>::type>::type
- get(const T& interval, direction_1d dir) {
- return interval_traits<T>::get(interval, dir);
- }
+struct interval_concept {};
 
- struct y_i_set : gtl_yes {};
+template <typename ConceptType>
+struct is_interval_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_interval_concept<interval_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename ConceptType>
+struct is_mutable_interval_concept {
+ typedef gtl_no type;
+};
+
+template <>
+struct is_mutable_interval_concept<interval_concept> {
+ typedef gtl_yes type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct interval_coordinate_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct interval_coordinate_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename interval_traits<GeometryType>::coordinate_type type;
+};
+
+template <typename GeometryType>
+struct interval_coordinate_type {
+ typedef typename interval_coordinate_type_by_concept<
+ GeometryType,
+ typename is_interval_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+template <typename GeometryType, typename BoolType>
+struct interval_difference_type_by_concept {
+ typedef void type;
+};
+
+template <typename GeometryType>
+struct interval_difference_type_by_concept<GeometryType, gtl_yes> {
+ typedef typename coordinate_traits<
+ typename interval_traits<GeometryType>::coordinate_type
+ >::coordinate_difference type;
+};
+
+template <typename GeometryType>
+struct interval_difference_type {
+ typedef typename interval_difference_type_by_concept<
+ GeometryType,
+ typename is_interval_concept<
+ typename geometry_concept<GeometryType>::type
+ >::type
+ >::type type;
+};
+
+struct y_i_get : gtl_yes {};
+
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_get,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type get(const IntervalType& interval, direction_1d dir) {
+ return interval_traits<IntervalType>::get(interval, dir);
+}
 
- template <typename T, typename coordinate_type>
- typename enable_if< typename gtl_and<
- y_i_set,
- typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type>::type,
- void>::type
- set(T& interval, direction_1d dir, coordinate_type value) {
- //this may need to be refined
- interval_mutable_traits<T>::set(interval, dir, value);
- if(high(interval) < low(interval))
- interval_mutable_traits<T>::set(interval, dir.backward(), value);
- }
+struct y_i_set : gtl_yes {};
+
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_set,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ void
+>::type set(IntervalType& interval, direction_1d dir,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ interval_mutable_traits<IntervalType>::set(interval, dir, value);
+}
 
- struct y_i_construct : gtl_yes {};
+struct y_i_construct : gtl_yes {};
 
- template <typename T, typename T2, typename T3>
- typename enable_if< typename gtl_and<
- y_i_construct,
- typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type>::type,
- T>::type
- construct(T2 low_value, T3 high_value) {
- if(low_value > high_value) std::swap(low_value, high_value);
- return interval_mutable_traits<T>::construct(low_value, high_value);
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_construct,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type construct(
+ typename interval_mutable_traits<IntervalType>::coordinate_type low,
+ typename interval_mutable_traits<IntervalType>::coordinate_type high) {
+ if (low > high) {
+ (std::swap)(low, high);
   }
+ return interval_mutable_traits<IntervalType>::construct(low, high);
+}
 
- struct y_i_copy_construct : gtl_yes {};
+struct y_i_copy_construct : gtl_yes {};
 
- template <typename T, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_copy_construct,
- typename is_mutable_interval_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
- T>::type
- copy_construct(const T2& interval) {
- return construct<T>(get(interval, LOW ), get(interval, HIGH));
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_copy_construct,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+IntervalType1>::type copy_construct(const IntervalType2& interval) {
+ return construct<IntervalType1>(get(interval, LOW), get(interval, HIGH));
+}
 
- struct y_i_assign : gtl_yes {};
+struct y_i_assign : gtl_yes {};
 
- template <typename T1, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_assign,
- typename is_mutable_interval_concept<typename geometry_concept<T1>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
- T1>::type &
- assign(T1& lvalue, const T2& rvalue) {
- lvalue = copy_construct<T1>(rvalue);
- return lvalue;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_assign,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+IntervalType1>::type& assign(IntervalType1& lvalue, const IntervalType2& rvalue) {
+ set(lvalue, LOW, get(rvalue, LOW));
+ set(lvalue, HIGH, get(rvalue, HIGH));
+ return lvalue;
+}
 
- struct y_i_equivalence : gtl_yes {};
+struct y_i_low : gtl_yes {};
 
- template <typename T, typename T2>
- typename enable_if< typename gtl_and_3<
- y_i_equivalence,
- typename is_interval_concept<typename geometry_concept<T>::type>::type,
- typename is_interval_concept<typename geometry_concept<T2>::type>::type>::type,
- bool>::type
- equivalence(const T& interval1, const T2& interval2) {
- return get(interval1, LOW) == get(interval2, LOW) &&
- get(interval1, HIGH) == get(interval2, HIGH);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_low,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type low(const IntervalType& interval) {
+ return get(interval, LOW);
+}
 
- struct y_i_contains : gtl_yes {};
+struct y_i_high : gtl_yes {};
 
- template <typename interval_type>
- typename enable_if< typename gtl_and< y_i_contains, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type >::type, bool>::type
- contains(const interval_type& interval,
- typename interval_coordinate_type<interval_type>::type value,
- bool consider_touch = true ) {
- if(consider_touch) {
- return value <= high(interval) && value >= low(interval);
- } else {
- return value < high(interval) && value > low(interval);
- }
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_high,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type high(const IntervalType& interval) {
+ return get(interval, HIGH);
+}
 
- struct y_i_contains2 : gtl_yes {};
+struct y_i_low2 : gtl_yes {};
 
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<
- y_i_contains2,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- contains(const interval_type& interval,
- const interval_type_2& value,
- bool consider_touch = true) {
- return contains(interval, get(value, LOW), consider_touch) &&
- contains(interval, get(value, HIGH), consider_touch);
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_low2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+void>::type low(IntervalType& interval,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ set(interval, LOW, value);
+}
 
- struct y_i_low : gtl_yes {};
+struct y_i_high2 : gtl_yes {};
 
- // get the low coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_low,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- low(const interval_type& interval) { return get(interval, LOW); }
-
- struct y_i_high : gtl_yes {};
-
- // get the high coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_high,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- high(const interval_type& interval) { return get(interval, HIGH); }
-
- struct y_i_center : gtl_yes {};
-
- // get the center coordinate
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_center,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_coordinate_type<interval_type>::type>::type
- center(const interval_type& interval) { return (high(interval) + low(interval))/2; }
-
-
- struct y_i_low2 : gtl_yes {};
-
- // set the low coordinate to v
- template <typename interval_type>
- typename enable_if<typename gtl_and<
- y_i_low2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- void>::type
- low(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type v) { set(interval, LOW, v); }
-
- struct y_i_high2 : gtl_yes {};
-
- // set the high coordinate to v
- template <typename interval_type>
- typename enable_if<typename gtl_and<
- y_i_high2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- void>::type
- high(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type v) { set(interval, HIGH, v); }
-
- struct y_i_delta : gtl_yes {};
-
- // get the magnitude of the interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_delta,
- typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_difference_type<interval_type>::type >::type
- delta(const interval_type& interval) {
- typedef typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::coordinate_difference diffT;
- return (diffT)high(interval) - (diffT)low(interval); }
-
- struct y_i_flip : gtl_yes {};
-
- // flip this about coordinate
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_flip, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- flip(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type axis = 0) {
- typename interval_coordinate_type<interval_type>::type newLow, newHigh;
- newLow = 2 * axis - high(interval);
- newHigh = 2 * axis - low(interval);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_high2,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+void>::type high(IntervalType& interval,
+ typename interval_mutable_traits<IntervalType>::coordinate_type value) {
+ set(interval, HIGH, value);
+}
 
- struct y_i_scale_up : gtl_yes {};
+struct y_i_equivalence : gtl_yes {};
 
- // scale interval by factor
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale_up, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale_up(interval_type& interval,
- typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::unsigned_area_type factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newHigh = high(interval) * (Unit)factor;
- low(interval, low(interval) * (Unit)factor);
- high(interval, (newHigh));
- return interval;
- }
+template <typename IntervalType1, typename IntervalType2>
+typename enable_if<
+ typename gtl_and_3<
+ y_i_equivalence,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType1>::type
+ >::type,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType2>::type
+ >::type
+ >::type,
+bool>::type equivalence(
+ const IntervalType1& interval1, const IntervalType2& interval2) {
+ return (get(interval1, LOW) == get(interval2, LOW)) &&
+ (get(interval1, HIGH) == get(interval2, HIGH));
+}
 
- struct y_i_scale_down : gtl_yes {};
+struct y_i_contains : gtl_yes {};
 
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale_down, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale_down(interval_type& interval,
- typename coordinate_traits<typename interval_coordinate_type<interval_type>::type>::unsigned_area_type factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- typedef typename coordinate_traits<Unit>::coordinate_distance dt;
- Unit newHigh = scaling_policy<Unit>::round((dt)(high(interval)) / (dt)factor);
- low(interval, scaling_policy<Unit>::round((dt)(low(interval)) / (dt)factor));
- high(interval, (newHigh));
- return interval;
+template <typename interval_type>
+typename enable_if< typename gtl_and< y_i_contains, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type >::type, bool>::type
+contains(const interval_type& interval,
+ typename interval_coordinate_type<interval_type>::type value,
+ bool consider_touch = true ) {
+ if(consider_touch) {
+ return value <= high(interval) && value >= low(interval);
+ } else {
+ return value < high(interval) && value > low(interval);
   }
+}
 
- struct y_i_scale : gtl_yes {};
+struct y_i_contains2 : gtl_yes {};
 
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_scale, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- scale(interval_type& interval, double factor) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newHigh = scaling_policy<Unit>::round((double)(high(interval)) * factor);
- low(interval, scaling_policy<Unit>::round((double)low(interval)* factor));
- high(interval, (newHigh));
- return interval;
- }
+template <typename interval_type, typename interval_type_2>
+typename enable_if< typename gtl_and_3<
+ y_i_contains2,
+ typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+contains(const interval_type& interval,
+ const interval_type_2& value,
+ bool consider_touch = true) {
+ return contains(interval, get(value, LOW), consider_touch) &&
+ contains(interval, get(value, HIGH), consider_touch);
+}
 
- struct y_i_move : gtl_yes {};
+struct y_i_center : gtl_yes {};
 
- // move interval by delta
- template <typename interval_type>
- typename enable_if< typename gtl_and<
- y_i_move,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- move(interval_type& interval, typename interval_difference_type<interval_type>::type displacement) {
- typedef typename interval_coordinate_type<interval_type>::type ctype;
- typedef typename coordinate_traits<ctype>::coordinate_difference Unit;
- Unit len = delta(interval);
- low(interval, static_cast<ctype>(static_cast<Unit>(low(interval)) + displacement));
- high(interval, static_cast<ctype>(static_cast<Unit>(low(interval)) + len));
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_center,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_coordinate_type<IntervalType>::type
+>::type center(const IntervalType& interval) {
+ return (high(interval) + low(interval)) / 2;
+}
 
- struct y_i_convolve : gtl_yes {};
+struct y_i_delta : gtl_yes {};
 
- // convolve this with b
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_convolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- convolve(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + b;
- Unit newHigh = high(interval) + b;
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_delta,
+ typename is_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+ typename interval_difference_type<IntervalType>::type
+>::type delta(const IntervalType& interval) {
+ typedef typename interval_difference_type<IntervalType>::type diff_type;
+ return static_cast<diff_type>(high(interval)) -
+ static_cast<diff_type>(low(interval));
+}
 
- struct y_i_deconvolve : gtl_yes {};
+struct y_i_flip : gtl_yes {};
 
- // deconvolve this with b
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_deconvolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
- deconvolve(interval_type& interval,
- typename interval_coordinate_type<interval_type>::type b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - b;
- Unit newHigh = high(interval) - b;
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_flip,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type& flip(IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type axis = 0) {
+ typename interval_coordinate_type<IntervalType>::type newLow, newHigh;
+ newLow = 2 * axis - high(interval);
+ newHigh = 2 * axis - low(interval);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_convolve2 : gtl_yes {};
+struct y_i_scale_up : gtl_yes {};
 
- // convolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_convolve2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- interval_type>::type &
- convolve(interval_type& interval,
- const interval_type_2& b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + low(b);
- Unit newHigh = high(interval) + high(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_scale_up,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type& scale_up(IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type factor) {
+ typename interval_coordinate_type<IntervalType>::type newHigh =
+ high(interval) * factor;
+ low(interval, low(interval) * factor);
+ high(interval, (newHigh));
+ return interval;
+}
 
- struct y_i_deconvolve2 : gtl_yes {};
+struct y_i_scale_down : gtl_yes {};
 
- // deconvolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3< y_i_deconvolve2,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- interval_type>::type &
- deconvolve(interval_type& interval,
- const interval_type_2& b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - low(b);
- Unit newHigh = high(interval) - high(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_scale_down,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type& scale_down(IntervalType& interval,
+ typename interval_coordinate_type<IntervalType>::type factor) {
+ typedef typename interval_coordinate_type<IntervalType>::type Unit;
+ typename interval_coordinate_type<IntervalType>::type newHigh =
+ high(interval) / factor;
+ low(interval, low(interval) / factor);
+ high(interval, (newHigh));
+ return interval;
+}
 
- struct y_i_reconvolve : gtl_yes {};
+// TODO(asydorchuk): Deprecated.
+struct y_i_scale : gtl_yes {};
 
- // reflected convolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_reconvolve,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- interval_type>::type &
- reflected_convolve(interval_type& interval,
- const interval_type_2& b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) - high(b);
- Unit newHigh = high(interval) - low(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename interval_type>
+typename enable_if<typename gtl_and<y_i_scale, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
+scale(interval_type& interval, double factor) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newHigh = scaling_policy<Unit>::round((double)(high(interval)) * factor);
+ low(interval, scaling_policy<Unit>::round((double)low(interval)* factor));
+ high(interval, (newHigh));
+ return interval;
+}
 
- struct y_i_redeconvolve : gtl_yes {};
+struct y_i_move : gtl_yes {};
 
- // reflected deconvolve this with b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3< y_i_redeconvolve,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- interval_type>::type &
- reflected_deconvolve(interval_type& interval,
- const interval_type_2& b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit newLow = low(interval) + high(b);
- Unit newHigh = high(interval) + low(b);
- low(interval, newLow);
- high(interval, newHigh);
- return interval;
- }
+template <typename IntervalType>
+typename enable_if<
+ typename gtl_and<
+ y_i_move,
+ typename is_mutable_interval_concept<
+ typename geometry_concept<IntervalType>::type
+ >::type
+ >::type,
+IntervalType>::type& move(IntervalType& interval,
+ typename interval_difference_type<IntervalType>::type displacement) {
+ typedef typename interval_coordinate_type<IntervalType>::type ctype;
+ typedef typename coordinate_traits<ctype>::coordinate_difference Unit;
+ low(interval, static_cast<ctype>(static_cast<Unit>(low(interval)) + displacement));
+ high(interval, static_cast<ctype>(static_cast<Unit>(high(interval)) + displacement));
+ return interval;
+}
 
- struct y_i_e_dist1 : gtl_yes {};
+struct y_i_convolve : gtl_yes {};
 
- // distance from a coordinate to an interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_e_dist1, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- typename interval_difference_type<interval_type>::type>::type
- euclidean_distance(const interval_type& interval,
- typename interval_coordinate_type<interval_type>::type position) {
- typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
- Unit dist[3] = {0, (Unit)low(interval) - (Unit)position, (Unit)position - (Unit)high(interval)};
- return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
- }
+// convolve this with b
+template <typename interval_type>
+typename enable_if<typename gtl_and<y_i_convolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
+convolve(interval_type& interval,
+ typename interval_coordinate_type<interval_type>::type b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) + b;
+ Unit newHigh = high(interval) + b;
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_e_dist2 : gtl_yes {};
+struct y_i_deconvolve : gtl_yes {};
 
- // distance between two intervals
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_dist2, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- typename interval_difference_type<interval_type>::type>::type
- euclidean_distance(const interval_type& interval,
- const interval_type_2& b) {
- typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
- Unit dist[3] = {0, (Unit)low(interval) - (Unit)high(b), (Unit)low(b) - (Unit)high(interval)};
- return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
- }
+// deconvolve this with b
+template <typename interval_type>
+typename enable_if<typename gtl_and<y_i_deconvolve, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type &
+deconvolve(interval_type& interval,
+ typename interval_coordinate_type<interval_type>::type b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) - b;
+ Unit newHigh = high(interval) - b;
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_e_intersects : gtl_yes {};
+struct y_i_convolve2 : gtl_yes {};
 
- // check if Interval b intersects `this` Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_intersects, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- intersects(const interval_type& interval, const interval_type_2& b,
- bool consider_touch = true) {
- return consider_touch ?
- (low(interval) <= high(b)) & (high(interval) >= low(b)) :
- (low(interval) < high(b)) & (high(interval) > low(b));
- }
+// convolve this with b
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_convolve2,
+ typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
+convolve(interval_type& interval,
+ const interval_type_2& b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) + low(b);
+ Unit newHigh = high(interval) + high(b);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_e_bintersect : gtl_yes {};
+struct y_i_deconvolve2 : gtl_yes {};
 
- // check if Interval b partially overlaps `this` Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_e_bintersect, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- boundaries_intersect(const interval_type& interval, const interval_type_2& b,
- bool consider_touch = true) {
- return (contains(interval, low(b), consider_touch) ||
- contains(interval, high(b), consider_touch)) &&
- (contains(b, low(interval), consider_touch) ||
- contains(b, high(interval), consider_touch));
- }
+// deconvolve this with b
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3< y_i_deconvolve2,
+ typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
+deconvolve(interval_type& interval,
+ const interval_type_2& b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) - low(b);
+ Unit newHigh = high(interval) - high(b);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_abuts1 : gtl_yes {};
+struct y_i_reconvolve : gtl_yes {};
 
- // check if they are end to end
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<y_i_abuts1, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- abuts(const interval_type& interval, const interval_type_2& b, direction_1d dir) {
- return dir.to_int() ? low(b) == high(interval) : low(interval) == high(b);
- }
+// reflected convolve this with b
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_reconvolve,
+ typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
+reflected_convolve(interval_type& interval,
+ const interval_type_2& b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) - high(b);
+ Unit newHigh = high(interval) - low(b);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_abuts2 : gtl_yes {};
+struct y_i_redeconvolve : gtl_yes {};
 
- // check if they are end to end
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_abuts2, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- abuts(const interval_type& interval, const interval_type_2& b) {
- return abuts(interval, b, HIGH) || abuts(interval, b, LOW);
- }
+// reflected deconvolve this with b
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3< y_i_redeconvolve,
+ typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
+reflected_deconvolve(interval_type& interval,
+ const interval_type_2& b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit newLow = low(interval) + high(b);
+ Unit newHigh = high(interval) + low(b);
+ low(interval, newLow);
+ high(interval, newHigh);
+ return interval;
+}
 
- struct y_i_intersect : gtl_yes {};
+struct y_i_e_dist1 : gtl_yes {};
 
- // set 'this' interval to the intersection of 'this' and b
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<y_i_intersect, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- intersect(interval_type& interval, const interval_type_2& b, bool consider_touch = true) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit lowVal = (std::max)(low(interval), low(b));
- Unit highVal = (std::min)(high(interval), high(b));
- bool valid = consider_touch ?
- lowVal <= highVal :
- lowVal < highVal;
- if(valid) {
- low(interval, lowVal);
- high(interval, highVal);
- }
- return valid;
- }
+// distance from a coordinate to an interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_e_dist1, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ typename interval_difference_type<interval_type>::type>::type
+euclidean_distance(const interval_type& interval,
+ typename interval_coordinate_type<interval_type>::type position) {
+ typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
+ Unit dist[3] = {0, (Unit)low(interval) - (Unit)position, (Unit)position - (Unit)high(interval)};
+ return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
+}
 
- struct y_i_g_intersect : gtl_yes {};
+struct y_i_e_dist2 : gtl_yes {};
 
- // set 'this' interval to the generalized intersection of 'this' and b
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_g_intersect, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- interval_type>::type &
- generalized_intersect(interval_type& interval, const interval_type_2& b) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
- //consider implementing faster sorting of small fixed length range
- polygon_sort(coords, coords+4);
- low(interval, coords[1]);
- high(interval, coords[2]);
- return interval;
- }
+// distance between two intervals
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_e_dist2, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ typename interval_difference_type<interval_type>::type>::type
+euclidean_distance(const interval_type& interval,
+ const interval_type_2& b) {
+ typedef typename coordinate_traits<typename interval_difference_type<interval_type>::type>::coordinate_difference Unit;
+ Unit dist[3] = {0, (Unit)low(interval) - (Unit)high(b), (Unit)low(b) - (Unit)high(interval)};
+ return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
+}
 
- struct y_i_bloat : gtl_yes {};
+struct y_i_e_intersects : gtl_yes {};
 
- // bloat the Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_bloat, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- bloat(interval_type& interval, typename interval_coordinate_type<interval_type>::type bloating) {
- low(interval, low(interval)-bloating);
- high(interval, high(interval)+bloating);
- return interval;
- }
+// check if Interval b intersects `this` Interval
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_e_intersects, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+ intersects(const interval_type& interval, const interval_type_2& b,
+ bool consider_touch = true) {
+ return consider_touch ?
+ (low(interval) <= high(b)) & (high(interval) >= low(b)) :
+ (low(interval) < high(b)) & (high(interval) > low(b));
+}
 
- struct y_i_bloat2 : gtl_yes {};
+struct y_i_e_bintersect : gtl_yes {};
 
- // bloat the specified side of `this` Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_bloat2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- bloat(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type bloating) {
- set(interval, dir, get(interval, dir) + dir.get_sign() * bloating);
- return interval;
- }
+// check if Interval b partially overlaps `this` Interval
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_e_bintersect, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+boundaries_intersect(const interval_type& interval, const interval_type_2& b,
+ bool consider_touch = true) {
+ return (contains(interval, low(b), consider_touch) ||
+ contains(interval, high(b), consider_touch)) &&
+ (contains(b, low(interval), consider_touch) ||
+ contains(b, high(interval), consider_touch));
+}
 
- struct y_i_shrink : gtl_yes {};
+struct y_i_abuts1 : gtl_yes {};
 
- // shrink the Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_shrink, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- shrink(interval_type& interval, typename interval_coordinate_type<interval_type>::type shrinking) {
- return bloat(interval, -shrinking);
- }
+// check if they are end to end
+template <typename interval_type, typename interval_type_2>
+typename enable_if< typename gtl_and_3<y_i_abuts1, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+abuts(const interval_type& interval, const interval_type_2& b, direction_1d dir) {
+ return dir.to_int() ? low(b) == high(interval) : low(interval) == high(b);
+}
 
- struct y_i_shrink2 : gtl_yes {};
+struct y_i_abuts2 : gtl_yes {};
 
- // shrink the specified side of `this` Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_shrink2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- interval_type>::type &
- shrink(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type shrinking) {
- return bloat(interval, dir, -shrinking);
- }
+// check if they are end to end
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_abuts2, typename is_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+abuts(const interval_type& interval, const interval_type_2& b) {
+ return abuts(interval, b, HIGH) || abuts(interval, b, LOW);
+}
 
- struct y_i_encompass : gtl_yes {};
+struct y_i_intersect : gtl_yes {};
 
- // Enlarge `this` Interval to encompass the specified Interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if< typename gtl_and_3<
- y_i_encompass,
- typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
- bool>::type
- encompass(interval_type& interval, const interval_type_2& b) {
- bool retval = !contains(interval, b, true);
- low(interval, (std::min)(low(interval), low(b)));
- high(interval, (std::max)(high(interval), high(b)));
- return retval;
+// set 'this' interval to the intersection of 'this' and b
+template <typename interval_type, typename interval_type_2>
+typename enable_if< typename gtl_and_3<y_i_intersect, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+intersect(interval_type& interval, const interval_type_2& b, bool consider_touch = true) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit lowVal = (std::max)(low(interval), low(b));
+ Unit highVal = (std::min)(high(interval), high(b));
+ bool valid = consider_touch ?
+ lowVal <= highVal :
+ lowVal < highVal;
+ if(valid) {
+ low(interval, lowVal);
+ high(interval, highVal);
   }
+ return valid;
+}
 
- struct y_i_encompass2 : gtl_yes {};
+struct y_i_g_intersect : gtl_yes {};
 
- // Enlarge `this` Interval to encompass the specified Interval
- template <typename interval_type>
- typename enable_if< typename gtl_and<y_i_encompass2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
- bool>::type
- encompass(interval_type& interval, typename interval_coordinate_type<interval_type>::type b) {
- bool retval = !contains(interval, b, true);
- low(interval, (std::min)(low(interval), b));
- high(interval, (std::max)(high(interval), b));
- return retval;
- }
+// set 'this' interval to the generalized intersection of 'this' and b
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_g_intersect, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ interval_type>::type &
+generalized_intersect(interval_type& interval, const interval_type_2& b) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit coords[4] = {low(interval), high(interval), low(b), high(b)};
+ //consider implementing faster sorting of small fixed length range
+ polygon_sort(coords, coords+4);
+ low(interval, coords[1]);
+ high(interval, coords[2]);
+ return interval;
+}
 
- struct y_i_get_half : gtl_yes {};
+struct y_i_bloat : gtl_yes {};
 
- // gets the half of the interval as an interval
- template <typename interval_type>
- typename enable_if<typename gtl_and<y_i_get_half, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type
- get_half(const interval_type& interval, direction_1d d1d) {
- typedef typename interval_coordinate_type<interval_type>::type Unit;
- Unit c = (get(interval, LOW) + get(interval, HIGH)) / 2;
- return construct<interval_type>((d1d == LOW) ? get(interval, LOW) : c,
- (d1d == LOW) ? c : get(interval, HIGH));
- }
+// bloat the Interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_bloat, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ interval_type>::type &
+bloat(interval_type& interval, typename interval_coordinate_type<interval_type>::type bloating) {
+ low(interval, low(interval)-bloating);
+ high(interval, high(interval)+bloating);
+ return interval;
+}
+
+struct y_i_bloat2 : gtl_yes {};
+
+// bloat the specified side of `this` Interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_bloat2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ interval_type>::type &
+bloat(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type bloating) {
+ set(interval, dir, get(interval, dir) + dir.get_sign() * bloating);
+ return interval;
+}
+
+struct y_i_shrink : gtl_yes {};
+
+// shrink the Interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_shrink, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ interval_type>::type &
+shrink(interval_type& interval, typename interval_coordinate_type<interval_type>::type shrinking) {
+ return bloat(interval, -shrinking);
+}
+
+struct y_i_shrink2 : gtl_yes {};
 
- struct y_i_join_with : gtl_yes {};
+// shrink the specified side of `this` Interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_shrink2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ interval_type>::type &
+shrink(interval_type& interval, direction_1d dir, typename interval_coordinate_type<interval_type>::type shrinking) {
+ return bloat(interval, dir, -shrinking);
+}
+
+struct y_i_encompass : gtl_yes {};
 
- // returns true if the 2 intervals exactly touch at one value, like in l1 <= h1 == l2 <= h2
- // sets the argument to the joined interval
- template <typename interval_type, typename interval_type_2>
- typename enable_if<
- typename gtl_and_3<y_i_join_with, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
- typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+// Enlarge `this` Interval to encompass the specified Interval
+template <typename interval_type, typename interval_type_2>
+typename enable_if< typename gtl_and_3<
+ y_i_encompass,
+ typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
     bool>::type
- join_with(interval_type& interval, const interval_type_2& b) {
- if(abuts(interval, b)) {
- encompass(interval, b);
- return true;
- }
- return false;
- }
+encompass(interval_type& interval, const interval_type_2& b) {
+ bool retval = !contains(interval, b, true);
+ low(interval, (std::min)(low(interval), low(b)));
+ high(interval, (std::max)(high(interval), high(b)));
+ return retval;
+}
 
- template <class T>
- template <class T2>
- interval_data<T>& interval_data<T>::operator=(const T2& rvalue) {
- assign(*this, rvalue);
- return *this;
- }
+struct y_i_encompass2 : gtl_yes {};
 
- template <typename T>
- struct geometry_concept<interval_data<T> > {
- typedef interval_concept type;
- };
+// Enlarge `this` Interval to encompass the specified Interval
+template <typename interval_type>
+typename enable_if< typename gtl_and<y_i_encompass2, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type,
+ bool>::type
+encompass(interval_type& interval, typename interval_coordinate_type<interval_type>::type b) {
+ bool retval = !contains(interval, b, true);
+ low(interval, (std::min)(low(interval), b));
+ high(interval, (std::max)(high(interval), b));
+ return retval;
 }
+
+struct y_i_get_half : gtl_yes {};
+
+// gets the half of the interval as an interval
+template <typename interval_type>
+typename enable_if<typename gtl_and<y_i_get_half, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type>::type, interval_type>::type
+get_half(const interval_type& interval, direction_1d d1d) {
+ typedef typename interval_coordinate_type<interval_type>::type Unit;
+ Unit c = (get(interval, LOW) + get(interval, HIGH)) / 2;
+ return construct<interval_type>((d1d == LOW) ? get(interval, LOW) : c,
+ (d1d == LOW) ? c : get(interval, HIGH));
+}
+
+struct y_i_join_with : gtl_yes {};
+
+// returns true if the 2 intervals exactly touch at one value, like in l1 <= h1 == l2 <= h2
+// sets the argument to the joined interval
+template <typename interval_type, typename interval_type_2>
+typename enable_if<
+ typename gtl_and_3<y_i_join_with, typename is_mutable_interval_concept<typename geometry_concept<interval_type>::type>::type,
+ typename is_interval_concept<typename geometry_concept<interval_type_2>::type>::type>::type,
+ bool>::type
+join_with(interval_type& interval, const interval_type_2& b) {
+ if(abuts(interval, b)) {
+ encompass(interval, b);
+ return true;
+ }
+ return false;
 }
-#endif
+} // polygon
+} // boost
+#endif // BOOST_POLYGON_INTERVAL_CONCEPT_HPP

Modified: trunk/boost/polygon/interval_data.hpp
==============================================================================
--- trunk/boost/polygon/interval_data.hpp (original)
+++ trunk/boost/polygon/interval_data.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,67 +1,119 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_data.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
 
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-*/
 #ifndef BOOST_POLYGON_INTERVAL_DATA_HPP
 #define BOOST_POLYGON_INTERVAL_DATA_HPP
+
 #include "isotropy.hpp"
-namespace boost { namespace polygon{
- template <typename T>
- class interval_data {
- public:
- typedef T coordinate_type;
- inline interval_data()
+#include "interval_concept.hpp"
+
+namespace boost {
+namespace polygon {
+
+template <typename T>
+class interval_data {
+ public:
+ typedef T coordinate_type;
+
+ interval_data()
 #ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
 #endif
     {}
- inline interval_data(coordinate_type low, coordinate_type high)
+
+ interval_data(coordinate_type low, coordinate_type high)
 #ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
 #endif
- {
- coords_[LOW] = low; coords_[HIGH] = high;
- }
- inline interval_data(const interval_data& that)
+ {
+ coords_[LOW] = low; coords_[HIGH] = high;
+ }
+
+ interval_data(const interval_data& that)
 #ifndef BOOST_POLYGON_MSVC
- :coords_()
+ : coords_()
 #endif
- {
- (*this) = that;
- }
- inline interval_data& operator=(const interval_data& that) {
- coords_[0] = that.coords_[0]; coords_[1] = that.coords_[1]; return *this;
- }
- template <typename T2>
- inline interval_data& operator=(const T2& rvalue);
- inline coordinate_type get(direction_1d dir) const {
- return coords_[dir.to_int()];
- }
- inline coordinate_type low() const { return coords_[0]; }
- inline coordinate_type high() const { return coords_[1]; }
- inline bool operator==(const interval_data& that) const {
- return low() == that.low() && high() == that.high(); }
- inline bool operator!=(const interval_data& that) const {
- return low() != that.low() || high() != that.high(); }
- inline bool operator<(const interval_data& that) const {
- if(coords_[0] < that.coords_[0]) return true;
- if(coords_[0] > that.coords_[0]) return false;
- if(coords_[1] < that.coords_[1]) return true;
- return false;
- }
- inline bool operator<=(const interval_data& that) const { return !(that < *this); }
- inline bool operator>(const interval_data& that) const { return that < *this; }
- inline bool operator>=(const interval_data& that) const { return !((*this) < that); }
- inline void set(direction_1d dir, coordinate_type value) {
+ {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ }
+
+ interval_data& operator=(const interval_data& that) {
+ coords_[0] = that.coords_[0];
+ coords_[1] = that.coords_[1];
+ return *this;
+ }
+
+ coordinate_type get(direction_1d dir) const {
+ return coords_[dir.to_int()];
+ }
+
+ void set(direction_1d dir, coordinate_type value) {
     coords_[dir.to_int()] = value;
   }
-private:
+
+ coordinate_type low() const {
+ return coords_[0];
+ }
+
+ interval_data& low(coordinate_type value) {
+ coords_[LOW] = value;
+ return *this;
+ }
+
+ coordinate_type high() const {
+ return coords_[1];
+ }
+
+ interval_data& high(coordinate_type value) {
+ coords_[HIGH] = value;
+ return *this;
+ }
+
+ bool operator==(const interval_data& that) const {
+ return low() == that.low() && high() == that.high();
+ }
+
+ bool operator!=(const interval_data& that) const {
+ return low() != that.low() || high() != that.high();
+ }
+
+ bool operator<(const interval_data& that) const {
+ if (coords_[0] != that.coords_[0]) {
+ return coords_[0] < that.coords_[0];
+ }
+ return coords_[1] < that.coords_[1];
+ }
+
+ bool operator<=(const interval_data& that) const {
+ return !(that < *this);
+ }
+
+ bool operator>(const interval_data& that) const {
+ return that < *this;
+ }
+
+ bool operator>=(const interval_data& that) const {
+ return !((*this) < that);
+ }
+
+ private:
   coordinate_type coords_[2];
 };
 
-}
-}
-#endif
+template <typename CType>
+struct geometry_concept< interval_data<CType> > {
+ typedef interval_concept type;
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLYGON_INTERVAL_DATA_HPP

Modified: trunk/boost/polygon/interval_traits.hpp
==============================================================================
--- trunk/boost/polygon/interval_traits.hpp (original)
+++ trunk/boost/polygon/interval_traits.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,32 +1,47 @@
-/*
- Copyright 2008 Intel Corporation
+// Boost.Polygon library interval_traits.hpp header file
+
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
+
+// See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is 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)
 
- Use, modification and distribution are subject to the Boost Software License,
- Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt).
-*/
 #ifndef BOOST_POLYGON_INTERVAL_TRAITS_HPP
 #define BOOST_POLYGON_INTERVAL_TRAITS_HPP
-namespace boost { namespace polygon{
- template <typename T>
- struct interval_traits {
- typedef typename T::coordinate_type coordinate_type;
-
- static inline coordinate_type get(const T& interval, direction_1d dir) {
- return interval.get(dir);
- }
- };
-
- template <typename T>
- struct interval_mutable_traits {
- static inline void set(T& interval, direction_1d dir, typename interval_traits<T>::coordinate_type value) {
- interval.set(dir, value);
- }
- static inline T construct(typename interval_traits<T>::coordinate_type low_value,
- typename interval_traits<T>::coordinate_type high_value) {
- return T(low_value, high_value);
- }
- };
-}
-}
-#endif
+
+#include "isotropy.hpp"
+
+namespace boost {
+namespace polygon {
+
+template <typename Interval>
+struct interval_traits {
+ typedef Interval interval_type;
+ typedef typename interval_type::coordinate_type coordinate_type;
+
+ static coordinate_type get(const interval_type& interval, direction_1d dir) {
+ return interval.get(dir);
+ }
+};
+
+template <typename Interval>
+struct interval_mutable_traits {
+ typedef Interval interval_type;
+ typedef typename interval_type::coordinate_type coordinate_type;
+
+ static void set(
+ interval_type& interval, direction_1d dir, coordinate_type value) {
+ interval.set(dir, value);
+ }
+
+ static interval_type construct(coordinate_type low, coordinate_type high) {
+ return interval_type(low, high);
+ }
+};
+} // polygon
+} // boost
+
+#endif // BOOST_POLICY_INTERVAL_TRAITS_HPP

Modified: trunk/boost/polygon/point_concept.hpp
==============================================================================
--- trunk/boost/polygon/point_concept.hpp (original)
+++ trunk/boost/polygon/point_concept.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library point_concept.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_POINT_CONCEPT_HPP
 #define BOOST_POLYGON_POINT_CONCEPT_HPP
@@ -68,7 +68,7 @@
 template <typename GeometryType>
 struct point_difference_type_by_concept<GeometryType, gtl_yes> {
   typedef typename coordinate_traits<
- typename point_coordinate_type<GeometryType>::type
+ typename point_traits<GeometryType>::coordinate_type
>::coordinate_difference type;
 };
 

Modified: trunk/boost/polygon/point_data.hpp
==============================================================================
--- trunk/boost/polygon/point_data.hpp (original)
+++ trunk/boost/polygon/point_data.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library point_data.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_POINT_DATA_HPP
 #define BOOST_POLYGON_POINT_DATA_HPP
@@ -61,6 +61,32 @@
     coords_[VERTICAL] = (coordinate_type)that.y();
   }
 
+ coordinate_type get(orientation_2d orient) const {
+ return coords_[orient.to_int()];
+ }
+
+ void set(orientation_2d orient, coordinate_type value) {
+ coords_[orient.to_int()] = value;
+ }
+
+ coordinate_type x() const {
+ return coords_[HORIZONTAL];
+ }
+
+ point_data& x(coordinate_type value) {
+ coords_[HORIZONTAL] = value;
+ return *this;
+ }
+
+ coordinate_type y() const {
+ return coords_[VERTICAL];
+ }
+
+ point_data& y(coordinate_type value) {
+ coords_[VERTICAL] = value;
+ return *this;
+ }
+
   bool operator==(const point_data& that) const {
     return (coords_[0] == that.coords_[0]) &&
       (coords_[1] == that.coords_[1]);
@@ -88,37 +114,10 @@
     return !(*this < that);
   }
 
- coordinate_type get(orientation_2d orient) const {
- return coords_[orient.to_int()];
- }
-
- void set(orientation_2d orient, coordinate_type value) {
- coords_[orient.to_int()] = value;
- }
-
- coordinate_type x() const {
- return coords_[HORIZONTAL];
- }
-
- coordinate_type y() const {
- return coords_[VERTICAL];
- }
-
- point_data& x(coordinate_type value) {
- coords_[HORIZONTAL] = value;
- return *this;
- }
-
- point_data& y(coordinate_type value) {
- coords_[VERTICAL] = value;
- return *this;
- }
-
  private:
   coordinate_type coords_[2];
 };
 
-
 template <typename CType>
 struct geometry_concept< point_data<CType> > {
   typedef point_concept type;

Modified: trunk/boost/polygon/point_traits.hpp
==============================================================================
--- trunk/boost/polygon/point_traits.hpp (original)
+++ trunk/boost/polygon/point_traits.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library point_traits.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_POINT_TRAITS_HPP
 #define BOOST_POLYGON_POINT_TRAITS_HPP

Modified: trunk/boost/polygon/segment_concept.hpp
==============================================================================
--- trunk/boost/polygon/segment_concept.hpp (original)
+++ trunk/boost/polygon/segment_concept.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library segment_concept.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_SEGMENT_CONCEPT_HPP
 #define BOOST_POLYGON_SEGMENT_CONCEPT_HPP

Modified: trunk/boost/polygon/segment_data.hpp
==============================================================================
--- trunk/boost/polygon/segment_data.hpp (original)
+++ trunk/boost/polygon/segment_data.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library segment_data.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_SEGMENT_DATA_HPP
 #define BOOST_POLYGON_SEGMENT_DATA_HPP

Modified: trunk/boost/polygon/segment_traits.hpp
==============================================================================
--- trunk/boost/polygon/segment_traits.hpp (original)
+++ trunk/boost/polygon/segment_traits.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library segment_traits.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_SEGMENT_TRAITS_HPP
 #define BOOST_POLYGON_SEGMENT_TRAITS_HPP

Modified: trunk/boost/polygon/transform.hpp
==============================================================================
--- trunk/boost/polygon/transform.hpp (original)
+++ trunk/boost/polygon/transform.hpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -1,13 +1,13 @@
 // Boost.Polygon library point_data.hpp header file
 
-// Copyright 2008 Intel Corporation.
-// Copyright Simonson Lucanus 2008-2012.
-// Copyright Andrii Sydorchuk 2012-2012.
-// Distributed under 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)
+// Copyright (c) Intel Corporation 2008.
+// Copyright (c) 2008-2012 Simonson Lucanus.
+// Copyright (c) 2012-2012 Andrii Sydorchuk.
 
 // See http://www.boost.org for updates, documentation, and revision history.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_POLYGON_TRANSFORM_HPP
 #define BOOST_POLYGON_TRANSFORM_HPP
@@ -16,7 +16,7 @@
 
 namespace boost {
 namespace polygon {
-// Transformation of Coordinate Systems
+// Transformation of Coordinate System.
 // Enum meaning:
 // Select which direction_2d to change the positive direction of each
 // axis in the old coordinate system to map it to the new coordiante system.
@@ -41,16 +41,6 @@
 // 111 SOUTH WEST
 class axis_transformation {
  public:
- // Enum Names and values
- // NULL_TRANSFORM = 0, BEGIN_TRANSFORM = 0,
- // EN = 0, EAST_NORTH = 0,
- // WN = 1, WEST_NORTH = 1, FLIP_X = 1,
- // ES = 2, EAST_SOUTH = 2, FLIP_Y = 2,
- // WS = 3, WEST_SOUTH = 3,
- // NE = 4, NORTH_EAST = 4, SWAP_XY = 4,
- // SE = 5, SOUTH_EAST = 5,
- // NW = 6, NORTH_WEST = 6,
- // SW = 7, SOUTH_WEST = 7,
   enum ATR {
     NULL_TRANSFORM = 0,
     BEGIN_TRANSFORM = 0,

Modified: trunk/libs/polygon/test/Jamfile.v2
==============================================================================
--- trunk/libs/polygon/test/Jamfile.v2 (original)
+++ trunk/libs/polygon/test/Jamfile.v2 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -20,6 +20,7 @@
     :
         [ run polygon_point_test.cpp ]
         [ run polygon_segment_test.cpp ]
+ [ run polygon_interval_test.cpp ]
         [ run gtl_boost_unit_test.cpp ]
     ;
 

Added: trunk/libs/polygon/test/polygon_interval_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/polygon/test/polygon_interval_test.cpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -0,0 +1,149 @@
+// Boost.Polygon library polygon_interval_test.cpp file
+
+// Copyright Andrii Sydorchuk 2012.
+// Distributed under 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)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#define BOOST_TEST_MODULE POLYGON_INTERVAL_TEST
+#include <boost/mpl/list.hpp>
+#include <boost/test/test_case_template.hpp>
+
+#include "boost/polygon/interval_concept.hpp"
+#include "boost/polygon/interval_data.hpp"
+#include "boost/polygon/interval_traits.hpp"
+using namespace boost::polygon;
+
+typedef boost::mpl::list<int> test_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_data_test, T, test_types) {
+ typedef interval_data<T> interval_type;
+ interval_type interval1(1, 2);
+ interval_type interval2;
+ interval2 = interval1;
+
+ BOOST_CHECK_EQUAL(interval1.low(), 1);
+ BOOST_CHECK_EQUAL(interval1.high(), 2);
+ BOOST_CHECK_EQUAL(interval1.get(LOW), 1);
+ BOOST_CHECK_EQUAL(interval1.get(HIGH), 2);
+ BOOST_CHECK(interval1 == interval2);
+ BOOST_CHECK(!(interval1 != interval2));
+ BOOST_CHECK(!(interval1 < interval2));
+ BOOST_CHECK(!(interval1 > interval2));
+ BOOST_CHECK(interval1 <= interval2);
+ BOOST_CHECK(interval1 >= interval2);
+
+ interval1.low(2);
+ interval1.high(1);
+ BOOST_CHECK_EQUAL(interval1.low(), 2);
+ BOOST_CHECK_EQUAL(interval1.high(), 1);
+ BOOST_CHECK(!(interval1 == interval2));
+ BOOST_CHECK(interval1 != interval2);
+
+ interval2.set(LOW, 2);
+ interval2.set(HIGH, 1);
+ BOOST_CHECK(interval1 == interval2);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_traits_test, T, test_types) {
+ typedef interval_data<T> interval_type;
+
+ interval_type interval = interval_mutable_traits<interval_type>::construct(1, 2);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, LOW), 1);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, HIGH), 2);
+
+ interval_mutable_traits<interval_type>::set(interval, LOW, 3);
+ interval_mutable_traits<interval_type>::set(interval, HIGH, 4);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, LOW), 3);
+ BOOST_CHECK_EQUAL(interval_traits<interval_type>::get(interval, HIGH), 4);
+}
+
+template <typename T>
+struct Interval {
+ T left;
+ T right;
+};
+
+namespace boost {
+namespace polygon {
+ template <typename T>
+ struct geometry_concept< Interval<T> > {
+ typedef interval_concept type;
+ };
+
+ template <typename T>
+ struct interval_traits< Interval<T> > {
+ typedef T coordinate_type;
+
+ static coordinate_type get(const Interval<T>& interval, direction_1d dir) {
+ return (dir == LOW) ? interval.left : interval.right;
+ }
+ };
+
+ template <typename T>
+ struct interval_mutable_traits< Interval<T> > {
+ typedef T coordinate_type;
+
+ static void set(Interval<T>& interval, direction_1d dir, T value) {
+ (dir == LOW) ? interval.left = value : interval.right = value;
+ }
+
+ static Interval<T> construct(coordinate_type left, coordinate_type right) {
+ Interval<T> interval;
+ interval.left = left;
+ interval.right = right;
+ return interval;
+ }
+ };
+} // polygon
+} // boost
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test1, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval1 = construct<interval_type>(2, 1);
+ BOOST_CHECK_EQUAL(interval1.left, 1);
+ BOOST_CHECK_EQUAL(interval1.right, 2);
+
+ set(interval1, LOW, 3);
+ set(interval1, HIGH, 4);
+ BOOST_CHECK_EQUAL(get(interval1, LOW), 3);
+ BOOST_CHECK_EQUAL(get(interval1, HIGH), 4);
+
+ interval_type interval2 = copy_construct<interval_type>(interval1);
+ BOOST_CHECK(equivalence(interval1, interval2));
+
+ low(interval2, 1);
+ high(interval2, 2);
+ BOOST_CHECK_EQUAL(low(interval2), 1);
+ BOOST_CHECK_EQUAL(high(interval2), 2);
+
+ assign(interval1, interval2);
+ BOOST_CHECK(equivalence(interval1, interval2));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(interval_concept_test2, T, test_types) {
+ typedef Interval<T> interval_type;
+
+ interval_type interval = construct<interval_type>(1, 3);
+ BOOST_CHECK_EQUAL(center(interval), 2);
+ BOOST_CHECK_EQUAL(delta(interval), 2);
+
+ flip(interval, -1);
+ BOOST_CHECK_EQUAL(low(interval), -5);
+ BOOST_CHECK_EQUAL(high(interval), -3);
+
+ scale_up(interval, 2);
+ BOOST_CHECK_EQUAL(low(interval), -10);
+ BOOST_CHECK_EQUAL(high(interval), -6);
+
+ scale_down(interval, 2);
+ BOOST_CHECK_EQUAL(low(interval), -5);
+ BOOST_CHECK_EQUAL(high(interval), -3);
+
+ move(interval, 5);
+ BOOST_CHECK_EQUAL(low(interval), 0);
+ BOOST_CHECK_EQUAL(high(interval), 2);
+}

Modified: trunk/libs/polygon/test/polygon_point_test.cpp
==============================================================================
--- trunk/libs/polygon/test/polygon_point_test.cpp (original)
+++ trunk/libs/polygon/test/polygon_point_test.cpp 2012-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -11,7 +11,9 @@
 #include <boost/mpl/list.hpp>
 #include <boost/test/test_case_template.hpp>
 
-#include "boost/polygon/polygon.hpp"
+#include "boost/polygon/point_concept.hpp"
+#include "boost/polygon/point_data.hpp"
+#include "boost/polygon/point_traits.hpp"
 using namespace boost::polygon;
 
 typedef boost::mpl::list<int> test_types;

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-12-10 18:13:43 EST (Mon, 10 Dec 2012)
@@ -11,7 +11,9 @@
 #include <boost/mpl/list.hpp>
 #include <boost/test/test_case_template.hpp>
 
-#include "boost/polygon/polygon.hpp"
+#include "boost/polygon/segment_concept.hpp"
+#include "boost/polygon/segment_data.hpp"
+#include "boost/polygon/segment_traits.hpp"
 using namespace boost::polygon;
 
 typedef boost::mpl::list<int> test_types;


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