annotate DEPENDENCIES/generic/include/boost/geometry/strategies/cartesian/buffer_end_flat.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +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_CARTESIAN_BUFFER_END_FLAT_HPP
Chris@102 10 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_FLAT_HPP
Chris@102 11
Chris@102 12 #include <boost/geometry/core/cs.hpp>
Chris@102 13 #include <boost/geometry/strategies/tags.hpp>
Chris@102 14 #include <boost/geometry/strategies/side.hpp>
Chris@102 15 #include <boost/geometry/util/math.hpp>
Chris@102 16 #include <boost/geometry/util/select_most_precise.hpp>
Chris@102 17
Chris@102 18 #include <boost/geometry/strategies/buffer.hpp>
Chris@102 19
Chris@102 20
Chris@102 21
Chris@102 22 namespace boost { namespace geometry
Chris@102 23 {
Chris@102 24
Chris@102 25
Chris@102 26 namespace strategy { namespace buffer
Chris@102 27 {
Chris@102 28
Chris@102 29
Chris@102 30 /*!
Chris@102 31 \brief Let the buffer create flat ends
Chris@102 32 \ingroup strategies
Chris@102 33 \details This strategy can be used as EndStrategy for the buffer algorithm.
Chris@102 34 It creates a flat end for each linestring-end. It can be applied
Chris@102 35 for (multi)linestrings. Also it is applicable for spikes in (multi)polygons.
Chris@102 36 This strategy is only applicable for Cartesian coordinate systems.
Chris@102 37
Chris@102 38 \qbk{
Chris@102 39 [heading Example]
Chris@102 40 [buffer_end_flat]
Chris@102 41 [heading Output]
Chris@102 42 [$img/strategies/buffer_end_flat.png]
Chris@102 43 [heading See also]
Chris@102 44 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
Chris@102 45 \* [link geometry.reference.strategies.strategy_buffer_end_round end_round]
Chris@102 46 }
Chris@102 47 */
Chris@102 48 class end_flat
Chris@102 49 {
Chris@102 50
Chris@102 51 public :
Chris@102 52
Chris@102 53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Chris@102 54 //! Fills output_range with a flat end
Chris@102 55 template <typename Point, typename RangeOut, typename DistanceStrategy>
Chris@102 56 inline void apply(Point const& penultimate_point,
Chris@102 57 Point const& perp_left_point,
Chris@102 58 Point const& ultimate_point,
Chris@102 59 Point const& perp_right_point,
Chris@102 60 buffer_side_selector side,
Chris@102 61 DistanceStrategy const& distance,
Chris@102 62 RangeOut& range_out) const
Chris@102 63 {
Chris@102 64 typedef typename coordinate_type<Point>::type coordinate_type;
Chris@102 65
Chris@102 66 typedef typename geometry::select_most_precise
Chris@102 67 <
Chris@102 68 coordinate_type,
Chris@102 69 double
Chris@102 70 >::type promoted_type;
Chris@102 71
Chris@102 72 promoted_type const dist_left = distance.apply(penultimate_point, ultimate_point, buffer_side_left);
Chris@102 73 promoted_type const dist_right = distance.apply(penultimate_point, ultimate_point, buffer_side_right);
Chris@102 74
Chris@102 75 bool reversed = (side == buffer_side_left && dist_right < 0 && -dist_right > dist_left)
Chris@102 76 || (side == buffer_side_right && dist_left < 0 && -dist_left > dist_right)
Chris@102 77 ;
Chris@102 78 if (reversed)
Chris@102 79 {
Chris@102 80 range_out.push_back(perp_right_point);
Chris@102 81 range_out.push_back(perp_left_point);
Chris@102 82 }
Chris@102 83 else
Chris@102 84 {
Chris@102 85 range_out.push_back(perp_left_point);
Chris@102 86 range_out.push_back(perp_right_point);
Chris@102 87 }
Chris@102 88 // Don't add the ultimate_point (endpoint of the linestring).
Chris@102 89 // The buffer might be generated completely at one side.
Chris@102 90 // In other cases it does no harm but is further useless
Chris@102 91 }
Chris@102 92
Chris@102 93 template <typename NumericType>
Chris@102 94 static inline NumericType max_distance(NumericType const& distance)
Chris@102 95 {
Chris@102 96 return distance;
Chris@102 97 }
Chris@102 98
Chris@102 99 //! Returns the piece_type (flat end)
Chris@102 100 static inline piece_type get_piece_type()
Chris@102 101 {
Chris@102 102 return buffered_flat_end;
Chris@102 103 }
Chris@102 104 #endif // DOXYGEN_SHOULD_SKIP_THIS
Chris@102 105 };
Chris@102 106
Chris@102 107
Chris@102 108 }} // namespace strategy::buffer
Chris@102 109
Chris@102 110 }} // namespace boost::geometry
Chris@102 111
Chris@102 112 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_FLAT_HPP