transform.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_MULTI_ALGORITHMS_TRANSFORM_HPP
  11. #define BOOST_GEOMETRY_MULTI_ALGORITHMS_TRANSFORM_HPP
  12. #include <boost/range.hpp>
  13. #include <boost/geometry/core/mutable_range.hpp>
  14. #include <boost/geometry/algorithms/transform.hpp>
  15. #include <boost/geometry/multi/core/tags.hpp>
  16. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. #ifndef DOXYGEN_NO_DETAIL
  20. namespace detail { namespace transform
  21. {
  22. /*!
  23. \brief Is able to transform any multi-geometry, calling the single-version as policy
  24. */
  25. template <typename Policy>
  26. struct transform_multi
  27. {
  28. template <typename Multi1, typename Multi2, typename S>
  29. static inline bool apply(Multi1 const& multi1, Multi2& multi2, S const& strategy)
  30. {
  31. traits::resize<Multi2>::apply(multi2, boost::size(multi1));
  32. typename boost::range_iterator<Multi1 const>::type it1
  33. = boost::begin(multi1);
  34. typename boost::range_iterator<Multi2>::type it2
  35. = boost::begin(multi2);
  36. for (; it1 != boost::end(multi1); ++it1, ++it2)
  37. {
  38. if (! Policy::apply(*it1, *it2, strategy))
  39. {
  40. return false;
  41. }
  42. }
  43. return true;
  44. }
  45. };
  46. }} // namespace detail::transform
  47. #endif // DOXYGEN_NO_DETAIL
  48. #ifndef DOXYGEN_NO_DISPATCH
  49. namespace dispatch
  50. {
  51. template <typename Multi1, typename Multi2>
  52. struct transform
  53. <
  54. Multi1, Multi2,
  55. multi_tag, multi_tag
  56. >
  57. : detail::transform::transform_multi
  58. <
  59. transform
  60. <
  61. typename boost::range_value<Multi1>::type,
  62. typename boost::range_value<Multi2>::type
  63. >
  64. >
  65. {};
  66. } // namespace dispatch
  67. #endif // DOXYGEN_NO_DISPATCH
  68. }} // namespace boost::geometry
  69. #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_TRANSFORM_HPP