linestring_concept.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  3. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020 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_LINESTRING_CONCEPT_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
  15. #include <boost/concept_check.hpp>
  16. #include <boost/range/concepts.hpp>
  17. #include <boost/geometry/core/access.hpp>
  18. #include <boost/geometry/core/mutable_range.hpp>
  19. #include <boost/geometry/core/point_type.hpp>
  20. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  21. namespace boost { namespace geometry { namespace concepts
  22. {
  23. /*!
  24. \brief Linestring concept
  25. \ingroup concepts
  26. \par Formal definition:
  27. The linestring concept is defined as following:
  28. - there must be a specialization of traits::tag defining linestring_tag as type
  29. - it must behave like a Boost.Range
  30. - it must implement a std::back_insert_iterator
  31. - either by implementing push_back
  32. - or by specializing std::back_insert_iterator
  33. \note to fulfill the concepts, no traits class has to be specialized to
  34. define the point type.
  35. \par Example:
  36. A custom linestring, defining the necessary specializations to fulfill to the concept.
  37. Suppose that the following linestring is defined:
  38. \dontinclude doxygen_5.cpp
  39. \skip custom_linestring1
  40. \until };
  41. It can then be adapted to the concept as following:
  42. \dontinclude doxygen_5.cpp
  43. \skip adapt custom_linestring1
  44. \until }}
  45. \note
  46. - There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING
  47. - For registration of std::vector<P> (and deque, and list) it is enough to
  48. include the header-file geometries/adapted/std_as_linestring.hpp. That registers
  49. a vector as a linestring (so it cannot be registered as a linear ring then,
  50. in the same source code).
  51. */
  52. template <typename Geometry>
  53. class Linestring
  54. {
  55. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  56. typedef typename point_type<Geometry>::type point_type;
  57. BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
  58. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  59. public :
  60. BOOST_CONCEPT_USAGE(Linestring)
  61. {
  62. Geometry* ls = 0;
  63. traits::clear<Geometry>::apply(*ls);
  64. traits::resize<Geometry>::apply(*ls, 0);
  65. point_type* point = 0;
  66. traits::push_back<Geometry>::apply(*ls, *point);
  67. }
  68. #endif
  69. };
  70. /*!
  71. \brief Linestring concept (const version)
  72. \ingroup const_concepts
  73. \details The ConstLinestring concept check the same as the Linestring concept,
  74. but does not check write access.
  75. */
  76. template <typename Geometry>
  77. class ConstLinestring
  78. {
  79. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  80. typedef typename point_type<Geometry>::type point_type;
  81. BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
  82. //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  83. // Relaxed the concept.
  84. BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
  85. public :
  86. BOOST_CONCEPT_USAGE(ConstLinestring)
  87. {
  88. }
  89. #endif
  90. };
  91. }}} // namespace boost::geometry::concepts
  92. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP