polygon_concept.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
  15. #include <type_traits>
  16. #include <boost/concept_check.hpp>
  17. #include <boost/core/ignore_unused.hpp>
  18. #include <boost/range/concepts.hpp>
  19. #include <boost/geometry/core/access.hpp>
  20. #include <boost/geometry/core/exterior_ring.hpp>
  21. #include <boost/geometry/core/interior_rings.hpp>
  22. #include <boost/geometry/core/point_type.hpp>
  23. #include <boost/geometry/core/ring_type.hpp>
  24. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  25. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  26. namespace boost { namespace geometry { namespace concepts
  27. {
  28. /*!
  29. \brief Checks polygon concept
  30. \ingroup concepts
  31. */
  32. template <typename PolygonType>
  33. class Polygon
  34. {
  35. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  36. typedef typename std::remove_const<PolygonType>::type polygon_type;
  37. typedef typename traits::ring_const_type<polygon_type>::type ring_const_type;
  38. typedef typename traits::ring_mutable_type<polygon_type>::type ring_mutable_type;
  39. typedef typename traits::interior_const_type<polygon_type>::type interior_const_type;
  40. typedef typename traits::interior_mutable_type<polygon_type>::type interior_mutable_type;
  41. typedef typename point_type<PolygonType>::type point_type;
  42. typedef typename ring_type<PolygonType>::type ring_type;
  43. BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
  44. BOOST_CONCEPT_ASSERT( (concepts::Ring<ring_type>) );
  45. //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
  46. struct checker
  47. {
  48. static inline void apply()
  49. {
  50. polygon_type* poly = 0;
  51. polygon_type const* cpoly = poly;
  52. ring_mutable_type e = traits::exterior_ring<PolygonType>::get(*poly);
  53. interior_mutable_type i = traits::interior_rings<PolygonType>::get(*poly);
  54. ring_const_type ce = traits::exterior_ring<PolygonType>::get(*cpoly);
  55. interior_const_type ci = traits::interior_rings<PolygonType>::get(*cpoly);
  56. boost::ignore_unused(poly, cpoly);
  57. boost::ignore_unused(e, i, ce, ci);
  58. }
  59. };
  60. public:
  61. BOOST_CONCEPT_USAGE(Polygon)
  62. {
  63. checker::apply();
  64. }
  65. #endif
  66. };
  67. /*!
  68. \brief Checks polygon concept (const version)
  69. \ingroup const_concepts
  70. */
  71. template <typename PolygonType>
  72. class ConstPolygon
  73. {
  74. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  75. typedef typename std::remove_const<PolygonType>::type const_polygon_type;
  76. typedef typename traits::ring_const_type<const_polygon_type>::type ring_const_type;
  77. typedef typename traits::interior_const_type<const_polygon_type>::type interior_const_type;
  78. typedef typename point_type<const_polygon_type>::type point_type;
  79. typedef typename ring_type<const_polygon_type>::type ring_type;
  80. BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
  81. BOOST_CONCEPT_ASSERT( (concepts::ConstRing<ring_type>) );
  82. ////BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
  83. struct checker
  84. {
  85. static inline void apply()
  86. {
  87. const_polygon_type const* cpoly = 0;
  88. ring_const_type ce = traits::exterior_ring<const_polygon_type>::get(*cpoly);
  89. interior_const_type ci = traits::interior_rings<const_polygon_type>::get(*cpoly);
  90. boost::ignore_unused(ce, ci, cpoly);
  91. }
  92. };
  93. public:
  94. BOOST_CONCEPT_USAGE(ConstPolygon)
  95. {
  96. checker::apply();
  97. }
  98. #endif
  99. };
  100. }}} // namespace boost::geometry::concepts
  101. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP