|
||||
File indexing completed on 2025-01-18 09:35:15
0001 // Boost.Geometry (aka GGL, Generic Geometry Library) 0002 0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 0004 0005 // This file was modified by Oracle on 2013-2022. 0006 // Modifications copyright (c) 2013-2022 Oracle and/or its affiliates. 0007 0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 0009 0010 // Use, modification and distribution is subject to the Boost Software License, 0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 0012 // http://www.boost.org/LICENSE_1_0.txt) 0013 0014 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP 0015 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP 0016 0017 #include <boost/geometry/algorithms/detail/relate/result.hpp> 0018 #include <boost/geometry/algorithms/detail/relate/topology_check.hpp> 0019 #include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp> 0020 0021 #include <boost/geometry/util/condition.hpp> 0022 0023 namespace boost { namespace geometry 0024 { 0025 0026 #ifndef DOXYGEN_NO_DETAIL 0027 namespace detail { namespace relate { 0028 0029 // non-point geometry 0030 template <typename Point, typename Geometry, bool Transpose = false> 0031 struct point_geometry 0032 { 0033 // TODO: interrupt only if the topology check is complex 0034 0035 static const bool interruption_enabled = true; 0036 0037 template <typename Result, typename Strategy> 0038 static inline void apply(Point const& point, Geometry const& geometry, Result & result, Strategy const& strategy) 0039 { 0040 int pig = detail::within::point_in_geometry(point, geometry, strategy); 0041 0042 if ( pig > 0 ) // within 0043 { 0044 update<interior, interior, '0', Transpose>(result); 0045 } 0046 else if ( pig == 0 ) 0047 { 0048 update<interior, boundary, '0', Transpose>(result); 0049 } 0050 else // pig < 0 - not within 0051 { 0052 update<interior, exterior, '0', Transpose>(result); 0053 } 0054 0055 update<exterior, exterior, result_dimension<Point>::value, Transpose>(result); 0056 0057 if ( BOOST_GEOMETRY_CONDITION(result.interrupt) ) 0058 return; 0059 0060 typedef detail::relate::topology_check<Geometry, Strategy> tc_t; 0061 0062 if ( relate::may_update<exterior, interior, tc_t::interior, Transpose>(result) 0063 || relate::may_update<exterior, boundary, tc_t::boundary, Transpose>(result) ) 0064 { 0065 // the point is on the boundary 0066 if ( pig == 0 ) 0067 { 0068 // NOTE: even for MLs, if there is at least one boundary point, 0069 // somewhere there must be another one 0070 update<exterior, interior, tc_t::interior, Transpose>(result); 0071 update<exterior, boundary, tc_t::boundary, Transpose>(result); 0072 } 0073 else 0074 { 0075 // check if there is a boundary in Geometry 0076 tc_t tc(geometry, strategy); 0077 if ( tc.has_interior() ) 0078 { 0079 update<exterior, interior, tc_t::interior, Transpose>(result); 0080 } 0081 if ( tc.has_boundary() ) 0082 { 0083 update<exterior, boundary, tc_t::boundary, Transpose>(result); 0084 } 0085 } 0086 } 0087 } 0088 }; 0089 0090 // transposed result of point_geometry 0091 template <typename Geometry, typename Point> 0092 struct geometry_point 0093 { 0094 // TODO: interrupt only if the topology check is complex 0095 0096 static const bool interruption_enabled = true; 0097 0098 template <typename Result, typename Strategy> 0099 static inline void apply(Geometry const& geometry, Point const& point, Result & result, Strategy const& strategy) 0100 { 0101 point_geometry<Point, Geometry, true>::apply(point, geometry, result, strategy); 0102 } 0103 }; 0104 0105 // TODO: rewrite the folowing: 0106 0107 //// NOTE: Those tests should be consistent with within(Point, Box) and covered_by(Point, Box) 0108 //// There is no EPS used in those functions, values are compared using < or <= 0109 //// so comparing MIN and MAX in the same way should be fine 0110 // 0111 //template <typename Box, std::size_t I = 0, std::size_t D = geometry::dimension<Box>::value> 0112 //struct box_has_interior 0113 //{ 0114 // static inline bool apply(Box const& box) 0115 // { 0116 // return geometry::get<min_corner, I>(box) < geometry::get<max_corner, I>(box) 0117 // && box_has_interior<Box, I + 1, D>::apply(box); 0118 // } 0119 //}; 0120 // 0121 //template <typename Box, std::size_t D> 0122 //struct box_has_interior<Box, D, D> 0123 //{ 0124 // static inline bool apply(Box const&) { return true; } 0125 //}; 0126 // 0127 //// NOTE: especially important here (see the NOTE above). 0128 // 0129 //template <typename Box, std::size_t I = 0, std::size_t D = geometry::dimension<Box>::value> 0130 //struct box_has_equal_min_max 0131 //{ 0132 // static inline bool apply(Box const& box) 0133 // { 0134 // return geometry::get<min_corner, I>(box) == geometry::get<max_corner, I>(box) 0135 // && box_has_equal_min_max<Box, I + 1, D>::apply(box); 0136 // } 0137 //}; 0138 // 0139 //template <typename Box, std::size_t D> 0140 //struct box_has_equal_min_max<Box, D, D> 0141 //{ 0142 // static inline bool apply(Box const&) { return true; } 0143 //}; 0144 // 0145 //template <typename Point, typename Box> 0146 //struct point_box 0147 //{ 0148 // static inline result apply(Point const& point, Box const& box) 0149 // { 0150 // result res; 0151 // 0152 // if ( geometry::within(point, box) ) // this also means that the box has interior 0153 // { 0154 // return result("0FFFFFTTT"); 0155 // } 0156 // else if ( geometry::covered_by(point, box) ) // point is on the boundary 0157 // { 0158 // //if ( box_has_interior<Box>::apply(box) ) 0159 // //{ 0160 // // return result("F0FFFFTTT"); 0161 // //} 0162 // //else if ( box_has_equal_min_max<Box>::apply(box) ) // no boundary outside point 0163 // //{ 0164 // // return result("F0FFFFFFT"); 0165 // //} 0166 // //else // no interior outside point 0167 // //{ 0168 // // return result("F0FFFFFTT"); 0169 // //} 0170 // return result("F0FFFF**T"); 0171 // } 0172 // else 0173 // { 0174 // /*if ( box_has_interior<Box>::apply(box) ) 0175 // { 0176 // return result("FF0FFFTTT"); 0177 // } 0178 // else 0179 // { 0180 // return result("FF0FFFFTT"); 0181 // }*/ 0182 // return result("FF0FFF*TT"); 0183 // } 0184 // 0185 // return res; 0186 // } 0187 //}; 0188 // 0189 //template <typename Box, typename Point> 0190 //struct box_point 0191 //{ 0192 // static inline result apply(Box const& box, Point const& point) 0193 // { 0194 // if ( geometry::within(point, box) ) 0195 // return result("0FTFFTFFT"); 0196 // else if ( geometry::covered_by(point, box) ) 0197 // return result("FF*0F*FFT"); 0198 // else 0199 // return result("FF*FFT0FT"); 0200 // } 0201 //}; 0202 0203 }} // namespace detail::relate 0204 #endif // DOXYGEN_NO_DETAIL 0205 0206 }} // namespace boost::geometry 0207 0208 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_GEOMETRY_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |