annotate DEPENDENCIES/generic/include/boost/geometry/policies/robustness/rescale_policy.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@102 2
Chris@102 3 // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4 // Copyright (c) 2014 Bruno Lalande, Paris, France.
Chris@102 5 // Copyright (c) 2014 Mateusz Loskot, London, UK.
Chris@102 6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
Chris@102 7
Chris@102 8 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 10 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 11
Chris@102 12 #ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP
Chris@102 13 #define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP
Chris@102 14
Chris@102 15 #include <cstddef>
Chris@102 16
Chris@102 17 #include <boost/type_traits.hpp>
Chris@102 18
Chris@102 19 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
Chris@102 20 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
Chris@102 21 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
Chris@102 22
Chris@102 23 namespace boost { namespace geometry
Chris@102 24 {
Chris@102 25
Chris@102 26 #ifndef DOXYGEN_NO_DETAIL
Chris@102 27 namespace detail
Chris@102 28 {
Chris@102 29
Chris@102 30 template <typename FpPoint, typename IntPoint, typename CalculationType>
Chris@102 31 struct robust_policy
Chris@102 32 {
Chris@102 33 static bool const enabled = true;
Chris@102 34
Chris@102 35 typedef typename geometry::coordinate_type<IntPoint>::type output_ct;
Chris@102 36
Chris@102 37 robust_policy(FpPoint const& fp_min, IntPoint const& int_min, CalculationType const& the_factor)
Chris@102 38 : m_fp_min(fp_min)
Chris@102 39 , m_int_min(int_min)
Chris@102 40 , m_multiplier(the_factor)
Chris@102 41 {
Chris@102 42 }
Chris@102 43
Chris@102 44 template <std::size_t Dimension, typename Value>
Chris@102 45 inline output_ct apply(Value const& value) const
Chris@102 46 {
Chris@102 47 // a + (v-b)*f
Chris@102 48 CalculationType const a = static_cast<CalculationType>(get<Dimension>(m_int_min));
Chris@102 49 CalculationType const b = static_cast<CalculationType>(get<Dimension>(m_fp_min));
Chris@102 50 CalculationType const result = a + (value - b) * m_multiplier;
Chris@102 51 return static_cast<output_ct>(result);
Chris@102 52 }
Chris@102 53
Chris@102 54 FpPoint m_fp_min;
Chris@102 55 IntPoint m_int_min;
Chris@102 56 CalculationType m_multiplier;
Chris@102 57 };
Chris@102 58
Chris@102 59 } // namespace detail
Chris@102 60 #endif
Chris@102 61
Chris@102 62
Chris@102 63 // Implement meta-functions for this policy
Chris@102 64
Chris@102 65 // Define the IntPoint as a robust-point type
Chris@102 66 template <typename Point, typename FpPoint, typename IntPoint, typename CalculationType>
Chris@102 67 struct robust_point_type<Point, detail::robust_policy<FpPoint, IntPoint, CalculationType> >
Chris@102 68 {
Chris@102 69 typedef IntPoint type;
Chris@102 70 };
Chris@102 71
Chris@102 72 // Meta function for rescaling, if rescaling is done segment_ratio is based on long long
Chris@102 73 template <typename Point, typename FpPoint, typename IntPoint, typename CalculationType>
Chris@102 74 struct segment_ratio_type<Point, detail::robust_policy<FpPoint, IntPoint, CalculationType> >
Chris@102 75 {
Chris@102 76 typedef segment_ratio<boost::long_long_type> type;
Chris@102 77 };
Chris@102 78
Chris@102 79
Chris@102 80 }} // namespace boost::geometry
Chris@102 81
Chris@102 82
Chris@102 83 #endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP