multi_polygon.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include <initializer_list>
  20. namespace boost { namespace geometry
  21. {
  22. namespace model
  23. {
  24. /*!
  25. \brief multi_polygon, a collection of polygons
  26. \details Multi-polygon can be used to group polygons belonging to each other,
  27. e.g. Hawaii
  28. \ingroup geometries
  29. \qbk{[include reference/geometries/multi_polygon.qbk]}
  30. \qbk{before.synopsis,
  31. [heading Model of]
  32. [link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept]
  33. }
  34. */
  35. template
  36. <
  37. typename Polygon,
  38. template<typename, typename> class Container = std::vector,
  39. template<typename> class Allocator = std::allocator
  40. >
  41. class multi_polygon : public Container<Polygon, Allocator<Polygon> >
  42. {
  43. BOOST_CONCEPT_ASSERT( (concepts::Polygon<Polygon>) );
  44. // default constructor and base_type definitions are required only
  45. // if the constructor taking std::initializer_list is defined
  46. typedef Container<Polygon, Allocator<Polygon> > base_type;
  47. public:
  48. /// \constructor_default{multi_polygon}
  49. multi_polygon()
  50. : base_type()
  51. {}
  52. /// \constructor_initializer_list{multi_polygon}
  53. inline multi_polygon(std::initializer_list<Polygon> l)
  54. : base_type(l.begin(), l.end())
  55. {}
  56. // Commented out for now in order to support Boost.Assign
  57. // Without this assignment operator first the object should be created
  58. // from initializer list, then it shoudl be moved.
  59. //// Without this workaround in MSVC the assignment operator is ambiguous
  60. //#ifndef BOOST_MSVC
  61. // /// \assignment_initializer_list{multi_polygon}
  62. // inline multi_polygon & operator=(std::initializer_list<Polygon> l)
  63. // {
  64. // base_type::assign(l.begin(), l.end());
  65. // return *this;
  66. // }
  67. //#endif
  68. };
  69. } // namespace model
  70. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  71. namespace traits
  72. {
  73. template
  74. <
  75. typename Polygon,
  76. template<typename, typename> class Container,
  77. template<typename> class Allocator
  78. >
  79. struct tag< model::multi_polygon<Polygon, Container, Allocator> >
  80. {
  81. typedef multi_polygon_tag type;
  82. };
  83. } // namespace traits
  84. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  85. }} // namespace boost::geometry
  86. #endif // BOOST_GEOMETRY_GEOMETRIES_MULTI_POLYGON_HPP