Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:35:15

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2013-2023 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2015-2024.
0009 // Modifications copyright (c) 2015-2024 Oracle and/or its affiliates.
0010 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0011 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0012 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_IS_EQUAL_OR_SPIKE_HPP
0019 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_IS_EQUAL_OR_SPIKE_HPP
0020 
0021 #include <boost/geometry/algorithms/detail/direction_code.hpp>
0022 #include <boost/geometry/core/cs.hpp>
0023 #include <boost/geometry/strategies/side.hpp>
0024 #include <boost/geometry/util/constexpr.hpp>
0025 #include <boost/geometry/util/math.hpp>
0026 
0027 
0028 namespace boost { namespace geometry
0029 {
0030 
0031 
0032 #ifndef DOXYGEN_NO_DETAIL
0033 namespace detail
0034 {
0035 
0036 // Checks if a point ("last_point") causes a spike w.r.t.
0037 // the specified two other points (segment_a, segment_b)
0038 //
0039 //  x-------x------x
0040 //  a       lp     b
0041 //
0042 // Above, lp generates a spike w.r.t. segment(a,b)
0043 // So specify last point first, then (a,b)
0044 // The segment's orientation does matter: if lp is to the right of b
0045 // no spike is reported
0046 template
0047 <
0048     typename Point1, typename Point2, typename Point3,
0049     typename SideStrategy
0050 >
0051 inline bool point_is_spike_or_equal(Point1 const& last_point, // prev | back
0052                                     Point2 const& segment_a,  // next | back - 2
0053                                     Point3 const& segment_b,  // curr | back - 1 | spike's vertex
0054                                     SideStrategy const& strategy)
0055 {
0056     using cs_tag = typename SideStrategy::cs_tag;
0057 
0058     int const side = strategy.apply(segment_a, segment_b, last_point);
0059     if (side == 0)
0060     {
0061         // Last point is collinear w.r.t previous segment.
0062         return direction_code<cs_tag>(segment_a, segment_b, last_point) < 1;
0063     }
0064     return false;
0065 }
0066 
0067 template
0068 <
0069     typename Point1,
0070     typename Point2,
0071     typename Point3,
0072     typename SideStrategy
0073 >
0074 inline bool point_is_collinear(Point1 const& last_point,
0075             Point2 const& segment_a,
0076             Point3 const& segment_b,
0077             SideStrategy const& strategy)
0078 {
0079     int const side = strategy.apply(segment_a, segment_b, last_point);
0080     if (side == 0)
0081     {
0082         return true;
0083     }
0084     return false;
0085 }
0086 
0087 
0088 //! Version with intuitive order (A, B, C). The original order was
0089 //! unclear (C, A, B). It was used in a different way in has_spikes.
0090 //! On longer term the C,A,B version can be deprecated
0091 template
0092 <
0093     typename Point1,
0094     typename Point2,
0095     typename Point3,
0096     typename SideStrategy
0097 >
0098 inline bool is_spike_or_equal(Point1 const& a,
0099             Point2 const& b,
0100             Point3 const& c,
0101             SideStrategy const& strategy)
0102 {
0103     return point_is_spike_or_equal(c, a, b, strategy);
0104 }
0105 
0106 
0107 } // namespace detail
0108 #endif
0109 
0110 }} // namespace boost::geometry
0111 
0112 
0113 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_IS_EQUAL_OR_SPIKE_HPP