5454#include < boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
5555#include < boost/geometry/algorithms/detail/overlay/traverse.hpp>
5656#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>
5858#include < boost/geometry/algorithms/detail/sections/sectionalize.hpp>
5959#include < boost/geometry/algorithms/detail/sections/section_box_policies.hpp>
6060
@@ -358,22 +358,59 @@ struct buffered_piece_collection
358358 // Check if a turn is inside any of the originals
359359 inline void check_turn_in_original ()
360360 {
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+
361376 turn_in_original_visitor
362377 <
363378 turn_vector_type,
364379 Strategy
365380 > visitor (m_turns, m_strategy);
366381
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
368386 <
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+ );
377414
378415 bool const deflate = m_distance_strategy.negative ();
379416
@@ -447,6 +484,8 @@ struct buffered_piece_collection
447484 {
448485 update_piece_administration ();
449486
487+ auto const & strategy = m_strategy;
488+
450489 {
451490 // Calculate the turns
452491 piece_turn_visitor
@@ -461,32 +500,75 @@ struct buffered_piece_collection
461500
462501 detail::sectionalize::enlarge_sections (monotonic_sections, m_strategy);
463502
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+ );
470518 }
471519
520+
472521 update_turn_administration ();
473522
474523 {
475- // Check if turns are inside pieces
476524 turn_in_piece_visitor
477525 <
478526 typename geometry::cs_tag<point_type>::type,
479527 turn_vector_type, piece_vector_type, DistanceStrategy, Strategy
480528 > visitor (m_turns, m_pieces, m_distance_strategy, m_strategy);
481529
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+ );
490572 }
491573 }
492574
0 commit comments