gc_topological_dimension.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Boost.Geometry
  2. // Copyright (c) 2022, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GC_TOPOLOGICAL_DIMENSION_HPP
  7. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GC_TOPOLOGICAL_DIMENSION_HPP
  8. #include <algorithm>
  9. #include <boost/geometry/algorithms/detail/visit.hpp>
  10. #include <boost/geometry/algorithms/is_empty.hpp>
  11. #include <boost/geometry/core/topological_dimension.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. #ifndef DOXYGEN_NO_DETAIL
  15. namespace detail
  16. {
  17. template <typename GeometryCollection>
  18. inline int gc_topological_dimension(GeometryCollection const& geometry)
  19. {
  20. int result = -1;
  21. detail::visit_breadth_first([&](auto const& g)
  22. {
  23. if (! geometry::is_empty(g))
  24. {
  25. static const int d = geometry::topological_dimension<decltype(g)>::value;
  26. result = (std::max)(result, d);
  27. }
  28. return result >= 2;
  29. }, geometry);
  30. return result;
  31. }
  32. } // namespace detail
  33. #endif // DOXYGEN_NO_DETAIL
  34. }} // namespace boost::geometry
  35. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GC_TOPOLOGICAL_DIMENSION_HPP