Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:42

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2018.
0006 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
0007 
0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 
0014 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
0015 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
0016 
0017 #include <cstddef>
0018 
0019 #include <boost/range/value_type.hpp>
0020 
0021 #include <boost/geometry/core/access.hpp>
0022 #include <boost/geometry/strategies/buffer.hpp>
0023 #include <boost/geometry/util/math.hpp>
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 namespace strategy { namespace buffer
0029 {
0030 
0031 /*!
0032 \brief Create a squared form buffer around a point
0033 \ingroup strategies
0034 \details This strategy can be used as PointStrategy for the buffer algorithm.
0035     It creates a square from each point, where the point lies in the center.
0036     It can be applied for points and multi_points, but also for a linestring (if it is degenerate,
0037     so consisting of only one point) and for polygons (if it is degenerate).
0038     This strategy is only applicable for Cartesian coordinate systems.
0039 
0040 \qbk{
0041 [heading Example]
0042 [buffer_point_square]
0043 [heading Output]
0044 [$img/strategies/buffer_point_square.png]
0045 [heading See also]
0046 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
0047 \* [link geometry.reference.strategies.strategy_buffer_point_circle point_circle]
0048 \* [link geometry.reference.strategies.strategy_buffer_geographic_point_circle geographic_point_circle]
0049 }
0050  */
0051 class point_square
0052 {
0053     template
0054     <
0055         typename Point,
0056         typename DistanceType,
0057         typename MultiplierType,
0058         typename OutputRange
0059     >
0060     inline void add_point(Point const& point,
0061                 DistanceType const& distance,
0062                 MultiplierType const& x,
0063                 MultiplierType const& y,
0064                 OutputRange& output_range) const
0065     {
0066         typename boost::range_value<OutputRange>::type p;
0067         set<0>(p, get<0>(point) + x * distance);
0068         set<1>(p, get<1>(point) + y * distance);
0069         output_range.push_back(p);
0070     }
0071 
0072     template
0073     <
0074         typename Point,
0075         typename DistanceType,
0076         typename OutputRange
0077     >
0078     inline void add_points(Point const& point,
0079                 DistanceType const& distance,
0080                 OutputRange& output_range) const
0081     {
0082         add_point(point, distance, -1.0, -1.0, output_range);
0083         add_point(point, distance, -1.0, +1.0, output_range);
0084         add_point(point, distance, +1.0, +1.0, output_range);
0085         add_point(point, distance, +1.0, -1.0, output_range);
0086 
0087         // Close it:
0088         output_range.push_back(output_range.front());
0089     }
0090 
0091 public :
0092 
0093 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0094     //! Fills output_range with a square around point using distance_strategy
0095     template
0096     <
0097         typename Point,
0098         typename DistanceStrategy,
0099         typename OutputRange
0100     >
0101     inline void apply(Point const& point,
0102                 DistanceStrategy const& distance_strategy,
0103                 OutputRange& output_range) const
0104     {
0105         add_points(point, distance_strategy.apply(point, point,
0106                         strategy::buffer::buffer_side_left), output_range);
0107     }
0108 #endif // DOXYGEN_SHOULD_SKIP_THIS
0109 
0110 };
0111 
0112 
0113 }} // namespace strategy::buffer
0114 
0115 }} // namespace boost::geometry
0116 
0117 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP