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