From ed1f680e6d72a2e0974de9bfa35cc145a06157d4 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 23 Apr 2014 15:37:51 +0200 Subject: [PATCH] [get_rescale_policy] follow up, avoid casts, use numeric constants for ttmath --- .../robustness/get_rescale_policy.hpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 7ecb11953..5b8529bee 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -52,17 +52,18 @@ static inline void init_rescale_policy(Geometry const& geometry, < typename geometry::coordinate_type::type >::type num_type; - num_type diff = boost::numeric_cast(detail::get_max_size(env)); - num_type range = 10000000.0; // Define a large range to get precise integer coordinates + num_type const diff = boost::numeric_cast(detail::get_max_size(env)); + num_type const range = 10000000.0; // Define a large range to get precise integer coordinates + num_type const half = 0.5; factor = boost::numeric_cast( - boost::long_long_type(0.5 + range / diff)); + boost::numeric_cast(half + range / diff)); // Assign input/output minimal points - num_type const two = 2; detail::assign_point_from_index<0>(env, min_point); - assign_values(min_robust_point, - boost::long_long_type(-range/two), - boost::long_long_type(-range/two)); + num_type const two = 2; + boost::long_long_type const min_coordinate + = boost::numeric_cast(-range / two); + assign_values(min_robust_point, min_coordinate, min_coordinate); } template @@ -83,17 +84,18 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, < typename geometry::coordinate_type::type >::type num_type; - num_type diff = boost::numeric_cast(detail::get_max_size(env)); - num_type range = 10000000.0; // Define a large range to get precise integer coordinates + num_type const diff = boost::numeric_cast(detail::get_max_size(env)); + num_type const range = 10000000.0; // Define a large range to get precise integer coordinates + num_type const half = 0.5; factor = boost::numeric_cast( - boost::long_long_type(0.5 + range / diff)); + boost::numeric_cast(half + range / diff)); // Assign input/output minimal points - num_type const two = 2; detail::assign_point_from_index<0>(env, min_point); - assign_values(min_robust_point, - boost::long_long_type(-range/two), - boost::long_long_type(-range/two)); + num_type const two = 2; + boost::long_long_type const min_coordinate + = boost::numeric_cast(-range / two); + assign_values(min_robust_point, min_coordinate, min_coordinate); }