]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/is_valid/segment.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / is_valid / segment.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2019, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
13
14 #include <boost/core/ignore_unused.hpp>
15
16 #include <boost/geometry/core/point_type.hpp>
17 #include <boost/geometry/core/tags.hpp>
18
19 #include <boost/geometry/algorithms/assign.hpp>
20 #include <boost/geometry/algorithms/validity_failure_type.hpp>
21 #include <boost/geometry/algorithms/detail/equals/point_point.hpp>
22 #include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
23 #include <boost/geometry/algorithms/dispatch/is_valid.hpp>
24
25
26 namespace boost { namespace geometry
27 {
28
29
30
31 #ifndef DOXYGEN_NO_DISPATCH
32 namespace dispatch
33 {
34
35
36 // A segment is a curve.
37 // A curve is simple if it does not pass through the same point twice,
38 // with the possible exception of its two endpoints
39 // A curve is 1-dimensional, hence we have to check is the two
40 // endpoints of the segment coincide, since in this case it is
41 // 0-dimensional.
42 //
43 // Reference: OGC 06-103r4 (6.1.6.1)
44 template <typename Segment>
45 struct is_valid<Segment, segment_tag>
46 {
47 template <typename VisitPolicy, typename Strategy>
48 static inline bool apply(Segment const& segment, VisitPolicy& visitor, Strategy const&)
49 {
50 typedef typename Strategy::equals_point_point_strategy_type eq_pp_strategy_type;
51
52 boost::ignore_unused(visitor);
53
54 typename point_type<Segment>::type p[2];
55 detail::assign_point_from_index<0>(segment, p[0]);
56 detail::assign_point_from_index<1>(segment, p[1]);
57
58 if (detail::is_valid::has_invalid_coordinate
59 <
60 Segment
61 >::apply(segment, visitor))
62 {
63 return false;
64 }
65 else if (! geometry::detail::equals::equals_point_point(
66 p[0], p[1], eq_pp_strategy_type()))
67 {
68 return visitor.template apply<no_failure>();
69 }
70 else
71 {
72 return
73 visitor.template apply<failure_wrong_topological_dimension>();
74 }
75 }
76 };
77
78
79 } // namespace dispatch
80 #endif // DOXYGEN_NO_DISPATCH
81
82
83 }} // namespace boost::geometry
84
85
86 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP