1- use alloc:: vec:: Vec ;
2- use i_shape:: util:: reserve:: Reserve ;
3- use crate :: segm:: boolean:: ShapeCountBoolean ;
4- use crate :: core:: link:: OverlayLinkFilter ;
5- use crate :: core:: graph:: OverlayNode ;
6- use crate :: core:: fill_rule:: FillRule ;
7- use crate :: core:: solver:: Solver ;
81use crate :: build:: builder:: { FillStrategy , GraphBuilder , InclusionFilterStrategy } ;
92use crate :: core:: extract:: VisitState ;
3+ use crate :: core:: fill_rule:: FillRule ;
104use crate :: core:: graph:: OverlayGraph ;
5+ use crate :: core:: graph:: OverlayNode ;
116use crate :: core:: link:: OverlayLink ;
7+ use crate :: core:: link:: OverlayLinkFilter ;
128use crate :: core:: overlay:: IntOverlayOptions ;
139use crate :: core:: overlay_rule:: OverlayRule ;
14- use crate :: segm:: segment:: { Segment , SegmentFill , ALL , BOTH_BOTTOM , BOTH_TOP , CLIP_BOTH , CLIP_BOTTOM , CLIP_TOP , SUBJ_BOTH , SUBJ_BOTTOM , SUBJ_TOP } ;
10+ use crate :: core:: solver:: Solver ;
11+ use crate :: segm:: boolean:: ShapeCountBoolean ;
12+ use crate :: segm:: segment:: {
13+ ALL , BOTH_BOTTOM , BOTH_TOP , CLIP_BOTH , CLIP_BOTTOM , CLIP_TOP , SUBJ_BOTH , SUBJ_BOTTOM , SUBJ_TOP , Segment ,
14+ SegmentFill ,
15+ } ;
1516use crate :: segm:: winding:: WindingCount ;
17+ use alloc:: vec:: Vec ;
18+ use i_shape:: util:: reserve:: Reserve ;
1619
1720impl GraphBuilder < ShapeCountBoolean , OverlayNode > {
1821 #[ inline]
19- pub ( crate ) fn build_boolean_all ( & mut self ,
20- fill_rule : FillRule ,
21- options : IntOverlayOptions ,
22- solver : & Solver ,
23- segments : & [ Segment < ShapeCountBoolean > ] ,
22+ pub ( crate ) fn build_boolean_all (
23+ & mut self ,
24+ fill_rule : FillRule ,
25+ options : IntOverlayOptions ,
26+ solver : & Solver ,
27+ segments : & [ Segment < ShapeCountBoolean > ] ,
2428 ) -> OverlayGraph < ' _ > {
2529 self . build_boolean_fills ( fill_rule, solver, segments) ;
2630 self . build_links_all ( segments) ;
2731 self . boolean_graph ( options, solver)
2832 }
2933
3034 #[ inline]
31- pub ( crate ) fn build_boolean_overlay ( & mut self ,
32- fill_rule : FillRule ,
33- overlay_rule : OverlayRule ,
34- options : IntOverlayOptions ,
35- solver : & Solver ,
36- segments : & [ Segment < ShapeCountBoolean > ] ,
35+ pub ( crate ) fn build_boolean_overlay (
36+ & mut self ,
37+ fill_rule : FillRule ,
38+ overlay_rule : OverlayRule ,
39+ options : IntOverlayOptions ,
40+ solver : & Solver ,
41+ segments : & [ Segment < ShapeCountBoolean > ] ,
3742 ) -> OverlayGraph < ' _ > {
3843 self . build_boolean_fills ( fill_rule, solver, segments) ;
3944 match overlay_rule {
@@ -49,7 +54,12 @@ impl GraphBuilder<ShapeCountBoolean, OverlayNode> {
4954 }
5055
5156 #[ inline]
52- fn build_boolean_fills ( & mut self , fill_rule : FillRule , solver : & Solver , segments : & [ Segment < ShapeCountBoolean > ] ) {
57+ fn build_boolean_fills (
58+ & mut self ,
59+ fill_rule : FillRule ,
60+ solver : & Solver ,
61+ segments : & [ Segment < ShapeCountBoolean > ] ,
62+ ) {
5363 match fill_rule {
5464 FillRule :: EvenOdd => self . build_fills_with_strategy :: < EvenOddStrategy > ( solver, segments) ,
5565 FillRule :: NonZero => self . build_fills_with_strategy :: < NonZeroStrategy > ( solver, segments) ,
@@ -64,7 +74,7 @@ impl GraphBuilder<ShapeCountBoolean, OverlayNode> {
6474 OverlayGraph {
6575 nodes : & self . nodes ,
6676 links : & self . links ,
67- options
77+ options,
6878 }
6979 }
7080}
@@ -76,10 +86,7 @@ struct NegativeStrategy;
7686
7787impl FillStrategy < ShapeCountBoolean > for EvenOddStrategy {
7888 #[ inline( always) ]
79- fn add_and_fill (
80- this : ShapeCountBoolean ,
81- bot : ShapeCountBoolean ,
82- ) -> ( ShapeCountBoolean , SegmentFill ) {
89+ fn add_and_fill ( this : ShapeCountBoolean , bot : ShapeCountBoolean ) -> ( ShapeCountBoolean , SegmentFill ) {
8390 let top = bot. add ( this) ;
8491 let subj_top = 1 & top. subj as SegmentFill ;
8592 let subj_bot = 1 & bot. subj as SegmentFill ;
@@ -94,10 +101,7 @@ impl FillStrategy<ShapeCountBoolean> for EvenOddStrategy {
94101
95102impl FillStrategy < ShapeCountBoolean > for NonZeroStrategy {
96103 #[ inline( always) ]
97- fn add_and_fill (
98- this : ShapeCountBoolean ,
99- bot : ShapeCountBoolean ,
100- ) -> ( ShapeCountBoolean , SegmentFill ) {
104+ fn add_and_fill ( this : ShapeCountBoolean , bot : ShapeCountBoolean ) -> ( ShapeCountBoolean , SegmentFill ) {
101105 let top = bot. add ( this) ;
102106 let subj_top = ( top. subj != 0 ) as SegmentFill ;
103107 let subj_bot = ( bot. subj != 0 ) as SegmentFill ;
@@ -112,10 +116,7 @@ impl FillStrategy<ShapeCountBoolean> for NonZeroStrategy {
112116
113117impl FillStrategy < ShapeCountBoolean > for PositiveStrategy {
114118 #[ inline( always) ]
115- fn add_and_fill (
116- this : ShapeCountBoolean ,
117- bot : ShapeCountBoolean ,
118- ) -> ( ShapeCountBoolean , SegmentFill ) {
119+ fn add_and_fill ( this : ShapeCountBoolean , bot : ShapeCountBoolean ) -> ( ShapeCountBoolean , SegmentFill ) {
119120 let top = bot. add ( this) ;
120121 let subj_top = ( top. subj > 0 ) as SegmentFill ;
121122 let subj_bot = ( bot. subj > 0 ) as SegmentFill ;
@@ -130,10 +131,7 @@ impl FillStrategy<ShapeCountBoolean> for PositiveStrategy {
130131
131132impl FillStrategy < ShapeCountBoolean > for NegativeStrategy {
132133 #[ inline( always) ]
133- fn add_and_fill (
134- this : ShapeCountBoolean ,
135- bot : ShapeCountBoolean ,
136- ) -> ( ShapeCountBoolean , SegmentFill ) {
134+ fn add_and_fill ( this : ShapeCountBoolean , bot : ShapeCountBoolean ) -> ( ShapeCountBoolean , SegmentFill ) {
137135 let top = bot. add ( this) ;
138136 let subj_top = ( top. subj < 0 ) as SegmentFill ;
139137 let subj_bot = ( bot. subj < 0 ) as SegmentFill ;
@@ -307,37 +305,58 @@ impl OverlayLinkFilter for [OverlayLink] {
307305
308306#[ inline]
309307fn filter_subject ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
310- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_subject ( ) ) ) . collect ( )
308+ links
309+ . iter ( )
310+ . map ( |link| VisitState :: new ( !link. fill . is_subject ( ) ) )
311+ . collect ( )
311312}
312313
313314#[ inline]
314315fn filter_clip ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
315- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_clip ( ) ) ) . collect ( )
316+ links
317+ . iter ( )
318+ . map ( |link| VisitState :: new ( !link. fill . is_clip ( ) ) )
319+ . collect ( )
316320}
317321
318322#[ inline]
319323fn filter_intersect ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
320- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_intersect ( ) ) ) . collect ( )
324+ links
325+ . iter ( )
326+ . map ( |link| VisitState :: new ( !link. fill . is_intersect ( ) ) )
327+ . collect ( )
321328}
322329
323330#[ inline]
324331fn filter_union ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
325- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_union ( ) ) ) . collect ( )
332+ links
333+ . iter ( )
334+ . map ( |link| VisitState :: new ( !link. fill . is_union ( ) ) )
335+ . collect ( )
326336}
327337
328338#[ inline]
329339fn filter_difference ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
330- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_difference ( ) ) ) . collect ( )
340+ links
341+ . iter ( )
342+ . map ( |link| VisitState :: new ( !link. fill . is_difference ( ) ) )
343+ . collect ( )
331344}
332345
333346#[ inline]
334347fn filter_inverse_difference ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
335- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_inverse_difference ( ) ) ) . collect ( )
348+ links
349+ . iter ( )
350+ . map ( |link| VisitState :: new ( !link. fill . is_inverse_difference ( ) ) )
351+ . collect ( )
336352}
337353
338354#[ inline]
339355fn filter_xor ( links : & [ OverlayLink ] ) -> Vec < VisitState > {
340- links. iter ( ) . map ( |link| VisitState :: new ( !link. fill . is_xor ( ) ) ) . collect ( )
356+ links
357+ . iter ( )
358+ . map ( |link| VisitState :: new ( !link. fill . is_xor ( ) ) )
359+ . collect ( )
341360}
342361
343362#[ inline]
@@ -401,4 +420,4 @@ fn filter_xor_into(links: &[OverlayLink], buffer: &mut Vec<VisitState>) {
401420 for link in links. iter ( ) {
402421 buffer. push ( VisitState :: new ( !link. fill . is_xor ( ) ) ) ;
403422 }
404- }
423+ }
0 commit comments