Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:36

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2014-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2014-2015 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2015, 2023.
0009 // Modifications copyright (c) 2015-2023, Oracle and/or its affiliates.
0010 
0011 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0012 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP
0019 #define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP
0020 
0021 #include <cstddef>
0022 
0023 #include <boost/geometry/core/access.hpp>
0024 #include <boost/geometry/core/coordinate_type.hpp>
0025 
0026 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
0027 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
0028 
0029 #include <boost/geometry/util/math.hpp>
0030 
0031 namespace boost { namespace geometry
0032 {
0033 
0034 #ifndef DOXYGEN_NO_DETAIL
0035 namespace detail
0036 {
0037 
0038 template <typename FpPoint, typename IntPoint, typename CalculationType>
0039 struct robust_policy
0040 {
0041     static bool const enabled = true;
0042 
0043     typedef typename geometry::coordinate_type<IntPoint>::type output_ct;
0044 
0045     robust_policy(FpPoint const& fp_min, IntPoint const& int_min, CalculationType const& the_factor)
0046         : m_fp_min(fp_min)
0047         , m_int_min(int_min)
0048         , m_multiplier(the_factor)
0049     {
0050     }
0051 
0052     template <std::size_t Dimension, typename Value>
0053     inline output_ct apply(Value const& value) const
0054     {
0055         // a + (v-b)*f
0056         CalculationType const a = static_cast<CalculationType>(get<Dimension>(m_int_min));
0057         CalculationType const b = static_cast<CalculationType>(get<Dimension>(m_fp_min));
0058         CalculationType const result = a + (value - b) * m_multiplier;
0059 
0060         return geometry::math::rounding_cast<output_ct>(result);
0061     }
0062 
0063     FpPoint m_fp_min;
0064     IntPoint m_int_min;
0065     CalculationType m_multiplier;
0066 };
0067 
0068 } // namespace detail
0069 #endif
0070 
0071 
0072 // Implement meta-functions for this policy
0073 
0074 // Define the IntPoint as a robust-point type
0075 template <typename Point, typename FpPoint, typename IntPoint, typename CalculationType>
0076 struct robust_point_type<Point, detail::robust_policy<FpPoint, IntPoint, CalculationType> >
0077 {
0078     typedef IntPoint type;
0079 };
0080 
0081 
0082 }} // namespace boost::geometry
0083 
0084 
0085 #endif // BOOST_GEOMETRY_POLICIES_ROBUSTNESS_RESCALE_POLICY_HPP