]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/relation/interface.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / relation / interface.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5// This file was modified by Oracle on 2013, 2014, 2015.
6// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates.
7
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
15#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
16
17
18#include <boost/geometry/algorithms/detail/relate/interface.hpp>
19
20
21namespace boost { namespace geometry
22{
23
24#ifndef DOXYGEN_NO_DETAIL
25namespace detail { namespace relate
26{
27
28template <typename Geometry1, typename Geometry2>
29struct result_handler_type<Geometry1, Geometry2, geometry::de9im::matrix, false>
30{
31 typedef matrix_handler<geometry::de9im::matrix> type;
32};
33
34
35}} // namespace detail::relate
36#endif // DOXYGEN_NO_DETAIL
37
38
39namespace resolve_variant
40{
41
42template <typename Geometry1, typename Geometry2>
43struct relation
44{
45 template <typename Matrix>
46 static inline Matrix apply(Geometry1 const& geometry1,
47 Geometry2 const& geometry2)
48 {
49 concepts::check<Geometry1 const>();
50 concepts::check<Geometry2 const>();
51 assert_dimension_equal<Geometry1, Geometry2>();
52
53 typename detail::relate::result_handler_type
54 <
55 Geometry1,
56 Geometry2,
57 Matrix
58 >::type handler;
59
60 dispatch::relate
61 <
62 Geometry1,
63 Geometry2
64 >::apply(geometry1, geometry2, handler);
65
66 return handler.result();
67 }
68};
69
70template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
71struct relation<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
72{
73 template <typename Matrix>
74 struct visitor : boost::static_visitor<Matrix>
75 {
76 Geometry2 const& m_geometry2;
77
78 visitor(Geometry2 const& geometry2)
79 : m_geometry2(geometry2) {}
80
81 template <typename Geometry1>
82 Matrix operator()(Geometry1 const& geometry1) const
83 {
84 return relation<Geometry1, Geometry2>
85 ::template apply<Matrix>(geometry1, m_geometry2);
86 }
87 };
88
89 template <typename Matrix>
90 static inline Matrix
91 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
92 Geometry2 const& geometry2)
93 {
94 return boost::apply_visitor(visitor<Matrix>(geometry2), geometry1);
95 }
96};
97
98template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
99struct relation<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
100{
101 template <typename Matrix>
102 struct visitor : boost::static_visitor<Matrix>
103 {
104 Geometry1 const& m_geometry1;
105
106 visitor(Geometry1 const& geometry1)
107 : m_geometry1(geometry1) {}
108
109 template <typename Geometry2>
110 Matrix operator()(Geometry2 const& geometry2) const
111 {
112 return relation<Geometry1, Geometry2>
113 ::template apply<Matrix>(m_geometry1, geometry2);
114 }
115 };
116
117 template <typename Matrix>
118 static inline Matrix
119 apply(Geometry1 const& geometry1,
120 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2)
121 {
122 return boost::apply_visitor(visitor<Matrix>(geometry1), geometry2);
123 }
124};
125
126template
127<
128 BOOST_VARIANT_ENUM_PARAMS(typename T1),
129 BOOST_VARIANT_ENUM_PARAMS(typename T2)
130>
131struct relation
132 <
133 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
134 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
135 >
136{
137 template <typename Matrix>
138 struct visitor : boost::static_visitor<Matrix>
139 {
140 template <typename Geometry1, typename Geometry2>
141 Matrix operator()(Geometry1 const& geometry1,
142 Geometry2 const& geometry2) const
143 {
144 return relation<Geometry1, Geometry2>
145 ::template apply<Matrix>(geometry1, geometry2);
146 }
147 };
148
149 template <typename Matrix>
150 static inline Matrix
151 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
152 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2)
153 {
154 return boost::apply_visitor(visitor<Matrix>(), geometry1, geometry2);
155 }
156};
157
158} // namespace resolve_variant
159
160
161/*!
162\brief Calculates the relation between a pair of geometries as defined in DE-9IM.
163\ingroup relation
164\tparam Geometry1 \tparam_geometry
165\tparam Geometry2 \tparam_geometry
166\param geometry1 \param_geometry
167\param geometry2 \param_geometry
168\return The DE-9IM matrix expressing the relation between geometries.
169
170\qbk{[include reference/algorithms/relation.qbk]}
171 */
172template <typename Geometry1, typename Geometry2>
173inline de9im::matrix relation(Geometry1 const& geometry1,
174 Geometry2 const& geometry2)
175{
176 return resolve_variant::relation
177 <
178 Geometry1,
179 Geometry2
180 >::template apply<de9im::matrix>(geometry1, geometry2);
181}
182
183
184}} // namespace boost::geometry
185
186#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP