annotate DEPENDENCIES/generic/include/boost/geometry/strategies/agnostic/buffer_distance_symmetric.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) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4
Chris@102 5 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 8
Chris@102 9 #ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP
Chris@102 10 #define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP
Chris@102 11
Chris@102 12
Chris@102 13 #include <boost/core/ignore_unused.hpp>
Chris@102 14
Chris@102 15 #include <boost/geometry/strategies/buffer.hpp>
Chris@102 16 #include <boost/geometry/util/math.hpp>
Chris@102 17
Chris@102 18
Chris@102 19 namespace boost { namespace geometry
Chris@102 20 {
Chris@102 21
Chris@102 22 namespace strategy { namespace buffer
Chris@102 23 {
Chris@102 24
Chris@102 25
Chris@102 26 /*!
Chris@102 27 \brief Let the buffer algorithm create buffers with same distances
Chris@102 28 \ingroup strategies
Chris@102 29 \tparam NumericType \tparam_numeric
Chris@102 30 \details This strategy can be used as DistanceStrategy for the buffer algorithm.
Chris@102 31 It can be applied for all geometries. It uses one distance for left and
Chris@102 32 for right.
Chris@102 33 If the distance is negative and used with a (multi)polygon or ring, the
Chris@102 34 geometry will shrink (deflate) instead of expand (inflate).
Chris@102 35
Chris@102 36 \qbk{
Chris@102 37 [heading Example]
Chris@102 38 [buffer_distance_symmetric]
Chris@102 39 [heading Output]
Chris@102 40 [$img/strategies/buffer_distance_symmetric.png]
Chris@102 41 [heading See also]
Chris@102 42 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
Chris@102 43 \* [link geometry.reference.strategies.strategy_buffer_distance_asymmetric distance_asymmetric]
Chris@102 44 }
Chris@102 45 */
Chris@102 46 template<typename NumericType>
Chris@102 47 class distance_symmetric
Chris@102 48 {
Chris@102 49 public :
Chris@102 50 //! \brief Constructs the strategy, a distance must be specified
Chris@102 51 //! \param distance The distance (or radius) of the buffer
Chris@102 52 explicit inline distance_symmetric(NumericType const& distance)
Chris@102 53 : m_distance(distance)
Chris@102 54 {}
Chris@102 55
Chris@102 56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@102 57 //! Returns the distance-value
Chris@102 58 template <typename Point>
Chris@102 59 inline NumericType apply(Point const& , Point const& ,
Chris@102 60 buffer_side_selector ) const
Chris@102 61 {
Chris@102 62 return negative() ? geometry::math::abs(m_distance) : m_distance;
Chris@102 63 }
Chris@102 64
Chris@102 65 //! Used internally, returns -1 for deflate, 1 for inflate
Chris@102 66 inline int factor() const
Chris@102 67 {
Chris@102 68 return negative() ? -1 : 1;
Chris@102 69 }
Chris@102 70
Chris@102 71 //! Returns true if distance is negative
Chris@102 72 inline bool negative() const
Chris@102 73 {
Chris@102 74 return m_distance < 0;
Chris@102 75 }
Chris@102 76
Chris@102 77 //! Returns the max distance distance up to the buffer will reach
Chris@102 78 template <typename JoinStrategy, typename EndStrategy>
Chris@102 79 inline NumericType max_distance(JoinStrategy const& join_strategy,
Chris@102 80 EndStrategy const& end_strategy) const
Chris@102 81 {
Chris@102 82 boost::ignore_unused(join_strategy, end_strategy);
Chris@102 83
Chris@102 84 NumericType const dist = geometry::math::abs(m_distance);
Chris@102 85 return (std::max)(join_strategy.max_distance(dist),
Chris@102 86 end_strategy.max_distance(dist));
Chris@102 87 }
Chris@102 88
Chris@102 89
Chris@102 90 //! Returns the distance at which the input is simplified before the buffer process
Chris@102 91 inline NumericType simplify_distance() const
Chris@102 92 {
Chris@102 93 return geometry::math::abs(m_distance) / 1000.0;
Chris@102 94 }
Chris@102 95 #endif // DOXYGEN_SHOULD_SKIP_THIS
Chris@102 96
Chris@102 97 private :
Chris@102 98 NumericType m_distance;
Chris@102 99 };
Chris@102 100
Chris@102 101
Chris@102 102 }} // namespace strategy::buffer
Chris@102 103
Chris@102 104
Chris@102 105 }} // namespace boost::geometry
Chris@102 106
Chris@102 107 #endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP