File indexing completed on 2025-01-18 09:36:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
0010 #define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
0011
0012 #include <boost/core/ignore_unused.hpp>
0013
0014 #include <boost/geometry/strategies/buffer.hpp>
0015 #include <boost/geometry/util/math.hpp>
0016
0017
0018 namespace boost { namespace geometry
0019 {
0020
0021 namespace strategy { namespace buffer
0022 {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template<typename NumericType>
0045 class distance_asymmetric
0046 {
0047 public :
0048
0049
0050
0051 distance_asymmetric(NumericType const& left,
0052 NumericType const& right)
0053 : m_left(left)
0054 , m_right(right)
0055 {}
0056
0057 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0058
0059 template <typename Point>
0060 inline NumericType apply(Point const& , Point const& ,
0061 buffer_side_selector side) const
0062 {
0063 NumericType result = side == buffer_side_left ? m_left : m_right;
0064 return negative() ? math::abs(result) : result;
0065 }
0066
0067
0068 inline int factor() const
0069 {
0070 return negative() ? -1 : 1;
0071 }
0072
0073
0074 inline bool negative() const
0075 {
0076 return m_left < 0 && m_right < 0;
0077 }
0078
0079 inline bool empty(buffer_side_selector side) const
0080 {
0081 return side == buffer_side_left ? m_left == 0 : m_right == 0;
0082 }
0083
0084
0085 template <typename JoinStrategy, typename EndStrategy>
0086 inline NumericType max_distance(JoinStrategy const& join_strategy,
0087 EndStrategy const& end_strategy) const
0088 {
0089 boost::ignore_unused(join_strategy, end_strategy);
0090
0091 NumericType const left = geometry::math::abs(m_left);
0092 NumericType const right = geometry::math::abs(m_right);
0093 NumericType const dist = (std::max)(left, right);
0094 return (std::max)(join_strategy.max_distance(dist),
0095 end_strategy.max_distance(dist));
0096 }
0097
0098
0099 inline NumericType simplify_distance() const
0100 {
0101 NumericType const left = geometry::math::abs(m_left);
0102 NumericType const right = geometry::math::abs(m_right);
0103 return (std::min)(left, right) / 1000.0;
0104 }
0105
0106 #endif
0107
0108 private :
0109 NumericType m_left;
0110 NumericType m_right;
0111 };
0112
0113
0114 }}
0115
0116
0117 }}
0118
0119 #endif