ring.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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_GEOMETRIES_RING_HPP
  11. #define BOOST_GEOMETRY_GEOMETRIES_RING_HPP
  12. #include <memory>
  13. #include <vector>
  14. #include <boost/concept/assert.hpp>
  15. #include <boost/geometry/core/closure.hpp>
  16. #include <boost/geometry/core/point_order.hpp>
  17. #include <boost/geometry/core/tag.hpp>
  18. #include <boost/geometry/core/tags.hpp>
  19. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  20. namespace boost { namespace geometry
  21. {
  22. namespace model
  23. {
  24. /*!
  25. \brief A ring (aka linear ring) is a closed line which should not be selfintersecting
  26. \ingroup geometries
  27. \tparam Point point type
  28. \tparam ClockWise true for clockwise direction,
  29. false for CounterClockWise direction
  30. \tparam Closed true for closed polygons (last point == first point),
  31. false open points
  32. \tparam Container container type, for example std::vector, std::deque
  33. \tparam Allocator container-allocator-type
  34. \qbk{before.synopsis,
  35. [heading Model of]
  36. [link geometry.reference.concepts.concept_ring Ring Concept]
  37. }
  38. */
  39. template
  40. <
  41. typename Point,
  42. bool ClockWise = true, bool Closed = true,
  43. template<typename, typename> class Container = std::vector,
  44. template<typename> class Allocator = std::allocator
  45. >
  46. class ring : public Container<Point, Allocator<Point> >
  47. {
  48. BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
  49. typedef Container<Point, Allocator<Point> > base_type;
  50. public :
  51. /// \constructor_default{ring}
  52. inline ring()
  53. : base_type()
  54. {}
  55. /// \constructor_begin_end{ring}
  56. template <typename Iterator>
  57. inline ring(Iterator begin, Iterator end)
  58. : base_type(begin, end)
  59. {}
  60. };
  61. } // namespace model
  62. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  63. namespace traits
  64. {
  65. template
  66. <
  67. typename Point,
  68. bool ClockWise, bool Closed,
  69. template<typename, typename> class Container,
  70. template<typename> class Allocator
  71. >
  72. struct tag<model::ring<Point, ClockWise, Closed, Container, Allocator> >
  73. {
  74. typedef ring_tag type;
  75. };
  76. template
  77. <
  78. typename Point,
  79. bool Closed,
  80. template<typename, typename> class Container,
  81. template<typename> class Allocator
  82. >
  83. struct point_order<model::ring<Point, false, Closed, Container, Allocator> >
  84. {
  85. static const order_selector value = counterclockwise;
  86. };
  87. template
  88. <
  89. typename Point,
  90. bool Closed,
  91. template<typename, typename> class Container,
  92. template<typename> class Allocator
  93. >
  94. struct point_order<model::ring<Point, true, Closed, Container, Allocator> >
  95. {
  96. static const order_selector value = clockwise;
  97. };
  98. template
  99. <
  100. typename Point,
  101. bool PointOrder,
  102. template<typename, typename> class Container,
  103. template<typename> class Allocator
  104. >
  105. struct closure<model::ring<Point, PointOrder, true, Container, Allocator> >
  106. {
  107. static const closure_selector value = closed;
  108. };
  109. template
  110. <
  111. typename Point,
  112. bool PointOrder,
  113. template<typename, typename> class Container,
  114. template<typename> class Allocator
  115. >
  116. struct closure<model::ring<Point, PointOrder, false, Container, Allocator> >
  117. {
  118. static const closure_selector value = open;
  119. };
  120. } // namespace traits
  121. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  122. }} // namespace boost::geometry
  123. #endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP