Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-21 08:45:50

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2025 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // Use, modification and distribution is subject to the Boost Software License,
0006 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_TOI_BY_INCOMING_HPP
0010 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_TOI_BY_INCOMING_HPP
0011 
0012 #include <boost/geometry/algorithms/detail/overlay/turn_operation_id.hpp>
0013 
0014 
0015 namespace boost { namespace geometry
0016 {
0017 
0018 #ifndef DOXYGEN_NO_DETAIL
0019 namespace detail { namespace overlay
0020 {
0021 
0022 // For two operations from a cluster, having the same target, and having the same rank,
0023 // the outgoing side makes it unclear. This function inspects the target and uses the incoming
0024 // side, which should be more clear.
0025 template <typename Turns, typename Operation>
0026 bool select_toi_for_union(turn_operation_id& result, Operation const& op0, Operation const& op1, 
0027         turn_operation_id const& toi0, turn_operation_id const& toi1,
0028         Turns const& turns)
0029 {
0030     if (op0.enriched.travels_to_ip_index != op1.enriched.travels_to_ip_index
0031         || op0.enriched.travels_to_ip_index < 0)
0032     {
0033         // Not the same target
0034         return false;
0035     }
0036     auto const& target_turn = turns[op0.enriched.travels_to_ip_index];
0037     auto const& target_op0 = target_turn.operations[0];
0038     auto const& target_op1 = target_turn.operations[1];
0039 
0040     bool const is_target_for_union0 = target_op0.enriched.count_left_incoming == 0;
0041     bool const is_target_for_union1 = target_op1.enriched.count_left_incoming == 0;
0042     if (is_target_for_union0 == is_target_for_union1)
0043     {
0044         // There is no incoming operation usable for union, or both are the same.
0045         return false;
0046     }
0047 
0048 #if defined(BOOST_GEOMETRY_DEBUG_TRAVERSE_GRAPH)
0049     std::cout << "SELECT_BY_INCOMING " << toi0 << " vs " << toi1
0050         << " " << operation_char(op0.operation) << operation_char(op1.operation)
0051         << " traveling to " << op0.enriched.travels_to_ip_index
0052         << std::endl;
0053 #endif
0054 
0055     if (target_op0.seg_id.multi_index == target_op1.seg_id.multi_index)
0056     {
0057         // They have the same ring (should not occur normally, in buffer)
0058         // so they cannot be used for selection.
0059         return false;
0060     }
0061 
0062     if (is_target_for_union0)
0063     {
0064         if (target_op0.seg_id.multi_index == op0.seg_id.multi_index)
0065         {
0066             result = toi0;
0067             return true;
0068         }
0069         if (target_op0.seg_id.multi_index == op1.seg_id.multi_index)
0070         {
0071             result = toi1;
0072             return true;
0073         }
0074     }
0075     else
0076     {
0077         if (target_op1.seg_id.multi_index == op0.seg_id.multi_index)
0078         {
0079             result = toi0;
0080             return true;
0081         }
0082         if (target_op1.seg_id.multi_index == op1.seg_id.multi_index)
0083         {
0084             result = toi1;
0085             return true;
0086         }
0087     }
0088     return false;
0089 }
0090 
0091 }} // namespace detail::overlay
0092 #endif // DOXYGEN_NO_DETAIL
0093 
0094 }} // namespace boost::geometry
0095 
0096 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_TOI_BY_INCOMING_HPP