interior_type.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  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_CORE_INTERIOR_TYPE_HPP
  11. #define BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/mpl/if.hpp>
  14. #include <boost/type_traits/is_const.hpp>
  15. #include <boost/type_traits/remove_const.hpp>
  16. #include <boost/type_traits/remove_reference.hpp>
  17. #include <boost/geometry/core/tag.hpp>
  18. #include <boost/geometry/core/tags.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. namespace traits
  22. {
  23. /*!
  24. \brief Traits class indicating interior container type of a polygon
  25. \details defines inner container type, so the container containing
  26. the interior rings
  27. \ingroup traits
  28. \par Geometries:
  29. - polygon
  30. \par Specializations should provide:
  31. - typedef X type ( e.g. std::vector&lt;myring&lt;P&gt;&gt; )
  32. \tparam Geometry geometry
  33. */
  34. template <typename Geometry>
  35. struct interior_const_type
  36. {
  37. BOOST_MPL_ASSERT_MSG
  38. (
  39. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  40. , (types<Geometry>)
  41. );
  42. };
  43. template <typename Geometry>
  44. struct interior_mutable_type
  45. {
  46. BOOST_MPL_ASSERT_MSG
  47. (
  48. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  49. , (types<Geometry>)
  50. );
  51. };
  52. } // namespace traits
  53. #ifndef DOXYGEN_NO_DISPATCH
  54. namespace core_dispatch
  55. {
  56. template <typename GeometryTag, typename Geometry>
  57. struct interior_return_type
  58. {
  59. BOOST_MPL_ASSERT_MSG
  60. (
  61. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  62. , (types<Geometry>)
  63. );
  64. };
  65. template <typename Polygon>
  66. struct interior_return_type<polygon_tag, Polygon>
  67. {
  68. typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
  69. typedef typename boost::mpl::if_
  70. <
  71. boost::is_const<Polygon>,
  72. typename traits::interior_const_type<nc_polygon_type>::type,
  73. typename traits::interior_mutable_type<nc_polygon_type>::type
  74. >::type type;
  75. };
  76. template <typename GeometryTag, typename Geometry>
  77. struct interior_type
  78. {
  79. BOOST_MPL_ASSERT_MSG
  80. (
  81. false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  82. , (types<Geometry>)
  83. );
  84. };
  85. template <typename Polygon>
  86. struct interior_type<polygon_tag, Polygon>
  87. {
  88. typedef typename boost::remove_reference
  89. <
  90. typename interior_return_type<polygon_tag, Polygon>::type
  91. >::type type;
  92. };
  93. } // namespace core_dispatch
  94. #endif
  95. /*!
  96. \brief \brief_meta{type, interior_type (container type
  97. of inner rings), \meta_geometry_type}
  98. \details Interior rings should be organized as a container
  99. (std::vector, std::deque, boost::array) with
  100. Boost.Range support. This metafunction defines the type
  101. of the container.
  102. \tparam Geometry A type fullfilling the Polygon or MultiPolygon concept.
  103. \ingroup core
  104. \qbk{[include reference/core/interior_type.qbk]}
  105. */
  106. template <typename Geometry>
  107. struct interior_type
  108. {
  109. typedef typename core_dispatch::interior_type
  110. <
  111. typename tag<Geometry>::type,
  112. Geometry
  113. >::type type;
  114. };
  115. template <typename Geometry>
  116. struct interior_return_type
  117. {
  118. typedef typename core_dispatch::interior_return_type
  119. <
  120. typename tag<Geometry>::type,
  121. Geometry
  122. >::type type;
  123. };
  124. }} // namespace boost::geometry
  125. #endif // BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP