Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:44

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014-2020.
0008 // Modifications copyright (c) 2014-2020, Oracle and/or its affiliates.
0009 
0010 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0011 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0012 
0013 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0014 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0015 
0016 // Use, modification and distribution is subject to the Boost Software License,
0017 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0018 // http://www.boost.org/LICENSE_1_0.txt)
0019 
0020 #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
0021 #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
0022 
0023 #include <iterator>
0024 #include <type_traits>
0025 #include <vector>
0026 
0027 #include <boost/concept_check.hpp>
0028 #include <boost/core/ignore_unused.hpp>
0029 
0030 #include <boost/geometry/core/static_assert.hpp>
0031 
0032 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0033 #include <boost/geometry/geometries/segment.hpp>
0034 #include <boost/geometry/geometries/point.hpp>
0035 
0036 #include <boost/geometry/strategies/distance.hpp>
0037 #include <boost/geometry/strategies/tags.hpp>
0038 
0039 #include <boost/geometry/util/parameter_type_of.hpp>
0040 
0041 
0042 namespace boost { namespace geometry { namespace concepts
0043 {
0044 
0045 
0046 /*!
0047     \brief Checks strategy for point-point or point-box or box-box distance
0048     \ingroup distance
0049 */
0050 template <typename Strategy, typename Point1, typename Point2>
0051 struct PointDistanceStrategy
0052 {
0053 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0054 private :
0055 
0056     struct checker
0057     {
0058         template <typename ApplyMethod>
0059         static void apply(ApplyMethod)
0060         {
0061             // 1: inspect and define both arguments of apply
0062             typedef typename parameter_type_of
0063                 <
0064                     ApplyMethod, 0
0065                 >::type ptype1;
0066 
0067             typedef typename parameter_type_of
0068                 <
0069                     ApplyMethod, 1
0070                 >::type ptype2;
0071 
0072             // 2) must define meta-function "return_type"
0073             typedef typename strategy::distance::services::return_type
0074                 <
0075                     Strategy, ptype1, ptype2
0076                 >::type rtype;
0077 
0078             // 3) must define meta-function "comparable_type"
0079             typedef typename strategy::distance::services::comparable_type
0080                 <
0081                     Strategy
0082                 >::type ctype;
0083 
0084             // 4) must define meta-function "tag"
0085             typedef typename strategy::distance::services::tag
0086                 <
0087                     Strategy
0088                 >::type tag;
0089 
0090             static const bool is_correct_strategy_tag =
0091                 std::is_same<tag, strategy_tag_distance_point_point>::value
0092                 || std::is_same<tag, strategy_tag_distance_point_box>::value
0093                 || std::is_same<tag, strategy_tag_distance_box_box>::value;
0094 
0095             BOOST_GEOMETRY_STATIC_ASSERT(
0096                  is_correct_strategy_tag,
0097                  "Incorrect Strategy tag.",
0098                  Strategy, tag);
0099 
0100             // 5) must implement apply with arguments
0101             Strategy* str = 0;
0102             ptype1 *p1 = 0;
0103             ptype2 *p2 = 0;
0104             rtype r = str->apply(*p1, *p2);
0105 
0106             // 6) must define (meta)struct "get_comparable" with apply
0107             ctype c = strategy::distance::services::get_comparable
0108                 <
0109                     Strategy
0110                 >::apply(*str);
0111 
0112             // 7) must define (meta)struct "result_from_distance" with apply
0113             r = strategy::distance::services::result_from_distance
0114                 <
0115                     Strategy,
0116                     ptype1, ptype2
0117                 >::apply(*str, 1.0);
0118 
0119             boost::ignore_unused<tag>();
0120             boost::ignore_unused(str, c, r);
0121         }
0122     };
0123 
0124 
0125 
0126 public :
0127     BOOST_CONCEPT_USAGE(PointDistanceStrategy)
0128     {
0129         checker::apply(&Strategy::template apply<Point1, Point2>);
0130     }
0131 #endif
0132 };
0133 
0134 
0135 /*!
0136     \brief Checks strategy for point-segment distance
0137     \ingroup strategy_concepts
0138 */
0139 template <typename Strategy, typename Point, typename PointOfSegment>
0140 struct PointSegmentDistanceStrategy
0141 {
0142 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0143 private :
0144 
0145     struct checker
0146     {
0147         template <typename ApplyMethod>
0148         static void apply(ApplyMethod)
0149         {
0150             // 1) inspect and define both arguments of apply
0151             typedef typename parameter_type_of
0152                 <
0153                     ApplyMethod, 0
0154                 >::type ptype;
0155 
0156             typedef typename parameter_type_of
0157                 <
0158                     ApplyMethod, 1
0159                 >::type sptype;
0160 
0161             namespace services = strategy::distance::services;
0162             // 2) must define meta-function "tag"
0163             typedef typename services::tag<Strategy>::type tag;
0164 
0165             BOOST_GEOMETRY_STATIC_ASSERT(
0166                 (std::is_same
0167                     <
0168                         tag, strategy_tag_distance_point_segment
0169                     >::value),
0170                 "Incorrect Strategy tag.",
0171                 Strategy, tag);
0172 
0173             // 3) must define meta-function "return_type"
0174             typedef typename services::return_type
0175                 <
0176                     Strategy, ptype, sptype
0177                 >::type rtype;
0178 
0179             // 4) must define meta-function "comparable_type"
0180             typedef typename services::comparable_type<Strategy>::type ctype;
0181 
0182             // 5) must implement apply with arguments
0183             Strategy *str = 0;
0184             ptype *p = 0;
0185             sptype *sp1 = 0;
0186             sptype *sp2 = 0;
0187 
0188             rtype r = str->apply(*p, *sp1, *sp2);
0189 
0190             // 6) must define (meta-)struct "get_comparable" with apply
0191             ctype cstrategy = services::get_comparable<Strategy>::apply(*str);
0192 
0193             // 7) must define (meta-)struct "result_from_distance" with apply
0194             r = services::result_from_distance
0195                 <
0196                     Strategy, ptype, sptype
0197                 >::apply(*str, rtype(1.0));
0198 
0199             boost::ignore_unused(str, r, cstrategy);
0200         }
0201     };
0202 
0203 public :
0204     BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy)
0205     {
0206         checker::apply(&Strategy::template apply<Point, PointOfSegment>);
0207     }
0208 #endif
0209 };
0210 
0211 
0212 }}} // namespace boost::geometry::concepts
0213 
0214 
0215 #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP