annotate DEPENDENCIES/generic/include/boost/geometry/strategies/distance_result.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +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-2015 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
Chris@102 5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
Chris@102 6 // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
Chris@102 7 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
Chris@102 8
Chris@102 9 // This file was modified by Oracle on 2014, 2015.
Chris@102 10 // Modifications copyright (c) 2014-2015, Oracle and/or its affiliates.
Chris@102 11
Chris@102 12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
Chris@102 13
Chris@102 14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@102 15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@102 16
Chris@102 17 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 18 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 19 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 20
Chris@102 21 #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
Chris@102 22 #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
Chris@102 23
Chris@102 24 #include <boost/mpl/always.hpp>
Chris@102 25 #include <boost/mpl/bool.hpp>
Chris@102 26 #include <boost/mpl/vector.hpp>
Chris@102 27
Chris@102 28 #include <boost/variant/variant_fwd.hpp>
Chris@102 29
Chris@102 30 #include <boost/geometry/core/point_type.hpp>
Chris@102 31
Chris@102 32 #include <boost/geometry/strategies/default_strategy.hpp>
Chris@102 33 #include <boost/geometry/strategies/distance.hpp>
Chris@102 34
Chris@102 35 #include <boost/geometry/util/compress_variant.hpp>
Chris@102 36 #include <boost/geometry/util/transform_variant.hpp>
Chris@102 37 #include <boost/geometry/util/combine_if.hpp>
Chris@102 38
Chris@102 39 #include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
Chris@102 40
Chris@102 41
Chris@102 42 namespace boost { namespace geometry
Chris@102 43 {
Chris@102 44
Chris@102 45
Chris@102 46 namespace resolve_strategy
Chris@102 47 {
Chris@102 48
Chris@102 49 template <typename Geometry1, typename Geometry2, typename Strategy>
Chris@102 50 struct distance_result
Chris@102 51 : strategy::distance::services::return_type
Chris@102 52 <
Chris@102 53 Strategy,
Chris@102 54 typename point_type<Geometry1>::type,
Chris@102 55 typename point_type<Geometry2>::type
Chris@102 56 >
Chris@102 57 {};
Chris@102 58
Chris@102 59 template <typename Geometry1, typename Geometry2>
Chris@102 60 struct distance_result<Geometry1, Geometry2, default_strategy>
Chris@102 61 : distance_result
Chris@102 62 <
Chris@102 63 Geometry1,
Chris@102 64 Geometry2,
Chris@102 65 typename detail::distance::default_strategy
Chris@102 66 <
Chris@102 67 Geometry1, Geometry2
Chris@102 68 >::type
Chris@102 69 >
Chris@102 70 {};
Chris@102 71
Chris@102 72 } // namespace resolve_strategy
Chris@102 73
Chris@102 74
Chris@102 75 namespace resolve_variant
Chris@102 76 {
Chris@102 77
Chris@102 78 template <typename Geometry1, typename Geometry2, typename Strategy>
Chris@102 79 struct distance_result
Chris@102 80 : resolve_strategy::distance_result
Chris@102 81 <
Chris@102 82 Geometry1,
Chris@102 83 Geometry2,
Chris@102 84 Strategy
Chris@102 85 >
Chris@102 86 {};
Chris@102 87
Chris@102 88
Chris@102 89 template
Chris@102 90 <
Chris@102 91 typename Geometry1,
Chris@102 92 BOOST_VARIANT_ENUM_PARAMS(typename T),
Chris@102 93 typename Strategy
Chris@102 94 >
Chris@102 95 struct distance_result
Chris@102 96 <
Chris@102 97 Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
Chris@102 98 >
Chris@102 99 {
Chris@102 100 // A set of all variant type combinations that are compatible and
Chris@102 101 // implemented
Chris@102 102 typedef typename util::combine_if<
Chris@102 103 typename boost::mpl::vector1<Geometry1>,
Chris@102 104 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
Chris@102 105 // Here we want should remove most of the combinations that
Chris@102 106 // are not valid, mostly to limit the size of the resulting MPL set.
Chris@102 107 // But is_implementedn is not ready for prime time
Chris@102 108 //
Chris@102 109 // util::is_implemented2<boost::mpl::_1, boost::mpl::_2, dispatch::distance<boost::mpl::_1, boost::mpl::_2> >
Chris@102 110 boost::mpl::always<boost::mpl::true_>
Chris@102 111 >::type possible_input_types;
Chris@102 112
Chris@102 113 // The (possibly variant) result type resulting from these combinations
Chris@102 114 typedef typename compress_variant<
Chris@102 115 typename transform_variant<
Chris@102 116 possible_input_types,
Chris@102 117 resolve_strategy::distance_result<
Chris@102 118 boost::mpl::first<boost::mpl::_>,
Chris@102 119 boost::mpl::second<boost::mpl::_>,
Chris@102 120 Strategy
Chris@102 121 >,
Chris@102 122 boost::mpl::back_inserter<boost::mpl::vector0<> >
Chris@102 123 >::type
Chris@102 124 >::type type;
Chris@102 125 };
Chris@102 126
Chris@102 127
Chris@102 128 // Distance arguments are commutative
Chris@102 129 template
Chris@102 130 <
Chris@102 131 BOOST_VARIANT_ENUM_PARAMS(typename T),
Chris@102 132 typename Geometry2,
Chris@102 133 typename Strategy
Chris@102 134 >
Chris@102 135 struct distance_result
Chris@102 136 <
Chris@102 137 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
Chris@102 138 Geometry2,
Chris@102 139 Strategy
Chris@102 140 > : public distance_result
Chris@102 141 <
Chris@102 142 Geometry2, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Strategy
Chris@102 143 >
Chris@102 144 {};
Chris@102 145
Chris@102 146
Chris@102 147 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Strategy>
Chris@102 148 struct distance_result
Chris@102 149 <
Chris@102 150 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
Chris@102 151 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
Chris@102 152 Strategy
Chris@102 153 >
Chris@102 154 {
Chris@102 155 // A set of all variant type combinations that are compatible and
Chris@102 156 // implemented
Chris@102 157 typedef typename util::combine_if
Chris@102 158 <
Chris@102 159 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
Chris@102 160 typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types,
Chris@102 161 // Here we want to try to remove most of the combinations
Chris@102 162 // that are not valid, mostly to limit the size of the
Chris@102 163 // resulting MPL vector.
Chris@102 164 // But is_implemented is not ready for prime time
Chris@102 165 //
Chris@102 166 // util::is_implemented2<boost::mpl::_1, boost::mpl::_2, dispatch::distance<boost::mpl::_1, boost::mpl::_2> >
Chris@102 167 boost::mpl::always<boost::mpl::true_>
Chris@102 168 >::type possible_input_types;
Chris@102 169
Chris@102 170 // The (possibly variant) result type resulting from these combinations
Chris@102 171 typedef typename compress_variant<
Chris@102 172 typename transform_variant<
Chris@102 173 possible_input_types,
Chris@102 174 resolve_strategy::distance_result<
Chris@102 175 boost::mpl::first<boost::mpl::_>,
Chris@102 176 boost::mpl::second<boost::mpl::_>,
Chris@102 177 Strategy
Chris@102 178 >,
Chris@102 179 boost::mpl::back_inserter<boost::mpl::vector0<> >
Chris@102 180 >::type
Chris@102 181 >::type type;
Chris@102 182 };
Chris@102 183
Chris@102 184 } // namespace resolve_variant
Chris@102 185
Chris@102 186
Chris@102 187 /*!
Chris@102 188 \brief Meta-function defining return type of distance function
Chris@102 189 \ingroup distance
Chris@102 190 \note The strategy defines the return-type (so this situation is different
Chris@102 191 from length, where distance is sqr/sqrt, but length always squared)
Chris@102 192 */
Chris@102 193 template
Chris@102 194 <
Chris@102 195 typename Geometry1,
Chris@102 196 typename Geometry2 = Geometry1,
Chris@102 197 typename Strategy = void
Chris@102 198 >
Chris@102 199 struct distance_result
Chris@102 200 : resolve_variant::distance_result<Geometry1, Geometry2, Strategy>
Chris@102 201 {};
Chris@102 202
Chris@102 203
Chris@102 204 template <typename Geometry1, typename Geometry2>
Chris@102 205 struct distance_result<Geometry1, Geometry2, void>
Chris@102 206 : distance_result<Geometry1, Geometry2, default_strategy>
Chris@102 207 {};
Chris@102 208
Chris@102 209
Chris@102 210 }} // namespace boost::geometry
Chris@102 211
Chris@102 212
Chris@102 213 #endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP