37
37
38
38
#include < boost/geometry/geometries/ring.hpp>
39
39
40
+ #include < boost/geometry/algorithms/detail/overlay/graph/assign_side_counts.hpp>
40
41
#include < boost/geometry/algorithms/detail/buffer/buffered_ring.hpp>
41
42
#include < boost/geometry/algorithms/detail/buffer/buffer_policies.hpp>
42
43
#include < boost/geometry/algorithms/detail/overlay/cluster_info.hpp>
44
+ #include < boost/geometry/algorithms/detail/overlay/get_properties_ahead.hpp>
45
+ #include < boost/geometry/algorithms/detail/overlay/handle_colocations.hpp>
43
46
#include < boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp>
44
47
#include < boost/geometry/algorithms/detail/buffer/piece_border.hpp>
45
48
#include < boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp>
@@ -308,7 +311,7 @@ struct buffered_piece_collection
308
311
// be three turns (which cannot be checked here - TODO: add to traverse)
309
312
for (auto & turn : m_turns)
310
313
{
311
- if (! turn.is_turn_traversable )
314
+ if (! turn.is_traversable )
312
315
{
313
316
continue ;
314
317
}
@@ -348,18 +351,18 @@ struct buffered_piece_collection
348
351
349
352
for (auto & turn : m_turns)
350
353
{
351
- if (turn.is_turn_traversable )
354
+ if (turn.is_traversable )
352
355
{
353
356
if (deflate && turn.count_in_original <= 0 )
354
357
{
355
358
// For deflate/negative buffers:
356
359
// it is not in the original, so don't use it
357
- turn.is_turn_traversable = false ;
360
+ turn.is_traversable = false ;
358
361
}
359
362
else if (! deflate && turn.count_in_original > 0 )
360
363
{
361
364
// For inflate: it is in original, so don't use it
362
- turn.is_turn_traversable = false ;
365
+ turn.is_traversable = false ;
363
366
}
364
367
}
365
368
}
@@ -439,6 +442,21 @@ struct buffered_piece_collection
439
442
detail::section::overlaps_section_box<Strategy>(m_strategy));
440
443
}
441
444
445
+ // This fixes the fact that sometimes wrong ix or xi turns are generated.
446
+ // See comments in get_turn_info (block_q).
447
+ // The ix turns are not relevant for buffer anyway, it is fine to remove them,
448
+ // as long as they are removed before calculating turn indices.
449
+ // It will also enhance performance a bit (no need to calculate point in original,
450
+ // point in piece). Therefore we remove ii and xx as well.
451
+ m_turns.erase (std::remove_if (m_turns.begin (), m_turns.end (),
452
+ [](auto const & turn)
453
+ {
454
+ bool const is_ix = turn.combination (overlay::operation_intersection, overlay::operation_blocked);
455
+ bool const is_ii = turn.both (overlay::operation_intersection);
456
+ return is_ix || is_ii || turn.blocked ();
457
+ }),
458
+ m_turns.end ());
459
+
442
460
update_turn_administration ();
443
461
}
444
462
@@ -869,29 +887,27 @@ struct buffered_piece_collection
869
887
870
888
inline void handle_colocations ()
871
889
{
872
- if (! detail::overlay::handle_colocations
873
- <
874
- false , false , overlay_buffer,
875
- ring_collection_t , ring_collection_t
876
- >(m_turns, m_clusters))
877
- {
878
- return ;
879
- }
880
-
881
- detail::overlay::gather_cluster_properties
882
- <
883
- false , false , overlay_buffer
884
- >(m_clusters, m_turns, detail::overlay::operation_union,
885
- offsetted_rings, offsetted_rings, m_strategy);
890
+ detail::overlay::handle_colocations (m_turns, m_clusters);
891
+ }
886
892
893
+ template <typename Visitor>
894
+ inline void assign_side_counts (Visitor& visitor)
895
+ {
896
+ // Assign count_left, count_right and open_count
897
+ detail::overlay::assign_side_counts
898
+ <false , false , overlay_buffer>
899
+ (offsetted_rings, offsetted_rings,
900
+ m_turns, m_clusters,
901
+ m_strategy, visitor);
902
+
903
+ // Mark closed clusters as not traversable
887
904
for (auto const & cluster : m_clusters)
888
905
{
889
- if (cluster.second .open_count == 0 && cluster. second . spike_count == 0 )
906
+ if (cluster.second .open_count == 0 )
890
907
{
891
- // If the cluster is completely closed, mark it as not traversable.
892
908
for (auto const & index : cluster.second .turn_indices )
893
909
{
894
- m_turns[index ].is_turn_traversable = false ;
910
+ m_turns[index ].is_traversable = false ;
895
911
}
896
912
}
897
913
}
@@ -904,7 +920,7 @@ struct buffered_piece_collection
904
920
bool is_traversable = false ;
905
921
for (auto const & index : cluster.second .turn_indices )
906
922
{
907
- if (m_turns[index ].is_turn_traversable )
923
+ if (m_turns[index ].is_traversable )
908
924
{
909
925
// If there is one turn traversable in the cluster,
910
926
// then all turns should be traversable.
@@ -916,17 +932,21 @@ struct buffered_piece_collection
916
932
{
917
933
for (auto const & index : cluster.second .turn_indices )
918
934
{
919
- m_turns[index ].is_turn_traversable = true ;
935
+ m_turns[index ].is_traversable = true ;
920
936
}
921
937
}
922
938
}
923
939
}
924
940
925
941
inline void enrich ()
926
942
{
927
- enrich_intersection_points<false , false , overlay_buffer>(m_turns,
928
- m_clusters, offsetted_rings, offsetted_rings,
929
- m_strategy);
943
+ detail::overlay::enrich_discard_turns<overlay_buffer>(
944
+ m_turns, m_clusters, offsetted_rings, offsetted_rings, m_strategy);
945
+ detail::overlay::enrich_turns<false , false , overlay_buffer>(
946
+ m_turns, offsetted_rings, offsetted_rings, m_strategy);
947
+
948
+ detail::overlay::get_properties_ahead<false , false >(m_turns, m_clusters, offsetted_rings,
949
+ offsetted_rings, m_strategy);
930
950
}
931
951
932
952
// Discards all rings which do have not-OK intersection points only.
@@ -935,7 +955,7 @@ struct buffered_piece_collection
935
955
{
936
956
for (auto const & turn : m_turns)
937
957
{
938
- if (turn.is_turn_traversable )
958
+ if (turn.is_traversable )
939
959
{
940
960
offsetted_rings[turn.operations [0 ].seg_id .multi_index ].has_accepted_intersections = true ;
941
961
offsetted_rings[turn.operations [1 ].seg_id .multi_index ].has_accepted_intersections = true ;
@@ -1013,28 +1033,27 @@ struct buffered_piece_collection
1013
1033
}
1014
1034
}
1015
1035
1016
- inline void block_turns ()
1036
+ inline void discard_non_traversable_turns ()
1017
1037
{
1018
1038
for (auto & turn : m_turns)
1019
1039
{
1020
- if (! turn.is_turn_traversable )
1040
+ if (! turn.is_traversable )
1021
1041
{
1022
- // Discard this turn (don't set it to blocked to avoid colocated
1023
- // clusters being discarded afterwards
1042
+ // Discard the non traversable turn
1024
1043
turn.discarded = true ;
1025
1044
}
1026
1045
}
1027
1046
}
1028
1047
1029
- inline void traverse ()
1048
+ template <typename PieceVisitor>
1049
+ inline void traverse (PieceVisitor const & piece_visitor)
1030
1050
{
1031
1051
using traverser = detail::overlay::traverse
1032
1052
<
1033
1053
false , false ,
1034
1054
buffered_ring_collection<buffered_ring<Ring> >,
1035
1055
buffered_ring_collection<buffered_ring<Ring > >,
1036
- overlay_buffer,
1037
- backtrack_for_buffer
1056
+ overlay_buffer
1038
1057
>;
1039
1058
std::map<ring_identifier, overlay::ring_turn_info> turn_info_per_ring;
1040
1059
0 commit comments