polygon_concept.hpp 4.4 KB

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