Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:07

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2019, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP
0013 
0014 #include <boost/core/ignore_unused.hpp>
0015 
0016 #include <boost/geometry/core/point_type.hpp>
0017 #include <boost/geometry/core/tags.hpp>
0018 
0019 #include <boost/geometry/algorithms/assign.hpp>
0020 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0021 #include <boost/geometry/algorithms/detail/equals/point_point.hpp>
0022 #include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
0023 #include <boost/geometry/algorithms/dispatch/is_valid.hpp>
0024 
0025 
0026 namespace boost { namespace geometry
0027 {
0028 
0029 
0030 
0031 #ifndef DOXYGEN_NO_DISPATCH
0032 namespace dispatch
0033 {
0034 
0035 
0036 // A segment is a curve.
0037 // A curve is simple if it does not pass through the same point twice,
0038 // with the possible exception of its two endpoints
0039 // A curve is 1-dimensional, hence we have to check is the two
0040 // endpoints of the segment coincide, since in this case it is
0041 // 0-dimensional.
0042 //
0043 // Reference: OGC 06-103r4 (6.1.6.1)
0044 template <typename Segment>
0045 struct is_valid<Segment, segment_tag>
0046 {
0047     template <typename VisitPolicy, typename Strategy>
0048     static inline bool apply(Segment const& segment, VisitPolicy& visitor, Strategy const& strategy)
0049     {
0050         boost::ignore_unused(visitor);
0051 
0052         typename point_type<Segment>::type p[2];
0053         detail::assign_point_from_index<0>(segment, p[0]);
0054         detail::assign_point_from_index<1>(segment, p[1]);
0055 
0056         if (detail::is_valid::has_invalid_coordinate
0057                 <
0058                     Segment
0059                 >::apply(segment, visitor))
0060         {
0061             return false;
0062         }
0063         else if (! detail::equals::equals_point_point(p[0], p[1], strategy))
0064         {
0065             return visitor.template apply<no_failure>();
0066         }
0067         else
0068         {
0069             return
0070                 visitor.template apply<failure_wrong_topological_dimension>();
0071         }
0072     }
0073 };
0074 
0075 
0076 } // namespace dispatch
0077 #endif // DOXYGEN_NO_DISPATCH
0078 
0079 
0080 }} // namespace boost::geometry
0081 
0082 
0083 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_SEGMENT_HPP