Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74523 - in sandbox/SOC/2010/sweepline: boost/sweepline boost/sweepline/detail libs/sweepline/test
From: sydorchuk.andriy_at_[hidden]
Date: 2011-09-22 17:22:07


Author: asydorchuk
Date: 2011-09-22 17:22:05 EDT (Thu, 22 Sep 2011)
New Revision: 74523
URL: http://svn.boost.org/trac/boost/changeset/74523

Log:
Added voronoi_calc_kernel to split predicates and underlying data representation.
Moved site - site, circle - circle, site - circle comparison predicates to voronoi_calc_kernel.
Added:
   sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_calc_kernel.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_formation.hpp | 132 ++-------------------------------------
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_builder.hpp | 20 ++++-
   sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp | 122 +++++++++++++++++++++---------------
   3 files changed, 94 insertions(+), 180 deletions(-)

Added: sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_calc_kernel.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_calc_kernel.hpp 2011-09-22 17:22:05 EDT (Thu, 22 Sep 2011)
@@ -0,0 +1,200 @@
+// Boost sweepline/voronoi_calc_kernel.hpp header file
+
+// Copyright Andrii Sydorchuk 2010-2011.
+// 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.
+
+#ifndef BOOST_SWEEPLINE_VORONOI_CALC_KERNEL
+#define BOOST_SWEEPLINE_VORONOI_CALC_KERNEL
+
+#include "voronoi_fpt_kernel.hpp"
+
+namespace boost {
+namespace sweepline {
+namespace detail {
+
+template <typename T>
+struct voronoi_calc_kernel_traits;
+
+template <>
+struct voronoi_calc_kernel_traits<int> {
+ typedef double fpt_type;
+ typedef polygon_ulong_long_type ulong_long_type;
+};
+
+template <typename T>
+class voronoi_calc_kernel;
+
+template <>
+class voronoi_calc_kernel<int> {
+public:
+ typedef voronoi_calc_kernel_traits<int>::fpt_type fpt_type;
+ typedef voronoi_calc_kernel_traits<int>::ulong_long_type ulong_long_type;
+
+ enum kOrientation {
+ RIGHT = -1,
+ COLLINEAR = 0,
+ LEFT = 1,
+ };
+
+ // Value is a determinant of two vectors.
+ // Return orientation based on the sign of the determinant.
+ template <typename T>
+ static kOrientation get_orientation(T value) {
+ if (value == static_cast<T>(0.0)) return COLLINEAR;
+ return (value < static_cast<T>(0.0)) ? RIGHT : LEFT;
+ }
+
+ // Compute robust cross_product: a1 * b2 - b1 * a2.
+ // The result is correct with epsilon relative error equal to 2EPS.
+ template <typename T>
+ static fpt_type robust_cross_product(T a1_, T b1_, T a2_, T b2_) {
+ ulong_long_type a1, b1, a2, b2;
+ bool a1_plus, a2_plus, b1_plus, b2_plus;
+ a1_plus = convert_to_65_bit(a1_, a1);
+ b1_plus = convert_to_65_bit(b1_, b1);
+ a2_plus = convert_to_65_bit(a2_, a2);
+ b2_plus = convert_to_65_bit(b2_, b2);
+
+ ulong_long_type expr_l = a1 * b2;
+ bool expr_l_plus = (a1_plus == b2_plus) ? true : false;
+ ulong_long_type expr_r = b1 * a2;
+ bool expr_r_plus = (a2_plus == b1_plus) ? true : false;
+
+ if (expr_l == 0) expr_l_plus = true;
+ if (expr_r == 0) expr_r_plus = true;
+
+ if ((expr_l_plus == expr_r_plus) && (expr_l == expr_r))
+ return static_cast<fpt_type>(0.0);
+
+ // Produce the result with epsilon relative error.
+ if (!expr_l_plus) {
+ if (expr_r_plus)
+ return -static_cast<fpt_type>(expr_l) -
+ static_cast<fpt_type>(expr_r);
+ else return (expr_l > expr_r) ?
+ -static_cast<fpt_type>(expr_l - expr_r) :
+ static_cast<fpt_type>(expr_r - expr_l);
+ } else {
+ if (!expr_r_plus)
+ return static_cast<fpt_type>(expr_l) +
+ static_cast<fpt_type>(expr_r);
+ else
+ return (expr_l < expr_r) ?
+ -static_cast<fpt_type>(expr_r - expr_l) :
+ static_cast<fpt_type>(expr_l - expr_r);
+ }
+ }
+
+ // Robust orientation test. Works correctly for any input type that
+ // can be casted without lose of data to the integer type within a range
+ // [-2^32, 2^32-1].
+ // Arguments: dif_x1_, dif_y1 - coordinates of the first vector.
+ // dif_x2_, dif_y2 - coordinates of the second vector.
+ // Returns orientation test result for input vectors.
+ template <typename T>
+ static kOrientation get_orientation(T dif_x1_, T dif_y1_, T dif_x2_, T dif_y2_) {
+ return get_orientation(robust_cross_product(dif_x1_, dif_y1_, dif_x2_, dif_y2_));
+ }
+
+ // Robust orientation test. Works correctly for any input coordinate type
+ // that can be casted without lose of data to integer type within a range
+ // [-2^31, 2^31 - 1] - signed integer type.
+ // Arguments: point1, point2 - represent the first vector;
+ // point2, point3 - represent the second vector;
+ // Returns orientation test result for input vectors.
+ template <typename Point>
+ static kOrientation get_orientation(const Point &point1,
+ const Point &point2,
+ const Point &point3) {
+ return get_orientation(robust_cross_product(point1.x() - point2.x(),
+ point1.y() - point2.y(),
+ point2.x() - point3.x(),
+ point2.y() - point3.y()));
+ }
+
+ struct site_comparison_predicate {
+ template <typename Site>
+ bool operator()(const Site &lhs, const Site &rhs) const {
+ if (lhs.x0() != rhs.x0()) return lhs.x0() < rhs.x0();
+ if (!lhs.is_segment()) {
+ if (!rhs.is_segment()) return lhs.y0() < rhs.y0();
+ if (rhs.is_vertical()) return lhs.y0() <= rhs.y0();
+ return true;
+ } else {
+ if (rhs.is_vertical()) {
+ if(lhs.is_vertical()) return lhs.y0() < rhs.y0();
+ return false;
+ }
+ if (lhs.is_vertical()) return true;
+ if (lhs.y0() != rhs.y0()) return lhs.y0() < rhs.y0();
+ return get_orientation(lhs.point1(), lhs.point0(), rhs.point1()) == LEFT;
+ }
+ }
+ };
+
+ struct site_equality_predicate {
+ template <typename Site>
+ bool operator()(const Site &lhs, const Site &rhs) const {
+ return lhs.point0() == rhs.point0() &&
+ lhs.point1() == rhs.point1();
+ }
+ };
+
+ struct circle_comparison_predicate {
+ static const unsigned int ULPS = 128;
+
+ template <typename Circle>
+ bool operator()(const Circle &lhs, const Circle &rhs) const {
+ if (almost_equal(lhs.lower_x(), rhs.lower_x(), ULPS)) {
+ if (almost_equal(lhs.lower_y(), rhs.lower_y(), ULPS)) {
+ return false;
+ }
+ return lhs.lower_y() < rhs.lower_y();
+ }
+ return lhs.lower_x() < rhs.lower_x();
+ }
+ };
+
+ struct event_comparison_predicate {
+ static const unsigned int ULPS = 64;
+
+ template <typename Site, typename Circle>
+ bool operator()(const Site &lhs, const Circle &rhs) const {
+ if (almost_equal(lhs.x(), rhs.lower_x(), ULPS)) {
+ if (almost_equal(lhs.y(), rhs.lower_y(), ULPS)) return false;
+ return lhs.y() < rhs.lower_y();
+ }
+ return lhs.x() < rhs.lower_x();
+ }
+ };
+
+ template <typename Node>
+ struct node_comparison_predicate {
+ bool operator()(const Node &lhs, const Node &rhs) const {
+ }
+ };
+
+private:
+ // Convert value to 64-bit unsigned integer.
+ // Return true if the value is positive, else false.
+ template <typename T>
+ static inline bool convert_to_65_bit(T value, ulong_long_type &res) {
+ if (value >= static_cast<T>(0.0)) {
+ res = static_cast<ulong_long_type>(value);
+ return true;
+ } else {
+ res = static_cast<ulong_long_type>(-value);
+ return false;
+ }
+ }
+};
+
+} // detail
+} // sweepline
+} // boost
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_formation.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_formation.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_formation.hpp 2011-09-22 17:22:05 EDT (Thu, 22 Sep 2011)
@@ -120,12 +120,15 @@
 
         // Point site contructors.
         site_event() :
+ point0_(0, 0),
+ point1_(0, 0),
             is_segment_(false),
             is_vertical_(true),
             is_inverse_(false) {}
 
         site_event(coordinate_type x, coordinate_type y, int index) :
             point0_(x, y),
+ point1_(x, y),
             site_index_(index),
             is_segment_(false),
             is_vertical_(true),
@@ -133,6 +136,7 @@
 
         site_event(const point_type &point, int index) :
             point0_(point),
+ point1_(point),
             site_index_(index),
             is_segment_(false),
             is_vertical_(true),
@@ -163,85 +167,6 @@
             is_vertical_ = (point0_.x() == point1_.x());
         }
 
- bool operator==(const site_event &that) const {
- return (point0_ == that.point0_) &&
- ((!is_segment_ && !that.is_segment_) ||
- (is_segment_ && that.is_segment_ &&
- point1_ == that.point1_));
- }
-
- bool operator!=(const site_event &that) const {
- return !((*this) == that);
- }
-
- // All the sites are sorted by the coordinates of the first point.
- // Point sites preceed vertical segment sites with equal first points.
- // Point sites and vertical segments preceed non-vertical segments
- // with the same x-coordinate of the first point (for any y).
- // Non-vertical segments with equal first points are ordered using
- // counterclockwise direction starting from the positive direction of
- // the x-axis. Such ordering simplifies the initialization step of the
- // algorithm.
- bool operator<(const site_event &that) const {
- // Compare x-coordinates of the first points.
- if (this->point0_.x() != that.point0_.x())
- return this->point0_.x() < that.point0_.x();
-
- // X-coordinates of the first points are the same.
- if (!(this->is_segment_)) {
- // The first site is a point.
- if (!that.is_segment_) {
- // The second site is a point.
- return this->point0_.y() < that.point0_.y();
- }
- if (that.is_vertical_) {
- // The second site is a vertical segment.
- return this->point0_.y() <= that.point0_.y();
- }
- // The second site is a non-vertical segment.
- return true;
- } else {
- // The first site is a segment.
- if (that.is_vertical_) {
- // The second site is a point or a vertical segment.
- if (this->is_vertical_) {
- // The first site is a vertical segment.
- return this->point0_.y() < that.point0_.y();
- }
- // The first site is a non-vertical segment.
- return false;
- }
-
- // The second site is a non-vertical segment.
- if (this->is_vertical_) {
- // The first site is a vertical segment.
- return true;
- }
-
- // Compare y-coordinates of the first points.
- if (this->point0_.y() != that.point0_.y())
- return this->point0_.y() < that.point0_.y();
-
- // Y-coordinates of the first points are the same.
- // Both sites are segment. Sort by angle using CCW ordering
- // starting at the positive direction of the x axis.
- return orientation_test(this->point1_, this->point0_,
- that.point1_) == LEFT_ORIENTATION;
- }
- }
-
- bool operator<=(const site_event &that) const {
- return !(that < (*this));
- }
-
- bool operator>(const site_event &that) const {
- return that < (*this);
- }
-
- bool operator>=(const site_event &that) const {
- return !((*this) < that);
- }
-
         coordinate_type x(bool oriented = false) const {
             return x0(oriented);
         }
@@ -373,51 +298,6 @@
             lower_x_(lower_x),
             is_active_(true) {}
 
- bool operator==(const circle_event &that) const {
- return almost_equal(this->lower_x_, that.lower_x_, 128) &&
- almost_equal(this->center_y_, that.center_y_, 128);
- }
-
- bool operator!=(const circle_event &that) const {
- return !((*this) == that);
- }
-
- // Compare rightmost points of the circle events.
- // Each rightmost point has next representation:
- // (lower_x / denom, center_y / denom), denom is always positive.
- bool operator<(const circle_event &that) const {
- if (almost_equal(this->lower_x_, that.lower_x_, 128)) {
- if (almost_equal(this->center_y_, that.center_y_, 128)) return false;
- return this->center_y_ < that.center_y_;
- }
- return this->lower_x_ < that.lower_x_;
- }
-
- bool operator<=(const circle_event &that) const {
- return !(that < (*this));
- }
-
- bool operator>(const circle_event &that) const {
- return that < (*this);
- }
-
- bool operator>=(const circle_event &that) const {
- return !((*this) < that);
- }
-
- // Compare the rightmost point of the circle event with
- // the point that represents the site event.
- // If circle point is less than site point return -1.
- // If circle point is equal to site point return 0.
- // If circle point is greater than site point return 1.
- kPredicateResult compare(const site_event_type &that) const {
- if (almost_equal(this->lower_x_, that.x(), 64)) {
- if (almost_equal(this->center_y_, that.y(), 64)) return UNDEFINED;
- return this->center_y_ < that.y() ? LESS : MORE;
- }
- return this->lower_x_ < that.x() ? LESS : MORE;
- }
-
         // Evaluate x-coordinate of the center of the circle.
         coordinate_type x() const {
             return center_x_;
@@ -441,6 +321,10 @@
             return lower_x_;
         }
 
+ coordinate_type lower_y() const {
+ return center_y_;
+ }
+
         void lower_x(coordinate_type lower_x) {
             lower_x_ = lower_x;
         }

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_builder.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_builder.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_builder.hpp 2011-09-22 17:22:05 EDT (Thu, 22 Sep 2011)
@@ -25,6 +25,7 @@
 using namespace boost::polygon;
 
 #include "detail/mpt_wrapper.hpp"
+#include "detail/voronoi_calc_kernel.hpp"
 #include "detail/voronoi_fpt_kernel.hpp"
 #include "detail/voronoi_formation.hpp"
 
@@ -41,6 +42,7 @@
     template <>
     struct voronoi_builder_traits<int> {
         typedef double coordinate_type;
+ typedef detail::voronoi_calc_kernel<int> calc_kernel_type;
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -148,6 +150,7 @@
             // The algorithm stops when there are no events to process.
             // The circle events with the same rightmost point as the next
             // site event go first.
+ event_comparison_predicate event_comparison;
             while (!circle_events_.empty() ||
                    !(site_event_iterator_ == site_events_.end())) {
                 if (circle_events_.empty()) {
@@ -155,7 +158,7 @@
                 } else if (site_event_iterator_ == site_events_.end()) {
                     process_circle_event();
                 } else {
- if (circle_events_.top().first.compare(*site_event_iterator_) == detail::MORE) {
+ if (event_comparison(*site_event_iterator_, circle_events_.top().first)) {
                         process_site_event();
                     } else {
                         process_circle_event();
@@ -177,13 +180,17 @@
         }
 
     private:
- typedef detail::point_2d<coordinate_type> point_type;
+ typedef voronoi_builder_traits<int>::calc_kernel_type calc_kernel_type;
         
+ typedef detail::point_2d<coordinate_type> point_type;
         typedef detail::site_event<coordinate_type> site_event_type;
+ typedef calc_kernel_type::site_comparison_predicate site_comparison_predicate;
+ typedef calc_kernel_type::site_equality_predicate site_equality_predicate;
         typedef typename std::vector<site_event_type>::const_iterator
             site_event_iterator_type;
-
         typedef detail::circle_event<coordinate_type> circle_event_type;
+ typedef calc_kernel_type::circle_comparison_predicate circle_comparison_predicate;
+ typedef calc_kernel_type::event_comparison_predicate event_comparison_predicate;
         typedef detail::beach_line_node_key<site_event_type> key_type;
         typedef detail::beach_line_node_data<circle_event_type> value_type;
         typedef detail::beach_line_node_comparer<key_type> node_comparer_type;
@@ -193,8 +200,9 @@
         typedef std::pair<circle_event_type, beach_line_iterator> event_type;
         typedef struct {
             bool operator()(const event_type &lhs, const event_type &rhs) const {
- return lhs.first > rhs.first;
+ return predicate(rhs.first, lhs.first);
             }
+ circle_comparison_predicate predicate;
         } event_comparison;
         typedef detail::ordered_queue<event_type, event_comparison>
             circle_event_queue_type;
@@ -207,11 +215,11 @@
         // segment itself).
         void init_sites_queue() {
             // Sort the site events.
- sort(site_events_.begin(), site_events_.end());
+ sort(site_events_.begin(), site_events_.end(), site_comparison_predicate());
 
             // Remove duplicates.
             site_events_.erase(unique(
- site_events_.begin(), site_events_.end()), site_events_.end());
+ site_events_.begin(), site_events_.end(), site_equality_predicate()), site_events_.end());
 
             // Number the sites.
             for (size_t cur = 0; cur < site_events_.size(); ++cur)

Modified: sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp 2011-09-22 17:22:05 EDT (Thu, 22 Sep 2011)
@@ -17,13 +17,35 @@
 
 typedef boost::mpl::list<double> test_types;
 
-#define EVENT_TYPES_CHECK_COMPARISON(A, B, ARR) \
- BOOST_CHECK_EQUAL((A)<(B), (ARR)[0]); \
- BOOST_CHECK_EQUAL((A)>(B), (ARR)[1]); \
- BOOST_CHECK_EQUAL((A)<=(B), (ARR)[2]); \
- BOOST_CHECK_EQUAL((A)>=(B), (ARR)[3]); \
- BOOST_CHECK_EQUAL((A)==(B), (ARR)[4]); \
- BOOST_CHECK_EQUAL((A)!=(B), (ARR)[5])
+#define POINT_COMPARISON_CHECK(A, B, ARR) \
+ BOOST_CHECK_EQUAL((A)<(B), (ARR)[0]); \
+ BOOST_CHECK_EQUAL((A)>(B), (ARR)[1]); \
+ BOOST_CHECK_EQUAL((A)<=(B), (ARR)[2]); \
+ BOOST_CHECK_EQUAL((A)>=(B), (ARR)[3]); \
+ BOOST_CHECK_EQUAL((A)==(B), (ARR)[4]); \
+ BOOST_CHECK_EQUAL((A)!=(B), (ARR)[5])
+
+voronoi_calc_kernel<int>::site_comparison_predicate site_comparison;
+voronoi_calc_kernel<int>::site_equality_predicate site_equality;
+voronoi_calc_kernel<int>::circle_comparison_predicate circle_comparison;
+voronoi_calc_kernel<int>::event_comparison_predicate event_comparison;
+
+#define SITE_COMPARISON_CHECK(A, B, ARR) \
+ BOOST_CHECK_EQUAL(site_comparison(A, B), (ARR)[0]); \
+ BOOST_CHECK_EQUAL(site_comparison(B, A), (ARR)[1]); \
+ BOOST_CHECK_EQUAL(!site_comparison(B, A), (ARR)[2]); \
+ BOOST_CHECK_EQUAL(!site_comparison(A, B), (ARR)[3]); \
+ BOOST_CHECK_EQUAL(site_equality(A, B), (ARR)[4]); \
+ BOOST_CHECK_EQUAL(!site_equality(A, B), (ARR)[5])
+
+#define CIRCLE_COMPARISON_CHECK(A, B, ARR) \
+ BOOST_CHECK_EQUAL(circle_comparison(A, B), (ARR)[0]); \
+ BOOST_CHECK_EQUAL(circle_comparison(B, A), (ARR)[1]); \
+ BOOST_CHECK_EQUAL(!circle_comparison(B, A), (ARR)[2]); \
+ BOOST_CHECK_EQUAL(!circle_comparison(A, B), (ARR)[3]); \
+ BOOST_CHECK_EQUAL(!circle_comparison(A, B) && !circle_comparison(B, A), (ARR)[4]); \
+ BOOST_CHECK_EQUAL(circle_comparison(A, B) || circle_comparison(B, A), (ARR)[5])
+
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(point_2d_test1, T, test_types) {
     point_2d<T> point1 = point_2d<T>(static_cast<T>(1), static_cast<T>(2));
@@ -34,15 +56,15 @@
 
     point2 = point_2d<T>(static_cast<T>(0), static_cast<T>(2));
     bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr1);
+ POINT_COMPARISON_CHECK(point1, point2, arr1);
 
     point2 = point_2d<T>(static_cast<T>(1), static_cast<T>(3));
     bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr2);
+ POINT_COMPARISON_CHECK(point1, point2, arr2);
 
     point2 = point_2d<T>(static_cast<T>(1), static_cast<T>(2));
     bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr3);
+ POINT_COMPARISON_CHECK(point1, point2, arr3);
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(site_event_test1, T, test_types) {
@@ -52,18 +74,17 @@
     BOOST_CHECK_EQUAL(site1.x(), static_cast<T>(1));
     BOOST_CHECK_EQUAL(site1.y(), static_cast<T>(2));
     BOOST_CHECK_EQUAL(site1.index(), 0);
-
     site2 = site_event<T>(static_cast<T>(0), static_cast<T>(2), 1);
     bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1);
+ SITE_COMPARISON_CHECK(site1, site2, arr1);
 
     site2 = site_event<T>(static_cast<T>(1), static_cast<T>(3), 1);
     bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr2);
+ SITE_COMPARISON_CHECK(site1, site2, arr2);
 
     site2 = site_event<T>(static_cast<T>(1), static_cast<T>(2), 1);
     bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr3);
+ SITE_COMPARISON_CHECK(site1, site2, arr3);
 }
 
 
@@ -86,32 +107,32 @@
 
     bool arr1_1[] = { true, false, true, false, false, true };
     bool arr1_2[] = { false , true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     site2 = site_event<T>(point2, 0);
     bool arr2_1[] = { false, true, false, true, false, true };
     bool arr2_2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr2_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr2_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr2_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr2_2);
 
     site2 = site_event<T>(point3, point4, 0);
     bool arr3_1[] = { false, true, false, true, false, true };
     bool arr3_2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr3_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr3_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr3_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr3_2);
 
     site2 = site_event<T>(point3, point5, 0);
     bool arr4_1[] = { true, false, true, false, false, true };
     bool arr4_2[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr4_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr4_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr4_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr4_2);
 
     site2 = site_event<T>(point2, point5, 0);
     bool arr5_1[] = { true, false, true, false, false, true };
     bool arr5_2[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr5_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr5_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr5_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr5_2);
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(site_event_test3, T, test_types) {
@@ -129,36 +150,36 @@
     site_event<T> site2 = site_event<T>(point2, 0);
     bool arr1_1[] = { false, true, false, true, false, true };
     bool arr1_2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     site2 = site_event<T>(static_cast<T>(0), static_cast<T>(-1), 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     site2 = site_event<T>(static_cast<T>(0), static_cast<T>(1), 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     site2 = site_event<T>(point3, point4, 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     point3 = point_2d<T>(static_cast<T>(0), static_cast<T>(-10));
     point4 = point_2d<T>(static_cast<T>(0), static_cast<T>(-1));
     site2 = site_event<T>(point3, point4, 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 
     point4 = point_2d<T>(static_cast<T>(10), static_cast<T>(9));
     site2 = site_event<T>(point2, point4, 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_2);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_1);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_2);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_1);
 
     point4 = point_2d<T>(static_cast<T>(9), static_cast<T>(10));
     site2 = site_event<T>(point2, point4, 0);
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1_1);
- EVENT_TYPES_CHECK_COMPARISON(site2, site1, arr1_2);
+ SITE_COMPARISON_CHECK(site1, site2, arr1_1);
+ SITE_COMPARISON_CHECK(site2, site1, arr1_2);
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test1, T, test_types) {
@@ -174,43 +195,44 @@
 
     circle2 = circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(3));
     bool arr1[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr1);
+ CIRCLE_COMPARISON_CHECK(circle1, circle2, arr1);
 
     circle2 = circle_event<T>(static_cast<T>(1), static_cast<T>(3), static_cast<T>(3));
     bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr2);
+ CIRCLE_COMPARISON_CHECK(circle1, circle2, arr2);
 
     circle2 = circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(4));
     bool arr3[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr3);
+ CIRCLE_COMPARISON_CHECK(circle1, circle2, arr3);
 
     circle2 = circle_event<T>(static_cast<T>(0), static_cast<T>(2), static_cast<T>(2));
     bool arr4[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr4);
+ CIRCLE_COMPARISON_CHECK(circle1, circle2, arr4);
 
     circle2 = circle_event<T>(static_cast<T>(-1), static_cast<T>(2), static_cast<T>(3));
     bool arr5[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr5);
+ CIRCLE_COMPARISON_CHECK(circle1, circle2, arr5);
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test2, T, test_types) {
     circle_event<T> circle = circle_event<T>(static_cast<T>(1),
- static_cast<T>(2),
- static_cast<T>(3));
+ static_cast<T>(2),
+ static_cast<T>(3));
     site_event<T> site;
 
+
     site = site_event<T>(static_cast<T>(0), static_cast<T>(100), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
+ BOOST_CHECK_EQUAL(event_comparison(site, circle), true);
 
     site = site_event<T>(static_cast<T>(3), static_cast<T>(0), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
+ BOOST_CHECK_EQUAL(event_comparison(site, circle), true);
 
     site = site_event<T>(static_cast<T>(3), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 0);
+ BOOST_CHECK_EQUAL(event_comparison(site, circle), false);
 
     site = site_event<T>(static_cast<T>(3), static_cast<T>(3), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), -1);
+ BOOST_CHECK_EQUAL(event_comparison(site, circle), false);
 
     site = site_event<T>(static_cast<T>(4), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), -1);
+ BOOST_CHECK_EQUAL(event_comparison(site, circle), false);
 }


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