| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tree::STR::Node;
|
|
2
|
1
|
|
|
1
|
|
10
|
use strict;
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
4
|
1
|
|
|
1
|
|
18
|
use 5.010;
|
|
|
1
|
|
|
|
|
3
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06';
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new {
|
|
9
|
126
|
|
|
126
|
0
|
373
|
my ($class, %args) = @_;
|
|
10
|
|
|
|
|
|
|
my $self = bless {
|
|
11
|
|
|
|
|
|
|
bbox => $args{bbox},
|
|
12
|
|
|
|
|
|
|
children => $args{children},
|
|
13
|
|
|
|
|
|
|
tip => $args{tip},
|
|
14
|
126
|
|
|
|
|
506
|
}, $class;
|
|
15
|
|
|
|
|
|
|
|
|
16
|
126
|
|
|
|
|
477
|
return $self;
|
|
17
|
|
|
|
|
|
|
}
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub is_tip_node {
|
|
20
|
184
|
|
|
184
|
0
|
576
|
!!$_[0]{tip};
|
|
21
|
|
|
|
|
|
|
}
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub is_inner_node {
|
|
24
|
0
|
|
|
0
|
0
|
0
|
!!$_[0]{children};
|
|
25
|
|
|
|
|
|
|
}
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub children {
|
|
28
|
129
|
|
100
|
129
|
0
|
578
|
$_[0]{children} // [];
|
|
29
|
|
|
|
|
|
|
}
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub tip {
|
|
32
|
97
|
|
|
97
|
0
|
362
|
$_[0]{tip};
|
|
33
|
|
|
|
|
|
|
}
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub tips {
|
|
36
|
17
|
|
|
17
|
0
|
44
|
my ($self) = @_;
|
|
37
|
|
|
|
|
|
|
|
|
38
|
17
|
100
|
|
|
|
53
|
return $self->{_tip_array} if $self->{_tip_array};
|
|
39
|
|
|
|
|
|
|
|
|
40
|
16
|
100
|
|
|
|
32
|
return [$self->tip] if $self->is_tip_node;
|
|
41
|
2
|
|
|
|
|
5
|
my @tips;
|
|
42
|
2
|
|
|
|
|
4
|
my @children = @{$self->children};
|
|
|
2
|
|
|
|
|
6
|
|
|
43
|
2
|
|
|
|
|
7
|
while (my $child = shift @children) {
|
|
44
|
122
|
100
|
|
|
|
262
|
if ($child->is_tip_node) {
|
|
45
|
83
|
|
|
|
|
149
|
push @tips, $child->tip;
|
|
46
|
|
|
|
|
|
|
}
|
|
47
|
|
|
|
|
|
|
else {
|
|
48
|
39
|
|
|
|
|
54
|
push @children, @{$child->children};
|
|
|
39
|
|
|
|
|
63
|
|
|
49
|
|
|
|
|
|
|
}
|
|
50
|
|
|
|
|
|
|
}
|
|
51
|
2
|
|
|
|
|
13
|
return $self->{_tip_array} = \@tips;
|
|
52
|
|
|
|
|
|
|
}
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub bbox {
|
|
55
|
205
|
|
|
205
|
0
|
406
|
$_[0]{bbox};
|
|
56
|
|
|
|
|
|
|
}
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub query_point {
|
|
59
|
0
|
|
|
0
|
0
|
|
my ($self, $x, $y) = @_;
|
|
60
|
0
|
|
|
|
|
|
my $bbox = $self->bbox;
|
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
0
|
|
|
|
return [] if $x < $bbox->[0] || $x > $bbox->[2] || $y < $bbox->[1] || $y > $bbox->[3];
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
return [$self->{tip}] if $self->is_tip_node;
|
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my @collated;
|
|
67
|
0
|
|
|
|
|
|
foreach my $child (@{ $self->children }) {
|
|
|
0
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $res = $child->query_point ($x, $y);
|
|
69
|
0
|
|
|
|
|
|
push @collated, @$res;
|
|
70
|
|
|
|
|
|
|
}
|
|
71
|
0
|
|
|
|
|
|
return \@collated;
|
|
72
|
|
|
|
|
|
|
}
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub query_partly_within_rect {
|
|
75
|
0
|
|
|
0
|
0
|
|
my ($self, $x1, $y1, $x2, $y2) = @_;
|
|
76
|
0
|
|
|
|
|
|
my $bbox = $self->bbox;
|
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
0
|
|
|
|
return []
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
79
|
|
|
|
|
|
|
if $x2 < $bbox->[0] || $x1 > $bbox->[2]
|
|
80
|
|
|
|
|
|
|
|| $y2 < $bbox->[1] || $y1 > $bbox->[3];
|
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
return [$self->{tip}] if $self->is_tip_node;
|
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my @collated;
|
|
85
|
0
|
|
|
|
|
|
foreach my $child (@{ $self->children }) {
|
|
|
0
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $res = $child->query_partly_within_rect ($x1, $y1, $x2, $y2);
|
|
87
|
0
|
|
|
|
|
|
push @collated, @$res;
|
|
88
|
|
|
|
|
|
|
}
|
|
89
|
0
|
|
|
|
|
|
return \@collated;
|
|
90
|
|
|
|
|
|
|
}
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub query_completely_within_rect {
|
|
93
|
0
|
|
|
0
|
0
|
|
my ($self, $x1, $y1, $x2, $y2) = @_;
|
|
94
|
0
|
|
|
|
|
|
my $bbox = $self->bbox;
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# no overlap
|
|
97
|
0
|
0
|
0
|
|
|
|
return []
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
98
|
|
|
|
|
|
|
if $x2 < $bbox->[0] || $x1 > $bbox->[2]
|
|
99
|
|
|
|
|
|
|
|| $y2 < $bbox->[1] || $y1 > $bbox->[3];
|
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if ($self->is_tip_node) {
|
|
102
|
|
|
|
|
|
|
# not fully contained
|
|
103
|
0
|
0
|
0
|
|
|
|
return []
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
104
|
|
|
|
|
|
|
if !($x1 < $bbox->[0] && $x2 > $bbox->[2]
|
|
105
|
|
|
|
|
|
|
&& $y1 < $bbox->[1] && $y2 > $bbox->[3]
|
|
106
|
|
|
|
|
|
|
);
|
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return [ $self->{tip} ];
|
|
109
|
|
|
|
|
|
|
}
|
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my @collated;
|
|
112
|
0
|
|
|
|
|
|
foreach my $child (@{ $self->children }) {
|
|
|
0
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $res = $child->query_completely_within_rect ($x1, $y1, $x2, $y2);
|
|
114
|
0
|
|
|
|
|
|
push @collated, @$res;
|
|
115
|
|
|
|
|
|
|
}
|
|
116
|
0
|
|
|
|
|
|
return \@collated;
|
|
117
|
|
|
|
|
|
|
}
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1;
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Tree::STR::Node - Internal helper class for Tree::STR
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 VERSION
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Version 0.01
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut
|