blib/lib/Tk/Image/Calculation.pm

filter: Statementstmt 94.4% 479 / 507 Branchbran 81.7% 170 / 208 Conditioncond 50.0% 24 / 48 MC/DCmcdc 22.5% 7 / 31 Subroutinesub 100% 19 / 19 Podpod 93.7% 15 / 16 totaltotal 86.1% 714 / 829 CC 122 SCAR 24.6
CC
122
Cov
88%
new
23.2
_CalculatePolygon
21.1
GetPointsCircle
9.5
CRAP 11.7
↑ Summary
1 package Tk::Image::Calculation;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 #-------------------------------------------------
7 1 $Tk::Image::Calculation::VERSION = '0.05';
8 #-------------------------------------------------
9
10 sub new
11 31 ▶{
Subroutine new: called CC=23 SCAR=31.5
Pod undocumented
12 31 my ($class, @args) = @_;
13 31 my $self = {@args};
14 31 ▶ bless($self, $class || ref($class));
Condition33%1/3
$class || ref $class
l!l&&r!l&&!r
3100
MC/DC0%0/2
$class || ref $class
$class ref $class
Truth table33%1/3
A || B
A= $classB= ref $class
ABresult
1X1
011
000
15
16 #-------------------------------------------------
17 31 ▶ if(defined($self->{-points}) && defined($self->{-form}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"-points"} and defined $self->{"-form"}) 30 1 31
Condition66%2/3
defined $self->{"-points"} and defined $self->{"-form"}
!ll&&!rl&&r
1030
MC/DC50%1/2
defined $self->{"-points"} and defined $self->{"-form"}
defined $self->{"-points"} defined $self->{"-form"}
Truth table66%2/3
A and B
A= defined $self->{"-points"}B= defined $self->{"-form"}
ABresult
0X0
100
111
18 {
19 FORM:
20 {
21 30 ▶ $self->{-subset} = "all" if(!(defined($self->{-subset})));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"-subset"} 0 30 30
22
23 ($self->{-form} eq "oval") && do
24 30 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-form"} eq "oval" and do { OVAL: { $self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutOval(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutOval(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_inside" and do { $self->GetPointsInOval(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInOval(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "all" and do { $self->GetPointsOval(@{$$self{"-points"};}); last FORM }; } } 10 20 30
25 OVAL:
26 {
27 10 ($self->{-subset} eq "lines_outside") && do
28 10 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutOval(@{$$self{"-points"};}); last FORM } 2 8 10
29 2 $self->GetLinesOutOval(@{$self->{-points}});
30 2 last(FORM);
31 };
32 ($self->{-subset} eq "points_outside") && do
33 8 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutOval(@{$$self{"-points"};}); last FORM } 2 6 8
34 2 $self->GetPointsOutOval(@{$self->{-points}});
35 2 last(FORM);
36 };
37 ($self->{-subset} eq "points_inside") && do
38 6 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_inside" and do { $self->GetPointsInOval(@{$$self{"-points"};}); last FORM } 2 4 6
39 2 $self->GetPointsInOval(@{$self->{-points}});
40 2 last(FORM);
41 };
42 ($self->{-subset} eq "lines_inside") && do
43 4 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInOval(@{$$self{"-points"};}); last FORM } 2 2 4
44 2 $self->GetLinesInOval(@{$self->{-points}});
45 2 last(FORM);
46 };
47 ($self->{-subset} eq "all") && do
48 2 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "all" and do { $self->GetPointsOval(@{$$self{"-points"};}); last FORM } 2 0 2
49 2 $self->GetPointsOval(@{$self->{-points}});
50 2 last(FORM);
51 };
52 }
53 };
54
55 ($self->{-form} eq "circle") && do
56 20 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-form"} eq "circle" and do { CIRCLE: { $self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutCircle(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutCircle(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_inside" and do { $self->GetPointsInCircle(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInCircle(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "all" and do { $self->GetPointsCircle(@{$$self{"-points"};}); last FORM }; } } 10 10 20
57 CIRCLE:
58 {
59 10 ($self->{-subset} eq "lines_outside") && do
60 10 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutCircle(@{$$self{"-points"};}); last FORM } 2 8 10
61 2 $self->GetLinesOutCircle(@{$self->{-points}});
62 2 last(FORM);
63 };
64 ($self->{-subset} eq "points_outside") && do
65 8 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutCircle(@{$$self{"-points"};}); last FORM } 2 6 8
66 2 $self->GetPointsOutCircle(@{$self->{-points}});
67 2 last(FORM);
68 };
69 ($self->{-subset} eq "points_inside") && do
70 6 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_inside" and do { $self->GetPointsInCircle(@{$$self{"-points"};}); last FORM } 2 4 6
71 2 $self->GetPointsInCircle(@{$self->{-points}});
72 2 last(FORM);
73 };
74 ($self->{-subset} eq "lines_inside") && do
75 4 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInCircle(@{$$self{"-points"};}); last FORM } 2 2 4
76 2 $self->GetLinesInCircle(@{$self->{-points}});
77 2 last(FORM);
78 };
79 ($self->{-subset} eq "all") && do
80 2 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "all" and do { $self->GetPointsCircle(@{$$self{"-points"};}); last FORM } 2 0 2
81 2 $self->GetPointsCircle(@{$self->{-points}});
82 2 last(FORM);
83 };
84 }
85 };
86
87 ($self->{-form} eq "polygon") && do
88 10 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-form"} eq "polygon" and do { POLYGON: { $self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutPolygon(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutPolygon(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInPolygon(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "points_inside" and do { $self->GetPointsInPolygon(@{$$self{"-points"};}); last FORM }; $self->{"-subset"} eq "all" and do { $self->GetPointsPolygon(@{$$self{"-points"};}); last FORM }; } } 10 0 10
89 POLYGON:
90 {
91 10 ($self->{-subset} eq "lines_outside") && do
92 10 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_outside" and do { $self->GetLinesOutPolygon(@{$$self{"-points"};}); last FORM } 2 8 10
93 2 $self->GetLinesOutPolygon(@{$self->{-points}});
94 2 last(FORM);
95 };
96 ($self->{-subset} eq "points_outside") && do
97 8 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_outside" and do { $self->GetPointsOutPolygon(@{$$self{"-points"};}); last FORM } 2 6 8
98 2 $self->GetPointsOutPolygon(@{$self->{-points}});
99 2 last(FORM);
100 };
101 ($self->{-subset} eq "lines_inside") && do
102 6 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "lines_inside" and do { $self->GetLinesInPolygon(@{$$self{"-points"};}); last FORM } 2 4 6
103 2 $self->GetLinesInPolygon(@{$self->{-points}});
104 2 last(FORM);
105 };
106 ($self->{-subset} eq "points_inside") && do
107 4 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "points_inside" and do { $self->GetPointsInPolygon(@{$$self{"-points"};}); last FORM } 2 2 4
108 2 $self->GetPointsInPolygon(@{$self->{-points}});
109 2 last(FORM);
110 };
111 ($self->{-subset} eq "all") && do
112 2 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"-subset"} eq "all" and do { $self->GetPointsPolygon(@{$$self{"-points"};}); last FORM } 2 0 2
113 2 $self->GetPointsPolygon(@{$self->{-points}});
114 2 last(FORM);
115 };
116 }
117 };
118
119 0 warn("wrong args in call to Tk::Image::Calculation::new()\n");
120 }
121 }
122 #-------------------------------------------------
123 31 return($self);
124 }
125
126 #-------------------------------------------------
127 # OVAL
128 #-------------------------------------------------
129 sub GetPointsOval
130 4 ▶{
Subroutine GetPointsOval: called CC=9 SCAR=22.3
Pod documented
131 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
132 4 my (@points_out, @points_in, @lines_out, @lines_in);
133 4 my ($pos_x_p, $pos_x_n, $pos_y1, $pos_y2);
134 4 my ($y, $y1, $y2);
135 4 my $diff;
136 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
137 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
138 4 my $width = ($p_x2 - $p_x1);
139 4 my $height= ($p_y2 - $p_y1);
140
141 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
142 {
143 0 $self->{points_outside} = [];
144 0 $self->{points_inside} = [];
145 0 $self->{lines_outside} = [];
146 0 $self->{lines_inside} = [];
147
148 return({
149 0 points_outside => [],
150 points_inside => [],
151 lines_outside => [],
152 lines_inside => []
153 });
154 }
155
156 4 my $a = ($width / 2);
157 4 my $a2 = $a ** 2;
158 4 my $b = ($height / 2);
159 4 my $c = ($b / $a);
160 4 my $pos_x = ($a + $p_x1);
161
162 4 ▶ for(my $x = 0; $x <= $a; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $a) 124 4 128
163 {
164 124 $diff = int($c * sqrt($a2 - ($x ** 2)));
165 124 $y1 = ($b - $diff);
166 124 $y2 = ($b + $diff);
167 124 $pos_y1 = ($y1 + $p_y1);
168 124 $pos_y2 = ($y2 + $p_y1);
169 124 $pos_x_p = int($x + $pos_x);
170 124 $pos_x_n = int(-$x + $pos_x);
171
172 124 push(@lines_out, [$pos_x_p, $p_y1, $pos_x_p, $pos_y1]);
173 124 push(@lines_out, [$pos_x_n, $p_y1, $pos_x_n, $pos_y1]);
174 124 push(@lines_in, [$pos_x_p, $pos_y1, $pos_x_p, $pos_y2]);
175 124 push(@lines_in, [$pos_x_n, $pos_y1, $pos_x_n, $pos_y2]);
176 124 push(@lines_out, [$pos_x_p, $pos_y2, $pos_x_p, $p_y2]);
177 124 push(@lines_out, [$pos_x_n, $pos_y2, $pos_x_n, $p_y2]);
178
179 124 ▶ for($y = 0; $y <= $y1; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $y1) 1418 124 1542
180 {
181 1418 $pos_y1 = ($y + $p_y1);
182 1418 push(@points_out, [$pos_x_p, $pos_y1]);
183 1418 push(@points_out, [$pos_x_n, $pos_y1]);
184 }
185
186 124 ▶ for($y = $y1; $y <= $y2; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $y2) 8616 124 8740
187 {
188 8616 $pos_y1 = ($y + $p_y1);
189 8616 push(@points_in, [$pos_x_p, $pos_y1]);
190 8616 push(@points_in, [$pos_x_n, $pos_y1]);
191 }
192
193 124 ▶ for($y = $y2; $y <= $height; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $height) 1418 124 1542
194 {
195 1418 $pos_y1 = ($y + $p_y1);
196 1418 push(@points_out, [$pos_x_p, $pos_y1]);
197 1418 push(@points_out, [$pos_x_n, $pos_y1]);
198 }
199 }
200 4 $self->{points_outside} = \@points_out;
201 4 $self->{points_inside} = \@points_in;
202 4 $self->{lines_outside} = \@lines_out;
203 4 $self->{lines_inside} = \@lines_in;
204
205 return({
206 4 points_outside => \@points_out,
207 points_inside => \@points_in,
208 lines_outside => \@lines_out,
209 lines_inside => \@lines_in
210 });
211 }
212
213 #-------------------------------------------------
214 sub GetPointsInOval
215 4 ▶{
Subroutine GetPointsInOval: called CC=7 SCAR=19.8
Pod documented
216 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
217 4 my ($pos_x_p, $pos_x_n, $pos_y1);
218 4 my ($y, $y1, $y2);
219 4 my $diff;
220 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
221 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
222 4 my $width = ($p_x2 - $p_x1);
223 4 my $height= ($p_y2 - $p_y1);
224
225 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
226 {
227 0 $self->{points_inside} = [];
228 0 return([]);
229 }
230
231 4 my $a = ($width / 2);
232 4 my $a2 = ($a**2);
233 4 my $b = ($height / 2);
234 4 my $c = ($b / $a);
235 4 my $pos_x = ($a + $p_x1);
236 4 my @points_in;
237
238 4 ▶ for(my $x = 0; $x <= $a; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $a) 124 4 128
239 {
240 124 $diff = int($c * sqrt($a2 - ($x**2)));
241 124 $y1 = ($b - $diff);
242 124 $y2 = ($b + $diff);
243 124 $pos_x_p = int($x + $pos_x);
244 124 $pos_x_n = int(-$x + $pos_x);
245
246 124 ▶ for($y = $y1; $y <= $y2; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $y2) 8616 124 8740
247 {
248 8616 $pos_y1 = ($y + $p_y1);
249 8616 push(@points_in, [$pos_x_p, $pos_y1]);
250 8616 push(@points_in, [$pos_x_n, $pos_y1]);
251 }
252 }
253 4 $self->{points_inside} = \@points_in;
254 4 return(\@points_in);
255 }
256
257 #-------------------------------------------------
258 sub GetPointsOutOval
259 4 ▶{
Subroutine GetPointsOutOval: called CC=8 SCAR=21.0
Pod documented
260 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
261 4 my ($pos_x_p, $pos_x_n, $pos_y1);
262 4 my ($y, $y1, $y2);
263 4 my $diff;
264 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
265 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
266 4 my $width = ($p_x2 - $p_x1);
267 4 my $height= ($p_y2 - $p_y1);
268
269 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
270 {
271 0 $self->{points_outside} = [];
272 0 return([]);
273 }
274
275 4 my $a = ($width / 2);
276 4 my $a2 = ($a**2);
277 4 my $b = ($height / 2);
278 4 my $c = ($b / $a);
279 4 my $pos_x = ($a + $p_x1);
280 4 my @points_out;
281
282 4 ▶ for(my $x = 0; $x <= $a; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $a) 124 4 128
283 {
284 124 $diff = int($c * sqrt($a2 - ($x**2)));
285 124 $y1 = ($b - $diff);
286 124 $y2 = ($b + $diff);
287 124 $pos_x_p = int($x + $pos_x);
288 124 $pos_x_n = int(-$x + $pos_x);
289
290 124 ▶ for($y = 0; $y <= $y1; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $y1) 1418 124 1542
291 {
292 1418 $pos_y1 = ($y + $p_y1);
293 1418 push(@points_out, [$pos_x_p, $pos_y1]);
294 1418 push(@points_out, [$pos_x_n, $pos_y1]);
295 }
296
297 124 ▶ for($y = $y2; $y <= $height; $y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($y <= $height) 1418 124 1542
298 {
299 1418 $pos_y1 = ($y + $p_y1);
300 1418 push(@points_out, [$pos_x_p, $pos_y1]);
301 1418 push(@points_out, [$pos_x_n, $pos_y1]);
302 }
303 }
304
305 4 $self->{points_outside} = \@points_out;
306 4 return(\@points_out);
307 }
308
309 #-------------------------------------------------
310 sub GetLinesInOval
311 4 ▶{
Subroutine GetLinesInOval: called CC=6 SCAR=18.2
Pod documented
312 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
313 4 my ($pos_x_p, $pos_x_n, $pos_y1, $pos_y2);
314 4 my ($y, $y1, $y2);
315 4 my $diff;
316 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
317 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
318 4 my $width = ($p_x2 - $p_x1);
319 4 my $height= ($p_y2 - $p_y1);
320
321 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
322 {
323 0 $self->{lines_inside} = [];
324 0 return([]);
325 }
326
327 4 my $a = ($width / 2);
328 4 my $a2 = ($a**2);
329 4 my $b = ($height / 2);
330 4 my $c = ($b / $a);
331 4 my $pos_x = ($a + $p_x1);
332 4 my @lines_in;
333
334 4 ▶ for(my $x = 0; $x <= $a; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $a) 124 4 128
335 {
336 124 $diff = int($c * sqrt($a2 - ($x**2)));
337 124 $y1 = ($b - $diff);
338 124 $y2 = ($b + $diff);
339 124 $pos_x_p = int($x + $pos_x);
340 124 $pos_x_n = int(-$x + $pos_x);
341 124 $pos_y1 = ($y1 + $p_y1);
342 124 $pos_y2 = ($y2 + $p_y1);
343 124 push(@lines_in, [$pos_x_p, $pos_y1, $pos_x_p, $pos_y2]);
344 124 push(@lines_in, [$pos_x_n, $pos_y1, $pos_x_n, $pos_y2]);
345 }
346
347 4 $self->{lines_inside} = \@lines_in;
348 4 return(\@lines_in);
349 }
350
351 #-------------------------------------------------
352 sub GetLinesOutOval
353 4 ▶{
Subroutine GetLinesOutOval: called CC=6 SCAR=18.2
Pod documented
354 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
355 4 my ($pos_x_p, $pos_x_n, $pos_y1, $pos_y2);
356 4 my ($y, $y1, $y2);
357 4 my $diff;
358 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
359 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
360 4 my $width = ($p_x2 - $p_x1);
361 4 my $height= ($p_y2 - $p_y1);
362
363 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
364 {
365 0 $self->{lines_outside} = [];
366 0 return([]);
367 }
368
369 4 my $a = ($width / 2);
370 4 my $a2 = ($a**2);
371 4 my $b = ($height / 2);
372 4 my $c = ($b / $a);
373 4 my $pos_x = ($a + $p_x1);
374 4 my @lines_out;
375
376 4 ▶ for(my $x = 0; $x <= $a; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x <= $a) 124 4 128
377 {
378 124 $diff = int($c * sqrt($a2 - ($x**2)));
379 124 $y1 = ($b - $diff);
380 124 $y2 = ($b + $diff);
381 124 $pos_x_p = int($x + $pos_x);
382 124 $pos_x_n = int(-$x + $pos_x);
383 124 $pos_y1 = ($y1 + $p_y1);
384 124 $pos_y2 = ($y2 + $p_y1);
385 124 push(@lines_out, [$pos_x_p, $p_y1, $pos_x_p, $pos_y1]);
386 124 push(@lines_out, [$pos_x_n, $p_y1, $pos_x_n, $pos_y1]);
387 124 push(@lines_out, [$pos_x_p, $pos_y2, $pos_x_p, $p_y2]);
388 124 push(@lines_out, [$pos_x_n, $pos_y2, $pos_x_n, $p_y2]);
389 }
390
391 4 $self->{lines_outside} = \@lines_out;
392 4 return(\@lines_out);
393 }
394
395 #-------------------------------------------------
396 # CIRCLE
397 #-------------------------------------------------
398 sub GetPointsCircle
399 4 ▶{
Subroutine GetPointsCircle: called CC=9 SCAR=22.5
Pod documented
400 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
401 4 my (@points_out, @points_in, @lines_out, @lines_in);
402 4 my ($x2py2, $pos_x, $pos_y1, $pos_y2);
403 4 my ($i_x2, $i_y);
404 4 my $diff_y;
405 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
406 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
407 4 my $width = ($p_x2 - $p_x1);
408 4 my $height= ($p_y2 - $p_y1);
409
410 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
411 {
412 0 $self->{points_outside} = [];
413 0 $self->{points_inside} = [];
414 0 $self->{lines_outside} = [];
415 0 $self->{lines_inside} = [];
416
417 return({
418 0 points_outside => [],
419 points_inside => [],
420 lines_outside => [],
421 lines_inside => []
422 });
423 }
424
425 4 my $r = int($width / 2);
426 4 my $r2 = ($r**2);
427 4 my $coord_x = ($p_x1 + $r);
428 4 my $coord_y = ($p_y1 + $r);
429 4 ▶ for(my $i_x = -$r; $i_x <= $r; $i_x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_x <= $r) 284 4 288
430 {
431 284 $i_x2 = ($i_x ** 2);
432 284 $diff_y = int(sqrt($r2 - $i_x2));
433 284 $pos_x = ($coord_x + $i_x);
434 284 $pos_y1 = ($coord_y + $diff_y);
435 284 $pos_y2 = ($coord_y - $diff_y);
436
437 284 push(@lines_out, [$pos_x, $p_y1, $pos_x, $pos_y2]);
438 284 push(@lines_out, [$pos_x, $pos_y1, $pos_x, $p_y2]);
439 284 push(@lines_in, [$pos_x, $pos_y2, $pos_x, $pos_y1]);
440
441 284 ▶ for($i_y = $r; $i_y >= -$r; $i_y--)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_y >= -$r) 23764 284 24048
442 {
443 23764 $pos_y1 = ($coord_y + $i_y);
444 23764 $x2py2 = ($i_x2 + ($i_y ** 2));
445
446 23764 ▶ if($x2py2 < $r2)
Branch: 2 branches
BranchTrueFalseTotal
if ($x2py2 < $r2) { } 18140 5624 23764
elsif ($x2py2 > $r2) { } 5560 64 5624
447 {
448 18140 push(@points_in, [$pos_x, $pos_y1]);
449 }
450 elsif($x2py2 > $r2)
451 {
452 5560 push(@points_out, [$pos_x, $pos_y1]);
453 }
454 }
455 }
456
457 4 $self->{points_outside} = \@points_out;
458 4 $self->{points_inside} = \@points_in;
459 4 $self->{lines_outside} = \@lines_out;
460 4 $self->{lines_inside} = \@lines_in;
461
462 return({
463 4 points_outside => \@points_out,
464 points_inside => \@points_in,
465 lines_outside => \@lines_out,
466 lines_inside => \@lines_in
467 });
468 }
469
470 #-------------------------------------------------
471 sub GetPointsInCircle
472 4 ▶{
Subroutine GetPointsInCircle: called CC=8 SCAR=21.4
Pod documented
473 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
474 4 my ($x2py2, $i_y);
475 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
476 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
477 4 my $width = ($p_x2 - $p_x1);
478 4 my $height= ($p_y2 - $p_y1);
479
480 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
481 {
482 0 $self->{points_inside} = [];
483 0 return([]);
484 }
485
486 4 my $r = int($width / 2);
487 4 my $r2 = ($r ** 2);
488 4 my $coord_x = ($p_x1 + $r);
489 4 my $coord_y = ($p_y1 + $r);
490 4 my @points_in;
491
492 4 ▶ for(my $i_x = -$r; $i_x <= $r; $i_x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_x <= $r) 284 4 288
493 {
494 284 ▶ for($i_y = $r; $i_y >= -$r; $i_y--)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_y >= -$r) 23764 284 24048
495 {
496 23764 $x2py2 = (($i_x ** 2) + ($i_y ** 2));
497 23764 ▶ if($x2py2 < $r2)
Branch: 1 branch
BranchTrueFalseTotal
if ($x2py2 < $r2) 18140 5624 23764
498 {
499 18140 push(@points_in, [($coord_x + $i_x), ($coord_y + $i_y)]);
500 }
501 }
502 }
503
504 4 $self->{points_inside} = \@points_in;
505 4 return(\@points_in);
506 }
507
508 #-------------------------------------------------
509 sub GetPointsOutCircle
510 4 ▶{
Subroutine GetPointsOutCircle: called CC=8 SCAR=21.4
Pod documented
511 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
512 4 my ($x2py2, $i_y);
513 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
514 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
515 4 my $width = ($p_x2 - $p_x1);
516 4 my $height= ($p_y2 - $p_y1);
517
518 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
519 {
520 0 $self->{points_outside} = [];
521 0 return([]);
522 }
523
524 4 my $r = int($width / 2);
525 4 my $r2 = ($r ** 2);
526 4 my $coord_x = ($p_x1 + $r);
527 4 my $coord_y = ($p_y1 + $r);
528 4 my @points_out;
529
530 4 ▶ for(my $i_x = -$r; $i_x <= $r; $i_x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_x <= $r) 284 4 288
531 {
532 284 ▶ for($i_y = $r; $i_y >= -$r; $i_y--)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_y >= -$r) 23764 284 24048
533 {
534 23764 $x2py2 = (($i_x ** 2) + ($i_y ** 2));
535 23764 ▶ if($x2py2 > $r2)
Branch: 1 branch
BranchTrueFalseTotal
if ($x2py2 > $r2) 5560 18204 23764
536 {
537 5560 push(@points_out, [($coord_x + $i_x), ($coord_y + $i_y)]);
538 }
539 }
540 }
541
542 4 $self->{points_outside} = \@points_out;
543 4 return(\@points_out);
544 }
545
546 #-------------------------------------------------
547 sub GetLinesInCircle
548 4 ▶{
Subroutine GetLinesInCircle: called CC=6 SCAR=18.6
Pod documented
549 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
550 4 my ($x2py2, $pos_x, $diff_y);
551 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
552 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
553 4 my $width = ($p_x2 - $p_x1);
554 4 my $height= ($p_y2 - $p_y1);
555
556 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
557 {
558 0 $self->{lines_inside} = [];
559 0 return([]);
560 }
561
562 4 my $r = int($width / 2);
563 4 my $r2 = ($r ** 2);
564 4 my $coord_x = ($p_x1 + $r);
565 4 my $coord_y = ($p_y1 + $r);
566 4 my @lines_in;
567
568 4 ▶ for(my $i_x = -$r; $i_x <= $r; $i_x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_x <= $r) 284 4 288
569 {
570 284 $pos_x = ($coord_x + $i_x);
571 284 $diff_y = int(sqrt($r2 - ($i_x ** 2)));
572 284 push(@lines_in, [$pos_x, ($coord_y - $diff_y), $pos_x, ($coord_y + $diff_y)]);
573 }
574
575 4 $self->{lines_inside} = \@lines_in;
576 4 return(\@lines_in);
577 }
578
579 #-------------------------------------------------
580 sub GetLinesOutCircle
581 4 ▶{
Subroutine GetLinesOutCircle: called CC=6 SCAR=18.5
Pod documented
582 4 my ($self, $p_x1, $p_y1, $p_x2, $p_y2) = @_;
583 4 my ($x2py2, $pos_x, $diff_y);
584 4 ▶ ($p_x1, $p_x2) = ($p_x2, $p_x1) if($p_x1 > $p_x2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_x1 > $p_x2 0 4 4
585 4 ▶ ($p_y1, $p_y2) = ($p_y2, $p_y1) if($p_y1 > $p_y2);
Branch: 1 branch
BranchTrueFalseTotal
if $p_y1 > $p_y2 0 4 4
586 4 my $width = ($p_x2 - $p_x1);
587 4 my $height= ($p_y2 - $p_y1);
588
589 4 ▶ if(($width < 5) || ($height < 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($width < 5 or $height < 5) 0 4 4
Condition33%1/3
$width < 5 or $height < 5
l!l&&r!l&&!r
004
MC/DC0%0/2
$width < 5 or $height < 5
$width < 5 $height < 5
Truth table33%1/3
A or B
A= $width < 5B= $height < 5
ABresult
1X1
011
000
590 {
591 0 $self->{lines_outside} = [];
592 0 return([]);
593 }
594
595 4 my $r = int($width / 2);
596 4 my $r2 = ($r ** 2);
597 4 my $coord_x = ($p_x1 + $r);
598 4 my $coord_y = ($p_y1 + $r);
599 4 my @lines_out;
600
601 4 ▶ for(my $i_x = -$r; $i_x <= $r; $i_x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_x <= $r) 284 4 288
602 {
603 284 $pos_x = ($coord_x + $i_x);
604 284 $diff_y = int(sqrt($r2 - ($i_x ** 2)));
605 284 push(@lines_out, [$pos_x, $p_y1, $pos_x, ($coord_y - $diff_y)]);
606 284 push(@lines_out, [$pos_x, ($coord_y + $diff_y), $pos_x, $p_y2]);
607 }
608
609 4 $self->{lines_outside} = \@lines_out;
610 4 return(\@lines_out);
611 }
612
613 #-------------------------------------------------
614 # POLYGON
615 #-------------------------------------------------
616 sub GetPointsPolygon
617 4 ▶{
Subroutine GetPointsPolygon: called CC=6 SCAR=17.9
Pod documented
618 4 my ($self) = @_;
619 4 my $ref_p_x = _CalculatePolygon(@_);
620 4 my (@points_out, @points_in, @lines_out, @lines_in);
621 4 my $i_1 = my $i_2 = my $i_3 = 0;
622 4 my $p_x_temp;
623
624 4 ▶ for(my $p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 1164 4 1168
625 {
626 1164 $p_x_temp = $self->{min_x};
627 1164 ▶ for($i_2 = 0; $i_2 <= $#{$ref_p_x->[$i_1]}; $i_2 += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_2 <= $#{$$ref_p_x[$i_1];}) 1258 1164 2422
628 {
629 1258 push(@lines_in, [$ref_p_x->[$i_1][$i_2], $p_y, $ref_p_x->[$i_1][$i_2 + 1], $p_y]);
630 1258 ▶ for($i_3 = $ref_p_x->[$i_1][$i_2]; $i_3 <= $ref_p_x->[$i_1][$i_2 + 1]; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $ref_p_x->[$i_1][$i_2 + 1]) 283914 1258 285172
631 {
632 283914 push(@points_in, [$i_3, $p_y]);
633 }
634
635 1258 push(@lines_out, [$p_x_temp, $p_y, $ref_p_x->[$i_1][$i_2], $p_y]);
636 1258 ▶ for($i_3 = $p_x_temp; $i_3 <= $ref_p_x->[$i_1][$i_2]; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $ref_p_x->[$i_1][$i_2]) 28138 1258 29396
637 {
638 28138 push(@points_out, [$i_3, $p_y]);
639 }
640
641 1258 $p_x_temp = $ref_p_x->[$i_1][$i_2 + 1];
642 }
643
644 1164 push(@lines_out, [$p_x_temp, $p_y, $self->{max_x}, $p_y]);
645 1164 ▶ for($i_3 = $p_x_temp; $i_3 <= $self->{max_x}; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $self->{"max_x"}) 148576 1164 149740
646 {
647 148576 push(@points_out, [$i_3, $p_y]);
648 }
649
650 1164 $i_1++;
651 }
652
653 4 $self->{lines_outside} = \@lines_out;
654 4 $self->{lines_inside} = \@lines_in;
655 4 $self->{points_outside} = \@points_out;
656 4 $self->{points_inside} = \@points_in;
657
658 return({
659 4 lines_outside => \@lines_out,
660 lines_inside => \@lines_in,
661 points_outside => \@points_out,
662 points_inside => \@points_in,
663 });
664 }
665
666 #-------------------------------------------------
667 sub GetPointsInPolygon
668 4 ▶{
Subroutine GetPointsInPolygon: called CC=4 SCAR=13.9
Pod documented
669 4 my ($self) = @_;
670 4 my $ref_p_x = _CalculatePolygon(@_);
671 4 my @points_in = ();
672 4 my $i_1 = my $i_2 = my $i_3 = 0;
673
674 4 ▶ for(my $p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 1164 4 1168
675 {
676 1164 ▶ for($i_2 = 0; $i_2 <= $#{$ref_p_x->[$i_1]}; $i_2 += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_2 <= $#{$$ref_p_x[$i_1];}) 1258 1164 2422
677 {
678 1258 ▶ for($i_3 = $ref_p_x->[$i_1][$i_2]; $i_3 <= $ref_p_x->[$i_1][$i_2 + 1]; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $ref_p_x->[$i_1][$i_2 + 1]) 283914 1258 285172
679 {
680 283914 push(@points_in, [$i_3, $p_y]);
681 }
682 }
683
684 1164 $i_1++;
685 }
686
687 4 $self->{points_inside} = \@points_in;
688 4 return(\@points_in);
689 }
690
691 #-------------------------------------------------
692 sub GetPointsOutPolygon
693 4 ▶{
Subroutine GetPointsOutPolygon: called CC=5 SCAR=16.1
Pod documented
694 4 my ($self) = @_;
695 4 my $ref_p_x = _CalculatePolygon(@_);
696 4 my @points_out = ();
697 4 my $i_1 = my $i_2 = my $i_3 = 0;
698 4 my $p_x_temp;
699
700 4 ▶ for(my $p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 1164 4 1168
701 {
702 1164 $p_x_temp = $self->{min_x};
703 1164 ▶ for($i_2 = 0; $i_2 <= $#{$ref_p_x->[$i_1]}; $i_2 += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_2 <= $#{$$ref_p_x[$i_1];}) 1258 1164 2422
704 {
705 1258 ▶ for($i_3 = $p_x_temp; $i_3 <= $ref_p_x->[$i_1][$i_2]; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $ref_p_x->[$i_1][$i_2]) 28138 1258 29396
706 {
707 28138 push(@points_out, [$i_3, $p_y]);
708 }
709 1258 $p_x_temp = $ref_p_x->[$i_1][$i_2 + 1];
710 }
711
712 1164 ▶ for($i_3 = $p_x_temp; $i_3 <= $self->{max_x}; $i_3++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_3 <= $self->{"max_x"}) 148576 1164 149740
713 {
714 148576 push(@points_out, [$i_3, $p_y]);
715 }
716
717 1164 $i_1++;
718 }
719
720 4 $self->{points_outside} = \@points_out;
721 4 return(\@points_out);
722 }
723
724 #-------------------------------------------------
725 sub GetLinesInPolygon
726 4 ▶{
Subroutine GetLinesInPolygon: called CC=3 SCAR=11.0
Pod documented
727 4 my ($self) = @_;
728 4 my $ref_p_x = _CalculatePolygon(@_);
729 4 my @lines_in = ();
730 4 my $i_1 = my $i_2 = 0;
731
732 4 ▶ for(my $p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 1164 4 1168
733 {
734 1164 ▶ for($i_2 = 0; $i_2 <= $#{$ref_p_x->[$i_1]}; $i_2 += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_2 <= $#{$$ref_p_x[$i_1];}) 1258 1164 2422
735 {
736 1258 push(@lines_in, [$ref_p_x->[$i_1][$i_2], $p_y, $ref_p_x->[$i_1][$i_2 + 1], $p_y]);
737 }
738
739 1164 $i_1++;
740 }
741
742 4 $self->{lines_inside} = \@lines_in;
743 4 return(\@lines_in);
744 }
745
746 #-------------------------------------------------
747 sub GetLinesOutPolygon
748 4 ▶{
Subroutine GetLinesOutPolygon: called CC=3 SCAR=11.0
Pod documented
749 4 my ($self) = @_;
750 4 my $ref_p_x = _CalculatePolygon(@_);
751 4 my @lines_out = ();
752 4 my $i_1 = my $i_2 = 0;
753 4 my $p_x_temp;
754
755 4 ▶ for(my $p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 1164 4 1168
756 {
757 1164 $p_x_temp = $self->{min_x};
758 1164 ▶ for($i_2 = 0; $i_2 <= $#{$ref_p_x->[$i_1]}; $i_2 += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i_2 <= $#{$$ref_p_x[$i_1];}) 1258 1164 2422
759 {
760 1258 push(@lines_out, [$p_x_temp, $p_y, $ref_p_x->[$i_1][$i_2], $p_y]);
761 1258 $p_x_temp = $ref_p_x->[$i_1][$i_2 + 1];
762 }
763
764 1164 push(@lines_out, [$p_x_temp, $p_y, $self->{max_x}, $p_y]);
765 1164 $i_1++;
766 }
767
768 4 $self->{lines_outside} = \@lines_out;
769 4 return(\@lines_out);
770 }
771
772 #-------------------------------------------------
773 sub _CalculatePolygon
774 20 ▶{
Subroutine _CalculatePolygon: called CC=21 SCAR=30.5
775 20 my ($self, @points) = @_;
776 20 my @p;
777
778 20 ▶ for(my $i = 0; $i <= $#points; $i += 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#points) 110 20 130
779 {
780 110 push(@p, { x => $points[$i], y => $points[$i + 1]});
781 }
782
783 20 push(@p, {x => $points[0], y => $points[1]});
784 20 my $points_count = $#p;
785 20 ▶ return([]) if($points_count < 3);
Branch: 1 branch
BranchTrueFalseTotal
if $points_count < 3 0 20 20
786
787 20 my ($index_1, $index_2, $index_count);
788 20 my ($p_y, $p_y1, $p_y2, $p_x1, $p_x2, $p_x_temp);
789 20 my @points_outline_x = ();
790 20 my @all_points_outline_x = ();
791 20 my ($i, $j);
792 20 $self->{min_y} = $self->{max_y} = $p[0]{y};
793 20 $self->{min_x} = $self->{max_x} = $p[0]{x};
794
795 20 for(0..$#p)
796 {
797 130 ▶ $self->{min_y} = $p[$_]{y} if($self->{min_y} > $p[$_]{y});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"min_y"} > $p[$_]{"y"} 0 130 130
798 130 ▶ $self->{max_y} = $p[$_]{y} if($self->{max_y} < $p[$_]{y});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"max_y"} < $p[$_]{"y"} 50 80 130
799 130 ▶ $self->{min_x} = $p[$_]{x} if($self->{min_x} > $p[$_]{x});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"min_x"} > $p[$_]{"x"} 20 110 130
800 130 ▶ $self->{max_x} = $p[$_]{x} if($self->{max_x} < $p[$_]{x});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"max_x"} < $p[$_]{"x"} 30 100 130
801 }
802
803 20 ▶ for($p_y = $self->{min_y}; $p_y <= $self->{max_y}; $p_y++)
Branch: 1 branch
BranchTrueFalseTotal
if ($p_y <= $self->{"max_y"}) 5820 20 5840
804 {
805 5820 $index_count = 0;
806 5820 @points_outline_x = ();
807 5820 ▶ for($i = 0; $i < $points_count; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $points_count) 41510 5820 47330
808 {
809 41510 ▶ if(!$i)
Branch: 1 branch
BranchTrueFalseTotal
if (not $i) { } 5820 35690 41510
810 {
811 5820 $index_1 = $points_count - 1;
812 5820 $index_2 = 0;
813 }
814 else
815 {
816 35690 $index_1 = $i - 1;
817 35690 $index_2 = $i;
818 }
819
820 41510 $p_y1 = $p[$index_1]{y};
821 41510 $p_y2 = $p[$index_2]{y};
822
823 41510 ▶ if($p_y1 < $p_y2)
Branch: 2 branches
BranchTrueFalseTotal
if ($p_y1 < $p_y2) { } 20250 21260 41510
elsif ($p_y1 > $p_y2) { } 21260 0 21260
824 {
825 20250 $p_x1 = $p[$index_1]{x};
826 20250 $p_x2 = $p[$index_2]{x};
827 }
828 elsif ($p_y1 > $p_y2)
829 {
830 21260 $p_y2 = $p[$index_1]{y};
831 21260 $p_y1 = $p[$index_2]{y};
832 21260 $p_x2 = $p[$index_1]{x};
833 21260 $p_x1 = $p[$index_2]{x};
834 }
835 else
836 {
837 0 next;
838 }
839
840 41510 ▶ if(($p_y >= $p_y1) && ($p_y < $p_y2))
Branch: 2 branches
BranchTrueFalseTotal
if ($p_y >= $p_y1 and $p_y < $p_y2) { } 12540 28970 41510
elsif ($p_y == $self->{'max_y'} and $p_y > $p_y1 and $p_y <= $p_y2) { } 40 57790 57830
Condition100%3/3
$p_y >= $p_y1 and $p_y < $p_y2
!ll&&!rl&&r
177201125012540
MC/DC100%2/2
$p_y >= $p_y1 and $p_y < $p_y2
$p_y >= $p_y1 $p_y < $p_y2
Truth table100%3/3
A and B
A= $p_y >= $p_y1B= $p_y < $p_y2
ABresult
0X0
100
111
841 {
842 12540 $points_outline_x[$index_count++] = int((($p_y - $p_y1) * ($p_x2 - $p_x1)) / ($p_y2 - $p_y1) + 0.5 + $p_x1);
843 }
844 ▶ elsif(($p_y == $self->{max_y}) && ($p_y > $p_y1) && ($p_y <= $p_y2))
Condition83%5/6
$p_y == $self->{"max_y"} and $p_y > $p_y1 and $p_y <= $p_y2
!ll&&!rl&&r
288607040
$p_y == $self->{"max_y"} and $p_y > $p_y1
!ll&&!rl&&r
288600110
MC/DC66%2/3
$p_y == $self->{"max_y"} and $p_y > $p_y1 and $p_y <= $p_y2
$p_y == $self->{"max_y"} $p_y > $p_y1 $p_y <= $p_y2
Truth table75%3/4
A and B and C
A= $p_y == $self->{"max_y"}B= $p_y > $p_y1C= $p_y <= $p_y2
ABCresult
0XX0
10X0
1100
1111
845 {
846 40 $points_outline_x[$index_count++] = int((($p_y - $p_y1) * ($p_x2 - $p_x1)) / ($p_y2 - $p_y1) + 0.5 + $p_x1);
847 }
848 }
849
850 5820 ▶ for($i = 1; $i < $index_count; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $index_count) 6760 5820 12580
851 {
852 6760 $p_x_temp = $points_outline_x[$i];
853 6760 $j = $i;
854
855 6760 ▶ while(($j > 0) && ($points_outline_x[$j - 1] > $p_x_temp))
Branch: 1 branch
BranchTrueFalseTotal
if ($j > 0 and $points_outline_x[$j - 1] > $p_x_temp) 6700 6760 13460
Condition100%3/3
$j > 0 and $points_outline_x[$j - 1] > $p_x_temp
!ll&&!rl&&r
529014706700
MC/DC100%2/2
$j > 0 and $points_outline_x[$j - 1] > $p_x_temp
$j > 0 $points_outline_x[$j - 1] > $p_x_temp
Truth table100%3/3
A and B
A= $j > 0B= $points_outline_x[$j - 1] > $p_x_temp
ABresult
0X0
100
111
856 {
857 6700 $points_outline_x[$j] = $points_outline_x[$j - 1];
858 6700 $j--;
859 }
860
861 6760 $points_outline_x[$j] = $p_x_temp;
862 }
863
864 5820 push(@all_points_outline_x, [@points_outline_x]);
865 }
866
867 20 return(\@all_points_outline_x);
868 }
869
870 1 1; # /Tk::Image::Calculation
871
872
873
874 __END__
↑ Summary