|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76589 - sandbox/gtl/boost/polygon/detail
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-19 17:40:03
Author: asydorchuk
Date: 2012-01-19 17:40:02 EST (Thu, 19 Jan 2012)
New Revision: 76589
URL: http://svn.boost.org/trac/boost/changeset/76589
Log:
Refactoring changes before moving to voronoi_ctypes.
Text files modified:
sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp | 120 +++++++++++++++++++--------------------
1 files changed, 59 insertions(+), 61 deletions(-)
Modified: sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp 2012-01-19 17:40:02 EST (Thu, 19 Jan 2012)
@@ -28,7 +28,9 @@
typedef uint32 uint_type;
typedef int64 int_x2_type;
typedef uint64 uint_x2_type;
+ typedef eint4096 int_x128_type;
typedef fpt64 fpt_type;
+ typedef efpt64 efpt_type;
typedef ulp_comparison<fpt_type> ulp_cmp_type;
typedef type_converter_fpt to_fpt_converter;
typedef type_converter_efpt to_efpt_converter;
@@ -527,7 +529,7 @@
typedef typename Site::point_type point_type;
typedef Site site_type;
typedef Circle circle_type;
- typedef robust_sqrt_expr<eint4096, efpt64, to_efpt_converter> robust_sqrt_expr_type;
+ typedef robust_sqrt_expr<int_x128_type, efpt_type, to_efpt_converter> robust_sqrt_expr_type;
void ppp(const site_type &site1,
const site_type &site2,
@@ -536,8 +538,7 @@
bool recompute_c_x = true,
bool recompute_c_y = true,
bool recompute_lower_x = true) {
- typedef eint256 eint;
- eint dif_x[3], dif_y[3], sum_x[2], sum_y[2];
+ int_x128_type dif_x[3], dif_y[3], sum_x[2], sum_y[2];
dif_x[0] = static_cast<int_x2_type>(site1.x()) -
static_cast<int_x2_type>(site2.x());
dif_x[1] = static_cast<int_x2_type>(site2.x()) -
@@ -559,18 +560,18 @@
sum_y[1] = static_cast<int_x2_type>(site2.y()) +
static_cast<int_x2_type>(site3.y());
fpt_type inv_denom = to_fpt(0.5) / to_fpt(dif_x[0] * dif_y[1] - dif_x[1] * dif_y[0]);
- eint numer1 = dif_x[0] * sum_x[0] + dif_y[0] * sum_y[0];
- eint numer2 = dif_x[1] * sum_x[1] + dif_y[1] * sum_y[1];
+ int_x128_type numer1 = dif_x[0] * sum_x[0] + dif_y[0] * sum_y[0];
+ int_x128_type numer2 = dif_x[1] * sum_x[1] + dif_y[1] * sum_y[1];
if (recompute_c_x || recompute_lower_x) {
- eint c_x = numer1 * dif_y[1] - numer2 * dif_y[0];
+ int_x128_type c_x = numer1 * dif_y[1] - numer2 * dif_y[0];
circle.x(to_fpt(c_x) * inv_denom);
if (recompute_lower_x) {
// Evaluate radius of the circle.
- eint sqr_r = (dif_x[0] * dif_x[0] + dif_y[0] * dif_y[0]) *
- (dif_x[1] * dif_x[1] + dif_y[1] * dif_y[1]) *
- (dif_x[2] * dif_x[2] + dif_y[2] * dif_y[2]);
+ int_x128_type sqr_r = (dif_x[0] * dif_x[0] + dif_y[0] * dif_y[0]) *
+ (dif_x[1] * dif_x[1] + dif_y[1] * dif_y[1]) *
+ (dif_x[2] * dif_x[2] + dif_y[2] * dif_y[2]);
fpt_type r = get_sqrt(to_fpt(sqr_r));
// If c_x >= 0 then lower_x = c_x + r,
@@ -583,7 +584,7 @@
circle.lower_x(circle.x() - r * inv_denom);
}
} else {
- eint numer = c_x * c_x - sqr_r;
+ int_x128_type numer = c_x * c_x - sqr_r;
fpt_type lower_x = to_fpt(numer) * inv_denom /
(to_fpt(c_x) + r);
circle.lower_x(lower_x);
@@ -592,7 +593,7 @@
}
if (recompute_c_y) {
- eint c_y = numer2 * dif_x[0] - numer1 * dif_x[1];
+ int_x128_type c_y = numer2 * dif_x[0] - numer1 * dif_x[1];
circle.y(to_fpt(c_y) * inv_denom);
}
}
@@ -606,39 +607,38 @@
bool recompute_c_x = true,
bool recompute_c_y = true,
bool recompute_lower_x = true) {
- typedef eint4096 eint;
- eint cA[4], cB[4];
- eint line_a = static_cast<int_x2_type>(site3.point1(true).y()) -
- static_cast<int_x2_type>(site3.point0(true).y());
- eint line_b = static_cast<int_x2_type>(site3.point0(true).x()) -
- static_cast<int_x2_type>(site3.point1(true).x());
- eint segm_len = line_a * line_a + line_b * line_b;
- eint vec_x = static_cast<int_x2_type>(site2.y()) -
- static_cast<int_x2_type>(site1.y());
- eint vec_y = static_cast<int_x2_type>(site1.x()) -
- static_cast<int_x2_type>(site2.x());
- eint sum_x = static_cast<int_x2_type>(site1.x()) +
- static_cast<int_x2_type>(site2.x());
- eint sum_y = static_cast<int_x2_type>(site1.y()) +
- static_cast<int_x2_type>(site2.y());
- eint teta = line_a * vec_x + line_b * vec_y;
- eint denom = vec_x * line_b - vec_y * line_a;
-
- eint dif0 = static_cast<int_x2_type>(site3.point1().y()) -
- static_cast<int_x2_type>(site1.y());
- eint dif1 = static_cast<int_x2_type>(site1.x()) -
- static_cast<int_x2_type>(site3.point1().x());
- eint A = line_a * dif1 - line_b * dif0;
+ int_x128_type cA[4], cB[4];
+ int_x128_type line_a = static_cast<int_x2_type>(site3.point1(true).y()) -
+ static_cast<int_x2_type>(site3.point0(true).y());
+ int_x128_type line_b = static_cast<int_x2_type>(site3.point0(true).x()) -
+ static_cast<int_x2_type>(site3.point1(true).x());
+ int_x128_type segm_len = line_a * line_a + line_b * line_b;
+ int_x128_type vec_x = static_cast<int_x2_type>(site2.y()) -
+ static_cast<int_x2_type>(site1.y());
+ int_x128_type vec_y = static_cast<int_x2_type>(site1.x()) -
+ static_cast<int_x2_type>(site2.x());
+ int_x128_type sum_x = static_cast<int_x2_type>(site1.x()) +
+ static_cast<int_x2_type>(site2.x());
+ int_x128_type sum_y = static_cast<int_x2_type>(site1.y()) +
+ static_cast<int_x2_type>(site2.y());
+ int_x128_type teta = line_a * vec_x + line_b * vec_y;
+ int_x128_type denom = vec_x * line_b - vec_y * line_a;
+
+ int_x128_type dif0 = static_cast<int_x2_type>(site3.point1().y()) -
+ static_cast<int_x2_type>(site1.y());
+ int_x128_type dif1 = static_cast<int_x2_type>(site1.x()) -
+ static_cast<int_x2_type>(site3.point1().x());
+ int_x128_type A = line_a * dif1 - line_b * dif0;
dif0 = static_cast<int_x2_type>(site3.point1().y()) -
static_cast<int_x2_type>(site2.y());
dif1 = static_cast<int_x2_type>(site2.x()) -
static_cast<int_x2_type>(site3.point1().x());
- eint B = line_a * dif1 - line_b * dif0;
- eint sum_AB = A + B;
+ int_x128_type B = line_a * dif1 - line_b * dif0;
+ int_x128_type sum_AB = A + B;
if (is_zero(denom)) {
- eint numer = teta * teta - sum_AB * sum_AB;
- eint denom = teta * sum_AB;
+ int_x128_type numer = teta * teta - sum_AB * sum_AB;
+ int_x128_type denom = teta * sum_AB;
cA[0] = denom * sum_x * 2 + numer * vec_x;
cB[0] = segm_len;
cA[1] = denom * sum_AB * 2 + numer * teta;
@@ -658,7 +658,7 @@
return;
}
- eint det = (teta * teta + denom * denom) * A * B * 4;
+ int_x128_type det = (teta * teta + denom * denom) * A * B * 4;
fpt_type inv_denom_sqr = to_fpt(1.0) / to_fpt(denom);
inv_denom_sqr *= inv_denom_sqr;
@@ -704,8 +704,7 @@
bool recompute_c_x = true,
bool recompute_c_y = true,
bool recompute_lower_x = true) {
- typedef eint4096 eint;
- eint a[2], b[2], c[2], cA[4], cB[4];
+ int_x128_type a[2], b[2], c[2], cA[4], cB[4];
const point_type &segm_start1 = site2.point1(true);
const point_type &segm_end1 = site2.point0(true);
const point_type &segm_start2 = site3.point0(true);
@@ -718,21 +717,21 @@
static_cast<int_x2_type>(segm_start2.x());
b[1] = static_cast<int_x2_type>(segm_end2.y()) -
static_cast<int_x2_type>(segm_start2.y());
- eint orientation = a[1] * b[0] - a[0] * b[1];
+ int_x128_type orientation = a[1] * b[0] - a[0] * b[1];
if (is_zero(orientation)) {
fpt_type denom = to_fpt(2.0) * to_fpt(a[0] * a[0] + b[0] * b[0]);
c[0] = b[0] * (static_cast<int_x2_type>(segm_start2.x()) -
static_cast<int_x2_type>(segm_start1.x())) -
a[0] * (static_cast<int_x2_type>(segm_start2.y()) -
static_cast<int_x2_type>(segm_start1.y()));
- eint dx = a[0] * (static_cast<int_x2_type>(site1.y()) -
- static_cast<int_x2_type>(segm_start1.y())) -
- b[0] * (static_cast<int_x2_type>(site1.x()) -
- static_cast<int_x2_type>(segm_start1.x()));
- eint dy = b[0] * (static_cast<int_x2_type>(site1.x()) -
- static_cast<int_x2_type>(segm_start2.x())) -
- a[0] * (static_cast<int_x2_type>(site1.y()) -
- static_cast<int_x2_type>(segm_start2.y()));
+ int_x128_type dx = a[0] * (static_cast<int_x2_type>(site1.y()) -
+ static_cast<int_x2_type>(segm_start1.y())) -
+ b[0] * (static_cast<int_x2_type>(site1.x()) -
+ static_cast<int_x2_type>(segm_start1.x()));
+ int_x128_type dy = b[0] * (static_cast<int_x2_type>(site1.x()) -
+ static_cast<int_x2_type>(segm_start2.x())) -
+ a[0] * (static_cast<int_x2_type>(site1.y()) -
+ static_cast<int_x2_type>(segm_start2.y()));
cB[0] = dx * dy;
cB[1] = 1;
@@ -775,10 +774,10 @@
a[0] * segm_end1.y();
c[1] = a[1] * segm_end2.y() -
b[1] * segm_end2.x();
- eint ix = a[0] * c[1] + a[1] * c[0];
- eint iy = b[0] * c[1] + b[1] * c[0];
- eint dx = ix - orientation * site1.x();
- eint dy = iy - orientation * site1.y();
+ int_x128_type ix = a[0] * c[1] + a[1] * c[0];
+ int_x128_type iy = b[0] * c[1] + b[1] * c[0];
+ int_x128_type dx = ix - orientation * site1.x();
+ int_x128_type dy = iy - orientation * site1.y();
if (is_zero(dx) && is_zero(dy)) {
fpt_type denom = to_fpt(orientation);
fpt_type c_x = to_fpt(ix) / denom;
@@ -787,7 +786,7 @@
return;
}
- eint sign = ((point_index == 2) ? 1 : -1) * (is_neg(orientation) ? 1 : -1);
+ int_x128_type sign = ((point_index == 2) ? 1 : -1) * (is_neg(orientation) ? 1 : -1);
cA[0] = a[1] * -dx + b[1] * -dy;
cA[1] = a[0] * -dx + b[0] * -dy;
cA[2] = sign;
@@ -796,14 +795,14 @@
cB[1] = a[1] * a[1] + b[1] * b[1];
cB[2] = a[0] * a[1] + b[0] * b[1];
cB[3] = (a[0] * dy - b[0] * dx) * (a[1] * dy - b[1] * dx) * -2;
- fpt_type temp = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type temp = to_fpt(sqrt_expr_evaluator_pss4<int_x128_type, efpt_type>(cA, cB));
fpt_type denom = temp * to_fpt(orientation);
if (recompute_c_y) {
cA[0] = b[1] * (dx * dx + dy * dy) - iy * (dx * a[1] + dy * b[1]);
cA[1] = b[0] * (dx * dx + dy * dy) - iy * (dx * a[0] + dy * b[0]);
cA[2] = iy * sign;
- fpt_type cy = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type cy = to_fpt(sqrt_expr_evaluator_pss4<int_x128_type, efpt_type>(cA, cB));
c_event.y(cy / denom);
}
@@ -813,13 +812,13 @@
cA[2] = ix * sign;
if (recompute_c_x) {
- fpt_type cx = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type cx = to_fpt(sqrt_expr_evaluator_pss4<int_x128_type, efpt_type>(cA, cB));
c_event.x(cx / denom);
}
if (recompute_lower_x) {
cA[3] = orientation * (dx * dx + dy * dy) * (is_neg(temp) ? -1 : 1);
- fpt_type lower_x = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type lower_x = to_fpt(sqrt_expr_evaluator_pss4<int_x128_type, efpt_type>(cA, cB));
c_event.lower_x(lower_x / denom);
}
}
@@ -833,8 +832,7 @@
bool recompute_c_x = true,
bool recompute_c_y = true,
bool recompute_lower_x = true) {
- typedef eint4096 eint;
- eint a[3], b[3], c[3], cA[4], cB[4];
+ int_x128_type a[3], b[3], c[3], cA[4], cB[4];
// cA - corresponds to the cross product.
// cB - corresponds to the squared length.
a[0] = static_cast<int_x2_type>(site1.x1(true)) -
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