buffer.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Use, modification and distribution is subject to the Boost Software License,
  4. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_GEOMETRY_STRATEGIES_BUFFER_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_BUFFER_HPP
  8. #include <cstdint>
  9. namespace boost { namespace geometry
  10. {
  11. namespace strategy { namespace buffer
  12. {
  13. /*
  14. A Buffer-join strategy gets 4 input points.
  15. On the two consecutive segments s1 and s2 (joining at vertex v):
  16. The lines from parallel at s1, s2 (at buffer-distance) end/start
  17. in two points perpendicular to the segments: p1 and p2.
  18. These parallel lines interesct in point ip
  19. (s2)
  20. |
  21. |
  22. ^
  23. |
  24. (p2) |(v)
  25. * +----<--- (s1)
  26. x(ip) *(p1)
  27. So, in clockwise order:
  28. v : vertex point
  29. p1: perpendicular on left side of segment1<1> (perp1)
  30. ip: intersection point
  31. p2: perpendicular on left side of segment2<0> (perp2)
  32. */
  33. /*!
  34. \brief Enumerates options for side of buffer (left/right w.r.t. directed
  35. segment)
  36. \ingroup enum
  37. \details Around a linestring, a buffer can be defined left or right.
  38. Around a polygon, assumed clockwise internally,
  39. a buffer is either on the left side (inflates the polygon), or on the
  40. right side (deflates the polygon)
  41. */
  42. enum buffer_side_selector { buffer_side_left, buffer_side_right };
  43. // Default number of points in a circle
  44. constexpr std::size_t default_points_per_circle = 90u;
  45. inline std::size_t get_point_count_for_join(std::size_t count)
  46. {
  47. std::size_t const min_count = 4u;
  48. return count > min_count ? count : min_count;
  49. }
  50. inline std::size_t get_point_count_for_end(std::size_t count)
  51. {
  52. std::size_t const min_count = 4u;
  53. return count > min_count ? count : min_count;
  54. }
  55. inline std::size_t get_point_count_for_circle(std::size_t count)
  56. {
  57. std::size_t const min_count = 3u;
  58. return count > min_count ? count : min_count;
  59. }
  60. /*!
  61. \brief Enumerates types of pieces (parts of buffer) around geometries
  62. \ingroup enum
  63. */
  64. enum piece_type
  65. {
  66. buffered_segment,
  67. buffered_join,
  68. buffered_round_end,
  69. buffered_flat_end,
  70. buffered_point,
  71. buffered_concave, // always on the inside
  72. buffered_empty_side, // for one-sided buffers
  73. piece_type_unknown
  74. };
  75. /*!
  76. \brief Enumerates types of joins
  77. \ingroup enum
  78. */
  79. enum join_selector
  80. {
  81. join_convex,
  82. join_concave,
  83. join_continue, // collinear, next segment touches previous segment
  84. join_spike // collinear, with overlap, next segment goes back
  85. };
  86. /*!
  87. \brief Enumerates types of result codes from buffer strategies
  88. \ingroup enum
  89. */
  90. enum result_code
  91. {
  92. result_normal,
  93. result_error_numerical,
  94. result_no_output
  95. };
  96. }} // namespace strategy::buffer
  97. }} // namespace boost::geometry
  98. #endif // BOOST_GEOMETRY_STRATEGIES_BUFFER_HPP