disjoint_segment_box.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Boost.Geometry
  2. // Copyright (c) 2017 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fysikopoulos, 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_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
  10. #include <cstddef>
  11. #include <utility>
  12. #include <boost/numeric/conversion/cast.hpp>
  13. #include <boost/geometry/util/math.hpp>
  14. #include <boost/geometry/util/calculation_type.hpp>
  15. #include <boost/geometry/core/access.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/core/coordinate_dimension.hpp>
  18. #include <boost/geometry/core/point_type.hpp>
  19. #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
  20. #include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
  21. #include <boost/geometry/strategies/spherical/azimuth.hpp>
  22. #include <boost/geometry/strategies/disjoint.hpp>
  23. namespace boost { namespace geometry { namespace strategy { namespace disjoint
  24. {
  25. // NOTE: This may be temporary place for this or corresponding strategy
  26. // It seems to be more appropriate to implement the opposite of it
  27. // e.g. intersection::segment_box because in disjoint() algorithm
  28. // other strategies that are used are intersection and covered_by strategies.
  29. struct segment_box_spherical
  30. {
  31. template <typename Segment, typename Box>
  32. struct point_in_geometry_strategy
  33. : services::default_strategy
  34. <
  35. typename point_type<Segment>::type,
  36. Box
  37. >
  38. {};
  39. template <typename Segment, typename Box>
  40. static inline typename point_in_geometry_strategy<Segment, Box>::type
  41. get_point_in_geometry_strategy()
  42. {
  43. typedef typename point_in_geometry_strategy<Segment, Box>::type strategy_type;
  44. return strategy_type();
  45. }
  46. template <typename Segment, typename Box>
  47. static inline bool apply(Segment const& segment, Box const& box)
  48. {
  49. typedef typename point_type<Segment>::type segment_point_type;
  50. typedef typename coordinate_type<segment_point_type>::type CT;
  51. geometry::strategy::azimuth::spherical<CT> azimuth_strategy;
  52. return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid
  53. <spherical_equatorial_tag>::apply(segment, box, azimuth_strategy);
  54. }
  55. };
  56. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  57. namespace services
  58. {
  59. template <typename Linear, typename Box, typename LinearTag>
  60. struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2,
  61. spherical_equatorial_tag, spherical_equatorial_tag>
  62. {
  63. typedef segment_box_spherical type;
  64. };
  65. template <typename Box, typename Linear, typename LinearTag>
  66. struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1,
  67. spherical_equatorial_tag, spherical_equatorial_tag>
  68. {
  69. typedef segment_box_spherical type;
  70. };
  71. } // namespace services
  72. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  73. }}}} // namespace boost::geometry::strategy::disjoint
  74. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP