// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2014 Bruno Lalande, Paris, France. // Copyright (c) 2014 Mateusz Loskot, London, UK. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP #define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { template struct robust_policy { static bool const enabled = true; typedef typename geometry::coordinate_type::type output_ct; robust_policy(FpPoint const& fp_min, IntPoint const& int_min, CalculationType const& the_factor) : m_fp_min(fp_min) , m_int_min(int_min) , m_multiplier(the_factor) { } template inline output_ct apply(Value const& value) const { // a + (v-b)*f CalculationType const a = static_cast(get(m_int_min)); CalculationType const b = static_cast(get(m_fp_min)); CalculationType const result = a + (value - b) * m_multiplier; return static_cast(result); } FpPoint m_fp_min; IntPoint m_int_min; CalculationType m_multiplier; }; } // namespace detail #endif // Implement meta-functions for this policy // Define the IntPoint as a robust-point type template struct robust_point_type > { typedef IntPoint type; }; // Meta function for rescaling, if rescaling is done segment_ratio is based on long long template struct segment_ratio_type > { typedef segment_ratio type; }; }} // namespace boost::geometry #endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP