lib/Graphics/Penplotter/GcodeXY/Hatch.pm

filter: Statementstmt 12.4% 28 / 225 Branchbran 0.0% 0 / 94 Conditioncond 0.0% 0 / 26 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 42.1% 8 / 19 Podpod 100% 3 / 3 totaltotal 10.2% 39 / 380 CC 63 SCAR 54.0
CC
63
Cov
8%
_dohatching
552.0
_get_bbox
182.0
_sameside
132.0
CRAP 221.6
« lib/Graphics/Penplotter/GcodeXY/Geometry2D.pm ↑ Summary lib/Graphics/Penplotter/GcodeXY/Geometry3D.pm »
1 package Graphics::Penplotter::GcodeXY::Hatch v0.9.4;
2  
3 9 ▶use v5.38.2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use feature qw( signatures );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶no warnings qw( experimental::signatures );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Readonly qw( Readonly );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use POSIX qw( floor );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # ---------------------------------------------------------------------------
13 # Graphics::Penplotter::GcodeXY::Hatch
14 #
15 # Role providing scanline hatch-fill for GcodeXY paths.
16 # ---------------------------------------------------------------------------
17  
18 9 requires qw(_croak gsave grestore _getsegintersect _addtopage _flushPsegments newpath);
19  
20 # ---------------------------------------------------------------------------
21 # Constants -- private copies of values defined in GcodeXY.pm.
22 # ---------------------------------------------------------------------------
23  
24 9 Readonly my $EOL => qq{\n};
25 9 Readonly my $BBMAX => 1_000_000.0; # sentinel for bounding-box initialisation
26 9 Readonly my $PI => 3.14159265359;
27  
28 # ===========================================================================
29 # PUBLIC API
30 # ===========================================================================
31  
32 # Set the spacing between hatch lines (in current units).
33 0 ▶sub sethatchsep ($self, $sep) {
Subroutine sethatchsep: not called CC=2 SCAR=17.9
Pod documented
34 0 ▶ if ( !defined $sep ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sep) 0 0 0
35 0 $self->_croak('wrong number of args for sethatchsep');
36 0 return 0;
37 }
38 0 $self->{hatchsep} = $sep;
39 0 return 1;
40 }
41  
42 # Set the angle of hatch lines in degrees (0 = horizontal, 90 = vertical).
43 # Positive angles rotate the lines counter-clockwise.
44 0 ▶sub sethatchangle ($self, $angle) {
Subroutine sethatchangle: not called CC=2 SCAR=17.9
Pod documented
45 0 ▶ if ( !defined $angle ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $angle) 0 0 0
46 0 $self->_croak('wrong number of args for sethatchangle');
47 0 return 0;
48 }
49 0 $self->{hatchangle} = $angle;
50 0 return 1;
51 }
52  
53 # Hatch-fill the current path, then flush and clear it.
54 0 ▶sub strokefill ($self) {
Subroutine strokefill: not called CC=1 SCAR=6.9
Pod documented
55 0 $self->_dohatching();
56 0 $self->_flushPsegments();
57 0 $self->newpath();
58 0 return 1;
59 }
60  
61 # ===========================================================================
62 # INTERNAL: BOUNDING BOX
63 # ===========================================================================
64  
65 # Compute the bounding box of the current path from its 'l' (line) segments.
66 # Returns (minx, miny, maxx, maxy), or (-1,-1,-1,-1) if no line segments exist.
67 0 ▶sub _get_bbox ($self) {
Subroutine _get_bbox: not called CC=13 SCAR=52.0
68 # Initialise to extreme sentinels so any real coordinate wins.
69 # maxx/maxy must start at -$BBMAX (not 0) so that negative
70 # coordinates -- which occur after rotating psegments for non-zero
71 # hatch angles -- are handled correctly.
72 0 my $maxx = -$BBMAX;
73 0 my $maxy = -$BBMAX;
74 0 my $minx = $BBMAX;
75 0 my $miny = $BBMAX;
76 0 my $len = scalar @{ $self->{psegments} };
77 0 my $count = 0;
78 0 ▶ return ( -1, -1, -1, -1 ) unless $len;
Branch: 1 branch
BranchTrueFalseTotal
unless $len 0 0 0
79 SEGMENT:
80 0 foreach my $i ( 0 .. $len - 1 ) {
81 0 ▶ next SEGMENT if $self->{psegments}[$i]{key} ne 'l';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"psegments"}[$i]{"key"} ne "l" 0 0 0
82 0 $count++;
83 0 my $k = $self->{psegments}[$i]{sx};
84 0 ▶ if ( $k > $maxx ) { $maxx = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k > $maxx) 0 0 0
85 0 ▶ if ( $k < $minx ) { $minx = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k < $minx) 0 0 0
86 0 $k = $self->{psegments}[$i]{sy};
87 0 ▶ if ( $k > $maxy ) { $maxy = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k > $maxy) 0 0 0
88 0 ▶ if ( $k < $miny ) { $miny = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k < $miny) 0 0 0
89 0 $k = $self->{psegments}[$i]{dx};
90 0 ▶ if ( $k > $maxx ) { $maxx = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k > $maxx) 0 0 0
91 0 ▶ if ( $k < $minx ) { $minx = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k < $minx) 0 0 0
92 0 $k = $self->{psegments}[$i]{dy};
93 0 ▶ if ( $k > $maxy ) { $maxy = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k > $maxy) 0 0 0
94 0 ▶ if ( $k < $miny ) { $miny = $k }
Branch: 1 branch
BranchTrueFalseTotal
if ($k < $miny) 0 0 0
95 }
96 0 ▶ return ( -1, -1, -1, -1 ) unless $count;
Branch: 1 branch
BranchTrueFalseTotal
unless $count 0 0 0
97 0 return ( $minx, $miny, $maxx, $maxy );
98 }
99  
100 # ===========================================================================
101 # INTERNAL: HATCH SEGMENT LIST
102 # ===========================================================================
103  
104 # Append a segment to the hatch segment list.
105 0 ▶sub _addhsegmentpath ($self, $key, $sx, $sy, $dx, $dy) {
Subroutine _addhsegmentpath: not called CC=2 SCAR=17.9
106 0 ▶ if ( !defined $dy ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dy) 0 0 0
107 0 $self->_croak('need 4 numbers for addhsegpath');
108 0 return 0;
109 }
110 0 my $len = scalar @{ $self->{hsegments} };
111 0 $self->{hsegments}[$len] = {
112 key => $key, sx => $sx, sy => $sy, dx => $dx, dy => $dy
113 };
114 0 return 1;
115 }
116  
117 # Clear the hatch segment list.
118 0 ▶sub _newhpath ($self) {
Subroutine _newhpath: not called CC=1 SCAR=6.9
119 0 @{ $self->{hsegments} } = ();
120 0 return 1;
121 }
122  
123 # Placeholder for future hatch-line ordering optimisation.
124 0 ▶sub _hoptimize ($self) {
Subroutine _hoptimize: not called CC=1 SCAR=6.9
125 0 return 1;
126 }
127  
128 # Flush hatch segments to the gcode page, computing pen-travel distances.
129 0 ▶sub _flushHsegments ($self) {
Subroutine _flushHsegments: not called CC=8 SCAR=42.8
130 0 my $len = scalar @{ $self->{hsegments} };
131 0 ▶ if ( !$len ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($len) 0 0 0
132 0 ▶ if ( $self->{check} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"check"}) 0 0 0
133 0 print STDOUT '*** no hsegments found' . $EOL;
134 }
135 0 return;
136 }
137 0 $self->_hoptimize();
138 0 foreach my $i ( 0 .. $len - 1 ) {
139 my $d = sqrt(
140 ( $self->{hsegments}[$i]{sx} - $self->{hsegments}[$i]{dx} ) ** 2 +
141 0 ( $self->{hsegments}[$i]{sy} - $self->{hsegments}[$i]{dy} ) ** 2
142 );
143 0 ▶ if ( $self->{hsegments}[$i]{key} eq 'm' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"hsegments"}[$i]{"key"} eq "m") 0 0 0
144 0 ▶ if ( !$self->{penlocked} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"penlocked"}) 0 0 0
145 0 $self->_addtopage( $self->{penupcmd} );
146 0 $self->{pencount}++;
147 }
148 $self->_addtopage(
149 sprintf "G00 X %.5f Y %.5f" . $EOL,
150 $self->{hsegments}[$i]{dx},
151 $self->{hsegments}[$i]{dy}
152 0 );
153 0 ▶ if ( !$self->{penlocked} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"penlocked"}) 0 0 0
154 0 $self->_addtopage( $self->{pendowncmd} );
155 }
156 0 $self->{fastdistcount} += $d;
157 }
158 0 ▶ if ( $self->{hsegments}[$i]{key} eq 'l' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"hsegments"}[$i]{"key"} eq "l") 0 0 0
159 $self->_addtopage(
160 sprintf "G01 X %.5f Y %.5f" . $EOL,
161 $self->{hsegments}[$i]{dx},
162 $self->{hsegments}[$i]{dy}
163 0 );
164 0 $self->{slowdistcount} += $d;
165 }
166 }
167 0 return 1;
168 }
169  
170  
171 # ===========================================================================
172 # INTERNAL: SCANLINE FILL
173 # ===========================================================================
174  
175 # Generate hatch-fill segments for the current path by scanline intersection.
176 # Works in device coordinates. Graphics state is saved and restored.
177 #
178 # When hatchangle is non-zero the algorithm works in a rotated "hatch space"
179 # where the scanlines are always horizontal:
180 #
181 # 1. All psegment endpoints are rotated by -hatchangle into hatch space.
182 # 2. The bbox, scanline sweep, intersection tests, and deduplication all
183 # run unchanged on the rotated copy (stored temporarily in psegments).
184 # 3. Before recording each hatch segment, its endpoints are rotated back
185 # by +hatchangle into drawing space.
186 # 4. The original psegments are restored before flushing.
187 #
188 # This keeps every helper (_get_bbox, _identical, _sameside, _getsegintersect)
189 # completely unaware of the angle — they always see horizontal scanlines.
190 0 ▶sub _dohatching ($self) {
Subroutine _dohatching: not called CC=23 SCAR=63.1
191 0 my ( $xmind, $ymind, $xmaxd, $ymaxd );
192 0 my ( @crossings, @csorted );
193 0 my $perc = 0;
194 # Normalise to [0, 180): hatch lines at θ and θ+180° are identical.
195 0 ▶ my $angle = ( $self->{hatchangle} // 0 ) % 180;
Condition0%0/2
$self->{"hatchangle"} // 0
l!l
00
MC/DC0%0/1
$self->{"hatchangle"} // 0
$self->{"hatchangle"}
Truth table0%0/2
A
A= $self->{"hatchangle"}
Aresult
11
00
196 0 my $margin = 10 * $self->{dscale};
197 0 my $sep = $self->{hatchsep};
198 0 my ( $p, $xstart, $xend, $ymindsave );
199 0 my ( $xmovex, $ymovey, $clen, $same );
200  
201 0 $self->gsave();
202 0 $self->_newhpath();
203  
204 # ------------------------------------------------------------------
205 # If a non-zero angle is requested, build a rotated working copy of
206 # psegments (rotate by -angle) and swap it in. All the geometry
207 # below then runs in hatch space where scanlines are horizontal.
208 # ------------------------------------------------------------------
209 0 my $orig_segs = $self->{psegments};
210 0 my ( $cos_a, $sin_a ) = ( 1.0, 0.0 );
211 0 ▶ if ( $angle != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($angle != 0) 0 0 0
212 0 my $rad = $angle * $PI / 180.0;
213 0 $cos_a = cos($rad);
214 0 $sin_a = sin($rad);
215 0 my @rotated;
216 0 for my $seg ( @{$orig_segs} ) {
217 push @rotated, {
218 key => $seg->{key},
219 sx => $seg->{sx} * $cos_a + $seg->{sy} * $sin_a,
220 sy => -$seg->{sx} * $sin_a + $seg->{sy} * $cos_a,
221 dx => $seg->{dx} * $cos_a + $seg->{dy} * $sin_a,
222 0 dy => -$seg->{dx} * $sin_a + $seg->{dy} * $cos_a,
223 };
224 }
225 0 $self->{psegments} = \@rotated;
226 }
227  
228 0 my $pathlen = scalar @{ $self->{psegments} };
229  
230 0 ( $xmind, $ymind, $xmaxd, $ymaxd ) = $self->_get_bbox();
231 0 $ymindsave = $ymind;
232 0 $xmovex = $xmind;
233 0 $ymovey = $ymind;
234 0 $xmind -= $margin;
235 0 $xmaxd += $margin;
236 0 $ymaxd += $margin;
237 # Anchor the sweep to the sep grid with a half-step offset so that no
238 # scanline ever falls exactly on a horizontal shape edge. This makes
239 # the hatch-line count independent of floating-point perturbations
240 # introduced by the rotation (e.g. cos(pi/2) != 0 exactly).
241 {
242 0 my $snapped = floor( $ymindsave / $sep ) * $sep + $sep / 2;
243 0 ▶ $snapped -= $sep if $snapped > $ymindsave;
Branch: 1 branch
BranchTrueFalseTotal
if $snapped > $ymindsave 0 0 0
244 0 $ymind = $snapped;
245 }
246  
247 0 ▶ while ( $ymind < $ymaxd ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ymind < $ymaxd) 0 0 0
248 0 @crossings = ();
249 0 foreach my $i ( 0 .. $pathlen - 1 ) {
250 0 ▶ if ( $self->{psegments}[$i]{key} eq 'l' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"psegments"}[$i]{"key"} eq "l") 0 0 0
251 $perc = $self->_getsegintersect(
252 $xmind, $ymind,
253 $xmaxd, $ymind,
254 $self->{psegments}[$i]{sx}, $self->{psegments}[$i]{sy},
255 $self->{psegments}[$i]{dx}, $self->{psegments}[$i]{dy}
256 0 );
257 0 ▶ if ( $perc > 0.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perc > 0) 0 0 0
258 0 push @crossings, { perc => $perc, seg => $i };
259 }
260 }
261 }
262 0 $clen = scalar @crossings;
263 0 ▶ if ($clen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($clen) 0 0 0
264 0 @csorted = sort { $a->{perc} <=> $b->{perc} } @crossings;
265 HATCH:
266 0 foreach my $i ( 0 .. $clen - 2 ) {
267 0 ▶ if ( $csorted[$i]{perc} == $csorted[ $i + 1 ]{perc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($csorted[$i]{"perc"} == $csorted[$i + 1]{"perc"}) 0 0 0
268 0 ▶ if ( $self->_identical( $csorted[$i]{seg}, $csorted[ $i + 1 ]{seg} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_identical($csorted[$i]{'seg'}, $csorted[$i + 1]{'seg'})) { } 0 0 0
269 0 splice @csorted, $i, 1; $clen--;
270 0 splice @csorted, $i, 1; $clen--;
271 }
272 else {
273 $same = $self->_sameside( $ymind,
274 0 $csorted[$i]{seg}, $csorted[ $i + 1 ]{seg} );
275 0 ▶ if ( $same == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($same == 1) { } 0 0 0
elsif (not $same) { } 0 0 0
276 0 splice @csorted, $i, 1; $clen--;
277 0 splice @csorted, $i, 1; $clen--;
278 }
279 elsif ( !$same ) {
280 0 splice @csorted, $i, 1; $clen--;
281 }
282 else {
283 0 next HATCH;
284 }
285 }
286 }
287 }
288 0 ▶ if ( $clen % 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($clen % 2) 0 0 0
289 0 ▶ if ( $self->{check} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"check"}) 0 0 0
290 0 print STDOUT 'dohatching: odd number of crossings' . $EOL;
291 }
292 }
293 }
294 0 ▶ if ($clen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($clen) 0 0 0
295 PAIR:
296 0 foreach my $i ( 0 .. $clen - 1 ) {
297 0 ▶ next PAIR if $i % 2;
Branch: 1 branch
BranchTrueFalseTotal
if $i % 2 0 0 0
298 0 ▶ last PAIR if $i + 1 >= $clen; # safety: skip unpaired crossing
Branch: 1 branch
BranchTrueFalseTotal
if $i + 1 >= $clen 0 0 0
299 0 $p = $csorted[ $i + 0 ]{perc};
300 0 $xstart = $xmind + $p * ( $xmaxd - $xmind );
301 0 $p = $csorted[ $i + 1 ]{perc};
302 0 $xend = $xmind + $p * ( $xmaxd - $xmind );
303 0 ▶ if ( $angle != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($angle != 0) { } 0 0 0
304 # Rotate all three points back from hatch space to drawing space
305 # (rotation by +angle: x' = x·cos - y·sin, y' = x·sin + y·cos)
306 0 my ( $ox, $oy ) = ( $xmovex * $cos_a - $ymovey * $sin_a,
307 $xmovex * $sin_a + $ymovey * $cos_a );
308 0 my ( $sx, $sy ) = ( $xstart * $cos_a - $ymind * $sin_a,
309 $xstart * $sin_a + $ymind * $cos_a );
310 0 my ( $ex, $ey ) = ( $xend * $cos_a - $ymind * $sin_a,
311 $xend * $sin_a + $ymind * $cos_a );
312 0 $self->_addhsegmentpath( 'm', $ox, $oy, $sx, $sy );
313 0 $self->_addhsegmentpath( 'l', $sx, $sy, $ex, $ey );
314 }
315 else {
316 0 $self->_addhsegmentpath( 'm', $xmovex, $ymovey, $xstart, $ymind );
317 0 $self->_addhsegmentpath( 'l', $xstart, $ymind, $xend, $ymind );
318 }
319 0 $xmovex = $xend;
320 0 $ymovey = $ymind;
321 }
322 }
323 0 $ymind += $sep;
324 }
325  
326 # Restore original segments before flushing.
327 0 ▶ $self->{psegments} = $orig_segs if $angle != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $angle != 0 0 0 0
328  
329 0 $self->_flushHsegments();
330 0 $self->grestore();
331 0 return 1;
332 }
333  
334  
335 # ===========================================================================
336 # INTERNAL: SCANLINE GEOMETRY HELPERS
337 # ===========================================================================
338  
339 # True if seg1 and seg2 are the same segment (possibly with endpoints reversed).
340 0 ▶sub _identical ($self, $seg1, $seg2) {
Subroutine _identical: not called CC=9 SCAR=45.0
341 0 my %h1 = %{ $self->{psegments}[$seg1] };
342 0 my %h2 = %{ $self->{psegments}[$seg2] };
343 0 my ( $ax, $ay, $bx, $by ) = ( $h1{sx}, $h1{sy}, $h1{dx}, $h1{dy} );
344 0 my ( $cx, $cy, $dx, $dy ) = ( $h2{sx}, $h2{sy}, $h2{dx}, $h2{dy} );
345 0 ▶ return 1 if $ax == $dx && $ay == $dy && $cx == $bx && $cy == $by;
Branch: 1 branch
BranchTrueFalseTotal
if $ax == $dx and $ay == $dy and $cx == $bx and $cy == $by 0 0 0
Condition0%0/9
$ax == $dx and $ay == $dy and $cx == $bx and $cy == $by
!ll&&!rl&&r
000
$ax == $dx and $ay == $dy and $cx == $bx
!ll&&!rl&&r
000
$ax == $dx and $ay == $dy
!ll&&!rl&&r
000
MC/DC0%0/4
$ax == $dx and $ay == $dy and $cx == $bx and $cy == $by
$ax == $dx $ay == $dy $cx == $bx $cy == $by
Truth table0%0/5
A and B and C and D
A= $ax == $dxB= $ay == $dyC= $cx == $bxD= $cy == $by
ABCDresult
0XXX0
10XX0
110X0
11100
11111
346 0 ▶ return 1 if $ax == $cx && $ay == $cy && $bx == $dx && $by == $dy;
Branch: 1 branch
BranchTrueFalseTotal
if $ax == $cx and $ay == $cy and $bx == $dx and $by == $dy 0 0 0
Condition0%0/9
$ax == $cx and $ay == $cy and $bx == $dx and $by == $dy
!ll&&!rl&&r
000
$ax == $cx and $ay == $cy and $bx == $dx
!ll&&!rl&&r
000
$ax == $cx and $ay == $cy
!ll&&!rl&&r
000
MC/DC0%0/4
$ax == $cx and $ay == $cy and $bx == $dx and $by == $dy
$ax == $cx $ay == $cy $bx == $dx $by == $dy
Truth table0%0/5
A and B and C and D
A= $ax == $cxB= $ay == $cyC= $bx == $dxD= $by == $dy
ABCDresult
0XXX0
10XX0
110X0
11100
11111
347 0 return 0;
348 }
349  
350 # True (1) if seg1 and seg2 share a vertex on the hatch line $y and their
351 # other endpoints are both on the same side of it.
352 # Returns -1 if the shared vertex cannot be determined.
353 0 ▶sub _sameside ($self, $y, $seg1, $seg2) {
Subroutine _sameside: not called CC=11 SCAR=48.8
354 0 my %h1 = %{ $self->{psegments}[$seg1] };
355 0 my %h2 = %{ $self->{psegments}[$seg2] };
356 0 my ( $ay, $by ) = ( $h1{sy}, $h1{dy} );
357 0 my ( $cy, $dy ) = ( $h2{sy}, $h2{dy} );
358 0 my ( $y1, $y2 );
359 0 ▶ if ( $ay == $y ) { $y1 = $by }
Branch: 2 branches
BranchTrueFalseTotal
if ($ay == $y) { } 0 0 0
elsif ($by == $y) { } 0 0 0
360 0 elsif ( $by == $y ) { $y1 = $ay }
361 else {
362 0 ▶ if ( $self->{check} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"check"}) 0 0 0
363 0 print STDOUT "sameside: cannot determine vertex 1 for $y of $seg1 and $seg2" . $EOL;
364 }
365 0 return -1;
366 }
367 0 ▶ if ( $cy == $y ) { $y2 = $dy }
Branch: 2 branches
BranchTrueFalseTotal
if ($cy == $y) { } 0 0 0
elsif ($dy == $y) { } 0 0 0
368 0 elsif ( $dy == $y ) { $y2 = $cy }
369 else {
370 0 ▶ if ( $self->{check} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"check"}) 0 0 0
371 0 print STDOUT "sameside: cannot determine vertex 2 for $y of $seg1 and $seg2" . $EOL;
372 }
373 0 return -1;
374 }
375 0 ▶ return 1 if $y1 > $y && $y2 > $y;
Branch: 1 branch
BranchTrueFalseTotal
if $y1 > $y and $y2 > $y 0 0 0
Condition0%0/3
$y1 > $y and $y2 > $y
!ll&&!rl&&r
000
MC/DC0%0/2
$y1 > $y and $y2 > $y
$y1 > $y $y2 > $y
Truth table0%0/3
A and B
A= $y1 > $yB= $y2 > $y
ABresult
0X0
100
111
376 0 ▶ return 1 if $y1 < $y && $y2 < $y;
Branch: 1 branch
BranchTrueFalseTotal
if $y1 < $y and $y2 < $y 0 0 0
Condition0%0/3
$y1 < $y and $y2 < $y
!ll&&!rl&&r
000
MC/DC0%0/2
$y1 < $y and $y2 < $y
$y1 < $y $y2 < $y
Truth table0%0/3
A and B
A= $y1 < $yB= $y2 < $y
ABresult
0X0
100
111
377 0 return 0;
378 }
379  
380  
381 9 1;
382  
383 __END__
« lib/Graphics/Penplotter/GcodeXY/Geometry2D.pm ↑ Summary lib/Graphics/Penplotter/GcodeXY/Geometry3D.pm »