line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Barcode::DataMatrix::CharDataFiller; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 Barcode::DataMatrix::CharDataFiller |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Handle filling character data within the data matrix array. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
The documentation for the methods in this class has been adapted from the |
8
|
|
|
|
|
|
|
comments in |
9
|
|
|
|
|
|
|
L. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2010
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 new |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Construct a C object. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
12
|
|
|
12
|
1
|
30
|
my $self = bless {}, shift; |
23
|
12
|
|
|
|
|
56
|
@$self{qw( ncol nrow array )} = @_; |
24
|
12
|
|
|
|
|
37
|
$self->fill(); |
25
|
12
|
|
|
|
|
61
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 module (i, j, k, l) |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Places "chr+bit" with the appropriate wrapping within the array. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub module { |
35
|
14064
|
|
|
14064
|
1
|
18646
|
my ($self,$i,$j,$k,$l) = @_; |
36
|
14064
|
100
|
|
|
|
25024
|
if($i < 0) { |
37
|
287
|
|
|
|
|
400
|
$i += $self->{nrow}; |
38
|
287
|
|
|
|
|
475
|
$j += 4 - ($self->{nrow} + 4) % 8; |
39
|
|
|
|
|
|
|
} |
40
|
14064
|
100
|
|
|
|
23014
|
if($j < 0) { |
41
|
369
|
|
|
|
|
456
|
$j += $self->{ncol}; |
42
|
369
|
|
|
|
|
591
|
$i += 4 - ($self->{ncol} + 4) % 8; |
43
|
|
|
|
|
|
|
} |
44
|
14064
|
|
|
|
|
22778
|
$self->{array}->[$i * $self->{ncol} + $j] = 10 * $k + $l; |
45
|
14064
|
|
|
|
|
19239
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 utah (i, j, k) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Places the 8 bits of a utah-shaped symbol character. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub utah { |
55
|
1754
|
|
|
1754
|
1
|
2415
|
my ($self,$i,$j,$k) = @_; |
56
|
1754
|
|
|
|
|
3709
|
$self->module($i - 2, $j - 2, $k, 1); |
57
|
1754
|
|
|
|
|
3704
|
$self->module($i - 2, $j - 1, $k, 2); |
58
|
1754
|
|
|
|
|
3535
|
$self->module($i - 1, $j - 2, $k, 3); |
59
|
1754
|
|
|
|
|
3501
|
$self->module($i - 1, $j - 1, $k, 4); |
60
|
1754
|
|
|
|
|
3499
|
$self->module($i - 1, $j, $k, 5); |
61
|
1754
|
|
|
|
|
3341
|
$self->module($i, $j - 2, $k, 6); |
62
|
1754
|
|
|
|
|
3432
|
$self->module($i, $j - 1, $k, 7); |
63
|
1754
|
|
|
|
|
3144
|
$self->module($i, $j, $k, 8); |
64
|
1754
|
|
|
|
|
2437
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 corner1 (i) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Places 8 bits of the first of the four special corner cases. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub corner1 { |
74
|
3
|
|
|
3
|
1
|
6
|
my ($self,$i) = @_; |
75
|
3
|
|
|
|
|
13
|
my ($ncol,$nrow) = @$self{qw( ncol nrow )}; |
76
|
3
|
|
|
|
|
10
|
$self->module($nrow - 1, 0, $i, 1); |
77
|
3
|
|
|
|
|
10
|
$self->module($nrow - 1, 1, $i, 2); |
78
|
3
|
|
|
|
|
7
|
$self->module($nrow - 1, 2, $i, 3); |
79
|
3
|
|
|
|
|
9
|
$self->module(0, $ncol - 2, $i, 4); |
80
|
3
|
|
|
|
|
9
|
$self->module(0, $ncol - 1, $i, 5); |
81
|
3
|
|
|
|
|
13
|
$self->module(1, $ncol - 1, $i, 6); |
82
|
3
|
|
|
|
|
8
|
$self->module(2, $ncol - 1, $i, 7); |
83
|
3
|
|
|
|
|
9
|
$self->module(3, $ncol - 1, $i, 8); |
84
|
3
|
|
|
|
|
6
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 corner2 (i) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Places 8 bits of the second of the four special corner cases. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub corner2 { #(int i) |
94
|
1
|
|
|
1
|
1
|
3
|
my ($self,$i) = @_; |
95
|
1
|
|
|
|
|
3
|
my ($ncol,$nrow) = @$self{qw( ncol nrow )}; |
96
|
1
|
|
|
|
|
3
|
$self->module($nrow - 3, 0, $i, 1); |
97
|
1
|
|
|
|
|
3
|
$self->module($nrow - 2, 0, $i, 2); |
98
|
1
|
|
|
|
|
4
|
$self->module($nrow - 1, 0, $i, 3); |
99
|
1
|
|
|
|
|
4
|
$self->module(0, $ncol - 4, $i, 4); |
100
|
1
|
|
|
|
|
4
|
$self->module(0, $ncol - 3, $i, 5); |
101
|
1
|
|
|
|
|
4
|
$self->module(0, $ncol - 2, $i, 6); |
102
|
1
|
|
|
|
|
4
|
$self->module(0, $ncol - 1, $i, 7); |
103
|
1
|
|
|
|
|
4
|
$self->module(1, $ncol - 1, $i, 8); |
104
|
1
|
|
|
|
|
2
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 corner3 (i) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Places 8 bits of the third of the four special corner cases. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub corner3 { #(int i) |
114
|
0
|
|
|
0
|
1
|
0
|
my ($self,$i) = @_; |
115
|
0
|
|
|
|
|
0
|
my ($ncol,$nrow) = @$self{qw( ncol nrow )}; |
116
|
0
|
|
|
|
|
0
|
$self->module($nrow - 3, 0, $i, 1); |
117
|
0
|
|
|
|
|
0
|
$self->module($nrow - 2, 0, $i, 2); |
118
|
0
|
|
|
|
|
0
|
$self->module($nrow - 1, 0, $i, 3); |
119
|
0
|
|
|
|
|
0
|
$self->module(0, $ncol - 2, $i, 4); |
120
|
0
|
|
|
|
|
0
|
$self->module(0, $ncol - 1, $i, 5); |
121
|
0
|
|
|
|
|
0
|
$self->module(1, $ncol - 1, $i, 6); |
122
|
0
|
|
|
|
|
0
|
$self->module(2, $ncol - 1, $i, 7); |
123
|
0
|
|
|
|
|
0
|
$self->module(3, $ncol - 1, $i, 8); |
124
|
0
|
|
|
|
|
0
|
return; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 corner4 (i) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Places 8 bits of the fourth of the four special corner cases. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub corner4 { #(int i) |
134
|
0
|
|
|
0
|
1
|
0
|
my ($self,$i) = @_; |
135
|
0
|
|
|
|
|
0
|
my ($ncol,$nrow) = @$self{qw( ncol nrow )}; |
136
|
0
|
|
|
|
|
0
|
$self->module($nrow - 1, 0, $i, 1); |
137
|
0
|
|
|
|
|
0
|
$self->module($nrow - 1, $ncol - 1, $i, 2); |
138
|
0
|
|
|
|
|
0
|
$self->module(0, $ncol - 3, $i, 3); |
139
|
0
|
|
|
|
|
0
|
$self->module(0, $ncol - 2, $i, 4); |
140
|
0
|
|
|
|
|
0
|
$self->module(0, $ncol - 1, $i, 5); |
141
|
0
|
|
|
|
|
0
|
$self->module(1, $ncol - 3, $i, 6); |
142
|
0
|
|
|
|
|
0
|
$self->module(1, $ncol - 2, $i, 7); |
143
|
0
|
|
|
|
|
0
|
$self->module(1, $ncol - 1, $i, 8); |
144
|
0
|
|
|
|
|
0
|
return; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 fill |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Fills an nrow x ncol array with appropriate values. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub fill { # (int ncol; int nrow; int array;) : void |
154
|
12
|
|
|
12
|
1
|
17
|
my $self = shift; |
155
|
12
|
|
|
|
|
29
|
my ($ncol,$nrow,$array) = @$self{qw( ncol nrow array )}; |
156
|
12
|
|
|
|
|
15
|
my $i = 1; |
157
|
12
|
|
|
|
|
15
|
my $j = 4; |
158
|
12
|
|
|
|
|
17
|
my $k = 0; |
159
|
12
|
|
|
|
|
35
|
for(my $l = 0; $l < $nrow; $l++) { |
160
|
350
|
|
|
|
|
695
|
for(my $i1 = 0; $i1 < $ncol; $i1++) { |
161
|
14076
|
|
|
|
|
32208
|
$array->[$l * $ncol + $i1] = 0; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
12
|
|
100
|
|
|
23
|
do { |
165
|
89
|
100
|
66
|
|
|
221
|
$self->corner1($i++) if $j == $nrow && $k == 0; |
166
|
89
|
50
|
66
|
|
|
215
|
$self->corner2($i++) if $j == $nrow - 2 && $k == 0 && $ncol % 4 != 0; |
|
|
|
66
|
|
|
|
|
167
|
89
|
50
|
66
|
|
|
208
|
$self->corner3($i++) if $j == $nrow - 2 && $k == 0 && $ncol % 8 == 4; |
|
|
|
66
|
|
|
|
|
168
|
89
|
50
|
100
|
|
|
293
|
$self->corner4($i++) if $j == $nrow + 4 && $k == 2 && $ncol % 8 == 0; |
|
|
|
66
|
|
|
|
|
169
|
89
|
|
100
|
|
|
95
|
do { |
170
|
1010
|
100
|
66
|
|
|
6088
|
$self->utah($j, $k, $i++) if $j < $nrow && $k >= 0 && $array->[$j * $ncol + $k] == 0; |
|
|
|
100
|
|
|
|
|
171
|
1010
|
|
|
|
|
1309
|
$j -= 2; |
172
|
1010
|
|
|
|
|
4041
|
$k += 2; |
173
|
|
|
|
|
|
|
} while($j >= 0 && $k < $ncol); |
174
|
89
|
|
|
|
|
115
|
$j++; |
175
|
89
|
|
|
|
|
98
|
$k += 3; |
176
|
89
|
|
100
|
|
|
93
|
do { |
177
|
1010
|
100
|
100
|
|
|
6416
|
$self->utah($j, $k, $i++) if $j >= 0 && $k < $ncol && $array->[$j * $ncol + $k] == 0; |
|
|
|
66
|
|
|
|
|
178
|
1010
|
|
|
|
|
1246
|
$j += 2; |
179
|
1010
|
|
|
|
|
4091
|
$k -= 2; |
180
|
|
|
|
|
|
|
} while($j < $nrow && $k >= 0); |
181
|
89
|
|
|
|
|
104
|
$j += 3; |
182
|
89
|
|
|
|
|
334
|
$k++; |
183
|
|
|
|
|
|
|
} while($j < $nrow || $k < $ncol); |
184
|
12
|
100
|
|
|
|
38
|
$array->[$nrow * $ncol - 1] = $array->[($nrow - 1) * $ncol - 2] = 1 |
185
|
|
|
|
|
|
|
if($array->[$nrow * $ncol - 1] == 0); |
186
|
12
|
|
|
|
|
20
|
return; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |