multi_polygon.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #ifndef BOOST_GEOMETRY_GEOMETRIES_MULTI_POLYGON_HPP
  12. #define BOOST_GEOMETRY_GEOMETRIES_MULTI_POLYGON_HPP
  13. #include <memory>
  14. #include <vector>
  15. #include <boost/concept/requires.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
  18. #include <boost/config.hpp>
  19. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  20. #include <initializer_list>
  21. #endif
  22. namespace boost { namespace geometry
  23. {
  24. namespace model
  25. {
  26. /*!
  27. \brief multi_polygon, a collection of polygons
  28. \details Multi-polygon can be used to group polygons belonging to each other,
  29. e.g. Hawaii
  30. \ingroup geometries
  31. \qbk{[include reference/geometries/multi_polygon.qbk]}
  32. \qbk{before.synopsis,
  33. [heading Model of]
  34. [link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept]
  35. }
  36. */
  37. template
  38. <
  39. typename Polygon,
  40. template<typename, typename> class Container = std::vector,
  41. template<typename> class Allocator = std::allocator
  42. >
  43. class multi_polygon : public Container<Polygon, Allocator<Polygon> >
  44. {
  45. BOOST_CONCEPT_ASSERT( (concepts::Polygon<Polygon>) );
  46. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  47. // default constructor and base_type definitions are required only
  48. // if the constructor taking std::initializer_list is defined
  49. typedef Container<Polygon, Allocator<Polygon> > base_type;
  50. public:
  51. /// \constructor_default{multi_polygon}
  52. multi_polygon()
  53. : base_type()
  54. {}
  55. /// \constructor_initializer_list{multi_polygon}
  56. inline multi_polygon(std::initializer_list<Polygon> l)
  57. : base_type(l.begin(), l.end())
  58. {}
  59. // Commented out for now in order to support Boost.Assign
  60. // Without this assignment operator first the object should be created
  61. // from initializer list, then it shoudl be moved.
  62. //// Without this workaround in MSVC the assignment operator is ambiguous
  63. //#ifndef BOOST_MSVC
  64. // /// \assignment_initializer_list{multi_polygon}
  65. // inline multi_polygon & operator=(std::initializer_list<Polygon> l)
  66. // {
  67. // base_type::assign(l.begin(), l.end());
  68. // return *this;
  69. // }
  70. //#endif
  71. #endif
  72. };
  73. } // namespace model
  74. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  75. namespace traits
  76. {
  77. template
  78. <
  79. typename Polygon,
  80. template<typename, typename> class Container,
  81. template<typename> class Allocator
  82. >
  83. struct tag< model::multi_polygon<Polygon, Container, Allocator> >
  84. {
  85. typedef multi_polygon_tag type;
  86. };
  87. } // namespace traits
  88. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  89. }} // namespace boost::geometry
  90. #endif // BOOST_GEOMETRY_GEOMETRIES_MULTI_POLYGON_HPP