envelope_segment.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2017-2018 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP
  10. #include <cstddef>
  11. #include <boost/geometry/core/coordinate_dimension.hpp>
  12. #include <boost/geometry/core/tags.hpp>
  13. #include <boost/geometry/strategies/cartesian/envelope_point.hpp>
  14. #include <boost/geometry/strategies/cartesian/expand_point.hpp>
  15. #include <boost/geometry/strategies/envelope.hpp>
  16. namespace boost { namespace geometry { namespace strategy { namespace envelope
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail
  20. {
  21. template <std::size_t Dimension, std::size_t DimensionCount>
  22. struct envelope_one_segment
  23. {
  24. template<typename Point, typename Box>
  25. static inline void apply(Point const& p1,
  26. Point const& p2,
  27. Box& mbr)
  28. {
  29. geometry::detail::envelope::envelope_one_point
  30. <
  31. Dimension, DimensionCount
  32. >::apply(p1, mbr);
  33. strategy::expand::detail::point_loop
  34. <
  35. Dimension, DimensionCount
  36. >::apply(mbr, p2);
  37. }
  38. };
  39. } // namespace detail
  40. #endif // DOXYGEN_NO_DETAIL
  41. template
  42. <
  43. typename CalculationType = void
  44. >
  45. class cartesian_segment
  46. {
  47. public:
  48. template <typename Point, typename Box>
  49. static inline void apply(Point const& point1, Point const& point2, Box& box)
  50. {
  51. strategy::envelope::detail::envelope_one_segment
  52. <
  53. 0,
  54. dimension<Point>::value
  55. >::apply(point1, point2, box);
  56. }
  57. };
  58. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  59. namespace services
  60. {
  61. template <typename CalculationType>
  62. struct default_strategy<segment_tag, cartesian_tag, CalculationType>
  63. {
  64. typedef strategy::envelope::cartesian_segment<CalculationType> type;
  65. };
  66. }
  67. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  68. }} // namespace strategy::envelope
  69. }} //namepsace boost::geometry
  70. #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP