ring_concept.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_RING_CONCEPT_HPP
  11. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
  12. #include <boost/concept_check.hpp>
  13. #include <boost/range/concepts.hpp>
  14. #include <boost/type_traits/remove_const.hpp>
  15. #include <boost/geometry/core/access.hpp>
  16. #include <boost/geometry/core/mutable_range.hpp>
  17. #include <boost/geometry/core/point_type.hpp>
  18. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  19. namespace boost { namespace geometry { namespace concepts
  20. {
  21. /*!
  22. \brief ring concept
  23. \ingroup concepts
  24. \par Formal definition:
  25. The ring concept is defined as following:
  26. - there must be a specialization of traits::tag defining ring_tag as type
  27. - it must behave like a Boost.Range
  28. - there can optionally be a specialization of traits::point_order defining the
  29. order or orientation of its points, clockwise or counterclockwise.
  30. - it must implement a std::back_insert_iterator
  31. (This is the same as the for the concept Linestring, and described there)
  32. \note to fulfill the concepts, no traits class has to be specialized to
  33. define the point type.
  34. */
  35. template <typename Geometry>
  36. class Ring
  37. {
  38. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  39. typedef typename point_type<Geometry>::type point_type;
  40. BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
  41. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  42. public :
  43. BOOST_CONCEPT_USAGE(Ring)
  44. {
  45. Geometry* ring = 0;
  46. traits::clear<Geometry>::apply(*ring);
  47. traits::resize<Geometry>::apply(*ring, 0);
  48. point_type* point = 0;
  49. traits::push_back<Geometry>::apply(*ring, *point);
  50. }
  51. #endif
  52. };
  53. /*!
  54. \brief (linear) ring concept (const version)
  55. \ingroup const_concepts
  56. \details The ConstLinearRing concept check the same as the Geometry concept,
  57. but does not check write access.
  58. */
  59. template <typename Geometry>
  60. class ConstRing
  61. {
  62. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  63. typedef typename point_type<Geometry>::type point_type;
  64. BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
  65. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  66. public :
  67. BOOST_CONCEPT_USAGE(ConstRing)
  68. {
  69. }
  70. #endif
  71. };
  72. }}} // namespace boost::geometry::concepts
  73. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP