54
54
#include < boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
55
55
#include < boost/geometry/algorithms/detail/overlay/traverse.hpp>
56
56
#include < boost/geometry/algorithms/detail/overlay/turn_info.hpp>
57
- #include < boost/geometry/algorithms/detail/partition .hpp>
57
+ #include < boost/geometry/algorithms/detail/partition_lambda .hpp>
58
58
#include < boost/geometry/algorithms/detail/sections/sectionalize.hpp>
59
59
#include < boost/geometry/algorithms/detail/sections/section_box_policies.hpp>
60
60
@@ -358,22 +358,59 @@ struct buffered_piece_collection
358
358
// Check if a turn is inside any of the originals
359
359
inline void check_turn_in_original ()
360
360
{
361
+ auto const & strategy = m_strategy;
362
+
363
+ struct specific_options : experimental::partition_options
364
+ {
365
+ struct include_turn_policy
366
+ {
367
+ static inline bool apply (buffer_turn_info_type const & turn)
368
+ {
369
+ return turn.is_turn_traversable && ! turn.within_original ;
370
+ }
371
+ };
372
+
373
+ using include_policy1 = include_turn_policy;
374
+ };
375
+
361
376
turn_in_original_visitor
362
377
<
363
378
turn_vector_type,
364
379
Strategy
365
380
> visitor (m_turns, m_strategy);
366
381
367
- geometry::partition
382
+ // Partition over the turns and original rings, visiting
383
+ // all turns located in an original and changing the turn's
384
+ // "count_in_original" and "within_original" values
385
+ experimental::partition
368
386
<
369
- box_type,
370
- include_turn_policy,
371
- detail::partition::include_all_policy
372
- >::apply (m_turns, original_rings, visitor,
373
- turn_get_box<Strategy>(m_strategy),
374
- turn_in_original_overlaps_box<Strategy>(m_strategy),
375
- original_get_box<Strategy>(m_strategy),
376
- original_overlaps_box<Strategy>(m_strategy));
387
+ box_type
388
+ >(m_turns, original_rings,
389
+ [&strategy](auto & box, auto const & turn)
390
+ {
391
+ geometry::expand (box, turn.point , strategy);
392
+ },
393
+ [&strategy](auto & box, auto const & turn)
394
+ {
395
+ return ! geometry::detail::disjoint::disjoint_point_box (turn.point ,
396
+ box, strategy);
397
+ },
398
+ [&strategy](auto & box, auto const & original)
399
+ {
400
+ geometry::expand (box, original.m_box , strategy);
401
+ },
402
+ [&strategy](auto & box, auto const & original)
403
+ {
404
+ return ! detail::disjoint::disjoint_box_box (box,
405
+ original.m_box , strategy);
406
+ },
407
+ [&visitor](auto const & turn, auto const & original)
408
+ {
409
+ return visitor.apply (turn, original);
410
+ },
411
+ [](auto const &, int ) {},
412
+ specific_options ()
413
+ );
377
414
378
415
bool const deflate = m_distance_strategy.negative ();
379
416
@@ -447,6 +484,8 @@ struct buffered_piece_collection
447
484
{
448
485
update_piece_administration ();
449
486
487
+ auto const & strategy = m_strategy;
488
+
450
489
{
451
490
// Calculate the turns
452
491
piece_turn_visitor
@@ -461,32 +500,75 @@ struct buffered_piece_collection
461
500
462
501
detail::sectionalize::enlarge_sections (monotonic_sections, m_strategy);
463
502
464
- geometry::partition
465
- <
466
- robust_box_type
467
- >::apply (monotonic_sections, visitor,
468
- detail::section::get_section_box<Strategy>(m_strategy),
469
- detail::section::overlaps_section_box<Strategy>(m_strategy));
503
+ experimental::partition<robust_box_type>(monotonic_sections,
504
+ [&strategy](auto & box, auto const & section)
505
+ {
506
+ geometry::expand (box, section.bounding_box , strategy);
507
+ },
508
+ [&strategy](auto const & box, auto const & section)
509
+ {
510
+ return ! detail::disjoint::disjoint_box_box (box,
511
+ section.bounding_box , strategy);
512
+ },
513
+ [&visitor](auto const & section1, auto const & section2)
514
+ {
515
+ return visitor.apply (section1, section2);
516
+ }
517
+ );
470
518
}
471
519
520
+
472
521
update_turn_administration ();
473
522
474
523
{
475
- // Check if turns are inside pieces
476
524
turn_in_piece_visitor
477
525
<
478
526
typename geometry::cs_tag<point_type>::type,
479
527
turn_vector_type, piece_vector_type, DistanceStrategy, Strategy
480
528
> visitor (m_turns, m_pieces, m_distance_strategy, m_strategy);
481
529
482
- geometry::partition
483
- <
484
- box_type
485
- >::apply (m_turns, m_pieces, visitor,
486
- turn_get_box<Strategy>(m_strategy),
487
- turn_overlaps_box<Strategy>(m_strategy),
488
- piece_get_box<Strategy>(m_strategy),
489
- piece_overlaps_box<Strategy>(m_strategy));
530
+ // Partition over the turns and pieces, checking if turns are inside pieces.
531
+ experimental::partition<box_type>(m_turns, m_pieces,
532
+ [&strategy](auto & box, auto const & turn)
533
+ {
534
+ geometry::expand (box, turn.point , strategy);
535
+ },
536
+ [&strategy](auto & box, auto const & turn)
537
+ {
538
+ return ! geometry::detail::disjoint::disjoint_point_box (turn.point ,
539
+ box, strategy);
540
+ },
541
+ [&strategy](auto & box, auto const & piece)
542
+ {
543
+ if (piece.m_piece_border .m_has_envelope )
544
+ {
545
+ geometry::expand (box, piece.m_piece_border .m_envelope , strategy);
546
+ }
547
+ },
548
+ [&strategy](auto & box, auto const & piece)
549
+ {
550
+ if (piece.type == strategy::buffer::buffered_flat_end
551
+ || piece.type == strategy::buffer::buffered_concave)
552
+ {
553
+ // Turns cannot be inside a flat end (though they can be on border)
554
+ // Neither we need to check if they are inside concave helper pieces
555
+
556
+ // Skip all pieces not used as soon as possible
557
+ return false ;
558
+ }
559
+ if (! piece.m_piece_border .m_has_envelope )
560
+ {
561
+ return false ;
562
+ }
563
+
564
+ return ! geometry::detail::disjoint::disjoint_box_box (box,
565
+ piece.m_piece_border .m_envelope , strategy);
566
+ },
567
+ [&visitor](auto const & turn, auto const & piece)
568
+ {
569
+ return visitor.apply (turn, piece);
570
+ }
571
+ );
490
572
}
491
573
}
492
574
0 commit comments