multi_polygon_concept.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // This file was modified by Oracle on 2020-2021.
  6. // Modifications copyright (c) 2020-2021 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_MULTI_POLYGON_CONCEPT_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_MULTI_POLYGON_CONCEPT_HPP
  15. #include <boost/concept_check.hpp>
  16. #include <boost/range/concepts.hpp>
  17. #include <boost/range/value_type.hpp>
  18. #include <boost/geometry/geometries/concepts/concept_type.hpp>
  19. #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
  20. namespace boost { namespace geometry { namespace concepts
  21. {
  22. template <typename Geometry>
  23. class MultiPolygon
  24. {
  25. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  26. typedef typename boost::range_value<Geometry>::type polygon_type;
  27. BOOST_CONCEPT_ASSERT( (concepts::Polygon<polygon_type>) );
  28. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  29. public :
  30. BOOST_CONCEPT_USAGE(MultiPolygon)
  31. {
  32. Geometry* mp = 0;
  33. traits::clear<Geometry>::apply(*mp);
  34. traits::resize<Geometry>::apply(*mp, 0);
  35. // The concept should support the second version of push_back, using &&
  36. polygon_type* poly = 0;
  37. traits::push_back<Geometry>::apply(*mp, std::move(*poly));
  38. }
  39. #endif
  40. };
  41. /*!
  42. \brief concept for multi-polygon (const version)
  43. \ingroup const_concepts
  44. */
  45. template <typename Geometry>
  46. class ConstMultiPolygon
  47. {
  48. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  49. typedef typename boost::range_value<Geometry>::type polygon_type;
  50. BOOST_CONCEPT_ASSERT( (concepts::ConstPolygon<polygon_type>) );
  51. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  52. public :
  53. BOOST_CONCEPT_USAGE(ConstMultiPolygon)
  54. {
  55. }
  56. #endif
  57. };
  58. template <typename Geometry>
  59. struct concept_type<Geometry, multi_polygon_tag>
  60. {
  61. using type = MultiPolygon<Geometry>;
  62. };
  63. template <typename Geometry>
  64. struct concept_type<Geometry const, multi_polygon_tag>
  65. {
  66. using type = ConstMultiPolygon<Geometry>;
  67. };
  68. }}} // namespace boost::geometry::concepts
  69. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_MULTI_POLYGON_CONCEPT_HPP