123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
- #define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
- #include <boost/core/ignore_unused.hpp>
- #include <boost/geometry/strategies/buffer.hpp>
- #include <boost/geometry/util/math.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace buffer
- {
- template<typename NumericType>
- class distance_asymmetric
- {
- public :
-
-
-
- distance_asymmetric(NumericType const& left,
- NumericType const& right)
- : m_left(left)
- , m_right(right)
- {}
- #ifndef DOXYGEN_SHOULD_SKIP_THIS
-
- template <typename Point>
- inline NumericType apply(Point const& , Point const& ,
- buffer_side_selector side) const
- {
- NumericType result = side == buffer_side_left ? m_left : m_right;
- return negative() ? math::abs(result) : result;
- }
-
- inline int factor() const
- {
- return negative() ? -1 : 1;
- }
-
- inline bool negative() const
- {
- return m_left < 0 && m_right < 0;
- }
- inline bool empty(buffer_side_selector side) const
- {
- return side == buffer_side_left ? m_left == 0 : m_right == 0;
- }
-
- template <typename JoinStrategy, typename EndStrategy>
- inline NumericType max_distance(JoinStrategy const& join_strategy,
- EndStrategy const& end_strategy) const
- {
- boost::ignore_unused(join_strategy, end_strategy);
- NumericType const left = geometry::math::abs(m_left);
- NumericType const right = geometry::math::abs(m_right);
- NumericType const dist = (std::max)(left, right);
- return (std::max)(join_strategy.max_distance(dist),
- end_strategy.max_distance(dist));
- }
-
- inline NumericType simplify_distance() const
- {
- NumericType const left = geometry::math::abs(m_left);
- NumericType const right = geometry::math::abs(m_right);
- return (std::min)(left, right) / 1000.0;
- }
- #endif
- private :
- NumericType m_left;
- NumericType m_right;
- };
- }}
- }}
- #endif
|