annotate DEPENDENCIES/generic/include/boost/geometry/policies/relate/intersection_ratios.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@102 2
Chris@102 3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4
Chris@102 5 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 8
Chris@102 9 #ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_RATIOS_HPP
Chris@102 10 #define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_RATIOS_HPP
Chris@102 11
Chris@102 12
Chris@102 13 #include <algorithm>
Chris@102 14 #include <string>
Chris@102 15
Chris@102 16 #include <boost/concept_check.hpp>
Chris@102 17 #include <boost/numeric/conversion/cast.hpp>
Chris@102 18
Chris@102 19 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
Chris@102 20 #include <boost/geometry/core/access.hpp>
Chris@102 21 #include <boost/geometry/strategies/side_info.hpp>
Chris@102 22
Chris@102 23
Chris@102 24 namespace boost { namespace geometry
Chris@102 25 {
Chris@102 26
Chris@102 27 namespace policies { namespace relate
Chris@102 28 {
Chris@102 29
Chris@102 30
Chris@102 31 /*!
Chris@102 32 \brief Policy returning segment ratios
Chris@102 33 \note Template argument FractionType should be a fraction_type<SegmentRatio>
Chris@102 34 */
Chris@102 35 template
Chris@102 36 <
Chris@102 37 typename FractionType
Chris@102 38 >
Chris@102 39 struct segments_intersection_ratios
Chris@102 40 {
Chris@102 41 typedef FractionType return_type;
Chris@102 42
Chris@102 43 template
Chris@102 44 <
Chris@102 45 typename Segment1,
Chris@102 46 typename Segment2,
Chris@102 47 typename SegmentIntersectionInfo
Chris@102 48 >
Chris@102 49 static inline return_type segments_crosses(side_info const&,
Chris@102 50 SegmentIntersectionInfo const& sinfo,
Chris@102 51 Segment1 const& , Segment2 const& )
Chris@102 52 {
Chris@102 53 return_type result;
Chris@102 54 result.assign(sinfo);
Chris@102 55 return result;
Chris@102 56 }
Chris@102 57
Chris@102 58 template <typename Segment1, typename Segment2, typename Ratio>
Chris@102 59 static inline return_type segments_collinear(
Chris@102 60 Segment1 const& , Segment2 const& ,
Chris@102 61 Ratio const& ra_from_wrt_b, Ratio const& ra_to_wrt_b,
Chris@102 62 Ratio const& rb_from_wrt_a, Ratio const& rb_to_wrt_a)
Chris@102 63 {
Chris@102 64 // We have only one result, for (potentially) two IP's,
Chris@102 65 // so we take a first one
Chris@102 66 return_type result;
Chris@102 67
Chris@102 68 if (ra_from_wrt_b.on_segment())
Chris@102 69 {
Chris@102 70 result.assign(Ratio::zero(), ra_from_wrt_b);
Chris@102 71 }
Chris@102 72 else if (rb_from_wrt_a.in_segment())
Chris@102 73 {
Chris@102 74 result.assign(rb_from_wrt_a, Ratio::zero());
Chris@102 75 }
Chris@102 76 else if (ra_to_wrt_b.on_segment())
Chris@102 77 {
Chris@102 78 result.assign(Ratio::one(), ra_to_wrt_b);
Chris@102 79 }
Chris@102 80 else if (rb_to_wrt_a.in_segment())
Chris@102 81 {
Chris@102 82 result.assign(rb_to_wrt_a, Ratio::one());
Chris@102 83 }
Chris@102 84
Chris@102 85 return result;
Chris@102 86 }
Chris@102 87
Chris@102 88 static inline return_type disjoint()
Chris@102 89 {
Chris@102 90 return return_type();
Chris@102 91 }
Chris@102 92 static inline return_type error(std::string const&)
Chris@102 93 {
Chris@102 94 return return_type();
Chris@102 95 }
Chris@102 96
Chris@102 97 template <typename Segment>
Chris@102 98 static inline return_type degenerate(Segment const& segment, bool)
Chris@102 99 {
Chris@102 100 return return_type();
Chris@102 101 }
Chris@102 102
Chris@102 103 template <typename Segment, typename Ratio>
Chris@102 104 static inline return_type one_degenerate(Segment const& ,
Chris@102 105 Ratio const& ratio, bool a_degenerate)
Chris@102 106 {
Chris@102 107 return_type result;
Chris@102 108 if (a_degenerate)
Chris@102 109 {
Chris@102 110 // IP lies on ratio w.r.t. segment b
Chris@102 111 result.assign(Ratio::zero(), ratio);
Chris@102 112 }
Chris@102 113 else
Chris@102 114 {
Chris@102 115 result.assign(ratio, Ratio::zero());
Chris@102 116 }
Chris@102 117 return result;
Chris@102 118 }
Chris@102 119
Chris@102 120 };
Chris@102 121
Chris@102 122
Chris@102 123 }} // namespace policies::relate
Chris@102 124
Chris@102 125 }} // namespace boost::geometry
Chris@102 126
Chris@102 127 #endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_RATIOS_HPP