File indexing completed on 2025-07-06 08:14:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_RATIOS_HPP
0010 #define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_RATIOS_HPP
0011
0012
0013 #include <algorithm>
0014 #include <string>
0015
0016 #include <boost/concept_check.hpp>
0017
0018 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
0019 #include <boost/geometry/core/access.hpp>
0020 #include <boost/geometry/strategies/side_info.hpp>
0021
0022
0023 namespace boost { namespace geometry
0024 {
0025
0026 namespace policies { namespace relate
0027 {
0028
0029
0030
0031
0032
0033
0034 template
0035 <
0036 typename FractionType
0037 >
0038 struct segments_intersection_ratios
0039 {
0040 typedef FractionType return_type;
0041
0042 template
0043 <
0044 typename Segment1,
0045 typename Segment2,
0046 typename SegmentIntersectionInfo
0047 >
0048 static inline return_type segments_crosses(side_info const&,
0049 SegmentIntersectionInfo const& sinfo,
0050 Segment1 const& , Segment2 const& )
0051 {
0052 return_type result;
0053 result.assign(sinfo);
0054 return result;
0055 }
0056
0057 template<typename SegmentIntersectionInfo, typename Point>
0058 static inline return_type
0059 segments_share_common_point(side_info const&, SegmentIntersectionInfo const& sinfo,
0060 Point const& p)
0061 {
0062 return_type result;
0063 result.assign(sinfo);
0064 return result;
0065 }
0066
0067 template <typename Segment1, typename Segment2, typename Ratio>
0068 static inline return_type segments_collinear(
0069 Segment1 const& , Segment2 const& ,
0070 Ratio const& ra_from_wrt_b, Ratio const& ra_to_wrt_b,
0071 Ratio const& rb_from_wrt_a, Ratio const& rb_to_wrt_a)
0072 {
0073
0074
0075 return_type result;
0076
0077 if (ra_from_wrt_b.on_segment())
0078 {
0079 result.assign(Ratio::zero(), ra_from_wrt_b);
0080 }
0081 else if (rb_from_wrt_a.in_segment())
0082 {
0083 result.assign(rb_from_wrt_a, Ratio::zero());
0084 }
0085 else if (ra_to_wrt_b.on_segment())
0086 {
0087 result.assign(Ratio::one(), ra_to_wrt_b);
0088 }
0089 else if (rb_to_wrt_a.in_segment())
0090 {
0091 result.assign(rb_to_wrt_a, Ratio::one());
0092 }
0093
0094 return result;
0095 }
0096
0097 static inline return_type disjoint()
0098 {
0099 return return_type();
0100 }
0101 static inline return_type error(std::string const&)
0102 {
0103 return return_type();
0104 }
0105
0106 template <typename Segment>
0107 static inline return_type degenerate(Segment const& segment, bool)
0108 {
0109 return return_type();
0110 }
0111
0112 template <typename Segment, typename Ratio>
0113 static inline return_type one_degenerate(Segment const& ,
0114 Ratio const& ratio, bool a_degenerate)
0115 {
0116 return_type result;
0117 if (a_degenerate)
0118 {
0119
0120 result.assign(Ratio::zero(), ratio);
0121 }
0122 else
0123 {
0124 result.assign(ratio, Ratio::zero());
0125 }
0126 return result;
0127 }
0128
0129 };
0130
0131
0132 }}
0133
0134 }}
0135
0136 #endif