segment.hpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-2018.
  6. // Modifications copyright (c) 2015-2018, 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. // For backward compatibility
  20. #include <boost/geometry/strategies/cartesian/envelope_segment.hpp>
  21. #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
  22. #include <boost/geometry/strategies/geographic/envelope_segment.hpp>
  23. namespace boost { namespace geometry
  24. {
  25. #ifndef DOXYGEN_NO_DETAIL
  26. namespace detail { namespace envelope
  27. {
  28. template <std::size_t DimensionCount>
  29. struct envelope_segment
  30. {
  31. template <typename Point, typename Box, typename Strategy>
  32. static inline void apply(Point const& p1,
  33. Point const& p2,
  34. Box& mbr,
  35. Strategy const& strategy)
  36. {
  37. strategy.apply(p1, p2, mbr);
  38. }
  39. template <typename Segment, typename Box, typename Strategy>
  40. static inline void apply(Segment const& segment, Box& mbr,
  41. Strategy const& strategy)
  42. {
  43. typename point_type<Segment>::type p[2];
  44. detail::assign_point_from_index<0>(segment, p[0]);
  45. detail::assign_point_from_index<1>(segment, p[1]);
  46. apply(p[0], p[1], mbr, strategy);
  47. }
  48. };
  49. }} // namespace detail::envelope
  50. #endif // DOXYGEN_NO_DETAIL
  51. #ifndef DOXYGEN_NO_DISPATCH
  52. namespace dispatch
  53. {
  54. template <typename Segment>
  55. struct envelope<Segment, segment_tag>
  56. {
  57. template <typename Box, typename Strategy>
  58. static inline void apply(Segment const& segment,
  59. Box& mbr,
  60. Strategy const& strategy)
  61. {
  62. typename point_type<Segment>::type p[2];
  63. detail::assign_point_from_index<0>(segment, p[0]);
  64. detail::assign_point_from_index<1>(segment, p[1]);
  65. detail::envelope::envelope_segment
  66. <
  67. dimension<Segment>::value
  68. >::apply(p[0], p[1], mbr, strategy);
  69. }
  70. };
  71. } // namespace dispatch
  72. #endif // DOXYGEN_NO_DISPATCH
  73. }} // namespace boost::geometry
  74. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_SEGMENT_HPP