disjoint_segment_box.hpp 3.5 KB

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