interface.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2013-2017.
  6. // Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTS_INTERFACE_HPP
  15. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTS_INTERFACE_HPP
  16. #include <boost/geometry/geometries/concepts/check.hpp>
  17. #include <boost/geometry/algorithms/detail/disjoint/interface.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_DETAIL
  21. namespace detail { namespace intersects
  22. {
  23. // Forward declaration
  24. template <typename Geometry>
  25. struct self_intersects;
  26. }} // namespace detail::intersects
  27. #endif // DOXYGEN_NO_DETAIL
  28. /*!
  29. \brief \brief_check{has at least one intersection (crossing or self-tangency)}
  30. \note This function can be called for one geometry (self-intersection) and
  31. also for two geometries (intersection)
  32. \ingroup intersects
  33. \tparam Geometry \tparam_geometry
  34. \param geometry \param_geometry
  35. \return \return_check{is self-intersecting}
  36. \qbk{distinguish,one geometry}
  37. \qbk{[def __one_parameter__]}
  38. \qbk{[include reference/algorithms/intersects.qbk]}
  39. */
  40. template <typename Geometry>
  41. inline bool intersects(Geometry const& geometry)
  42. {
  43. return detail::intersects::self_intersects<Geometry>::apply(geometry);
  44. }
  45. /*!
  46. \brief \brief_check2{have at least one intersection}
  47. \ingroup intersects
  48. \tparam Geometry1 \tparam_geometry
  49. \tparam Geometry2 \tparam_geometry
  50. \tparam Strategy \tparam_strategy{Intersects}
  51. \param geometry1 \param_geometry
  52. \param geometry2 \param_geometry
  53. \param strategy \param_strategy{intersects}
  54. \return \return_check2{intersect each other}
  55. \qbk{distinguish,with strategy}
  56. \qbk{[include reference/algorithms/intersects.qbk]}
  57. */
  58. template <typename Geometry1, typename Geometry2, typename Strategy>
  59. inline bool intersects(Geometry1 const& geometry1,
  60. Geometry2 const& geometry2,
  61. Strategy const& strategy)
  62. {
  63. concepts::check<Geometry1 const>();
  64. concepts::check<Geometry2 const>();
  65. return ! geometry::disjoint(geometry1, geometry2, strategy);
  66. }
  67. /*!
  68. \brief \brief_check2{have at least one intersection}
  69. \ingroup intersects
  70. \tparam Geometry1 \tparam_geometry
  71. \tparam Geometry2 \tparam_geometry
  72. \param geometry1 \param_geometry
  73. \param geometry2 \param_geometry
  74. \return \return_check2{intersect each other}
  75. \qbk{distinguish,two geometries}
  76. \qbk{[include reference/algorithms/intersects.qbk]}
  77. */
  78. template <typename Geometry1, typename Geometry2>
  79. inline bool intersects(Geometry1 const& geometry1, Geometry2 const& geometry2)
  80. {
  81. concepts::check<Geometry1 const>();
  82. concepts::check<Geometry2 const>();
  83. return ! geometry::disjoint(geometry1, geometry2);
  84. }
  85. }} // namespace boost::geometry
  86. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTS_INTERFACE_HPP