segment.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2015-2020.
  6. // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Distributed under the Boost Software License, Version 1.0.
  11. // (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_SEGMENT_HPP
  14. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_SEGMENT_HPP
  15. #include <cstddef>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
  18. #include <boost/geometry/algorithms/dispatch/envelope.hpp>
  19. // TEMP
  20. #include <boost/geometry/strategies/detail.hpp>
  21. namespace boost { namespace geometry
  22. {
  23. #ifndef DOXYGEN_NO_DETAIL
  24. namespace detail { namespace envelope
  25. {
  26. // TEMP
  27. template
  28. <
  29. typename Strategy,
  30. bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
  31. >
  32. struct envelope_segment_call_strategy
  33. {
  34. template <typename Point, typename Segment, typename Box>
  35. static inline void apply(Point const& p1, Point const& p2,
  36. Segment const& segment, Box& mbr,
  37. Strategy const& strategy)
  38. {
  39. strategy.envelope(segment, mbr).apply(p1, p2, mbr);
  40. }
  41. };
  42. template <typename Strategy>
  43. struct envelope_segment_call_strategy<Strategy, false>
  44. {
  45. template <typename Point, typename Segment, typename Box>
  46. static inline void apply(Point const& p1, Point const& p2,
  47. Segment const&, Box& mbr,
  48. Strategy const& strategy)
  49. {
  50. strategy.apply(p1, p2, mbr);
  51. }
  52. };
  53. struct envelope_segment
  54. {
  55. template <typename Segment, typename Box, typename Strategy>
  56. static inline void apply(Segment const& segment, Box& mbr,
  57. Strategy const& strategy)
  58. {
  59. typename point_type<Segment>::type p[2];
  60. detail::assign_point_from_index<0>(segment, p[0]);
  61. detail::assign_point_from_index<1>(segment, p[1]);
  62. // TEMP - expand calls this and Umbrella strategies are not yet supported there
  63. envelope_segment_call_strategy<Strategy>::apply(p[0], p[1], segment, mbr, strategy);
  64. }
  65. };
  66. }} // namespace detail::envelope
  67. #endif // DOXYGEN_NO_DETAIL
  68. #ifndef DOXYGEN_NO_DISPATCH
  69. namespace dispatch
  70. {
  71. template <typename Segment>
  72. struct envelope<Segment, segment_tag>
  73. {
  74. template <typename Box, typename Strategy>
  75. static inline void apply(Segment const& segment,
  76. Box& mbr,
  77. Strategy const& strategy)
  78. {
  79. detail::envelope::envelope_segment
  80. /*<
  81. dimension<Segment>::value
  82. >*/::apply(segment, mbr, strategy);
  83. }
  84. };
  85. } // namespace dispatch
  86. #endif // DOXYGEN_NO_DISPATCH
  87. }} // namespace boost::geometry
  88. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_SEGMENT_HPP