polygon_concept.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/core/ignore_unused.hpp>
  14. #include <boost/range/concepts.hpp>
  15. #include <boost/geometry/core/access.hpp>
  16. #include <boost/geometry/core/exterior_ring.hpp>
  17. #include <boost/geometry/core/interior_rings.hpp>
  18. #include <boost/geometry/core/point_type.hpp>
  19. #include <boost/geometry/core/ring_type.hpp>
  20. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  21. #include <boost/geometry/geometries/concepts/ring_concept.hpp>
  22. namespace boost { namespace geometry { namespace concepts
  23. {
  24. /*!
  25. \brief Checks polygon concept
  26. \ingroup concepts
  27. */
  28. template <typename PolygonType>
  29. class Polygon
  30. {
  31. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  32. typedef typename boost::remove_const<PolygonType>::type polygon_type;
  33. typedef typename traits::ring_const_type<polygon_type>::type ring_const_type;
  34. typedef typename traits::ring_mutable_type<polygon_type>::type ring_mutable_type;
  35. typedef typename traits::interior_const_type<polygon_type>::type interior_const_type;
  36. typedef typename traits::interior_mutable_type<polygon_type>::type interior_mutable_type;
  37. typedef typename point_type<PolygonType>::type point_type;
  38. typedef typename ring_type<PolygonType>::type ring_type;
  39. BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
  40. BOOST_CONCEPT_ASSERT( (concepts::Ring<ring_type>) );
  41. //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
  42. struct checker
  43. {
  44. static inline void apply()
  45. {
  46. polygon_type* poly = 0;
  47. polygon_type const* cpoly = poly;
  48. ring_mutable_type e = traits::exterior_ring<PolygonType>::get(*poly);
  49. interior_mutable_type i = traits::interior_rings<PolygonType>::get(*poly);
  50. ring_const_type ce = traits::exterior_ring<PolygonType>::get(*cpoly);
  51. interior_const_type ci = traits::interior_rings<PolygonType>::get(*cpoly);
  52. boost::ignore_unused(poly, cpoly);
  53. boost::ignore_unused(e, i, ce, ci);
  54. }
  55. };
  56. public:
  57. BOOST_CONCEPT_USAGE(Polygon)
  58. {
  59. checker::apply();
  60. }
  61. #endif
  62. };
  63. /*!
  64. \brief Checks polygon concept (const version)
  65. \ingroup const_concepts
  66. */
  67. template <typename PolygonType>
  68. class ConstPolygon
  69. {
  70. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  71. typedef typename boost::remove_const<PolygonType>::type const_polygon_type;
  72. typedef typename traits::ring_const_type<const_polygon_type>::type ring_const_type;
  73. typedef typename traits::interior_const_type<const_polygon_type>::type interior_const_type;
  74. typedef typename point_type<const_polygon_type>::type point_type;
  75. typedef typename ring_type<const_polygon_type>::type ring_type;
  76. BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
  77. BOOST_CONCEPT_ASSERT( (concepts::ConstRing<ring_type>) );
  78. ////BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
  79. struct checker
  80. {
  81. static inline void apply()
  82. {
  83. const_polygon_type const* cpoly = 0;
  84. ring_const_type ce = traits::exterior_ring<const_polygon_type>::get(*cpoly);
  85. interior_const_type ci = traits::interior_rings<const_polygon_type>::get(*cpoly);
  86. boost::ignore_unused(ce, ci, cpoly);
  87. }
  88. };
  89. public:
  90. BOOST_CONCEPT_USAGE(ConstPolygon)
  91. {
  92. checker::apply();
  93. }
  94. #endif
  95. };
  96. }}} // namespace boost::geometry::concepts
  97. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP