Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64848 - in sandbox/SOC/2010/sweepline: boost/sweepline boost/sweepline/detail libs/sweepline/example libs/sweepline/example/input_data libs/sweepline/example/output_data libs/sweepline/test libs/sweepline/test/voronoi_point libs/sweepline/test/voronoi_segment
From: sydorchuk.andriy_at_[hidden]
Date: 2010-08-16 12:21:45


Author: asydorchuk
Date: 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
New Revision: 64848
URL: http://svn.boost.org/trac/boost/changeset/64848

Log:
Optimized "new site" event processing.
Added robust predicates that avoid cancellation issues.
Moved voronoi verification checks to voronoi_output_verification.hpp.
Added benchmark test.
Added screenshots from visualizer application.
Made code refactoring.
Added:
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_001.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_001.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_002.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_002.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_003.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_003.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_004.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_004.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_005.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_005.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_006.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_006.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_007.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_007.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_008.txt
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_009.txt
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_010.txt
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_011.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_011.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_012.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_012.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_013.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_013.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_014.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_014.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_015.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_015.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_016_random.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_016_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_017_random.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_017_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_018_random.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_018_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_019_random.txt
      - copied unchanged from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_019_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_020.txt (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_001.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_002.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_003.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_004.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_005.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_006.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_007.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_008.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_009.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_010.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_011.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_012.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_013.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_014.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_015.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_016_random.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_017_random.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_018_random.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_019_random.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_020.jpg (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_output_verification.hpp (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_queue_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_types_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/node_comparer_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_benchmark_test.cpp (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_builder_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_clipping_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_queue_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_types_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_node_comparer_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_benchmark_test.cpp (contents, props changed)
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_builder_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_clipping_test.cpp
      - copied, changed from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp
Removed:
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_001.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_002.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_003.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_004.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_005.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_006.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_007.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_011.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_012.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_013.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_014.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_015.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_016_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_017_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_018_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/example/example_019_random.txt
   sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp
Text files modified:
   sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_formation.hpp | 403 ++++++++++++++++++++-------------------
   sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_segment_formation.hpp | 216 ++++++++++-----------
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_builder.hpp | 72 +-----
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_output.hpp | 162 ----------------
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_builder.hpp | 28 +-
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_output.hpp | 162 ----------------
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_sweepline.hpp | 15 +
   sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_sweepline.hpp | 10
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_008.txt | 20
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_009.txt | 20
   sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_010.txt | 4
   sandbox/SOC/2010/sweepline/libs/sweepline/example/voronoi_visualizer.cpp | 2
   sandbox/SOC/2010/sweepline/libs/sweepline/test/Jamfile.v2 | 28 +-
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_queue_test.cpp | 9
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_types_test.cpp | 14
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/node_comparer_test.cpp | 2
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_builder_test.cpp | 191 +++++++++---------
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_clipping_test.cpp | 2
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_queue_test.cpp | 9
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_types_test.cpp | 14
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_node_comparer_test.cpp | 4
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_builder_test.cpp | 65 +++---
   sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_clipping_test.cpp | 4
   23 files changed, 564 insertions(+), 892 deletions(-)

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 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,20 +10,189 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_FORMATION
 #define BOOST_SWEEPLINE_VORONOI_FORMATION
 
-#include <list>
-#include <map>
-#include <queue>
-#include <vector>
-
 #define INT_PREDICATE_COMPUTE_DIFFERENCE(a, b, res, sign) \
         if (a >= b) { res = static_cast<ull>(a - b); sign = true; } \
         else { res = static_cast<ull>(b - a); sign = false; }
 
+#define INT_PREDICATE_AVOID_CANCELLATION(val, first_expr, second_expr) \
+ if ((val) >= 0) first_expr += (val); \
+ else second_expr -= (val);
+
 namespace boost {
 namespace sweepline {
 namespace detail {
 
     ///////////////////////////////////////////////////////////////////////////
+ // GEOMETRY PREDICATES ////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+
+ // If two floating-point numbers in the same format are ordered (x < y), then
+ // they are ordered the same way when their bits are reinterpreted as
+ // sign-magnitude integers.
+ bool almost_equal(double a, double b, long long maxUlps) {
+ long long ll_a, ll_b;
+ // Reinterpret double bits as long long.
+ memcpy(&ll_a, &a, sizeof(double));
+ memcpy(&ll_b, &b, sizeof(double));
+
+ // Positive 0.0 is integer zero. Negative 0.0 is 0x8000000000000000.
+ // Map negative zero to an integer zero representation - making it
+ // identical to positive zero - and it makes it so that the smallest
+ // negative number is represented by negative one, and downwards from there.
+ if (ll_a < 0)
+ ll_a = 0x8000000000000000LL - ll_a;
+ if (ll_b < 0)
+ ll_b = 0x8000000000000000LL - ll_b;
+
+ // Compare long long representations of input values.
+ // Difference in 1 Ulp is equivalent to a relative error of between
+ // 1/4,000,000,000,000,000 and 1/8,000,000,000,000,000.
+ long long dif = ll_a - ll_b;
+ return (dif <= maxUlps) && (dif >= -maxUlps);
+ }
+
+ // TODO(asydorchuk): Make templates specification for integer coordinate type,
+ // as it is actually working with integer input.
+ template <typename T>
+ bool right_orientation_test(const point_2d<T> &point1,
+ const point_2d<T> &point2,
+ const point_2d<T> &point3) {
+ typedef long long ll;
+ typedef unsigned long long ull;
+ ull dif_x1, dif_x2, dif_y1, dif_y2;
+ bool dif_x1_plus, dif_x2_plus, dif_y1_plus, dif_y2_plus;
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point1.x()),
+ static_cast<ll>(point2.x()),
+ dif_x1, dif_x1_plus);
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point2.x()),
+ static_cast<ll>(point3.x()),
+ dif_x2, dif_x2_plus);
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point1.y()),
+ static_cast<ll>(point2.y()),
+ dif_y1, dif_y1_plus);
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point2.y()),
+ static_cast<ll>(point3.y()),
+ dif_y2, dif_y2_plus);
+ ull expr_l = dif_x1 * dif_y2;
+ bool expr_l_plus = (dif_x1_plus == dif_y2_plus) ? true : false;
+ ull expr_r = dif_x2 * dif_y1;
+ bool expr_r_plus = (dif_x2_plus == dif_y1_plus) ? true : false;
+
+ if (expr_l == 0)
+ expr_l_plus = true;
+ if (expr_r == 0)
+ expr_r_plus = true;
+
+ if (!expr_l_plus) {
+ if (expr_r_plus)
+ return true;
+ else
+ return expr_l > expr_r;
+ } else {
+ if (!expr_r_plus)
+ return false;
+ else
+ return expr_l < expr_r;
+ }
+ }
+
+ enum kPredicateResult {
+ LESS = -1,
+ UNDEFINED = 0,
+ MORE = 1,
+ };
+
+ // Returns true if horizontal line going through new site intersects
+ // right arc at first, else returns false. If horizontal line goes
+ // through intersection point of the given two arcs returns false also.
+ // Used during nodes comparison.
+ // Let x0 be sweepline coordinate, left site coordinates be (x1, y1),
+ // right site coordinates be (x2, y2). Equations of the arcs will be:
+ // x1(y) = ((y - y1)^2 + x1^2 - x0^2) / (2*(x1 - x0));
+ // x2(y) = ((y - y2)^2 + x2^2 - x0^2) / (2*(x2 - x0)).
+ // Horizontal line going throught site (x*, y*) intersects second arc
+ // at first if x2(y*) > x1(y*) or:
+ // (x0-x2)*(x0-x1)*(x1-x2) + (x0-x2)*(y*-y1)^2 < (x0-x1)*(y*-y2)^2.
+ template <typename T>
+ kPredicateResult fast_less_predicate(const point_2d<T> &left_point,
+ const point_2d<T> &right_point,
+ const point_2d<T> &new_point) {
+ double fast_a1 = static_cast<double>(new_point.x()) - static_cast<double>(left_point.x());
+ double fast_a2 = static_cast<double>(new_point.x()) - static_cast<double>(right_point.x());
+ double fast_b1 = static_cast<double>(new_point.y()) - static_cast<double>(left_point.y());
+ double fast_b2 = static_cast<double>(new_point.y()) - static_cast<double>(right_point.y());
+ double fast_c = static_cast<double>(left_point.x()) - static_cast<double>(right_point.x());
+ double fast_left_expr = fast_a1 * fast_b2 * fast_b2;
+ double fast_right_expr = fast_a2 * fast_b1 * fast_b1;
+
+ // Avoid cancellation.
+ INT_PREDICATE_AVOID_CANCELLATION(fast_a1 * fast_a2 * fast_c,
+ fast_left_expr, fast_right_expr);
+ if (!almost_equal(fast_left_expr, fast_right_expr, 5))
+ return (fast_left_expr < fast_right_expr) ? LESS : MORE;
+ return UNDEFINED;
+ }
+
+ template <typename T>
+ bool less_predicate(const point_2d<T> &left_point,
+ const point_2d<T> &right_point,
+ const point_2d<T> &new_point) {
+ kPredicateResult fast_res = fast_less_predicate(left_point, right_point, new_point);
+ if (fast_res != UNDEFINED)
+ return (fast_res == LESS);
+
+ typedef long long ll;
+ typedef unsigned long long ull;
+ ull a1, a2, b1, b2, b1_sqr, b2_sqr, l_expr, r_expr;
+ bool l_expr_plus, r_expr_plus;
+
+ // a1 and a2 are greater than zero.
+ a1 = static_cast<ull>(static_cast<ll>(new_point.x()) -
+ static_cast<ll>(left_point.x()));
+ a2 = static_cast<ull>(static_cast<ll>(new_point.x()) -
+ static_cast<ll>(right_point.x()));
+
+ // We don't need to know signs of b1 and b2, because we use their squared values.
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(new_point.y()),
+ static_cast<ll>(left_point.y()),
+ b1, l_expr_plus);
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(new_point.y()),
+ static_cast<ll>(right_point.y()),
+ b2, l_expr_plus);
+ b1_sqr = b1 * b1;
+ b2_sqr = b2 * b2;
+ ull b1_sqr_mod = b1_sqr % a1;
+ ull b2_sqr_mod = b2_sqr % a2;
+
+ // Compute left expression.
+ INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(left_point.x()),
+ static_cast<ll>(right_point.x()),
+ l_expr, l_expr_plus);
+ if (b2_sqr_mod * a1 < b1_sqr_mod * a2) {
+ if (!l_expr_plus)
+ l_expr++;
+ else if (l_expr != 0)
+ l_expr--;
+ else {
+ l_expr++;
+ l_expr_plus = false;
+ }
+ }
+
+ // Compute right expression.
+ INT_PREDICATE_COMPUTE_DIFFERENCE(b1_sqr / a1, b2_sqr / a2, r_expr, r_expr_plus);
+
+ // Compare left and right expressions.
+ if (!l_expr_plus && r_expr_plus)
+ return true;
+ if (l_expr_plus && !r_expr_plus)
+ return false;
+ if (l_expr_plus && r_expr_plus)
+ return l_expr < r_expr;
+ return l_expr > r_expr;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
     // VORONOI EVENT TYPES ////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
 
@@ -110,14 +279,8 @@
 
     // Circle event type. Occurs when sweepline sweeps over the bottom point of
     // the voronoi circle (with center at the bisectors intersection point).
- // Circle event contains circle center and squared radius (to avoid sqrt
- // computation). To compare bottom points of two different voronoi circles
- // we don't compute exact radius and use special arithmetic for that. This
- // way voronoi diagram implementation may be used with rational arithmetic.
- // Let circle center coordinates be (x, y), squared radius be r.
- // Bottom point of the voronoi circle will be defined as (x + sqrt(r), y).
- // Contains reference to the second bisector node (ordered from left to
- // right in the beach line) that creates given circle event.
+ // Circle event contains circle center, lowest x coordinate, event state and
+ // iterator to the corresponding bisectors.
     template <typename T>
     struct circle_event {
     public:
@@ -130,45 +293,30 @@
 
         circle_event() : is_active_(true) {}
 
- circle_event(coordinate_type c_x, coordinate_type c_y, coordinate_type sqr_r) :
- center_(c_x, c_y), sqr_radius_(sqr_r), is_active_(true) {}
+ circle_event(coordinate_type c_x, coordinate_type c_y, coordinate_type lower_x) :
+ center_(c_x, c_y), lower_x_(lower_x), is_active_(true) {}
 
- circle_event(const Point2D &center, coordinate_type sqr_r) :
- center_(center), sqr_radius_(sqr_r), is_active_(true) {}
+ circle_event(const Point2D &center, coordinate_type lower_x) :
+ center_(center), lower_x_(lower_x), is_active_(true) {}
 
         circle_event(const circle_event& c_event) {
             center_ = c_event.center_;
- sqr_radius_ = c_event.sqr_radius_;
+ lower_x_ = c_event.lower_x_;
             bisector_node_ = c_event.bisector_node_;
             is_active_ = c_event.is_active_;
         }
 
         void operator=(const circle_event& c_event) {
             center_ = c_event.center_;
- sqr_radius_ = c_event.sqr_radius_;
+ lower_x_ = c_event.lower_x_;
             bisector_node_ = c_event.bisector_node_;
             is_active_ = c_event.is_active_;
         }
 
         bool operator==(const circle_event &c_event) const {
- if (center_.y() != c_event.y())
- return false;
-
- if ((center_.x() > c_event.x() && sqr_radius_ > c_event.get_sqr_radius()) ||
- (center_.x() < c_event.x() && sqr_radius_ < c_event.get_sqr_radius()))
- return false;
-
- coordinate_type sqr_dif_x = (center_.x() - c_event.x()) * (center_.x() - c_event.x());
- coordinate_type sum_r_sqr = sqr_radius_ + c_event.get_sqr_radius();
-
- if (sqr_dif_x > sum_r_sqr)
- return false;
-
- coordinate_type value_left = (sum_r_sqr - sqr_dif_x) * (sum_r_sqr - sqr_dif_x);
- coordinate_type value_right = static_cast<coordinate_type>(4) * sqr_radius_ *
- c_event.get_sqr_radius();
-
- return value_left == value_right;
+ return (center_.y() == c_event.y()) &&
+ (center_.x() == c_event.x()) &&
+ (lower_x_ == c_event.lower_x_);
         }
 
         bool operator!=(const circle_event &c_event) const {
@@ -176,48 +324,9 @@
         }
 
         bool operator<(const circle_event &c_event) const {
- coordinate_type x1 = center_.x();
- coordinate_type y1 = center_.y();
- coordinate_type sqr_r1 = sqr_radius_;
- coordinate_type x2 = c_event.x();
- coordinate_type y2 = c_event.y();
- coordinate_type sqr_r2 = c_event.get_sqr_radius();
-
- coordinate_type sqr_dif_x = (x1 - x2) * (x1 - x2);
- coordinate_type sum_r_sqr = sqr_r1 + sqr_r2;
- coordinate_type value_left = (sum_r_sqr - sqr_dif_x) * (sum_r_sqr - sqr_dif_x);
- coordinate_type value_right = static_cast<coordinate_type>(4) * sqr_r1 * sqr_r2;
-
- if (x1 > x2) {
- if (sqr_r2 <= sqr_r1)
- return false;
-
- if (sqr_dif_x > sum_r_sqr)
- return false;
-
- if (value_left != value_right)
- return value_left > value_right;
-
- return y1 < y2;
- }
- else if (x1 < x2) {
- if (sqr_r1 <= sqr_r2)
- return true;
-
- if (sqr_dif_x > sum_r_sqr)
- return true;
-
- if (value_left != value_right)
- return value_left < value_right;
-
- return y1 < y2;
- }
- else {
- if (sqr_r1 != sqr_r2)
- return sqr_r1 < sqr_r2;
-
- return y1 < y2;
- }
+ if (lower_x_ != c_event.lower_x_)
+ return lower_x_ < c_event.lower_x_;
+ return center_.y() < c_event.y();
         }
 
         bool operator<=(const circle_event &c_event) const {
@@ -237,15 +346,12 @@
         // If circle point is equal to site point return 0.
         // If circle point is greater than site point return 1.
         int compare(const site_event<coordinate_type> &s_event) const {
- if (s_event.x() < center_.x())
- return 1;
- coordinate_type sqr_dif_x = (s_event.x() - center_.x()) * (s_event.x() - center_.x());
- if (sqr_dif_x == sqr_radius_) {
- if (center_.y() == s_event.y())
- return 0;
- return (center_.y() < s_event.y()) ? -1 : 1;
+ if (s_event.x() != lower_x_) {
+ return (lower_x_ < s_event.x()) ? -1 : 1;
             }
- return (sqr_dif_x < sqr_radius_) ? 1 : -1;
+ if (s_event.y() != center_.y())
+ return (center_.y() < s_event.y()) ? -1 : 1;
+ return 0;
         }
 
         coordinate_type x() const {
@@ -260,8 +366,8 @@
             return center_;
         }
 
- const coordinate_type &get_sqr_radius() const {
- return sqr_radius_;
+ const coordinate_type &get_lower_x() const {
+ return lower_x_;
         }
 
         void set_bisector(beach_line_iterator iterator) {
@@ -280,10 +386,9 @@
             return is_active_;
         }
 
-
     private:
         Point2D center_;
- coordinate_type sqr_radius_;
+ coordinate_type lower_x_;
         beach_line_iterator bisector_node_;
         bool is_active_;
     };
@@ -426,75 +531,19 @@
             return right_site_;
         }
 
- // Returns true if horizontal line going through new site intersects
- // right arc at first, else returns false. If horizontal line goes
- // through intersection point of the given two arcs returns false also.
- // Used during nodes comparison.
- // Let x0 be sweepline coordinate, left site coordinates be (x1, y1),
- // right site coordinates be (x2, y2). Equations of the arcs will be:
- // x1(y) = ((y - y1)^2 + x1^2 - x0^2) / (2*(x1 - x0));
- // x2(y) = ((y - y2)^2 + x2^2 - x0^2) / (2*(x2 - x0)).
- // Horizontal line going throught site (x*, y*) intersects second arc
- // at first if x2(y*) > x1(y*) or:
- // (x0-x2)*(x0-x1)*(x1-x2) + (x0-x2)*(y*-y1)^2 < (x0-x1)*(y*-y2)^2.
- bool less(const site_event_type &new_site) const {
- typedef long long ll;
- typedef unsigned long long ull;
- ull a1, a2, b1, b2, b1_sqr, b2_sqr, l_expr, r_expr;
- bool l_expr_plus, r_expr_plus;
-
- // a1 and a2 are greater than zero.
- a1 = static_cast<ull>(static_cast<ll>(new_site.x()) -
- static_cast<ll>(left_site_.x()));
- a2 = static_cast<ull>(static_cast<ll>(new_site.x()) -
- static_cast<ll>(right_site_.x()));
-
- // We don't need to know signs of b1 and b2, because we use their squared values.
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(new_site.y()),
- static_cast<ll>(left_site_.y()),
- b1, l_expr_plus);
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(new_site.y()),
- static_cast<ll>(right_site_.y()),
- b2, l_expr_plus);
- b1_sqr = b1 * b1;
- b2_sqr = b2 * b2;
- ull b1_sqr_mod = b1_sqr % a1;
- ull b2_sqr_mod = b2_sqr % a2;
-
- // Compute left expression.
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(left_site_.x()),
- static_cast<ll>(right_site_.x()),
- l_expr, l_expr_plus);
- if (b2_sqr_mod * a1 < b1_sqr_mod * a2) {
- if (!l_expr_plus)
- l_expr++;
- else if (l_expr != 0)
- l_expr--;
- else {
- l_expr++;
- l_expr_plus = false;
- }
+ bool less(const Point2D &new_site) const {
+ if (left_site_.x() > right_site_.x()) {
+ if (new_site.y() <= left_site_.y())
+ return false;
+ return less_predicate(left_site_.get_point(), right_site_.get_point(), new_site);
+ } else if (left_site_.x() < right_site_.x()) {
+ if (new_site.y() >= right_site_.y())
+ return true;
+ return less_predicate(left_site_.get_point(), right_site_.get_point(), new_site);
+ } else {
+ return left_site_.y() + right_site_.y() <
+ static_cast<coordinate_type>(2.0) * new_site.y();
             }
-
- // Compute right expression.
- INT_PREDICATE_COMPUTE_DIFFERENCE(b1_sqr / a1, b2_sqr / a2, r_expr, r_expr_plus);
-
- // Compare left and right expressions.
- if (!l_expr_plus && r_expr_plus)
- return true;
- if (l_expr_plus && !r_expr_plus)
- return false;
- if (l_expr_plus && r_expr_plus)
- return l_expr < r_expr;
- return l_expr > r_expr;
-
- /*mpz_class a1, a2, b1, b2, c, left_expr, right_expr;
- a1 = static_cast<int>(new_site.x() - left_site.x());
- a2 = static_cast<int>(new_site.x() - right_site.x());
- b1 = static_cast<int>(new_site.y() - left_site.y());
- b2 = static_cast<int>(new_site.y() - right_site.y());
- c = static_cast<int>(left_site.x() - right_site.x());
- return a1 * a2 * c + a1 * b2 * b2 < a2 * b1 * b1;*/
         }
 
     private:
@@ -547,41 +596,9 @@
             coordinate_type node2_line = node2.get_new_site().x();
 
             if (node1_line < node2_line) {
- coordinate_type left_site_x = node1.get_left_site().x();
- coordinate_type left_site_y = node1.get_left_site().y();
- coordinate_type right_site_x = node1.get_right_site().x();
- coordinate_type right_site_y = node1.get_right_site().y();
- coordinate_type new_node_y = node2.get_new_site().y();
- if (left_site_x > right_site_x) {
- if (new_node_y <= left_site_y)
- return false;
- return node1.less(node2.get_new_site());
- } else if (left_site_x < right_site_x) {
- if (new_node_y >= right_site_y)
- return true;
- return node1.less(node2.get_new_site());
- } else {
- return left_site_y + right_site_y <
- static_cast<coordinate_type>(2.0) * new_node_y;
- }
+ return node1.less(node2.get_new_site().get_point());
             } else if (node1_line > node2_line) {
- coordinate_type left_site_x = node2.get_left_site().x();
- coordinate_type left_site_y = node2.get_left_site().y();
- coordinate_type right_site_x = node2.get_right_site().x();
- coordinate_type right_site_y = node2.get_right_site().y();
- coordinate_type new_node_y = node1.get_new_site().y();
- if (left_site_x > right_site_x) {
- if (new_node_y <= left_site_y)
- return true;
- return !node2.less(node1.get_new_site());
- } else if (left_site_x < right_site_x) {
- if (new_node_y >= right_site_y)
- return false;
- return !node2.less(node1.get_new_site());
- } else {
- return !(left_site_y + right_site_y <
- static_cast<coordinate_type>(2.0) * new_node_y);
- }
+ return !node2.less(node1.get_new_site().get_point());
             } else {
                 // Both nodes are situated on the same vertical line.
                 // Let A be the new site event point, and B the site that

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_segment_formation.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_segment_formation.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/detail/voronoi_segment_formation.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,12 +10,6 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_SEGMENT_FORMATION
 #define BOOST_SWEEPLINE_VORONOI_SEGMENT_FORMATION
 
-#include <cstring>
-#include <list>
-#include <map>
-#include <queue>
-#include <vector>
-
 #define INT_PREDICATE_COMPUTE_DIFFERENCE(a, b, res, sign) \
         if (a >= b) { res = static_cast<ull>(a - b); sign = true; } \
         else { res = static_cast<ull>(b - a); sign = false; }
@@ -24,6 +18,10 @@
         if (a >= 0) { res = static_cast<ull>(a); sign = true; } \
         else { res = static_cast<ull>(-a); sign = false; }
 
+#define INT_PREDICATE_AVOID_CANCELLATION(val, first_expr, second_expr) \
+ if ((val) >= 0) first_expr += (val); \
+ else second_expr -= (val);
+
 namespace boost {
 namespace sweepline {
 namespace detail {
@@ -32,20 +30,33 @@
     // GEOMETRY PREDICATES ////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
 
+ // If two floating-point numbers in the same format are ordered (x < y), then
+ // they are ordered the same way when their bits are reinterpreted as
+ // sign-magnitude integers.
     bool almost_equal(double a, double b, long long maxUlps) {
         long long ll_a, ll_b;
+ // Reinterpret double bits as long long.
         memcpy(&ll_a, &a, sizeof(double));
         memcpy(&ll_b, &b, sizeof(double));
+
+ // Positive 0.0 is integer zero. Negative 0.0 is 0x8000000000000000.
+ // Map negative zero to an integer zero representation - making it
+ // identical to positive zero - and it makes it so that the smallest
+ // negative number is represented by negative one, and downwards from there.
         if (ll_a < 0)
- ll_a = 0x8000000000000000LL;
+ ll_a = 0x8000000000000000LL - ll_a;
         if (ll_b < 0)
- ll_b = 0x8000000000000000LL;
+ ll_b = 0x8000000000000000LL - ll_b;
+
+ // Compare long long representations of input values.
+ // Difference in 1 Ulp is equivalent to a relative error of between
+ // 1/4,000,000,000,000,000 and 1/8,000,000,000,000,000.
         long long dif = ll_a - ll_b;
         return (dif <= maxUlps) && (dif >= -maxUlps);
     }
 
- // TODO(asydorchuk): Remove code inside of this template. Left orientation test
- // works only for integer input points.
+ // TODO(asydorchuk): Make templates specification for integer coordinate type,
+ // as it is actually working with integer input.
     template <typename T>
     bool right_orientation_test(const point_2d<T> &point1,
                                 const point_2d<T> &point2,
@@ -115,9 +126,13 @@
         double fast_b1 = static_cast<double>(new_point.y()) - static_cast<double>(left_point.y());
         double fast_b2 = static_cast<double>(new_point.y()) - static_cast<double>(right_point.y());
         double fast_c = static_cast<double>(left_point.x()) - static_cast<double>(right_point.x());
- double fast_left_expr = fast_a1 * fast_a2 * fast_c + fast_a1 * fast_b2 * fast_b2;
+ double fast_left_expr = fast_a1 * fast_b2 * fast_b2;
         double fast_right_expr = fast_a2 * fast_b1 * fast_b1;
- if (!almost_equal(fast_left_expr, fast_right_expr, 6))
+
+ // Avoid cancellation.
+ INT_PREDICATE_AVOID_CANCELLATION(fast_a1 * fast_a2 * fast_c,
+ fast_left_expr, fast_right_expr);
+ if (!almost_equal(fast_left_expr, fast_right_expr, 5))
             return (fast_left_expr < fast_right_expr) ? LESS : MORE;
         return UNDEFINED;
     }
@@ -179,14 +194,6 @@
         if (l_expr_plus && r_expr_plus)
             return l_expr < r_expr;
         return l_expr > r_expr;
-
- /*mpz_class a1, a2, b1, b2, c, left_expr, right_expr;
- a1 = static_cast<int>(new_point.x() - left_point.x());
- a2 = static_cast<int>(new_point.x() - right_point.x());
- b1 = static_cast<int>(new_point.y() - left_point.y());
- b2 = static_cast<int>(new_point.y() - right_point.y());
- c = static_cast<int>(left_point.x() - right_point.x());
- return a1 * a2 * c + a1 * b2 * b2 < a2 * b1 * b1;*/
     }
 
     template <typename T>
@@ -227,13 +234,14 @@
             }
         }
 
+ // dif_x and dif_y are integers, so there will be no cancellation issues.
         double fast_left_expr = static_cast<double>(a) *
                                 static_cast<double>(dif_y + dif_x) *
                                 static_cast<double>(dif_y - dif_x);
         double fast_right_expr = static_cast<double>(b<<1) *
                                  static_cast<double>(dif_x) *
                                  static_cast<double>(dif_y);
- if (!(almost_equal(fast_left_expr, fast_right_expr, 6))) {
+ if (!(almost_equal(fast_left_expr, fast_right_expr, 4))) {
             if (is_right_oriented1 ^ (fast_left_expr > fast_right_expr) ^ !reverse_order)
                 return reverse_order ? LESS : MORE;
             return UNDEFINED;
@@ -286,6 +294,37 @@
         return UNDEFINED;
     }
 
+#ifdef USE_MULTI_PRECISION_LIBRARY
+ template<typename T>
+ bool mpz_less_predicate(point_2d<T> segment_start, point_2d<T> segment_end,
+ point_2d<T> site_point, point_2d<T> new_point, bool reverse_order) {
+ mpz_class segment_start_x, segment_start_y, segment_end_x, segment_end_y,
+ site_point_x, site_point_y, new_point_x, new_point_y;
+ segment_start_x = static_cast<int>(segment_start.x());
+ segment_start_y = static_cast<int>(segment_start.y());
+ segment_end_x = static_cast<int>(segment_end.x());
+ segment_end_y = static_cast<int>(segment_end.y());
+ site_point_x = static_cast<int>(site_point.x());
+ site_point_y = static_cast<int>(site_point.y());
+ new_point_x = static_cast<int>(new_point.x());
+ new_point_y = static_cast<int>(new_point.y());
+
+ mpz_class dif_x, dif_y, a, b, mul1, mul2, temp, left_expr, right_expr;
+ dif_x = new_point_x - site_point_x;
+ dif_y = new_point_y - site_point_y;
+ a = segment_end_x - segment_start_x;
+ b = segment_end_y - segment_start_y;
+ mul1 = new_point_x - segment_end_x;
+ mul2 = new_point_y - segment_end_y;
+ temp = dif_x * dif_x + dif_y * dif_y;
+ left_expr = (a * a + b * b) * temp * temp;
+ right_expr = (2.0 * dif_x * (b * mul1 - a * mul2) - b * temp);
+ right_expr = right_expr * right_expr;
+
+ return (!reverse_order) ? (left_expr > right_expr) : (left_expr < right_expr);
+ }
+#endif
+
     // Returns true if horizontal line going through new site intersects
     // right arc at first, else returns false. If horizontal line goes
     // through intersection point of the given two arcs returns false also.
@@ -314,26 +353,33 @@
         double mul1 = static_cast<double>(new_point.x()) - static_cast<double>(segment_end.x());
         double mul2 = static_cast<double>(new_point.y()) - static_cast<double>(segment_end.y());
         double temp = dif_x * dif_x + dif_y * dif_y;
- double left_expr = (a * a + b * b) * temp * temp;
- double right_expr = (2.0 * dif_x * (b * mul1 - a * mul2) - b * temp);
- right_expr *= right_expr;
+ double a_sqr = a * a;
+ double b_sqr = b * b;
+ double left_expr = (a_sqr * temp + (4.0 * dif_x * mul1) * b_sqr) * temp;
+ double right_expr = (4.0 * dif_x * dif_x) * ((mul1 * mul1) * b_sqr + (mul2 * mul2) * a_sqr);
+ double common_expr = (4.0 * dif_x * a) * (b * mul2);
+ INT_PREDICATE_AVOID_CANCELLATION(common_expr * temp, right_expr, left_expr);
+ INT_PREDICATE_AVOID_CANCELLATION(common_expr * (2.0 * dif_x * mul1), left_expr, right_expr);
 
- if (!almost_equal(left_expr, right_expr, 128)) {
+ if (!almost_equal(left_expr, right_expr, 18)) {
             if (!reverse_order)
                 return left_expr > right_expr;
             return left_expr < right_expr;
         }
 
- // TODO(asydorchuk): Add mpl there.
- if (!reverse_order)
- return left_expr > right_expr;
- return left_expr < right_expr;
+#ifndef USE_MULTI_PRECISION_LIBRARY
+ return (!reverse_order) ? (left_expr > right_expr) : (left_expr < right_expr);
+#else
+ return mpz_less_predicate(segment_start, segment_end, site_point,
+ new_point, reverse_order);
+#endif
     }
 
     template <typename T>
     bool less_predicate(point_2d<T> segment1_start, point_2d<T> segment1_end,
                         point_2d<T> segment2_start, point_2d<T> segment2_end,
                         point_2d<T> new_point) {
+
         return true;
     }
 
@@ -486,14 +532,8 @@
 
     // Circle event type. Occurs when sweepline sweeps over the bottom point of
     // the voronoi circle (with center at the bisectors intersection point).
- // Circle event contains circle center and squared radius (to avoid sqrt
- // computation). To compare bottom points of two different voronoi circles
- // we don't compute exact radius and use special arithmetic for that. This
- // way voronoi diagram implementation may be used with rational arithmetic.
- // Let circle center coordinates be (x, y), squared radius be r.
- // Bottom point of the voronoi circle will be defined as (x + sqrt(r), y).
- // Contains reference to the second bisector node (ordered from left to
- // right in the beach line) that creates given circle event.
+ // Circle event contains circle center, lowest x coordinate, event state and
+ // iterator to the corresponding bisectors.
     template <typename T>
     struct circle_event {
     public:
@@ -506,45 +546,30 @@
 
         circle_event() : is_active_(true) {}
 
- circle_event(coordinate_type c_x, coordinate_type c_y, coordinate_type sqr_r) :
- center_(c_x, c_y), sqr_radius_(sqr_r), is_active_(true) {}
+ circle_event(coordinate_type c_x, coordinate_type c_y, coordinate_type lower_x) :
+ center_(c_x, c_y), lower_x_(lower_x), is_active_(true) {}
 
- circle_event(const Point2D &center, coordinate_type sqr_r) :
- center_(center), sqr_radius_(sqr_r), is_active_(true) {}
+ circle_event(const Point2D &center, coordinate_type lower_x) :
+ center_(center), lower_x_(lower_x), is_active_(true) {}
 
         circle_event(const circle_event& c_event) {
             center_ = c_event.center_;
- sqr_radius_ = c_event.sqr_radius_;
+ lower_x_ = c_event.lower_x_;
             bisector_node_ = c_event.bisector_node_;
             is_active_ = c_event.is_active_;
         }
 
         void operator=(const circle_event& c_event) {
             center_ = c_event.center_;
- sqr_radius_ = c_event.sqr_radius_;
+ lower_x_ = c_event.lower_x_;
             bisector_node_ = c_event.bisector_node_;
             is_active_ = c_event.is_active_;
         }
 
         bool operator==(const circle_event &c_event) const {
- if (center_.y() != c_event.y())
- return false;
-
- if ((center_.x() > c_event.x() && sqr_radius_ > c_event.get_sqr_radius()) ||
- (center_.x() < c_event.x() && sqr_radius_ < c_event.get_sqr_radius()))
- return false;
-
- coordinate_type sqr_dif_x = (center_.x() - c_event.x()) * (center_.x() - c_event.x());
- coordinate_type sum_r_sqr = sqr_radius_ + c_event.get_sqr_radius();
-
- if (sqr_dif_x > sum_r_sqr)
- return false;
-
- coordinate_type value_left = (sum_r_sqr - sqr_dif_x) * (sum_r_sqr - sqr_dif_x);
- coordinate_type value_right = static_cast<coordinate_type>(4) * sqr_radius_ *
- c_event.get_sqr_radius();
-
- return value_left == value_right;
+ return (center_.y() == c_event.y()) &&
+ (center_.x() == c_event.x()) &&
+ (lower_x_ == c_event.lower_x_);
         }
 
         bool operator!=(const circle_event &c_event) const {
@@ -552,48 +577,9 @@
         }
 
         bool operator<(const circle_event &c_event) const {
- coordinate_type x1 = center_.x();
- coordinate_type y1 = center_.y();
- coordinate_type sqr_r1 = sqr_radius_;
- coordinate_type x2 = c_event.x();
- coordinate_type y2 = c_event.y();
- coordinate_type sqr_r2 = c_event.get_sqr_radius();
-
- coordinate_type sqr_dif_x = (x1 - x2) * (x1 - x2);
- coordinate_type sum_r_sqr = sqr_r1 + sqr_r2;
- coordinate_type value_left = (sum_r_sqr - sqr_dif_x) * (sum_r_sqr - sqr_dif_x);
- coordinate_type value_right = static_cast<coordinate_type>(4) * sqr_r1 * sqr_r2;
-
- if (x1 > x2) {
- if (sqr_r2 <= sqr_r1)
- return false;
-
- if (sqr_dif_x > sum_r_sqr)
- return false;
-
- if (value_left != value_right)
- return value_left > value_right;
-
- return y1 < y2;
- }
- else if (x1 < x2) {
- if (sqr_r1 <= sqr_r2)
- return true;
-
- if (sqr_dif_x > sum_r_sqr)
- return true;
-
- if (value_left != value_right)
- return value_left < value_right;
-
- return y1 < y2;
- }
- else {
- if (sqr_r1 != sqr_r2)
- return sqr_r1 < sqr_r2;
-
- return y1 < y2;
- }
+ if (lower_x_ != c_event.lower_x_)
+ return lower_x_ < c_event.lower_x_;
+ return center_.y() < c_event.y();
         }
 
         bool operator<=(const circle_event &c_event) const {
@@ -613,15 +599,12 @@
         // If circle point is equal to site point return 0.
         // If circle point is greater than site point return 1.
         int compare(const site_event<coordinate_type> &s_event) const {
- if (s_event.x() < center_.x())
- return 1;
- coordinate_type sqr_dif_x = (s_event.x() - center_.x()) * (s_event.x() - center_.x());
- if (sqr_dif_x == sqr_radius_) {
- if (center_.y() == s_event.y())
- return 0;
- return (center_.y() < s_event.y()) ? -1 : 1;
+ if (s_event.x() != lower_x_) {
+ return (lower_x_ < s_event.x()) ? -1 : 1;
             }
- return (sqr_dif_x < sqr_radius_) ? 1 : -1;
+ if (s_event.y() != center_.y())
+ return (center_.y() < s_event.y()) ? -1 : 1;
+ return 0;
         }
 
         coordinate_type x() const {
@@ -636,8 +619,8 @@
             return center_;
         }
 
- const coordinate_type &get_sqr_radius() const {
- return sqr_radius_;
+ const coordinate_type &get_lower_x() const {
+ return lower_x_;
         }
 
         void set_bisector(beach_line_iterator iterator) {
@@ -656,10 +639,9 @@
             return is_active_;
         }
 
-
     private:
         Point2D center_;
- coordinate_type sqr_radius_;
+ coordinate_type lower_x_;
         beach_line_iterator bisector_node_;
         bool is_active_;
     };
@@ -909,6 +891,10 @@
                     node2.get_left_site().get_site_index())
                     return node1.get_right_site().x() == node1_line;
 
+ if (node1.get_right_site().get_point0().x() == node1_line &&
+ node1.get_right_site().get_point0() == node2.get_left_site().get_point0())
+ return true;
+
                 // Just compare coordinates of the sites situated on the sweepline.
                 return node1.get_new_site().y() < node2.get_new_site().y();
             }

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 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,8 +10,6 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_BUILDER
 #define BOOST_SWEEPLINE_VORONOI_BUILDER
 
-#include <algorithm>
-
 namespace boost {
 namespace sweepline {
 
@@ -185,6 +183,7 @@
             // lying above the new site point.
             Key new_key(site_event);
             beach_line_iterator it = beach_line_.lower_bound(new_key);
+ beach_line_iterator position = it;
 
             site_event_type site_arc;
             if (it == beach_line_.end()) {
@@ -192,7 +191,7 @@
                 site_arc = it->first.get_right_site();
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
                 new_node_it--;
 
                 // Add candidate circle to the event queue.
@@ -204,7 +203,7 @@
                 site_arc = it->first.get_left_site();
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
                 new_node_it++;
 
                 // Add candidate circle to the event queue.
@@ -224,7 +223,7 @@
 
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
 
                 // Add candidate circles to the event queue.
                 new_node_it--;
@@ -298,7 +297,8 @@
 
         // Insert new arc below site arc into the beach line.
         beach_line_iterator insert_new_arc(const site_event_type &site_arc,
- const site_event_type &site_event) {
+ const site_event_type &site_event,
+ const beach_line_iterator &position) {
             // Create two new nodes.
             Key new_left_node(site_arc, site_event);
             Key new_right_node(site_event, site_arc);
@@ -306,50 +306,10 @@
             // Insert two new nodes into the binary search tree.
             // Update output.
             edge_type *edge = output_.insert_new_edge(site_arc, site_event);
- beach_line_.insert(std::pair<Key, Value>(new_left_node, Value(edge)));
- return beach_line_.insert(std::pair<Key, Value>(new_right_node, Value(edge->twin))).first;
- }
-
- bool bisectors_intersection_test(const Point2D &point1,
- const Point2D &point2,
- const Point2D &point3) const {
- typedef long long ll;
- typedef unsigned long long ull;
- ull dif_x1, dif_x2, dif_y1, dif_y2;
- bool dif_x1_plus, dif_x2_plus, dif_y1_plus, dif_y2_plus;
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point1.x()),
- static_cast<ll>(point2.x()),
- dif_x1, dif_x1_plus);
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point2.x()),
- static_cast<ll>(point3.x()),
- dif_x2, dif_x2_plus);
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point1.y()),
- static_cast<ll>(point2.y()),
- dif_y1, dif_y1_plus);
- INT_PREDICATE_COMPUTE_DIFFERENCE(static_cast<ll>(point2.y()),
- static_cast<ll>(point3.y()),
- dif_y2, dif_y2_plus);
- ull expr_l = dif_x1 * dif_y2;
- bool expr_l_plus = (dif_x1_plus == dif_y2_plus) ? true : false;
- ull expr_r = dif_x2 * dif_y1;
- bool expr_r_plus = (dif_x2_plus == dif_y1_plus) ? true : false;
-
- if (expr_l == 0)
- expr_l_plus = true;
- if (expr_r == 0)
- expr_r_plus = true;
-
- if (!expr_l_plus) {
- if (expr_r_plus)
- return true;
- else
- return expr_l > expr_r;
- } else {
- if (!expr_r_plus)
- return false;
- else
- return expr_l < expr_r;
- }
+ beach_line_iterator it = beach_line_.insert(position,
+ std::pair<Key, Value>(new_right_node, Value(edge->twin)));
+ beach_line_.insert(it, std::pair<Key, Value>(new_left_node, Value(edge)));
+ return it;
         }
 
         // Create circle event from the given three points.
@@ -394,9 +354,9 @@
             //return true;
 
             // Check if bisectors intersect.
- if (!bisectors_intersection_test(site1.get_point(),
- site2.get_point(),
- site3.get_point()))
+ if (!detail::right_orientation_test(site1.get_point(),
+ site2.get_point(),
+ site3.get_point()))
                 return false;
 
             coordinate_type a = ((site1.x() - site2.x()) * (site2.y() - site3.y()) -
@@ -411,9 +371,9 @@
             // Create new circle event.
             coordinate_type c_x = (b1*(site2.y() - site3.y()) - b2*(site1.y() - site2.y())) / a;
             coordinate_type c_y = (b2*(site1.x() - site2.x()) - b1*(site2.x() - site3.x())) / a;
- coordinate_type sqr_radius = (c_x-site1.x())*(c_x-site1.x()) +
- (c_y-site1.y())*(c_y-site1.y());
- c_event = detail::make_circle_event<coordinate_type>(c_x, c_y, sqr_radius);
+ coordinate_type radius = sqrt((c_x-site1.x())*(c_x-site1.x()) +
+ (c_y-site1.y())*(c_y-site1.y()));
+ c_event = detail::make_circle_event<coordinate_type>(c_x, c_y, c_x + radius);
             return true;
         }
 

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_output.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_output.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_output.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,13 +10,6 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_OUTPUT
 #define BOOST_SWEEPLINE_VORONOI_OUTPUT
 
-#include <list>
-#include <map>
-#include <vector>
-
-//#pragma warning( disable : 4800 )
-//#include "gmpxx.h"
-
 namespace boost {
 namespace sweepline {
     template <typename T>
@@ -279,162 +272,7 @@
             return num_edges_ / 2;
         }
 
- // Check correct orientation of each half_edge.
- bool half_edge_orientation_check() const {
- typename std::list<edge_type>::const_iterator edge_it;
- for (edge_it = edges_.begin(); edge_it != edges_.end(); edge_it++) {
- if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
- const Point2D &site = edge_it->cell->voronoi_point;
- const Point2D &start_point = edge_it->start_point->voronoi_point;
- const Point2D &end_point = edge_it->end_point->voronoi_point;
- if (check_orientation(start_point, end_point, site) != LEFT_ORIENTATION)
- return false;
- }
- }
- return true;
- }
-
- // Check if boundary of each cell is convex.
- bool cell_convexity_check() const {
- voronoi_const_iterator_type cell_it;
- for (cell_it = cell_records_.begin(); cell_it != cell_records_.end(); cell_it++) {
- const edge_type *edge = cell_it->incident_edge;
- if (edge)
- do {
- if (edge->next->prev != edge)
- return false;
- if (edge->cell != &(*cell_it))
- return false;
- if (edge->start_point != NULL &&
- edge->end_point != NULL &&
- edge->end_point == edge->next->start_point &&
- edge->next->end_point != NULL) {
- const Point2D &vertex1 = edge->start_point->voronoi_point;
- const Point2D &vertex2 = edge->end_point->voronoi_point;
- const Point2D &vertex3 = edge->next->end_point->voronoi_point;
- if (check_orientation(vertex1, vertex2, vertex3) != LEFT_ORIENTATION)
- return false;
- }
- edge = edge->next;
- } while(edge != cell_it->incident_edge);
- }
- return true;
- }
-
- // Check CCW ordering of incident edges of voronoi vertices.
- bool incident_edges_order_check() const {
- voronoi_const_iterator_type vertex_it;
- for (vertex_it = vertex_records_.begin();
- vertex_it != vertex_records_.end(); vertex_it++) {
- if (vertex_it->num_incident_edges < 3)
- continue;
- edge_type *edge = vertex_it->incident_edge;
- do {
- edge_type *edge_next1 = edge->rot_next;
- edge_type *edge_next2 = edge_next1->rot_next;
- const Point2D &site1 = edge->cell->voronoi_point;
- const Point2D &site2 = edge_next1->cell->voronoi_point;
- const Point2D &site3 = edge_next2->cell->voronoi_point;
-
- if (check_orientation(site1, site2, site3) != LEFT_ORIENTATION)
- return false;
-
- edge = edge->rot_next;
- } while (edge != vertex_it->incident_edge);
- }
- return true;
- }
-
- // Check if any two half_edges intersect not at the end point.
- bool half_edges_intersection_check() const {
- // Create map from edges with first point less than the second one.
- // Key is the first point of the edge, value is a vector of second points
- // with the same first point.
- std::map< Point2D, std::vector<Point2D> > edge_map;
- typedef typename std::map< Point2D, std::vector<Point2D> >::const_iterator
- edge_map_iterator;
- typename std::list<edge_type>::const_iterator edge_it;
- for (edge_it = edges_.begin(); edge_it != edges_.end(); edge_it++) {
- if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
- const Point2D &start_point = edge_it->start_point->voronoi_point;
- const Point2D &end_point = edge_it->end_point->voronoi_point;
- if (start_point < end_point)
- edge_map[start_point].push_back(end_point);
- }
- }
-
- // Iterate over map of edges and check if there are any intersections.
- // All the edges are stored by the low x value. That's why we iterate
- // left to right checking for intersections between all pairs of edges
- // that overlap in the x dimension.
- // Complexity. Approximately N*sqrt(N). Worst case N^2.
- typedef typename std::vector<Point2D>::size_type size_type;
- edge_map_iterator edge_map_it1, edge_map_it2, edge_map_it_bound;
- for (edge_map_it1 = edge_map.begin();
- edge_map_it1 != edge_map.end(); edge_map_it1++) {
- const Point2D &point1 = edge_map_it1->first;
- for (size_type i = 0; i < edge_map_it1->second.size(); i++) {
- const Point2D &point2 = edge_map_it1->second[i];
- coordinate_type min_y1 = std::min(point1.y(), point2.y());
- coordinate_type max_y1 = std::max(point1.y(), point2.y());
-
- // Find the first edge with greater or equal first point.
- edge_map_it_bound = edge_map.lower_bound(point2);
-
- edge_map_it2 = edge_map_it1;
- edge_map_it2++;
- for (; edge_map_it2 != edge_map_it_bound; edge_map_it2++) {
- const Point2D &point3 = edge_map_it2->first;
- for (size_type j = 0; j < edge_map_it2->second.size(); j++) {
- const Point2D &point4 = edge_map_it2->second[j];
- coordinate_type min_y2 = std::min(point3.y(), point4.y());
- coordinate_type max_y2 = std::max(point3.y(), point4.y());
-
- // In most cases it is enought to make
- // simple intersection check in the y dimension.
- if (!(max_y1 > min_y2 && max_y2 > min_y1))
- continue;
-
- // Intersection check.
- if (check_orientation(point1, point2, point3) *
- check_orientation(point1, point2, point4) == -1 &&
- check_orientation(point3, point4, point1) *
- check_orientation(point3, point4, point2) == -1)
- return false;
- }
- }
- }
- }
- return true;
- }
-
- // Make a few output checks.
- bool check() const {
- return half_edge_orientation_check() &&
- cell_convexity_check() &&
- incident_edges_order_check() &&
- half_edges_intersection_check();
- }
-
     private:
- enum kOrientation {
- LEFT_ORIENTATION = 1,
- RIGHT_ORIENTATION = -1,
- collinear = 0,
- };
-
- int check_orientation(const Point2D &point1,
- const Point2D &point2,
- const Point2D &point3) const {
- coordinate_type a = (point2.x() - point1.x()) * (point3.y() - point2.y());
- coordinate_type b = (point2.y() - point1.y()) * (point3.x() - point2.x());
- if (a > b)
- return LEFT_ORIENTATION;
- else if (a < b)
- return RIGHT_ORIENTATION;
- return collinear;
- }
-
         voronoi_records_type cell_records_;
         voronoi_records_type vertex_records_;
         voronoi_edges_type edges_;

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_builder.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_builder.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_builder.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,8 +10,6 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_SEGMENT_BUILDER
 #define BOOST_SWEEPLINE_VORONOI_SEGMENT_BUILDER
 
-#include <algorithm>
-
 namespace boost {
 namespace sweepline {
 
@@ -227,6 +225,7 @@
             // lying above the new site point.
             Key new_key(site_event);
             beach_line_iterator it = beach_line_.lower_bound(new_key);
+ beach_line_iterator position = it;
 
             site_event_type site_arc;
             if (it == beach_line_.end()) {
@@ -234,7 +233,7 @@
                 site_arc = it->first.get_right_site();
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
                 new_node_it--;
 
                 // Add candidate circle to the event queue.
@@ -246,7 +245,7 @@
                 site_arc = it->first.get_left_site();
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
                 new_node_it++;
 
                 // Add candidate circle to the event queue.
@@ -266,7 +265,7 @@
 
 
                 // Insert new arc into the sweepline.
- beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event);
+ beach_line_iterator new_node_it = insert_new_arc(site_arc, site_event, position);
 
                 // Add candidate circles to the event queue.
                 new_node_it--;
@@ -340,7 +339,8 @@
 
         // Insert new arc below site arc into the beach line.
         beach_line_iterator insert_new_arc(const site_event_type &site_arc,
- const site_event_type &site_event) {
+ const site_event_type &site_event,
+ const beach_line_iterator &position) {
             // Create two new nodes.
             Key new_left_node(site_arc, site_event);
             Key new_right_node(site_event, site_arc);
@@ -348,8 +348,10 @@
             // Insert two new nodes into the binary search tree.
             // Update output.
             edge_type *edge = output_.insert_new_edge(site_arc, site_event);
- beach_line_.insert(std::pair<Key, Value>(new_left_node, Value(edge)));
- return beach_line_.insert(std::pair<Key, Value>(new_right_node, Value(edge->twin))).first;
+ beach_line_iterator it = beach_line_.insert(position,
+ std::pair<Key, Value>(new_right_node, Value(edge->twin)));
+ beach_line_.insert(it, std::pair<Key, Value>(new_left_node, Value(edge)));
+ return it;
         }
 
         // Create circle event from the given three points.
@@ -400,20 +402,20 @@
                 return false;
 
             coordinate_type a = ((site1.x() - site2.x()) * (site2.y() - site3.y()) -
- (site1.y() - site2.y()) * (site2.x() - site3.x())) *
+ (site1.y() - site2.y()) * (site2.x() - site3.x())) *
                                 static_cast<coordinate_type>(2.0);
             
             coordinate_type b1 = (site1.x() - site2.x()) * (site1.x() + site2.x()) +
                                  (site1.y() - site2.y()) * (site1.y() + site2.y());
             coordinate_type b2 = (site2.x() - site3.x()) * (site2.x() + site3.x()) +
- (site2.y() - site3.y()) * (site2.y() + site3.y());
+ (site2.y() - site3.y()) * (site2.y() + site3.y());
 
             // Create new circle event.
             coordinate_type c_x = (b1*(site2.y() - site3.y()) - b2*(site1.y() - site2.y())) / a;
             coordinate_type c_y = (b2*(site1.x() - site2.x()) - b1*(site2.x() - site3.x())) / a;
- coordinate_type sqr_radius = (c_x-site1.x())*(c_x-site1.x()) +
- (c_y-site1.y())*(c_y-site1.y());
- c_event = detail::make_circle_event<coordinate_type>(c_x, c_y, sqr_radius);
+ coordinate_type radius = sqrt((c_x-site1.x())*(c_x-site1.x()) +
+ (c_y-site1.y())*(c_y-site1.y()));
+ c_event = detail::make_circle_event<coordinate_type>(c_x, c_y, c_x + radius);
             return true;
         }
 

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_output.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_output.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_output.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,13 +10,6 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_SEGMENT_OUTPUT
 #define BOOST_SWEEPLINE_VORONOI_SEGMENT_OUTPUT
 
-#include <list>
-#include <map>
-#include <vector>
-
-//#pragma warning( disable : 4800 )
-//#include "gmpxx.h"
-
 namespace boost {
 namespace sweepline {
     template <typename T>
@@ -279,162 +272,7 @@
             return num_edges_ / 2;
         }
 
- // Check correct orientation of each half_edge.
- bool half_edge_orientation_check() const {
- typename std::list<edge_type>::const_iterator edge_it;
- for (edge_it = edges_.begin(); edge_it != edges_.end(); edge_it++) {
- if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
- const Point2D &site = edge_it->cell->voronoi_point;
- const Point2D &start_point = edge_it->start_point->voronoi_point;
- const Point2D &end_point = edge_it->end_point->voronoi_point;
- if (check_orientation(start_point, end_point, site) != LEFT_ORIENTATION)
- return false;
- }
- }
- return true;
- }
-
- // Check if boundary of each cell is convex.
- bool cell_convexity_check() const {
- voronoi_const_iterator_type cell_it;
- for (cell_it = cell_records_.begin(); cell_it != cell_records_.end(); cell_it++) {
- const edge_type *edge = cell_it->incident_edge;
- if (edge)
- do {
- if (edge->next->prev != edge)
- return false;
- if (edge->cell != &(*cell_it))
- return false;
- if (edge->start_point != NULL &&
- edge->end_point != NULL &&
- edge->end_point == edge->next->start_point &&
- edge->next->end_point != NULL) {
- const Point2D &vertex1 = edge->start_point->voronoi_point;
- const Point2D &vertex2 = edge->end_point->voronoi_point;
- const Point2D &vertex3 = edge->next->end_point->voronoi_point;
- if (check_orientation(vertex1, vertex2, vertex3) != LEFT_ORIENTATION)
- return false;
- }
- edge = edge->next;
- } while(edge != cell_it->incident_edge);
- }
- return true;
- }
-
- // Check CCW ordering of incident edges of voronoi vertices.
- bool incident_edges_order_check() const {
- voronoi_const_iterator_type vertex_it;
- for (vertex_it = vertex_records_.begin();
- vertex_it != vertex_records_.end(); vertex_it++) {
- if (vertex_it->num_incident_edges < 3)
- continue;
- edge_type *edge = vertex_it->incident_edge;
- do {
- edge_type *edge_next1 = edge->rot_next;
- edge_type *edge_next2 = edge_next1->rot_next;
- const Point2D &site1 = edge->cell->voronoi_point;
- const Point2D &site2 = edge_next1->cell->voronoi_point;
- const Point2D &site3 = edge_next2->cell->voronoi_point;
-
- if (check_orientation(site1, site2, site3) != LEFT_ORIENTATION)
- return false;
-
- edge = edge->rot_next;
- } while (edge != vertex_it->incident_edge);
- }
- return true;
- }
-
- // Check if any two half_edges intersect not at the end point.
- bool half_edges_intersection_check() const {
- // Create map from edges with first point less than the second one.
- // Key is the first point of the edge, value is a vector of second points
- // with the same first point.
- std::map< Point2D, std::vector<Point2D> > edge_map;
- typedef typename std::map< Point2D, std::vector<Point2D> >::const_iterator
- edge_map_iterator;
- typename std::list<edge_type>::const_iterator edge_it;
- for (edge_it = edges_.begin(); edge_it != edges_.end(); edge_it++) {
- if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
- const Point2D &start_point = edge_it->start_point->voronoi_point;
- const Point2D &end_point = edge_it->end_point->voronoi_point;
- if (start_point < end_point)
- edge_map[start_point].push_back(end_point);
- }
- }
-
- // Iterate over map of edges and check if there are any intersections.
- // All the edges are stored by the low x value. That's why we iterate
- // left to right checking for intersections between all pairs of edges
- // that overlap in the x dimension.
- // Complexity. Approximately N*sqrt(N). Worst case N^2.
- typedef typename std::vector<Point2D>::size_type size_type;
- edge_map_iterator edge_map_it1, edge_map_it2, edge_map_it_bound;
- for (edge_map_it1 = edge_map.begin();
- edge_map_it1 != edge_map.end(); edge_map_it1++) {
- const Point2D &point1 = edge_map_it1->first;
- for (size_type i = 0; i < edge_map_it1->second.size(); i++) {
- const Point2D &point2 = edge_map_it1->second[i];
- coordinate_type min_y1 = std::min(point1.y(), point2.y());
- coordinate_type max_y1 = std::max(point1.y(), point2.y());
-
- // Find the first edge with greater or equal first point.
- edge_map_it_bound = edge_map.lower_bound(point2);
-
- edge_map_it2 = edge_map_it1;
- edge_map_it2++;
- for (; edge_map_it2 != edge_map_it_bound; edge_map_it2++) {
- const Point2D &point3 = edge_map_it2->first;
- for (size_type j = 0; j < edge_map_it2->second.size(); j++) {
- const Point2D &point4 = edge_map_it2->second[j];
- coordinate_type min_y2 = std::min(point3.y(), point4.y());
- coordinate_type max_y2 = std::max(point3.y(), point4.y());
-
- // In most cases it is enought to make
- // simple intersection check in the y dimension.
- if (!(max_y1 > min_y2 && max_y2 > min_y1))
- continue;
-
- // Intersection check.
- if (check_orientation(point1, point2, point3) *
- check_orientation(point1, point2, point4) == -1 &&
- check_orientation(point3, point4, point1) *
- check_orientation(point3, point4, point2) == -1)
- return false;
- }
- }
- }
- }
- return true;
- }
-
- // Make a few output checks.
- bool check() const {
- return half_edge_orientation_check() &&
- cell_convexity_check() &&
- incident_edges_order_check() &&
- half_edges_intersection_check();
- }
-
     private:
- enum kOrientation {
- LEFT_ORIENTATION = 1,
- RIGHT_ORIENTATION = -1,
- collinear = 0,
- };
-
- int check_orientation(const Point2D &point1,
- const Point2D &point2,
- const Point2D &point3) const {
- coordinate_type a = (point2.x() - point1.x()) * (point3.y() - point2.y());
- coordinate_type b = (point2.y() - point1.y()) * (point3.x() - point2.x());
- if (a > b)
- return LEFT_ORIENTATION;
- else if (a < b)
- return RIGHT_ORIENTATION;
- return collinear;
- }
-
         voronoi_records_type cell_records_;
         voronoi_records_type vertex_records_;
         voronoi_edges_type edges_;

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_sweepline.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_sweepline.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_segment_sweepline.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,10 +10,23 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_SEGMENT_SWEEPLINE
 #define BOOST_SWEEPLINE_VORONOI_SEGMENT_SWEEPLINE
 
+#include <algorithm>
+#include <cmath>
+#include <cstring>
+#include <list>
+#include <map>
+#include <queue>
+#include <vector>
+
+#ifdef USE_MULTI_PRECISION_LIBRARY
+ #pragma warning( disable : 4800 )
+ #include "gmpxx.h"
+#endif
+
 #include "voronoi_segment_output.hpp"
 
 #include "detail/voronoi_segment_formation.hpp"
 
 #include "voronoi_segment_builder.hpp"
 
-#endif
\ No newline at end of file
+#endif

Modified: sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_sweepline.hpp
==============================================================================
--- sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_sweepline.hpp (original)
+++ sandbox/SOC/2010/sweepline/boost/sweepline/voronoi_sweepline.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,10 +10,18 @@
 #ifndef BOOST_SWEEPLINE_VORONOI_SWEEPLINE
 #define BOOST_SWEEPLINE_VORONOI_SWEEPLINE
 
+#include <algorithm>
+#include <cmath>
+#include <cstring>
+#include <list>
+#include <map>
+#include <queue>
+#include <vector>
+
 #include "voronoi_output.hpp"
 
 #include "detail/voronoi_formation.hpp"
 
 #include "voronoi_builder.hpp"
 
-#endif
\ No newline at end of file
+#endif

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_001.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_001.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,2 +0,0 @@
-1
-0 0
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_002.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_002.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,3 +0,0 @@
-2
-0 0
-1 0
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_003.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_003.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,3 +0,0 @@
-2
-0 0
-0 1
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_004.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_004.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,3 +0,0 @@
-2
-0 0
-1 1
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_005.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_005.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-0 0
-0 1
-0 2
-0 3
-0 4
-0 -1
-0 -2
-0 -3
-0 -4
-0 -5
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_006.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_006.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-0 0
-1 0
-2 0
-3 0
-4 0
-5 0
--1 0
--2 0
--3 0
--4 0
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_007.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_007.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,12 +0,0 @@
-10
-0 0
-1 1
-2 2
-3 3
-4 4
-5 5
-6 6
-7 7
-8 8
-9 9
-10 10
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
--4.6 -3.7
--4.0 -3.0
--3.4 -2.3
--2.8 -1.6
--2.2 -0.9
--1.6 -0.2
--1.0 0.5
--0.4 1.2
-0.2 1.9
-0.8 2.6
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-0.33333 0.11111
-0.66666 0.0
-0.99999 -0.11111
-1.33332 -0.22222
-1.66665 -0.33333
-1.99998 -0.44444
-2.33331 -0.55555
-2.66664 -0.66666
-2.99997 -0.77777
-3.33330 -0.88888
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,4 +0,0 @@
-3
-0 0
-200.5 200.5
-1002.5 1002.5
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_011.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_011.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,4 +0,0 @@
-3
-0 0
-0 4
-1 1
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_012.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_012.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,5 +0,0 @@
-4
-0 0
-0 1
-1 0
-1 1
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_013.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_013.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,14 +0,0 @@
-13
-0 5
-0 -5
--4 -3
-4 -3
-4 3
--4 3
-3 -4
--3 4
--3 -4
-3 4
--5 0
-5 0
-0 0
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_014.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_014.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-12
-0 5
-0 -5
--4 -3
-4 -3
-4 3
--4 3
-3 -4
--3 4
--3 -4
-3 4
--5 0
-5 0
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_015.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_015.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,5 +0,0 @@
-4
-4 3
-4 8
-9 2
-9 9
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_016_random.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_016_random.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-9 1
-4 3
-9 6
-9 8
-3 9
-6 8
-0 5
-9 5
-3 0
-2 1
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_017_random.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_017_random.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-9 9
-2 6
-3 1
-6 4
-9 1
-9 7
-6 2
-2 4
-3 7
-6 7
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_018_random.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_018_random.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,11 +0,0 @@
-10
-4 1
-5 4
-5 5
-2 6
-3 4
-0 7
-2 5
-8 9
-0 4
-2 7
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/example/example_019_random.txt
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/example_019_random.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,101 +0,0 @@
-100
-29 76
-99 94
-74 20
-53 26
-95 55
-94 21
-50 70
-19 93
-31 30
-73 61
-87 23
-60 66
-51 29
-82 51
-74 40
-31 77
-1 82
-43 0
-58 67
-63 32
-19 90
-68 31
-49 63
-76 83
-72 20
-70 11
-80 23
-4 90
-32 56
-63 75
-51 71
-62 10
-80 57
-71 47
-2 8
-67 85
-64 72
-85 6
-53 91
-92 25
-95 79
-24 6
-1 10
-10 85
-11 30
-22 14
-48 55
-82 8
-14 54
-84 60
-33 91
-85 60
-65 81
-60 23
-10 44
-29 32
-21 11
-90 15
-73 71
-41 62
-9 36
-44 80
-27 39
-41 38
-25 23
-86 15
-4 76
-52 6
-39 97
-42 25
-93 93
-97 24
-13 16
-58 62
-48 78
-43 74
-99 85
-13 42
-8 82
-13 9
-51 50
-85 83
-30 11
-58 42
-44 32
-88 74
-37 21
-65 28
-79 94
-50 94
-38 83
-82 13
-30 88
-16 92
-73 66
-24 0
-40 82
-57 25
-55 88
-13 33
\ No newline at end of file

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_008.txt (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_008.txt (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_008.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -1,11 +1,11 @@
 10
--4.6 -3.7
--4.0 -3.0
--3.4 -2.3
--2.8 -1.6
--2.2 -0.9
--1.6 -0.2
--1.0 0.5
--0.4 1.2
-0.2 1.9
-0.8 2.6
\ No newline at end of file
+-46 -37
+-40 -30
+-34 -23
+-28 -16
+-22 -09
+-16 -02
+-10 05
+-04 12
+02 19
+08 26
\ No newline at end of file

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_009.txt (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_009.txt (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_009.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -1,11 +1,11 @@
 10
-0.33333 0.11111
-0.66666 0.0
-0.99999 -0.11111
-1.33332 -0.22222
-1.66665 -0.33333
-1.99998 -0.44444
-2.33331 -0.55555
-2.66664 -0.66666
-2.99997 -0.77777
-3.33330 -0.88888
\ No newline at end of file
+33333 11111
+66666 0
+99999 -11111
+133332 -22222
+166665 -33333
+199998 -44444
+233331 -55555
+266664 -66666
+299997 -77777
+333330 -88888
\ No newline at end of file

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_010.txt (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/example/example_010.txt (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_010.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -1,4 +1,4 @@
 3
 0 0
-200.5 200.5
-1002.5 1002.5
\ No newline at end of file
+2005 2005
+10025 10025
\ No newline at end of file

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_020.txt
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/example/input_data/example_020.txt 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -0,0 +1,101 @@
+100
+100 0
+99 6
+99 12
+98 18
+96 24
+95 30
+92 36
+90 42
+87 48
+84 53
+80 58
+77 63
+72 68
+68 72
+63 77
+58 80
+53 84
+48 87
+42 90
+36 92
+30 95
+24 96
+18 98
+12 99
+6 99
+0 99
+-6 99
+-12 99
+-18 98
+-24 96
+-30 95
+-36 93
+-42 90
+-48 87
+-53 84
+-58 80
+-63 77
+-68 72
+-72 68
+-76 63
+-80 58
+-84 53
+-87 48
+-90 42
+-92 36
+-95 31
+-96 25
+-98 18
+-99 12
+-99 6
+-99 0
+-99 -6
+-99 -12
+-98 -18
+-96 -24
+-95 -30
+-93 -36
+-90 -42
+-87 -48
+-84 -53
+-81 -58
+-77 -63
+-73 -68
+-68 -72
+-63 -76
+-58 -80
+-53 -84
+-48 -87
+-42 -90
+-37 -92
+-31 -95
+-25 -96
+-18 -98
+-12 -99
+-6 -99
+0 -99
+6 -99
+12 -99
+18 -98
+24 -96
+30 -95
+36 -93
+42 -90
+47 -87
+53 -84
+58 -81
+63 -77
+68 -73
+72 -68
+76 -63
+80 -59
+84 -53
+87 -48
+90 -42
+92 -37
+95 -31
+96 -25
+98 -19
+99 -12
+99 -6
\ No newline at end of file

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_001.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_002.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_003.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_004.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_005.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_006.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_007.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_008.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_009.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_010.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_011.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_012.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_013.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_014.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_015.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_016_random.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_017_random.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_018_random.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_019_random.jpg
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2010/sweepline/libs/sweepline/example/output_data/example_020.jpg
==============================================================================
Binary file. No diff available.

Modified: sandbox/SOC/2010/sweepline/libs/sweepline/example/voronoi_visualizer.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/example/voronoi_visualizer.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/example/voronoi_visualizer.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -152,7 +152,7 @@
         QString file_path = file_dir_.filePath(file_name);
         message_label_->setText("Building...");
         glWidget_->build(file_path);
- message_label_->setText("Double click item to build voronoi diagram:");
+ message_label_->setText("Double click the item to build voronoi diagram:");
         setWindowTitle(tr("Voronoi Visualizer - ") + file_path);
     }
 

Modified: sandbox/SOC/2010/sweepline/libs/sweepline/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/Jamfile.v2 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,20 +10,26 @@
       <library>$(BOOST_ROOT)/libs/test/build//boost_unit_test_framework
     ;
 
-test-suite "sweepline"
+test-suite "sweepline_benchmark"
+ :
+ [ run voronoi_point/voronoi_benchmark_test.cpp ]
+ [ run voronoi_segment/segment_voronoi_benchmark_test.cpp ]
+ ;
+
+test-suite "sweepline_point"
     :
- [ run event_queue_test.cpp ]
- [ run event_types_test.cpp ]
- [ run node_comparer_test.cpp ]
- [ run voronoi_builder_test.cpp ]
- [ run voronoi_clipping_test.cpp ]
+ [ run voronoi_point/event_queue_test.cpp ]
+ [ run voronoi_point/event_types_test.cpp ]
+ [ run voronoi_point/node_comparer_test.cpp ]
+ [ run voronoi_point/voronoi_builder_test.cpp ]
+ [ run voronoi_point/voronoi_clipping_test.cpp ]
     ;
 
 test-suite "sweepline_segment"
     :
- [ run segment_event_queue_test.cpp ]
- [ run segment_event_types_test.cpp ]
- [ run segment_node_comparer_test.cpp ]
- [ run segment_voronoi_builder_test.cpp ]
- [ run segment_voronoi_clipping_test.cpp ]
+ [ run voronoi_segment/segment_event_queue_test.cpp ]
+ [ run voronoi_segment/segment_event_types_test.cpp ]
+ [ run voronoi_segment/segment_node_comparer_test.cpp ]
+ [ run voronoi_segment/segment_voronoi_builder_test.cpp ]
+ [ run voronoi_segment/segment_voronoi_clipping_test.cpp ]
     ;
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,67 +0,0 @@
-// Boost sweepline library event_queue_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <cmath>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE event_queue_test
-#include <boost/test/test_case_template.hpp>
-
-#define CHECK_TOP_ELEMENT_EQUALITY(TOP, X, Y) \
- BOOST_CHECK_EQUAL(TOP.x() + sqrt(static_cast<T>(TOP.get_sqr_radius())) \
- == static_cast<T>(X) && \
- TOP.y() == static_cast<T>(Y), true)
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test1, T, test_types) {
- detail::circle_events_queue<T> event_q;
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-
- event_q.reset();
-
- for (int i = 0; i < 10; i++) {
- T x = static_cast<T>(-i);
- T y = static_cast<T>(10-i);
- event_q.push(detail::make_circle_event<T>(x, y, static_cast<T>(100)));
- }
-
- for (int i = 0; i < 10; i++) {
- CHECK_TOP_ELEMENT_EQUALITY(event_q.top(), 1 + i, 1 + i);
- event_q.pop();
- }
-
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test2, T, test_types) {
- typedef detail::circle_event<T> circle_event_type;
-
- detail::circle_events_queue<T> event_q;
- detail::site_event<T> temp_site =
- detail::make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0);
-
- for (int i = 0; i < 10; i++) {
- T x = static_cast<T>(10-i);
- T y = static_cast<T>(10-i);
- circle_event_type c = detail::make_circle_event<T>(x, y, static_cast<T>(0));
- if (i&1)
- event_q.push(c)->deactivate();
- else
- event_q.push(c);
- }
-
- for (int i = 0; i < 5; i++) {
- CHECK_TOP_ELEMENT_EQUALITY(event_q.top(), 2 + 2*i, 2 + 2*i);
- event_q.pop();
- }
-
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/event_types_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,119 +0,0 @@
-// Boost sweepline library event_types_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_sweepline.hpp"
-using namespace boost::sweepline;
-using namespace boost::sweepline::detail;
-
-#define BOOST_TEST_MODULE event_types_test
-#include <boost/test/test_case_template.hpp>
-
-#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])
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(point_2d_test1, T, test_types) {
- point_2d<T> point1 = make_point_2d(static_cast<T>(1), static_cast<T>(1.05));
- point_2d<T> point2;
-
- BOOST_CHECK_EQUAL(point1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(point1.y(), static_cast<T>(1.05));
-
- point2 = make_point_2d(static_cast<T>(0.999999), static_cast<T>(1));
- bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr1);
-
- point2 = make_point_2d(static_cast<T>(1), static_cast<T>(1.1));
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr2);
-
- point2 = make_point_2d(static_cast<T>(1), static_cast<T>(1.05));
- bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr3);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(site_event_test1, T, test_types) {
- site_event<T> site1 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.05), 0);
- site_event<T> site2;
-
- BOOST_CHECK_EQUAL(site1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(site1.y(), static_cast<T>(1.05));
- BOOST_CHECK_EQUAL(site1.get_site_index(), 0);
-
- site2 = make_site_event<T>(static_cast<T>(0.999999), static_cast<T>(1), 1);
- bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1);
-
- site2 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.1), 1);
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr2);
-
- site2 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.05), 1);
- bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr3);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test1, T, test_types) {
- circle_event<T> circle1 = make_circle_event<T>(static_cast<T>(1),
- static_cast<T>(2),
- static_cast<T>(4));
- site_event<T> temp_site = make_site_event<T>(static_cast<T>(0), static_cast<T>(0),0);
- circle_event<T> circle2;
-
- BOOST_CHECK_EQUAL(circle1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(circle1.y(), static_cast<T>(2));
- BOOST_CHECK_EQUAL(circle1.get_sqr_radius(), static_cast<T>(4));
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(4));
- bool arr1[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr1);
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(3), static_cast<T>(4));
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr2);
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(5));
- bool arr3[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr3);
-
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(2), static_cast<T>(4));
- bool arr4[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr4);
-
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(10));
- bool arr5[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr5);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test2, T, test_types) {
- circle_event<T> circle = make_circle_event<T>(static_cast<T>(1),
- static_cast<T>(2),
- static_cast<T>(4));
- site_event<T> site;
-
- site = make_site_event<T>(static_cast<T>(0), static_cast<T>(100), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(0), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 0);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 0);
-
- site = make_site_event<T>(static_cast<T>(4), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), -1);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,255 +0,0 @@
-// Boost sweepline library node_comparer_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_sweepline.hpp"
-using namespace boost::sweepline;
-using namespace boost::sweepline::detail;
-
-#define BOOST_TEST_MODULE node_comparer_test
-#include <boost/test/test_case_template.hpp>
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test1, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef site_event<T> site_event_type;
- typedef beach_line_node<T> bline_node;
- typedef typename std::map< bline_node, int,
- node_comparer<bline_node> >::const_iterator bline_it;
-
- std::map< bline_node, int, node_comparer<bline_node> > test_beach_line;
-
- site_event_type site1 = make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0);
- site_event_type site2 = make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1);
- bline_node initial_node(site1, site2);
- test_beach_line[initial_node] = 2;
-
- site_event_type site3 = make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2);
- bline_node node1(site1, site3);
- bline_node node2(site3, site1);
- test_beach_line.insert(std::pair< bline_node, int>(node1, 0));
- test_beach_line.insert(std::pair< bline_node, int>(node2, 1));
-
- int cur_value = 0;
- for (bline_it it = test_beach_line.begin();
- it != test_beach_line.end();
- it++, cur_value++)
- BOOST_CHECK_EQUAL(it->second, cur_value);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test2, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef site_event<T> site_event_type;
- typedef beach_line_node<T> bline_node;
- typedef typename std::map< bline_node, int,
- node_comparer<bline_node> >::const_iterator bline_it;
-
- std::map< bline_node, int, node_comparer<bline_node> > test_beach_line;
-
- site_event_type site1 = make_site_event<T>(static_cast<T>(0), static_cast<T>(1), 0);
- site_event_type site2 = make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 1);
- site_event_type site3 = make_site_event<T>(static_cast<T>(2), static_cast<T>(4), 2);
- bline_node initial_node1(site1, site2);
- bline_node initial_node2(site2, site1);
- test_beach_line[initial_node1] = 0;
- test_beach_line[initial_node2] = 1;
-
- bline_node new_node1(site1, site3);
- bline_node new_node2(site3, site1);
- test_beach_line[new_node1] = 2;
- test_beach_line[new_node2] = 3;
-
- int cur_value = 0;
- for (bline_it it = test_beach_line.begin();
- it != test_beach_line.end();
- it++, cur_value++)
- BOOST_CHECK_EQUAL(it->second, cur_value);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test3, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-10), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-1), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test4, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(1), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-3), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-2), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(-1), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
- bline_node new_node7(make_site_event<T>(static_cast<T>(2), static_cast<T>(10), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node7), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node7, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test5, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-10), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(5), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(20), 4));
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test6, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-3), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-2), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
- bline_node new_node7(make_site_event<T>(static_cast<T>(2), static_cast<T>(5), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node7), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node7, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test7, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test8, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1));
- bline_node new_node3(make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 3));
- bline_node new_node4(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,67 +0,0 @@
-// Boost sweepline library segment_event_queue_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <cmath>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_segment_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE event_queue_test
-#include <boost/test/test_case_template.hpp>
-
-#define CHECK_TOP_ELEMENT_EQUALITY(TOP, X, Y) \
- BOOST_CHECK_EQUAL(TOP.x() + sqrt(static_cast<T>(TOP.get_sqr_radius())) \
- == static_cast<T>(X) && \
- TOP.y() == static_cast<T>(Y), true)
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test1, T, test_types) {
- detail::circle_events_queue<T> event_q;
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-
- event_q.reset();
-
- for (int i = 0; i < 10; i++) {
- T x = static_cast<T>(-i);
- T y = static_cast<T>(10-i);
- event_q.push(detail::make_circle_event<T>(x, y, static_cast<T>(100)));
- }
-
- for (int i = 0; i < 10; i++) {
- CHECK_TOP_ELEMENT_EQUALITY(event_q.top(), 1 + i, 1 + i);
- event_q.pop();
- }
-
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test2, T, test_types) {
- typedef detail::circle_event<T> circle_event_type;
-
- detail::circle_events_queue<T> event_q;
- detail::site_event<T> temp_site =
- detail::make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0);
-
- for (int i = 0; i < 10; i++) {
- T x = static_cast<T>(10-i);
- T y = static_cast<T>(10-i);
- circle_event_type c = detail::make_circle_event<T>(x, y, static_cast<T>(0));
- if (i&1)
- event_q.push(c)->deactivate();
- else
- event_q.push(c);
- }
-
- for (int i = 0; i < 5; i++) {
- CHECK_TOP_ELEMENT_EQUALITY(event_q.top(), 2 + 2*i, 2 + 2*i);
- event_q.pop();
- }
-
- BOOST_CHECK_EQUAL(event_q.empty(), true);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,119 +0,0 @@
-// Boost sweepline library segment_event_types_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_segment_sweepline.hpp"
-using namespace boost::sweepline;
-using namespace boost::sweepline::detail;
-
-#define BOOST_TEST_MODULE event_types_test
-#include <boost/test/test_case_template.hpp>
-
-#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])
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(point_2d_test1, T, test_types) {
- point_2d<T> point1 = make_point_2d(static_cast<T>(1), static_cast<T>(1.05));
- point_2d<T> point2;
-
- BOOST_CHECK_EQUAL(point1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(point1.y(), static_cast<T>(1.05));
-
- point2 = make_point_2d(static_cast<T>(0.999999), static_cast<T>(1));
- bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr1);
-
- point2 = make_point_2d(static_cast<T>(1), static_cast<T>(1.1));
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr2);
-
- point2 = make_point_2d(static_cast<T>(1), static_cast<T>(1.05));
- bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(point1, point2, arr3);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(site_event_test1, T, test_types) {
- site_event<T> site1 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.05), 0);
- site_event<T> site2;
-
- BOOST_CHECK_EQUAL(site1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(site1.y(), static_cast<T>(1.05));
- BOOST_CHECK_EQUAL(site1.get_site_index(), 0);
-
- site2 = make_site_event<T>(static_cast<T>(0.999999), static_cast<T>(1), 1);
- bool arr1[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr1);
-
- site2 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.1), 1);
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr2);
-
- site2 = make_site_event<T>(static_cast<T>(1), static_cast<T>(1.05), 1);
- bool arr3[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(site1, site2, arr3);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test1, T, test_types) {
- circle_event<T> circle1 = make_circle_event<T>(static_cast<T>(1),
- static_cast<T>(2),
- static_cast<T>(4));
- site_event<T> temp_site = make_site_event<T>(static_cast<T>(0), static_cast<T>(0),0);
- circle_event<T> circle2;
-
- BOOST_CHECK_EQUAL(circle1.x(), static_cast<T>(1));
- BOOST_CHECK_EQUAL(circle1.y(), static_cast<T>(2));
- BOOST_CHECK_EQUAL(circle1.get_sqr_radius(), static_cast<T>(4));
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(4));
- bool arr1[] = { false, false, true, true, true, false };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr1);
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(3), static_cast<T>(4));
- bool arr2[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr2);
-
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(5));
- bool arr3[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr3);
-
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(2), static_cast<T>(4));
- bool arr4[] = { false, true, false, true, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr4);
-
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(10));
- bool arr5[] = { true, false, true, false, false, true };
- EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr5);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test2, T, test_types) {
- circle_event<T> circle = make_circle_event<T>(static_cast<T>(1),
- static_cast<T>(2),
- static_cast<T>(4));
- site_event<T> site;
-
- site = make_site_event<T>(static_cast<T>(0), static_cast<T>(100), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(0), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 1);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 0);
-
- site = make_site_event<T>(static_cast<T>(3), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), 0);
-
- site = make_site_event<T>(static_cast<T>(4), static_cast<T>(2), 0);
- BOOST_CHECK_EQUAL(circle.compare(site), -1);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,255 +0,0 @@
-// Boost sweepline library segment_node_comparer_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_segment_sweepline.hpp"
-using namespace boost::sweepline;
-using namespace boost::sweepline::detail;
-
-#define BOOST_TEST_MODULE node_comparer_test
-#include <boost/test/test_case_template.hpp>
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test1, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef site_event<T> site_event_type;
- typedef beach_line_node<T> bline_node;
- typedef typename std::map< bline_node, int,
- node_comparer<bline_node> >::const_iterator bline_it;
-
- std::map< bline_node, int, node_comparer<bline_node> > test_beach_line;
-
- site_event_type site1 = make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0);
- site_event_type site2 = make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1);
- bline_node initial_node(site1, site2);
- test_beach_line[initial_node] = 2;
-
- site_event_type site3 = make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2);
- bline_node node1(site1, site3);
- bline_node node2(site3, site1);
- test_beach_line.insert(std::pair< bline_node, int>(node1, 0));
- test_beach_line.insert(std::pair< bline_node, int>(node2, 1));
-
- int cur_value = 0;
- for (bline_it it = test_beach_line.begin();
- it != test_beach_line.end();
- it++, cur_value++)
- BOOST_CHECK_EQUAL(it->second, cur_value);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test2, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef site_event<T> site_event_type;
- typedef beach_line_node<T> bline_node;
- typedef typename std::map< bline_node, int,
- node_comparer<bline_node> >::const_iterator bline_it;
-
- std::map< bline_node, int, node_comparer<bline_node> > test_beach_line;
-
- site_event_type site1 = make_site_event<T>(static_cast<T>(0), static_cast<T>(1), 0);
- site_event_type site2 = make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 1);
- site_event_type site3 = make_site_event<T>(static_cast<T>(2), static_cast<T>(4), 2);
- bline_node initial_node1(site1, site2);
- bline_node initial_node2(site2, site1);
- test_beach_line[initial_node1] = 0;
- test_beach_line[initial_node2] = 1;
-
- bline_node new_node1(site1, site3);
- bline_node new_node2(site3, site1);
- test_beach_line[new_node1] = 2;
- test_beach_line[new_node2] = 3;
-
- int cur_value = 0;
- for (bline_it it = test_beach_line.begin();
- it != test_beach_line.end();
- it++, cur_value++)
- BOOST_CHECK_EQUAL(it->second, cur_value);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test3, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-10), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-1), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test4, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(1), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-3), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-2), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(-1), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
- bline_node new_node7(make_site_event<T>(static_cast<T>(2), static_cast<T>(10), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node7), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node7, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test5, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-10), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(5), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(20), 4));
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), true);
-
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test6, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(2), static_cast<T>(-3), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(2), static_cast<T>(-2), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(2), static_cast<T>(0), 4));
- bline_node new_node4(make_site_event<T>(static_cast<T>(2), static_cast<T>(1), 4));
- bline_node new_node5(make_site_event<T>(static_cast<T>(2), static_cast<T>(2), 4));
- bline_node new_node6(make_site_event<T>(static_cast<T>(2), static_cast<T>(3), 4));
- bline_node new_node7(make_site_event<T>(static_cast<T>(2), static_cast<T>(5), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node5), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node6), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node7), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node5, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node6, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node7, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test7, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(2), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 3));
- bline_node new_node3(make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 4));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(node_comparer_test8, T, test_types) {
- typedef point_2d<T> Point2D;
- typedef beach_line_node<T> bline_node;
- node_comparer<bline_node> node_comparer_test;
-
- bline_node initial_node(
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0),
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1));
-
- bline_node new_node1(make_site_event<T>(static_cast<T>(1), static_cast<T>(0), 2));
- bline_node new_node2(make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1));
- bline_node new_node3(make_site_event<T>(static_cast<T>(1), static_cast<T>(2), 3));
- bline_node new_node4(
- make_site_event<T>(static_cast<T>(1), static_cast<T>(1), 1),
- make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0));
-
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
-
- BOOST_CHECK_EQUAL(node_comparer_test(new_node1, initial_node), true);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node2, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node3, initial_node), false);
- BOOST_CHECK_EQUAL(node_comparer_test(new_node4, initial_node), false);
-}

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,622 +0,0 @@
-// Boost sweepline library segment_voronoi_builder_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <stdlib.h>
-#include <time.h>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_segment_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE voronoi_builder_test
-#include <boost/test/test_case_template.hpp>
-
-#define CHECK_EQUAL_POINTS(p1, p2) \
- BOOST_CHECK_EQUAL(p1.x() == static_cast<coordinate_type>(p2.x()) && \
- p1.y() == static_cast<coordinate_type>(p2.y()), true)
-
-// Sites: (0, 0).
-BOOST_AUTO_TEST_CASE_TEMPLATE(single_site_test, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(0), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 1);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 0);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 0);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 0);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 0);
- BOOST_CHECK_EQUAL(it->incident_edge == NULL, true);
-}
-
-// Sites: (0, 0), (0, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(collinear_sites_test1, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(1)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(1), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 2);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 2);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 2);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 2);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 1);
-
- voronoi_const_iterator_type cell_it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
-
- edge_type *edge1_1 = cell_it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
-
- BOOST_CHECK_EQUAL(edge1_1->twin == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->next == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->prev == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_prev == edge1_2, true);
-}
-
-// Sites: (0, 0), (1, 1), (2, 2).
-BOOST_AUTO_TEST_CASE_TEMPLATE(collinear_sites_test2, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(1)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(2),
- static_cast<coordinate_type>(2)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(2) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(2), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 4);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 3);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 2);
-
- voronoi_const_iterator_type cell_it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- edge_type *edge1_1 = cell_it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 2);
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- edge_type *edge2_2 = cell_it->incident_edge;
- edge_type *edge2_1 = edge2_2->twin;
-
- BOOST_CHECK_EQUAL(edge1_1->twin == edge1_2 && edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_1->twin == edge2_2 && edge2_2->twin == edge2_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->next == edge1_1 && edge1_1->prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge1_1 && edge1_1->rot_prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_next == edge1_2 && edge1_2->rot_prev == edge1_2, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge2_1 && edge2_1->rot_prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge2_2 && edge2_2->prev == edge2_2, true);
- BOOST_CHECK_EQUAL(edge2_2->rot_next == edge2_2 && edge2_2->rot_prev == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->next == edge1_2 && edge2_1->prev == edge1_2, true);
-}
-
-// Sites: (0, 0), (0, 4), (2, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(triangle_test1, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(0));
- point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(4));
- point_2d<coordinate_type> point3 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(1));
-
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(point1);
- points.push_back(point2);
- points.push_back(point3);
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_beach_line.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(2) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(4), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 3);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(0.25) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(2.0), true);
-
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, point3);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, point1);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, point1);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, point2);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, point2);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, point3);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge3_2 && edge1_1->next == edge3_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge1_1 && edge3_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: (0, 1), (2, 0), (2, 4).
-BOOST_AUTO_TEST_CASE_TEMPLATE(triangle_test2, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(1));
- point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(0));
- point_2d<coordinate_type> point3 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(4));
-
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(point1);
- points.push_back(point2);
- points.push_back(point3);
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 3);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(1.75) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(2.0), true);
-
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, point2);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, point1);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, point1);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, point3);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, point3);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, point2);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge3_2 && edge1_1->next == edge3_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge1_1 && edge3_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: (0, 0), (0, 1), (1, 0), (1, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(square_test3, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(1)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(1)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_cells().size()), 4);
- BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_vertices().size()), 5);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 4);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 4);
-
- // Check voronoi vertex.
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 4);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(0.5) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(0.5), true);
-
- // Check voronoi edges.
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, points[1]);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, points[3]);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, points[3]);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, points[2]);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, points[2]);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, points[0]);
-
- edge_type *edge4_1 = edge3_1->rot_prev;
- edge_type *edge4_2 = edge4_1->twin;
- CHECK_EQUAL_POINTS(edge4_1->cell->voronoi_point, points[0]);
- CHECK_EQUAL_POINTS(edge4_2->cell->voronoi_point, points[1]);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
- BOOST_CHECK_EQUAL(edge4_2->twin == edge4_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge4_2 && edge1_1->next == edge4_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
- BOOST_CHECK_EQUAL(edge4_1->prev == edge3_2 && edge4_1->next == edge3_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge4_1 && edge3_2->prev == edge4_1, true);
- BOOST_CHECK_EQUAL(edge4_2->next == edge1_1 && edge4_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge4_1, true);
- BOOST_CHECK_EQUAL(edge4_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: {(x, y) | x = 0 .. 3, y = 0 .. 3}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test1, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 3; i++)
- for (int j = 0; j < 3; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 9);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 4);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 12);
-}
-
-// Sites: {(x, y) | x = 0 .. 9, y = 0 .. 9}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test2, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10; i++)
- for (int j = 0; j < 10; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 100);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 81);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 180);
-}
-
-// Sites: {(x, y) | x = 0 .. 33, y = 0 .. 33}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test3, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 33; i++)
- for (int j = 0; j < 33; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1089);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1024);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 2112);
-}
-
-// Sites: {(x, y) | x = 0 .. 100, y = 0 .. 100}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test4, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 100; i++)
- for (int j = 0; j < 100; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 10000);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 9801);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 19800);
-}
-
-// Sites: {(x, y) | x = 0 .. 333, y = 0 .. 333}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test5, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 333; i++)
- for (int j = 0; j < 333; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 110889);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 110224);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 221112);
-}
-
-// Generate 10 random sites 10000 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test1, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10000; i++) {
- points.clear();
- for (int j = 0; j < 10; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5 - 5),
- static_cast<coordinate_type>(rand() % 5 - 5)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 100 random sites 1000 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test2, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1000; i++) {
- points.clear();
- for (int j = 0; j < 100; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 1000 random sites 100 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test3, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 100; i++) {
- points.clear();
- for (int j = 0; j < 1000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 10000 random sites 10 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test4, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10; i++) {
- points.clear();
- for (int j = 0; j < 10000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 100000 random sites.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test5, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1; i++) {
- points.clear();
- for (int j = 0; j < 100000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 1000000 random sites.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test6, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1; i++) {
- points.clear();
- for (int j = 0; j < 1000000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5000 - 5000),
- static_cast<coordinate_type>(rand() % 5000 - 5000)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- //BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,296 +0,0 @@
-// Boost sweepline library segment_voronoi_clipping_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <stdlib.h>
-#include <time.h>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_segment_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE voronoi_clipping_test
-#include <boost/test/test_case_template.hpp>
-
-// Test segment clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1_1(static_cast<T>(8), static_cast<T>(-8));
- point_2d<T> test_direction1_2(static_cast<T>(2), static_cast<T>(-2));
- point_2d<T> test_direction1_3(static_cast<T>(0.5), static_cast<T>(-0.5));
- point_2d<T> test_direction2(static_cast<T>(2), static_cast<T>(-4));
- point_2d<T> test_direction3(static_cast<T>(2), static_cast<T>(-1));
- point_2d<T> test_direction4(static_cast<T>(1), static_cast<T>(-4));
- point_2d<T> test_direction5(static_cast<T>(5), static_cast<T>(-1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1_1,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(3) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction1_2,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction1_3,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(intersections.empty(), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- point_2d<T> test_direction(static_cast<T>(i), static_cast<T>(j));
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- if (abs(i) >= 2 || abs(j) >= 2)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- else
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 0);
- }
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test3, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 0);
- }
-}
-
-// Test ray clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(ray_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1(static_cast<T>(2), static_cast<T>(-2));
- point_2d<T> test_direction2(static_cast<T>(2), static_cast<T>(-4));
- point_2d<T> test_direction3(static_cast<T>(2), static_cast<T>(-1));
- point_2d<T> test_direction4(static_cast<T>(1), static_cast<T>(-4));
- point_2d<T> test_direction5(static_cast<T>(5), static_cast<T>(-1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(3) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(4) &&
- intersections[1].y() == static_cast<T>(0.5), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ray_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- if (i && j)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- }
-}
-
-// Test line clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(line_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1(static_cast<T>(-1), static_cast<T>(1));
- point_2d<T> test_direction2(static_cast<T>(-1), static_cast<T>(2));
- point_2d<T> test_direction3(static_cast<T>(-2), static_cast<T>(1));
- point_2d<T> test_direction4(static_cast<T>(-1), static_cast<T>(4));
- point_2d<T> test_direction5(static_cast<T>(-5), static_cast<T>(1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(3) &&
- intersections[0].y() == static_cast<T>(-1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(0) &&
- intersections[1].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(-1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(0) &&
- intersections[1].y() == static_cast<T>(1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(0.5), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(line_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- if (i && j)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- }
-}
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,622 +0,0 @@
-// Boost sweepline library voronoi_builder_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <stdlib.h>
-#include <time.h>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE voronoi_builder_test
-#include <boost/test/test_case_template.hpp>
-
-#define CHECK_EQUAL_POINTS(p1, p2) \
- BOOST_CHECK_EQUAL(p1.x() == static_cast<coordinate_type>(p2.x()) && \
- p1.y() == static_cast<coordinate_type>(p2.y()), true)
-
-// Sites: (0, 0).
-BOOST_AUTO_TEST_CASE_TEMPLATE(single_site_test, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(0), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 1);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 0);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 0);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 0);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 0);
- BOOST_CHECK_EQUAL(it->incident_edge == NULL, true);
-}
-
-// Sites: (0, 0), (0, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(collinear_sites_test1, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(1)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(1), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 2);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 2);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 2);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 2);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 1);
-
- voronoi_const_iterator_type cell_it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
-
- edge_type *edge1_1 = cell_it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
-
- BOOST_CHECK_EQUAL(edge1_1->twin == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->next == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->prev == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_prev == edge1_2, true);
-}
-
-// Sites: (0, 0), (1, 1), (2, 2).
-BOOST_AUTO_TEST_CASE_TEMPLATE(collinear_sites_test2, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_voronoi_builder;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(1)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(2),
- static_cast<coordinate_type>(2)));
-
- test_voronoi_builder.init(points);
- test_voronoi_builder.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(2) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(2), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_edges().size()), 4);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 3);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 0);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 2);
-
- voronoi_const_iterator_type cell_it = test_output.get_voronoi_cells().begin();
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- edge_type *edge1_1 = cell_it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 2);
- cell_it++;
- BOOST_CHECK_EQUAL(cell_it->num_incident_edges, 1);
- edge_type *edge2_2 = cell_it->incident_edge;
- edge_type *edge2_1 = edge2_2->twin;
-
- BOOST_CHECK_EQUAL(edge1_1->twin == edge1_2 && edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_1->twin == edge2_2 && edge2_2->twin == edge2_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->next == edge1_1 && edge1_1->prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge1_1 && edge1_1->rot_prev == edge1_1, true);
- BOOST_CHECK_EQUAL(edge1_2->rot_next == edge1_2 && edge1_2->rot_prev == edge1_2, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge2_1 && edge2_1->rot_prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge2_2 && edge2_2->prev == edge2_2, true);
- BOOST_CHECK_EQUAL(edge2_2->rot_next == edge2_2 && edge2_2->rot_prev == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->next == edge1_2 && edge2_1->prev == edge1_2, true);
-}
-
-// Sites: (0, 0), (0, 4), (2, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(triangle_test1, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(0));
- point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(4));
- point_2d<coordinate_type> point3 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(1));
-
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(point1);
- points.push_back(point2);
- points.push_back(point3);
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BRect<coordinate_type> bounding_rectangle = test_beach_line.get_bounding_rectangle();
- BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
- bounding_rectangle.x_max == static_cast<coordinate_type>(2) &&
- bounding_rectangle.y_max == static_cast<coordinate_type>(4), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 3);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(0.25) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(2.0), true);
-
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, point3);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, point1);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, point1);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, point2);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, point2);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, point3);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge3_2 && edge1_1->next == edge3_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge1_1 && edge3_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: (0, 1), (2, 0), (2, 4).
-BOOST_AUTO_TEST_CASE_TEMPLATE(triangle_test2, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(0), static_cast<coordinate_type>(1));
- point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(0));
- point_2d<coordinate_type> point3 = make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(2), static_cast<coordinate_type>(4));
-
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(point1);
- points.push_back(point2);
- points.push_back(point3);
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
- BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
-
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 3);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(1.75) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(2.0), true);
-
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, point2);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, point1);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, point1);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, point3);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, point3);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, point2);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge3_2 && edge1_1->next == edge3_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge1_1 && edge3_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: (0, 0), (0, 1), (1, 0), (1, 1).
-BOOST_AUTO_TEST_CASE_TEMPLATE(square_test3, T, test_types) {
- typedef T coordinate_type;
- typedef typename voronoi_output_clipped<coordinate_type>::edge_type edge_type;
- typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
- voronoi_const_iterator_type;
-
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
- static_cast<coordinate_type>(1)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(0)));
- points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
- static_cast<coordinate_type>(1)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_cells().size()), 4);
- BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_vertices().size()), 5);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 4);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 4);
-
- // Check voronoi vertex.
- voronoi_const_iterator_type it = test_output.get_voronoi_vertices().begin();
- BOOST_CHECK_EQUAL(it->num_incident_edges, 4);
- BOOST_CHECK_EQUAL(it->voronoi_point.x() == static_cast<coordinate_type>(0.5) &&
- it->voronoi_point.y() == static_cast<coordinate_type>(0.5), true);
-
- // Check voronoi edges.
- edge_type *edge1_1 = it->incident_edge;
- edge_type *edge1_2 = edge1_1->twin;
- CHECK_EQUAL_POINTS(edge1_1->cell->voronoi_point, points[1]);
- CHECK_EQUAL_POINTS(edge1_2->cell->voronoi_point, points[3]);
-
- edge_type *edge2_1 = edge1_1->rot_prev;
- edge_type *edge2_2 = edge2_1->twin;
- CHECK_EQUAL_POINTS(edge2_1->cell->voronoi_point, points[3]);
- CHECK_EQUAL_POINTS(edge2_2->cell->voronoi_point, points[2]);
-
- edge_type *edge3_1 = edge2_1->rot_prev;
- edge_type *edge3_2 = edge3_1->twin;
- CHECK_EQUAL_POINTS(edge3_1->cell->voronoi_point, points[2]);
- CHECK_EQUAL_POINTS(edge3_2->cell->voronoi_point, points[0]);
-
- edge_type *edge4_1 = edge3_1->rot_prev;
- edge_type *edge4_2 = edge4_1->twin;
- CHECK_EQUAL_POINTS(edge4_1->cell->voronoi_point, points[0]);
- CHECK_EQUAL_POINTS(edge4_2->cell->voronoi_point, points[1]);
-
- BOOST_CHECK_EQUAL(edge1_2->twin == edge1_1, true);
- BOOST_CHECK_EQUAL(edge2_2->twin == edge2_1, true);
- BOOST_CHECK_EQUAL(edge3_2->twin == edge3_1, true);
- BOOST_CHECK_EQUAL(edge4_2->twin == edge4_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->prev == edge4_2 && edge1_1->next == edge4_2, true);
- BOOST_CHECK_EQUAL(edge2_1->prev == edge1_2 && edge2_1->next == edge1_2, true);
- BOOST_CHECK_EQUAL(edge3_1->prev == edge2_2 && edge3_1->next == edge2_2, true);
- BOOST_CHECK_EQUAL(edge4_1->prev == edge3_2 && edge4_1->next == edge3_2, true);
-
- BOOST_CHECK_EQUAL(edge1_2->next == edge2_1 && edge1_2->prev == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_2->next == edge3_1 && edge2_2->prev == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_2->next == edge4_1 && edge3_2->prev == edge4_1, true);
- BOOST_CHECK_EQUAL(edge4_2->next == edge1_1 && edge4_2->prev == edge1_1, true);
-
- BOOST_CHECK_EQUAL(edge1_1->rot_next == edge4_1, true);
- BOOST_CHECK_EQUAL(edge4_1->rot_next == edge3_1, true);
- BOOST_CHECK_EQUAL(edge3_1->rot_next == edge2_1, true);
- BOOST_CHECK_EQUAL(edge2_1->rot_next == edge1_1, true);
-}
-
-// Sites: {(x, y) | x = 0 .. 3, y = 0 .. 3}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test1, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 3; i++)
- for (int j = 0; j < 3; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 9);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 4);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 12);
-}
-
-// Sites: {(x, y) | x = 0 .. 9, y = 0 .. 9}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test2, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10; i++)
- for (int j = 0; j < 10; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 100);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 81);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 180);
-}
-
-// Sites: {(x, y) | x = 0 .. 33, y = 0 .. 33}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test3, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 33; i++)
- for (int j = 0; j < 33; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1089);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1024);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 2112);
-}
-
-// Sites: {(x, y) | x = 0 .. 100, y = 0 .. 100}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test4, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 100; i++)
- for (int j = 0; j < 100; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 10000);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 9801);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 19800);
-}
-
-// Sites: {(x, y) | x = 0 .. 333, y = 0 .. 333}.
-BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test5, T, test_types) {
- typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 333; i++)
- for (int j = 0; j < 333; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
-
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
-
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 110889);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 110224);
- BOOST_CHECK_EQUAL(test_output.get_num_voronoi_edges(), 221112);
-}
-
-// Generate 10 random sites 10000 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test1, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10000; i++) {
- points.clear();
- for (int j = 0; j < 10; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5 - 5),
- static_cast<coordinate_type>(rand() % 5 - 5)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 100 random sites 1000 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test2, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1000; i++) {
- points.clear();
- for (int j = 0; j < 100; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 1000 random sites 100 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test3, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 100; i++) {
- points.clear();
- for (int j = 0; j < 1000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 10000 random sites 10 times.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test4, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 10; i++) {
- points.clear();
- for (int j = 0; j < 10000; j++)
- points.push_back(make_point_2d<coordinate_type>(\
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 100000 random sites.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test5, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1; i++) {
- points.clear();
- for (int j = 0; j < 100000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
-
-// Generate 1000000 random sites.
-BOOST_AUTO_TEST_CASE_TEMPLATE(random_test6, T, test_types) {
- typedef T coordinate_type;
- srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
- voronoi_output_clipped<coordinate_type> test_output;
- std::vector< point_2d<coordinate_type> > points;
- for (int i = 0; i < 1; i++) {
- points.clear();
- for (int j = 0; j < 1000000; j++)
- points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5000 - 5000),
- static_cast<coordinate_type>(rand() % 5000 - 5000)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- //BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
- }
-}
\ No newline at end of file

Deleted: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp
==============================================================================
--- sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
+++ (empty file)
@@ -1,296 +0,0 @@
-// Boost sweepline library voronoi_clipping_test.cpp file
-
-// Copyright Andrii Sydorchuk 2010.
-// 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.
-
-#include <stdlib.h>
-#include <time.h>
-
-#include "test_type_list.hpp"
-#include "boost/sweepline/voronoi_sweepline.hpp"
-using namespace boost::sweepline;
-
-#define BOOST_TEST_MODULE voronoi_clipping_test
-#include <boost/test/test_case_template.hpp>
-
-// Test segment clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1_1(static_cast<T>(8), static_cast<T>(-8));
- point_2d<T> test_direction1_2(static_cast<T>(2), static_cast<T>(-2));
- point_2d<T> test_direction1_3(static_cast<T>(0.5), static_cast<T>(-0.5));
- point_2d<T> test_direction2(static_cast<T>(2), static_cast<T>(-4));
- point_2d<T> test_direction3(static_cast<T>(2), static_cast<T>(-1));
- point_2d<T> test_direction4(static_cast<T>(1), static_cast<T>(-4));
- point_2d<T> test_direction5(static_cast<T>(5), static_cast<T>(-1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1_1,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(3) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction1_2,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction1_3,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(intersections.empty(), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- point_2d<T> test_direction(static_cast<T>(i), static_cast<T>(j));
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- if (abs(i) >= 2 || abs(j) >= 2)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- else
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 0);
- }
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(segment_clipping_test3, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::SEGMENT,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 0);
- }
-}
-
-// Test ray clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(ray_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1(static_cast<T>(2), static_cast<T>(-2));
- point_2d<T> test_direction2(static_cast<T>(2), static_cast<T>(-4));
- point_2d<T> test_direction3(static_cast<T>(2), static_cast<T>(-1));
- point_2d<T> test_direction4(static_cast<T>(1), static_cast<T>(-4));
- point_2d<T> test_direction5(static_cast<T>(5), static_cast<T>(-1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(3) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(2), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(4) &&
- intersections[1].y() == static_cast<T>(0.5), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(ray_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::RAY,
- test_rect, intersections);
- if (i && j)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- }
-}
-
-// Test line clipping.
-BOOST_AUTO_TEST_CASE_TEMPLATE(line_clipping_test1, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(2.0));
- detail::voronoi_output<T> test_output;
- point_2d<T> test_origin(static_cast<T>(-1), static_cast<T>(3));
- point_2d<T> test_direction1(static_cast<T>(-1), static_cast<T>(1));
- point_2d<T> test_direction2(static_cast<T>(-1), static_cast<T>(2));
- point_2d<T> test_direction3(static_cast<T>(-2), static_cast<T>(1));
- point_2d<T> test_direction4(static_cast<T>(-1), static_cast<T>(4));
- point_2d<T> test_direction5(static_cast<T>(-5), static_cast<T>(1));
-
- std::vector< point_2d<T> > intersections;
- test_output.find_intersections(test_origin, test_direction1,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(3) &&
- intersections[0].y() == static_cast<T>(-1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(0) &&
- intersections[1].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction2,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(1) &&
- intersections[0].y() == static_cast<T>(-1), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(0) &&
- intersections[1].y() == static_cast<T>(1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction3,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(0.5), true);
- BOOST_CHECK_EQUAL(intersections[1].x() == static_cast<T>(1) &&
- intersections[1].y() == static_cast<T>(2), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction4,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(0) &&
- intersections[0].y() == static_cast<T>(-1), true);
-
- intersections.clear();
- test_output.find_intersections(test_origin, test_direction5,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 1);
- BOOST_CHECK_EQUAL(intersections[0].x() == static_cast<T>(4) &&
- intersections[0].y() == static_cast<T>(2), true);
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(line_clipping_test2, T, test_types) {
- BRect<T> test_rect(static_cast<T>(0.0), static_cast<T>(-1.0),
- static_cast<T>(4.0), static_cast<T>(3.0));
- detail::voronoi_output<T> test_output;
- std::vector< point_2d<T> > intersections;
- srand(static_cast<unsigned int>(time(NULL)));
- point_2d<T> test_origin(2, 1);
-
- for (int i = -50; i <= 50; i++)
- for (int j = -50; j <= 50; j++) {
- intersections.clear();
- T x = static_cast<T>(i) / static_cast<T>(26);
- T y = static_cast<T>(j) / static_cast<T>(26);
- point_2d<T> test_direction(x, y);
- test_output.find_intersections(test_origin, test_direction,
- detail::voronoi_output<T>::LINE,
- test_rect, intersections);
- if (i && j)
- BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
- }
-}
\ No newline at end of file

Added: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_output_verification.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_output_verification.hpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -0,0 +1,192 @@
+// Boost sweepline library voronoi_output_verification.hpp file
+
+// Copyright Andrii Sydorchuk 2010.
+// 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 VORONOI_OUTPUT_VERIFICATION
+#define VORONOI_OUTPUT_VERIFICATION
+
+#include <map>
+#include <vector>
+
+enum kOrientation {
+ RIGHT_ORIENTATION = -1,
+ COLLINEAR = 0,
+ LEFT_ORIENTATION = 1,
+};
+
+template <typename Point2D>
+kOrientation get_orientation(const Point2D &point1,
+ const Point2D &point2,
+ const Point2D &point3) {
+ typename Point2D::coordinate_type a = (point2.x() - point1.x()) * (point3.y() - point2.y());
+ typename Point2D::coordinate_type b = (point2.y() - point1.y()) * (point3.x() - point2.x());
+ if (a == b)
+ return COLLINEAR;
+ return (a < b) ? RIGHT_ORIENTATION : LEFT_ORIENTATION;
+}
+
+template <typename Output>
+bool verify_half_edge_orientation(const Output &output) {
+ typedef typename Output::Point2D Point2D;
+ typename Output::edges_const_iterator_type edge_it;
+ for (edge_it = output.get_voronoi_edges().begin();
+ edge_it != output.get_voronoi_edges().end(); edge_it++) {
+ if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
+ const Point2D &site = edge_it->cell->voronoi_point;
+ const Point2D &start_point = edge_it->start_point->voronoi_point;
+ const Point2D &end_point = edge_it->end_point->voronoi_point;
+ if (get_orientation(start_point, end_point, site) != LEFT_ORIENTATION)
+ return false;
+ }
+ }
+ return true;
+}
+
+template <typename Output>
+bool verify_cell_convexity(const Output &output) {
+ typedef typename Output::Point2D Point2D;
+ typename Output::voronoi_const_iterator_type cell_it;
+ for (cell_it = output.get_voronoi_cells().begin();
+ cell_it != output.get_voronoi_cells().end(); cell_it++) {
+ const typename Output::edge_type *edge = cell_it->incident_edge;
+ if (edge)
+ do {
+ if (edge->next->prev != edge)
+ return false;
+ if (edge->cell != &(*cell_it))
+ return false;
+ if (edge->start_point != NULL &&
+ edge->end_point != NULL &&
+ edge->end_point == edge->next->start_point &&
+ edge->next->end_point != NULL) {
+ const Point2D &vertex1 = edge->start_point->voronoi_point;
+ const Point2D &vertex2 = edge->end_point->voronoi_point;
+ const Point2D &vertex3 = edge->next->end_point->voronoi_point;
+ if (get_orientation(vertex1, vertex2, vertex3) != LEFT_ORIENTATION)
+ return false;
+ }
+ edge = edge->next;
+ } while(edge != cell_it->incident_edge);
+ }
+ return true;
+}
+
+template <typename Output>
+bool verify_incident_edges_ccw_order(const Output &output) {
+ typedef typename Output::Point2D Point2D;
+ typename Output::voronoi_const_iterator_type vertex_it;
+ for (vertex_it = output.get_voronoi_vertices().begin();
+ vertex_it != output.get_voronoi_vertices().end(); vertex_it++) {
+ if (vertex_it->num_incident_edges < 3)
+ continue;
+ typename Output::edge_type *edge = vertex_it->incident_edge;
+ do {
+ typename Output::edge_type *edge_next1 = edge->rot_next;
+ typename Output::edge_type *edge_next2 = edge_next1->rot_next;
+ const Point2D &site1 = edge->cell->voronoi_point;
+ const Point2D &site2 = edge_next1->cell->voronoi_point;
+ const Point2D &site3 = edge_next2->cell->voronoi_point;
+
+ if (get_orientation(site1, site2, site3) != LEFT_ORIENTATION)
+ return false;
+
+ edge = edge->rot_next;
+ } while (edge != vertex_it->incident_edge);
+ }
+ return true;
+}
+
+template <typename Output>
+bool verfiy_no_half_edge_intersections(const Output &output) {
+ // Create map from edges with first point less than the second one.
+ // Key is the first point of the edge, value is a vector of second points
+ // with the same first point.
+ typedef typename Output::Point2D Point2D;
+ std::map< Point2D, std::vector<Point2D> > edge_map;
+ typedef typename std::map< Point2D, std::vector<Point2D> >::const_iterator
+ edge_map_iterator;
+ typename Output::edges_const_iterator_type edge_it;
+ for (edge_it = output.get_voronoi_edges().begin();
+ edge_it != output.get_voronoi_edges().end(); edge_it++) {
+ if (edge_it->start_point != NULL && edge_it->end_point != NULL) {
+ const Point2D &start_point = edge_it->start_point->voronoi_point;
+ const Point2D &end_point = edge_it->end_point->voronoi_point;
+ if (start_point < end_point)
+ edge_map[start_point].push_back(end_point);
+ }
+ }
+
+ // Iterate over map of edges and check if there are any intersections.
+ // All the edges are stored by the low x value. That's why we iterate
+ // left to right checking for intersections between all pairs of edges
+ // that overlap in the x dimension.
+ // Complexity. Approximately N*sqrt(N). Worst case N^2.
+ typedef typename std::vector<Point2D>::size_type size_type;
+ edge_map_iterator edge_map_it1, edge_map_it2, edge_map_it_bound;
+ for (edge_map_it1 = edge_map.begin();
+ edge_map_it1 != edge_map.end(); edge_map_it1++) {
+ const Point2D &point1 = edge_map_it1->first;
+ for (size_type i = 0; i < edge_map_it1->second.size(); i++) {
+ const Point2D &point2 = edge_map_it1->second[i];
+ typename Output::coordinate_type min_y1 = std::min(point1.y(), point2.y());
+ typename Output::coordinate_type max_y1 = std::max(point1.y(), point2.y());
+
+ // Find the first edge with greater or equal first point.
+ edge_map_it_bound = edge_map.lower_bound(point2);
+
+ edge_map_it2 = edge_map_it1;
+ edge_map_it2++;
+ for (; edge_map_it2 != edge_map_it_bound; edge_map_it2++) {
+ const Point2D &point3 = edge_map_it2->first;
+ for (size_type j = 0; j < edge_map_it2->second.size(); j++) {
+ const Point2D &point4 = edge_map_it2->second[j];
+ typename Output::coordinate_type min_y2 = std::min(point3.y(), point4.y());
+ typename Output::coordinate_type max_y2 = std::max(point3.y(), point4.y());
+
+ // In most cases it is enought to make
+ // simple intersection check in the y dimension.
+ if (!(max_y1 > min_y2 && max_y2 > min_y1))
+ continue;
+
+ // Intersection check.
+ if (get_orientation(point1, point2, point3) *
+ get_orientation(point1, point2, point4) == -1 &&
+ get_orientation(point3, point4, point1) *
+ get_orientation(point3, point4, point2) == -1)
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+enum kVerification {
+ HALF_EDGE_ORIENTATION = 1,
+ CELL_CONVEXITY = 2,
+ INCIDENT_EDGES_CCW_ORDER = 4,
+ NO_HALF_EDGE_INTERSECTIONS = 8,
+ FAST_VERIFICATION = 7,
+ COMPLETE_VERIFICATION = 15,
+};
+
+template <typename Output>
+bool verify_output(const Output &output, kVerification mask) {
+ bool result = true;
+ if (mask & HALF_EDGE_ORIENTATION)
+ result &= verify_half_edge_orientation(output);
+ if (mask & CELL_CONVEXITY)
+ result &= verify_cell_convexity(output);
+ if (mask & INCIDENT_EDGES_CCW_ORDER)
+ result &= verify_incident_edges_ccw_order(output);
+ if (mask & NO_HALF_EDGE_INTERSECTIONS)
+ result &= verfiy_no_half_edge_intersections(output);
+ return result;
+}
+
+#endif

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_queue_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/event_queue_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_queue_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -9,7 +9,7 @@
 
 #include <cmath>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_sweepline.hpp"
 using namespace boost::sweepline;
 
@@ -17,8 +17,7 @@
 #include <boost/test/test_case_template.hpp>
 
 #define CHECK_TOP_ELEMENT_EQUALITY(TOP, X, Y) \
- BOOST_CHECK_EQUAL(TOP.x() + sqrt(static_cast<T>(TOP.get_sqr_radius())) \
- == static_cast<T>(X) && \
+ BOOST_CHECK_EQUAL(TOP.get_lower_x() == static_cast<T>(X) && \
                       TOP.y() == static_cast<T>(Y), true)
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test1, T, test_types) {
@@ -30,7 +29,7 @@
     for (int i = 0; i < 10; i++) {
         T x = static_cast<T>(-i);
         T y = static_cast<T>(10-i);
- event_q.push(detail::make_circle_event<T>(x, y, static_cast<T>(100)));
+ event_q.push(detail::make_circle_event<T>(x, y, x + static_cast<T>(10)));
     }
 
     for (int i = 0; i < 10; i++) {
@@ -51,7 +50,7 @@
     for (int i = 0; i < 10; i++) {
         T x = static_cast<T>(10-i);
         T y = static_cast<T>(10-i);
- circle_event_type c = detail::make_circle_event<T>(x, y, static_cast<T>(0));
+ circle_event_type c = detail::make_circle_event<T>(x, y, x);
         if (i&1)
             event_q.push(c)->deactivate();
         else

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/event_types_test.cpp (from r64812, /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/voronoi_point/event_types_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -7,7 +7,7 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_sweepline.hpp"
 using namespace boost::sweepline;
 using namespace boost::sweepline::detail;
@@ -67,19 +67,19 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test1, T, test_types) {
     circle_event<T> circle1 = make_circle_event<T>(static_cast<T>(1),
                                                    static_cast<T>(2),
- static_cast<T>(4));
+ static_cast<T>(3));
     site_event<T> temp_site = make_site_event<T>(static_cast<T>(0), static_cast<T>(0),0);
     circle_event<T> circle2;
     
     BOOST_CHECK_EQUAL(circle1.x(), static_cast<T>(1));
     BOOST_CHECK_EQUAL(circle1.y(), static_cast<T>(2));
- BOOST_CHECK_EQUAL(circle1.get_sqr_radius(), static_cast<T>(4));
+ BOOST_CHECK_EQUAL(circle1.get_lower_x(), static_cast<T>(3));
 
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(4));
+ circle2 = make_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);
 
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(3), static_cast<T>(4));
+ circle2 = make_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);
 
@@ -87,7 +87,7 @@
     bool arr3[] = { true, false, true, false, false, true };
     EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr3);
 
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(2), static_cast<T>(4));
+ circle2 = make_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);
 
@@ -99,7 +99,7 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test2, T, test_types) {
     circle_event<T> circle = make_circle_event<T>(static_cast<T>(1),
                                                   static_cast<T>(2),
- static_cast<T>(4));
+ static_cast<T>(3));
     site_event<T> site;
 
     site = make_site_event<T>(static_cast<T>(0), static_cast<T>(100), 0);

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/node_comparer_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/node_comparer_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/node_comparer_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -7,7 +7,7 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_sweepline.hpp"
 using namespace boost::sweepline;
 using namespace boost::sweepline::detail;

Added: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_benchmark_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_benchmark_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -0,0 +1,59 @@
+// Boost sweepline library voronoi_benchmark_test.cpp file
+
+// Copyright Andrii Sydorchuk 2010.
+// 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.
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "../test_type_list.hpp"
+#include "boost/sweepline/voronoi_sweepline.hpp"
+using namespace boost::sweepline;
+
+#define BOOST_TEST_MODULE voronoi_benchmark_test
+#include <boost/test/test_case_template.hpp>
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(benchmark_test1, T, test_types) {
+ typedef T coordinate_type;
+ srand(static_cast<unsigned int>(time(NULL)));
+
+ voronoi_builder<coordinate_type> test_builder;
+ voronoi_output_clipped<coordinate_type> test_output;
+
+ FILE *bench_file = fopen("benchmark.txt", "a");
+ fprintf(bench_file, "Voronoi Sweepline Benchmark Test (time in seconds):\n");
+
+ for (int num_points = 10; num_points <= 1000000; num_points *= 10) {
+ std::vector< point_2d<coordinate_type> > points;
+ points.reserve(num_points);
+
+ time_t start_time = time(NULL);
+ int num_times = 1000000 / num_points;
+ for (int cur = 0; cur < num_times; cur++) {
+ for (int cur_point = 0; cur_point < num_points; cur_point++) {
+ points.push_back(make_point_2d<coordinate_type>(
+ static_cast<coordinate_type>(rand() % 5000 - 10000),
+ static_cast<coordinate_type>(rand() % 5000 - 10000)));
+ }
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ test_builder.reset();
+ test_output.reset();
+ points.clear();
+ }
+ time_t end_time = time(NULL);
+ double running_time = static_cast<double>(end_time - start_time) / num_times;
+
+ fprintf(bench_file,
+ "Number of points = %8d; Overall time = %2d; Time per one input = %9.6f.\n",
+ num_points, static_cast<int>(end_time - start_time), running_time);
+ }
+ fclose(bench_file);
+}

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_builder_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_builder_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_builder_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,7 +10,8 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
+#include "../voronoi_output_verification.hpp"
 #include "boost/sweepline/voronoi_sweepline.hpp"
 using namespace boost::sweepline;
 
@@ -21,6 +22,8 @@
         BOOST_CHECK_EQUAL(p1.x() == static_cast<coordinate_type>(p2.x()) && \
                           p1.y() == static_cast<coordinate_type>(p2.y()), true)
 
+#define VERIFY_VORONOI_OUTPUT(output, mask) BOOST_CHECK_EQUAL(verify_output(output, mask), true)
+
 // Sites: (0, 0).
 BOOST_AUTO_TEST_CASE_TEMPLATE(single_site_test, T, test_types) {
     typedef T coordinate_type;
@@ -36,7 +39,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -75,7 +78,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -133,7 +136,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -181,7 +184,7 @@
     typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
         voronoi_const_iterator_type;
 
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
         static_cast<coordinate_type>(0), static_cast<coordinate_type>(0));
     point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
@@ -194,13 +197,13 @@
     points.push_back(point2);
     points.push_back(point3);
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
- BRect<coordinate_type> bounding_rectangle = test_beach_line.get_bounding_rectangle();
+ BRect<coordinate_type> bounding_rectangle = test_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
                       bounding_rectangle.y_min == static_cast<coordinate_type>(0) &&
                       bounding_rectangle.x_max == static_cast<coordinate_type>(2) &&
@@ -253,7 +256,7 @@
     typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
         voronoi_const_iterator_type;
 
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     point_2d<coordinate_type> point1 = make_point_2d<coordinate_type>(
         static_cast<coordinate_type>(0), static_cast<coordinate_type>(1));
     point_2d<coordinate_type> point2 = make_point_2d<coordinate_type>(
@@ -266,11 +269,11 @@
     points.push_back(point2);
     points.push_back(point3);
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
     BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
@@ -319,7 +322,7 @@
     typedef typename voronoi_output_clipped<coordinate_type>::voronoi_const_iterator_type
         voronoi_const_iterator_type;
 
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(0),
                                                     static_cast<coordinate_type>(0)));
@@ -330,11 +333,11 @@
     points.push_back(make_point_2d<coordinate_type>(static_cast<coordinate_type>(1),
                                                     static_cast<coordinate_type>(1)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_cells().size()), 4);
     BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_vertices().size()), 5);
@@ -393,18 +396,18 @@
 // Sites: {(x, y) | x = 0 .. 3, y = 0 .. 3}.
 BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test1, T, test_types) {
     typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 3; i++)
         for (int j = 0; j < 3; j++)
             points.push_back(make_point_2d<coordinate_type>(
                 static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 9);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 4);
@@ -414,18 +417,18 @@
 // Sites: {(x, y) | x = 0 .. 9, y = 0 .. 9}.
 BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test2, T, test_types) {
     typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 10; i++)
         for (int j = 0; j < 10; j++)
             points.push_back(make_point_2d<coordinate_type>(
                 static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 100);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 81);
@@ -435,18 +438,18 @@
 // Sites: {(x, y) | x = 0 .. 33, y = 0 .. 33}.
 BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test3, T, test_types) {
     typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 33; i++)
         for (int j = 0; j < 33; j++)
             points.push_back(make_point_2d<coordinate_type>(
                 static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1089);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1024);
@@ -456,18 +459,18 @@
 // Sites: {(x, y) | x = 0 .. 100, y = 0 .. 100}.
 BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test4, T, test_types) {
     typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 100; i++)
         for (int j = 0; j < 100; j++)
             points.push_back(make_point_2d<coordinate_type>(
                 static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 10000);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 9801);
@@ -477,18 +480,18 @@
 // Sites: {(x, y) | x = 0 .. 333, y = 0 .. 333}.
 BOOST_AUTO_TEST_CASE_TEMPLATE(grid_test5, T, test_types) {
     typedef T coordinate_type;
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 333; i++)
         for (int j = 0; j < 333; j++)
             points.push_back(make_point_2d<coordinate_type>(
                 static_cast<coordinate_type>(i), static_cast<coordinate_type>(j)));
     
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
+ test_builder.init(points);
+ test_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 110889);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 110224);
@@ -499,20 +502,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test1, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 10000; i++) {
         points.clear();
         for (int j = 0; j < 10; j++)
             points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5 - 5),
- static_cast<coordinate_type>(rand() % 5 - 5)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 5 - 10),
+ static_cast<coordinate_type>(rand() % 5 - 10)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
+ test_builder.reset();
     }
 }
 
@@ -520,20 +523,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test2, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 1000; i++) {
         points.clear();
         for (int j = 0; j < 100; j++)
             points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 50 - 100),
+ static_cast<coordinate_type>(rand() % 50 - 100)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
+ test_builder.reset();
     }
 }
 
@@ -541,20 +544,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test3, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 100; i++) {
         points.clear();
         for (int j = 0; j < 1000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 50 - 100),
+ static_cast<coordinate_type>(rand() % 50 - 100)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
+ test_builder.reset();
     }
 }
 
@@ -562,20 +565,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test4, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 10; i++) {
         points.clear();
         for (int j = 0; j < 10000; j++)
         points.push_back(make_point_2d<coordinate_type>(\
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 500 - 1000),
+ static_cast<coordinate_type>(rand() % 500 - 1000)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
+ test_builder.reset();
     }
 }
 
@@ -583,20 +586,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test5, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 1; i++) {
         points.clear();
         for (int j = 0; j < 100000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 500 - 1000),
+ static_cast<coordinate_type>(rand() % 500 - 1000)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
+ test_builder.reset();
     }
 }
 
@@ -604,19 +607,19 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(random_test6, T, test_types) {
     typedef T coordinate_type;
     srand(static_cast<unsigned int>(time(NULL)));
- voronoi_builder<coordinate_type> test_beach_line;
+ voronoi_builder<coordinate_type> test_builder;
     voronoi_output_clipped<coordinate_type> test_output;
     std::vector< point_2d<coordinate_type> > points;
     for (int i = 0; i < 1; i++) {
         points.clear();
         for (int j = 0; j < 1000000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5000 - 5000),
- static_cast<coordinate_type>(rand() % 5000 - 5000)));
- test_beach_line.init(points);
- test_beach_line.run_sweepline();
- test_beach_line.clip(test_output);
- //BOOST_CHECK_EQUAL(test_output.check(), true);
- test_beach_line.reset();
+ static_cast<coordinate_type>(rand() % 5000 - 10000),
+ static_cast<coordinate_type>(rand() % 5000 - 10000)));
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ VERIFY_VORONOI_OUTPUT(test_output, FAST_VERIFICATION);
+ test_builder.reset();
     }
-}
\ No newline at end of file
+}

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_clipping_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_clipping_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_point/voronoi_clipping_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_sweepline.hpp"
 using namespace boost::sweepline;
 

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_queue_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_queue_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_queue_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -9,7 +9,7 @@
 
 #include <cmath>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_segment_sweepline.hpp"
 using namespace boost::sweepline;
 
@@ -17,8 +17,7 @@
 #include <boost/test/test_case_template.hpp>
 
 #define CHECK_TOP_ELEMENT_EQUALITY(TOP, X, Y) \
- BOOST_CHECK_EQUAL(TOP.x() + sqrt(static_cast<T>(TOP.get_sqr_radius())) \
- == static_cast<T>(X) && \
+ BOOST_CHECK_EQUAL(TOP.get_lower_x() == static_cast<T>(X) && \
                       TOP.y() == static_cast<T>(Y), true)
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(event_queue_test1, T, test_types) {
@@ -30,7 +29,7 @@
     for (int i = 0; i < 10; i++) {
         T x = static_cast<T>(-i);
         T y = static_cast<T>(10-i);
- event_q.push(detail::make_circle_event<T>(x, y, static_cast<T>(100)));
+ event_q.push(detail::make_circle_event<T>(x, y, x + static_cast<T>(10)));
     }
 
     for (int i = 0; i < 10; i++) {
@@ -51,7 +50,7 @@
     for (int i = 0; i < 10; i++) {
         T x = static_cast<T>(10-i);
         T y = static_cast<T>(10-i);
- circle_event_type c = detail::make_circle_event<T>(x, y, static_cast<T>(0));
+ circle_event_type c = detail::make_circle_event<T>(x, y, x);
         if (i&1)
             event_q.push(c)->deactivate();
         else

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_types_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_event_types_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_event_types_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -7,7 +7,7 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_segment_sweepline.hpp"
 using namespace boost::sweepline;
 using namespace boost::sweepline::detail;
@@ -67,19 +67,19 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test1, T, test_types) {
     circle_event<T> circle1 = make_circle_event<T>(static_cast<T>(1),
                                                    static_cast<T>(2),
- static_cast<T>(4));
+ static_cast<T>(3));
     site_event<T> temp_site = make_site_event<T>(static_cast<T>(0), static_cast<T>(0),0);
     circle_event<T> circle2;
     
     BOOST_CHECK_EQUAL(circle1.x(), static_cast<T>(1));
     BOOST_CHECK_EQUAL(circle1.y(), static_cast<T>(2));
- BOOST_CHECK_EQUAL(circle1.get_sqr_radius(), static_cast<T>(4));
+ BOOST_CHECK_EQUAL(circle1.get_lower_x(), static_cast<T>(3));
 
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(2), static_cast<T>(4));
+ circle2 = make_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);
 
- circle2 = make_circle_event<T>(static_cast<T>(1), static_cast<T>(3), static_cast<T>(4));
+ circle2 = make_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);
 
@@ -87,7 +87,7 @@
     bool arr3[] = { true, false, true, false, false, true };
     EVENT_TYPES_CHECK_COMPARISON(circle1, circle2, arr3);
 
- circle2 = make_circle_event<T>(static_cast<T>(0), static_cast<T>(2), static_cast<T>(4));
+ circle2 = make_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);
 
@@ -99,7 +99,7 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE(circle_event_test2, T, test_types) {
     circle_event<T> circle = make_circle_event<T>(static_cast<T>(1),
                                                   static_cast<T>(2),
- static_cast<T>(4));
+ static_cast<T>(3));
     site_event<T> site;
 
     site = make_site_event<T>(static_cast<T>(0), static_cast<T>(100), 0);

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_node_comparer_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_node_comparer_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_node_comparer_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -7,7 +7,7 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_segment_sweepline.hpp"
 using namespace boost::sweepline;
 using namespace boost::sweepline::detail;
@@ -244,7 +244,7 @@
         make_site_event<T>(static_cast<T>(0), static_cast<T>(0), 0));
     
     BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node1), false);
- BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), false);
+ BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node2), true);
     BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node3), true);
     BOOST_CHECK_EQUAL(node_comparer_test(initial_node, new_node4), true);
 

Added: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_benchmark_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_benchmark_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -0,0 +1,59 @@
+// Boost sweepline library segment_voronoi_benchmark_test.cpp file
+
+// Copyright Andrii Sydorchuk 2010.
+// 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.
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "../test_type_list.hpp"
+#include "boost/sweepline/voronoi_segment_sweepline.hpp"
+using namespace boost::sweepline;
+
+#define BOOST_TEST_MODULE voronoi_benchmark_test
+#include <boost/test/test_case_template.hpp>
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(benchmark_test1, T, test_types) {
+ typedef T coordinate_type;
+ srand(static_cast<unsigned int>(time(NULL)));
+
+ voronoi_builder<coordinate_type> test_builder;
+ voronoi_output_clipped<coordinate_type> test_output;
+
+ FILE *bench_file = fopen("benchmark.txt", "a");
+ fprintf(bench_file, "Voronoi Segment Sweepline Benchmark Test (time in seconds):\n");
+
+ for (int num_points = 10; num_points <= 1000000; num_points *= 10) {
+ std::vector< point_2d<coordinate_type> > points;
+ points.reserve(num_points);
+
+ time_t start_time = time(NULL);
+ int num_times = 1000000 / num_points;
+ for (int cur = 0; cur < num_times; cur++) {
+ for (int cur_point = 0; cur_point < num_points; cur_point++) {
+ points.push_back(make_point_2d<coordinate_type>(
+ static_cast<coordinate_type>(rand() % 5000 - 10000),
+ static_cast<coordinate_type>(rand() % 5000 - 10000)));
+ }
+ test_builder.init(points);
+ test_builder.run_sweepline();
+ test_builder.clip(test_output);
+ test_builder.reset();
+ test_output.reset();
+ points.clear();
+ }
+ time_t end_time = time(NULL);
+ double running_time = static_cast<double>(end_time - start_time) / num_times;
+
+ fprintf(bench_file,
+ "Number of points = %8d; Overall time = %2d; Time per one input = %9.6f.\n",
+ num_points, static_cast<int>(end_time - start_time), running_time);
+ }
+ fclose(bench_file);
+}

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_builder_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_builder_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_builder_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,7 +10,8 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
+#include "../voronoi_output_verification.hpp"
 #include "boost/sweepline/voronoi_segment_sweepline.hpp"
 using namespace boost::sweepline;
 
@@ -21,6 +22,8 @@
         BOOST_CHECK_EQUAL(p1.x() == static_cast<coordinate_type>(p2.x()) && \
                           p1.y() == static_cast<coordinate_type>(p2.y()), true)
 
+#define VERIFY_VORONOI_OUTPUT(output, mask) BOOST_CHECK_EQUAL(verify_output(output, mask), true)
+
 // Sites: (0, 0).
 BOOST_AUTO_TEST_CASE_TEMPLATE(single_site_test, T, test_types) {
     typedef T coordinate_type;
@@ -36,7 +39,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -75,7 +78,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -133,7 +136,7 @@
     test_voronoi_builder.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_voronoi_builder.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_voronoi_builder.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -198,7 +201,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BRect<coordinate_type> bounding_rectangle = test_beach_line.get_bounding_rectangle();
     BOOST_CHECK_EQUAL(bounding_rectangle.x_min == static_cast<coordinate_type>(0) &&
@@ -270,7 +273,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_cells().size()), 3);
     BOOST_CHECK_EQUAL(static_cast<int>(test_output.get_voronoi_vertices().size()), 4);
@@ -334,7 +337,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_cells().size()), 4);
     BOOST_CHECK_EQUAL(static_cast<coordinate_type>(test_output.get_voronoi_vertices().size()), 5);
@@ -404,7 +407,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 9);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 4);
@@ -425,7 +428,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 100);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 81);
@@ -446,7 +449,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 1089);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 1024);
@@ -467,7 +470,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 10000);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 9801);
@@ -488,7 +491,7 @@
     test_beach_line.run_sweepline();
     voronoi_output_clipped<coordinate_type> test_output;
     test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
 
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_cells(), 110889);
     BOOST_CHECK_EQUAL(test_output.get_num_voronoi_vertices(), 110224);
@@ -506,12 +509,12 @@
         points.clear();
         for (int j = 0; j < 10; j++)
             points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5 - 5),
- static_cast<coordinate_type>(rand() % 5 - 5)));
+ static_cast<coordinate_type>(rand() % 10 - 5),
+ static_cast<coordinate_type>(rand() % 10 - 5)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
         test_beach_line.reset();
     }
 }
@@ -527,12 +530,12 @@
         points.clear();
         for (int j = 0; j < 100; j++)
             points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
+ static_cast<coordinate_type>(rand() % 100 - 50),
+ static_cast<coordinate_type>(rand() % 100 - 50)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
         test_beach_line.reset();
     }
 }
@@ -548,12 +551,12 @@
         points.clear();
         for (int j = 0; j < 1000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 50 - 50),
- static_cast<coordinate_type>(rand() % 50 - 50)));
+ static_cast<coordinate_type>(rand() % 100 - 50),
+ static_cast<coordinate_type>(rand() % 100 - 50)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
         test_beach_line.reset();
     }
 }
@@ -569,12 +572,12 @@
         points.clear();
         for (int j = 0; j < 10000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
+ static_cast<coordinate_type>(rand() % 1000 - 500),
+ static_cast<coordinate_type>(rand() % 1000 - 500)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
         test_beach_line.reset();
     }
 }
@@ -590,12 +593,12 @@
         points.clear();
         for (int j = 0; j < 100000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 500 - 500),
- static_cast<coordinate_type>(rand() % 500 - 500)));
+ static_cast<coordinate_type>(rand() % 1000 - 500),
+ static_cast<coordinate_type>(rand() % 1000 - 500)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, COMPLETE_VERIFICATION);
         test_beach_line.reset();
     }
 }
@@ -611,12 +614,12 @@
         points.clear();
         for (int j = 0; j < 1000000; j++)
         points.push_back(make_point_2d<coordinate_type>(
- static_cast<coordinate_type>(rand() % 5000 - 5000),
- static_cast<coordinate_type>(rand() % 5000 - 5000)));
+ static_cast<coordinate_type>(rand() % 10000 - 5000),
+ static_cast<coordinate_type>(rand() % 10000 - 5000)));
         test_beach_line.init(points);
         test_beach_line.run_sweepline();
         test_beach_line.clip(test_output);
- //BOOST_CHECK_EQUAL(test_output.check(), true);
+ VERIFY_VORONOI_OUTPUT(test_output, FAST_VERIFICATION);
         test_beach_line.reset();
     }
-}
\ No newline at end of file
+}

Copied: sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_clipping_test.cpp (from r64812, /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp)
==============================================================================
--- /sandbox/SOC/2010/sweepline/libs/sweepline/test/segment_voronoi_clipping_test.cpp (original)
+++ sandbox/SOC/2010/sweepline/libs/sweepline/test/voronoi_segment/segment_voronoi_clipping_test.cpp 2010-08-16 12:21:33 EDT (Mon, 16 Aug 2010)
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include "test_type_list.hpp"
+#include "../test_type_list.hpp"
 #include "boost/sweepline/voronoi_segment_sweepline.hpp"
 using namespace boost::sweepline;
 
@@ -293,4 +293,4 @@
             if (i && j)
                 BOOST_CHECK_EQUAL(static_cast<int>(intersections.size()), 2);
         }
-}
\ No newline at end of file
+}


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