Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:43:12

0001 // Boost.Geometry Index
0002 //
0003 // n-dimensional Indexable validity check
0004 //
0005 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2020-2021.
0008 // Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 //
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
0014 
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
0017 
0018 #include <cstddef>
0019 
0020 #include <boost/geometry/core/access.hpp>
0021 #include <boost/geometry/core/coordinate_dimension.hpp>
0022 #include <boost/geometry/core/static_assert.hpp>
0023 
0024 namespace boost { namespace geometry { namespace index { namespace detail {
0025 
0026 namespace dispatch {
0027 
0028 template <typename Box,
0029           std::size_t Dimension = geometry::dimension<Box>::value>
0030 struct is_valid_box
0031 {
0032     static inline bool apply(Box const& b)
0033     {
0034         return is_valid_box<Box, Dimension - 1>::apply(b) &&
0035             ( get<min_corner, Dimension - 1>(b) <= get<max_corner, Dimension - 1>(b) );
0036     }
0037 };
0038 
0039 template <typename Box>
0040 struct is_valid_box<Box, 1>
0041 {
0042     static inline bool apply(Box const& b)
0043     {
0044         return get<min_corner, 0>(b) <= get<max_corner, 0>(b);
0045     }
0046 };
0047 
0048 template <typename Indexable, typename Tag = geometry::tag_t<Indexable>>
0049 struct is_valid
0050 {
0051     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0052         "Not implemented for this Indexable type.",
0053         Indexable, Tag);
0054 };
0055 
0056 template <typename Indexable>
0057 struct is_valid<Indexable, point_tag>
0058 {
0059     static inline bool apply(Indexable const&)
0060     {
0061         return true;
0062     }
0063 };
0064 
0065 template <typename Indexable>
0066 struct is_valid<Indexable, box_tag>
0067 {
0068     static inline bool apply(Indexable const& b)
0069     {
0070         return dispatch::is_valid_box<Indexable>::apply(b);
0071     }
0072 };
0073 
0074 template <typename Indexable>
0075 struct is_valid<Indexable, segment_tag>
0076 {
0077     static inline bool apply(Indexable const&)
0078     {
0079         return true;
0080     }
0081 };
0082 
0083 } // namespace dispatch
0084 
0085 template <typename Indexable>
0086 inline bool is_valid(Indexable const& b)
0087 {
0088     // CONSIDER: detection of NaNs
0089     // e.g. by comparison of b with copy of b
0090 
0091     return dispatch::is_valid<Indexable>::apply(b);
0092 }
0093 
0094 }}}} // namespace boost::geometry::index::detail
0095 
0096 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP