append_no_duplicates.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2018.
  4. // Modifications copyright (c) 2018 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP
  10. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP
  11. #include <boost/geometry/algorithms/append.hpp>
  12. #include <boost/geometry/algorithms/detail/equals/point_point.hpp>
  13. #include <boost/geometry/util/range.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. #ifndef DOXYGEN_NO_DETAIL
  17. namespace detail { namespace overlay
  18. {
  19. template <typename Range, typename Point>
  20. inline void append_with_duplicates(Range& range, Point const& point)
  21. {
  22. #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
  23. std::cout << " add: ("
  24. << geometry::get<0>(point) << ", " << geometry::get<1>(point) << ")"
  25. << std::endl;
  26. #endif
  27. geometry::append(range, point);
  28. }
  29. template <typename Range, typename Point, typename EqPPStrategy>
  30. inline void append_no_duplicates(Range& range, Point const& point,
  31. EqPPStrategy const& strategy)
  32. {
  33. if ( boost::empty(range)
  34. || ! geometry::detail::equals::equals_point_point(geometry::range::back(range),
  35. point,
  36. strategy) )
  37. {
  38. #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
  39. std::cout << " add: ("
  40. << geometry::get<0>(point) << ", " << geometry::get<1>(point) << ")"
  41. << std::endl;
  42. #endif
  43. geometry::append(range, point);
  44. }
  45. }
  46. }} // namespace detail::overlay
  47. #endif // DOXYGEN_NO_DETAIL
  48. }} // namespace boost::geometry
  49. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP