Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:28

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,
0049           typename Tag = typename geometry::tag<Indexable>::type>
0050 struct is_valid
0051 {
0052     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0053         "Not implemented for this Indexable type.",
0054         Indexable, Tag);
0055 };
0056 
0057 template <typename Indexable>
0058 struct is_valid<Indexable, point_tag>
0059 {
0060     static inline bool apply(Indexable const&)
0061     {
0062         return true;
0063     }
0064 };
0065 
0066 template <typename Indexable>
0067 struct is_valid<Indexable, box_tag>
0068 {
0069     static inline bool apply(Indexable const& b)
0070     {
0071         return dispatch::is_valid_box<Indexable>::apply(b);
0072     }
0073 };
0074 
0075 template <typename Indexable>
0076 struct is_valid<Indexable, segment_tag>
0077 {
0078     static inline bool apply(Indexable const&)
0079     {
0080         return true;
0081     }
0082 };
0083 
0084 } // namespace dispatch
0085 
0086 template <typename Indexable>
0087 inline bool is_valid(Indexable const& b)
0088 {
0089     // CONSIDER: detection of NaNs
0090     // e.g. by comparison of b with copy of b
0091 
0092     return dispatch::is_valid<Indexable>::apply(b);
0093 }
0094 
0095 }}}} // namespace boost::geometry::index::detail
0096 
0097 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP