Skip to content

Commit dc7c173

Browse files
committed
[traverse] dont use blocked turns for region, and simplify
expressions by static consts
1 parent 18eb8c5 commit dc7c173

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ template
4848
>
4949
struct traversal_switch_detector
5050
{
51+
static const operation_type target_operation
52+
= operation_from_overlay<OverlayType>::value;
53+
static const operation_type opposite_operation
54+
= target_operation == operation_union
55+
? operation_intersection
56+
: operation_union;
57+
5158
enum isolation_type
5259
{
5360
isolation_unknown = -1,
@@ -322,6 +329,12 @@ struct traversal_switch_detector
322329
{
323330
turn_type& turn = m_turns[*sit];
324331

332+
if (! acceptable(turn))
333+
{
334+
// No assignment necessary
335+
continue;
336+
}
337+
325338
for (int i = 0; i < 2; i++)
326339
{
327340
turn_operation_type& op = turn.operations[i];
@@ -382,12 +395,19 @@ struct traversal_switch_detector
382395
}
383396
}
384397

398+
inline bool acceptable(turn_type const& turn) const
399+
{
400+
// Discarded turns don't connect rings to the same region
401+
// Also xx are not relevant
402+
// (otherwise discarded colocated uu turn could make a connection)
403+
return ! turn.discarded
404+
&& ! turn.both(operation_blocked);
405+
}
406+
385407
inline bool connects_same_region(turn_type const& turn) const
386408
{
387-
if (turn.discarded)
409+
if (! acceptable(turn))
388410
{
389-
// Discarded turns don't connect same region (otherwise discarded colocated uu turn
390-
// could make a connection)
391411
return false;
392412
}
393413

@@ -397,7 +417,7 @@ struct traversal_switch_detector
397417
return ! (turn.both(operation_union) || turn.both(operation_intersection));
398418
}
399419

400-
if (operation_from_overlay<OverlayType>::value == operation_union)
420+
if (target_operation == operation_union)
401421
{
402422
// It is a cluster, check zones
403423
// (assigned by sort_by_side/handle colocations) of both operations
@@ -492,8 +512,7 @@ struct traversal_switch_detector
492512
{
493513
turn_type const& turn = m_turns[turn_index];
494514

495-
if (turn.discarded
496-
&& operation_from_overlay<OverlayType>::value == operation_intersection)
515+
if (turn.discarded && target_operation == operation_intersection)
497516
{
498517
// Discarded turn (union currently still needs it to determine regions)
499518
continue;

0 commit comments

Comments
 (0)