File indexing completed on 2025-01-18 09:35:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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
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 }
0069 #endif
0070
0071
0072
0073
0074
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 }}
0083
0084
0085 #endif