blib/lib/Math/Geometry/Delaunay.pm

filter: Statementstmt 28.3% 294 / 1037 Branchbran 15.8% 93 / 586 Conditioncond 4.3% 16 / 372 MC/DCmcdc 4.0% 8 / 196 Subroutinesub 59.1% 29 / 49 Podpod 57.5% 23 / 40 totaltotal 20.3% 463 / 2280 CC 451 SCAR 82.5
CC
451
Cov
20%
to_svg
10506.0
mic_adjust
6162.0
ray_from_index_poly_intersections
3660.0
CRAP 3825.1
↑ Summary src/triangle.c »
1 package Math::Geometry::Delaunay;
2  
3 8 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Carp qw(carp);;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Exporter();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 our @ISA = qw(Exporter);
10 8 our $VERSION;
11  
12 8 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 ▶ use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 $VERSION = '0.21';
15 8 XSLoader::load('Math::Geometry::Delaunay');
16 8 exactinit();
17 }
18  
19 8 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
20 8 TRI_CONSTRAINED => 'Y',
21 TRI_CONFORMING => 'Dq0',
22 TRI_CCDT => 'q',
23 TRI_VORONOI => 'v',
24 8 };
25  
26 8 our @EXPORT_OK = qw(TRI_CONSTRAINED TRI_CONFORMING TRI_CCDT TRI_VORONOI);
27 8 our @EXPORT = qw();
28  
29 8 my $pi = atan2(1,1)*4;
30  
31 8 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
32 8 my $class = shift;
33 8 my $self = {};
34 8 $self->{in} = Math::Geometry::Delaunay::Triangulateio->new();
35 8 $self->{out} = undef;
36 8 $self->{vorout} = undef;
37 $self->{poly} = {
38 8 regions => [],
39 holes => [],
40 polylines => [],
41 points => [],
42 segments => [],
43 outnodes => [], #for cache, first time C output arrays are imported
44 voutnodes => [], #for cache
45 segptrefs => {}, #used to avoid dups of points added with addSegments
46 };
47  
48 8 $self->{optstr} = '';
49 # Triangle switches
50 # prq__a__uAcDjevngBPNEIOXzo_YS__iFlsCQVh
51 # where __ is an optional number
52 8 $self->{a} = -1; # max tri area
53 8 $self->{q} = -1; # quality min angle
54 8 $self->{e} = 0; # produce edges switch
55 8 $self->{v} = 0; # voronoi switch
56 8 $self->{n} = 0; # neighbors switch
57 8 $self->{N} = 0; # suppress node output
58 8 $self->{E} = 0; # suppress element output
59 8 $self->{O} = 0; # suppress holes - ignore input holes
60 8 $self->{o2}= 0; # subparametric switch (for 6 pts/tri)
61 8 $self->{Q} = 1; # quiet - switch for Triangle's printed output
62 8 $self->{V} = 0; # verbose - from 0 to 3 for increasing verbosity
63  
64 8 bless $self, $class;
65 8 return $self;
66 }
67  
68 21 ▶sub reset {
Subroutine reset: called CC=3 SCAR=11.0
Pod undocumented
69 21 my $self = shift;
70 # clear input
71 21 $self->{poly}->{$_} = [] for qw(regions holes polylines points segments);
72 21 $self->{poly}->{segptrefs} = {};
73 # clear any previous output
74 21 $self->{poly}->{$_} = [] for qw(outnodes voutnodes);
75 }
76  
77 # triangulatio interfaces
78 63 ▶sub in {return $_[0]->{in};}
Subroutine in: called CC=1 SCAR=0.0
Pod undocumented
79 84 ▶sub out {return $_[0]->{out};}
Subroutine out: called CC=1 SCAR=0.0
Pod undocumented
80 29 ▶sub vorout {return $_[0]->{vorout};}
Subroutine vorout: called CC=1 SCAR=0.0
Pod undocumented
81  
82 # getter/setters for the triangulate switches that take numbers
83  
84 3 ▶sub area_constraint { # -1 for disabled
Subroutine area_constraint: called CC=2 SCAR=7.1
Pod documented
85 3 ▶ if (@_>1) {$_[0]->{a}=$_[1];}
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 3 0 3
86 3 return $_[0]->{a};
87 }
88 0 ▶sub minimum_angle { # "q" switch, in degrees, -1 for disabled
Subroutine minimum_angle: not called CC=2 SCAR=17.9
Pod documented
89 0 ▶ if (@_>1) {$_[0]->{q}=$_[1];}
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
90 0 return $_[0]->{q};
91 }
92 0 ▶sub subparametric {
Subroutine subparametric: not called CC=3 SCAR=24.8
Pod undocumented
93 0 ▶ if (@_>1) {$_[0]->{o2}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
$_[1] ? : 0 0 0
94 0 return $_[0]->{o2};
95 }
96 0 ▶sub doEdges {
Subroutine doEdges: not called CC=3 SCAR=24.8
Pod documented
97 0 ▶ if (@_>1) {$_[0]->{e}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
$_[1] ? : 0 0 0
98 0 return $_[0]->{e};
99 }
100 0 ▶sub doVoronoi {
Subroutine doVoronoi: not called CC=3 SCAR=24.8
Pod documented
101 0 ▶ if (@_>1) {$_[0]->{v}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
$_[1] ? : 0 0 0
102 0 return $_[0]->{v};
103 }
104 0 ▶sub doNeighbors {
Subroutine doNeighbors: not called CC=3 SCAR=24.8
Pod documented
105 0 ▶ if (@_>1) {$_[0]->{n}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
$_[1] ? : 0 0 0
106 0 return $_[0]->{n};
107 }
108 8 ▶sub quiet {
Subroutine quiet: called CC=3 SCAR=11.1
Pod documented
109 8 ▶ if (@_>1) {$_[0]->{Q}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 8 0 8
$_[1] ? : 2 6 8
110 8 return $_[0]->{Q};
111 }
112 0 ▶sub verbose { # 0 to 3
Subroutine verbose: not called CC=3 SCAR=24.8
Pod documented
113 0 ▶ if (@_>1) {$_[0]->{V}=$_[1]?1:0;}
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
$_[1] ? : 0 0 0
114 0 return $_[0]->{V};
115 }
116  
117 # everything to add input geometry
118  
119 0 ▶sub addRegion {
Subroutine addRegion: not called CC=11 SCAR=48.8
Pod documented
120 0 my $self = shift;
121 0 my $poly = shift;
122 0 ▶ my $attribute = @_ ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
123 0 ▶ my $area = @_ ? shift:undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
124 0 ▶ my $point_inside = @_ ? shift : undef; # not expected, but we'll use it
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
125  
126 0 ▶ if (@{$poly}==1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$poly;} == 1) { } 0 0 0
elsif (@{$poly;} == 2 and not ref $poly->[0]) { } 0 0 0
127 0 carp "first arg to addRegion should be a polygon, or point";
128 0 return;
129 }
130 0 ▶ elsif (@{$poly}==2 && !ref($poly->[0])) { # a region identifying point
Condition0%0/3
@{$poly;} == 2 and not ref $poly->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@{$poly;} == 2 and not ref $poly->[0]
@{$poly;} == 2 not ref $poly->[0]
Truth table0%0/3
A and not(B)
A= @{$poly;} == 2B= not ref $poly->[0]
ABresult
0X0
100
111
131 0 $point_inside = $poly;
132 }
133 else {
134 0 $self->addPolygon($poly);
135 }
136  
137 0 my $ray; # return ray used for $point_inside calc for debugging, for now
138  
139 0 ▶ if (!$point_inside) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($point_inside) 0 0 0
140 0 ($point_inside, $ray) = get_point_in_polygon($poly);
141 }
142 0 ▶ if (defined $point_inside) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $point_inside) 0 0 0
143 0 ▶ push @{$self->{poly}->{regions}}, [ $point_inside, $attribute, ($area && $area > 0) ? $area : -1 ];
Branch: 1 branch
BranchTrueFalseTotal
$area && $area > 0 ? : 0 0 0
Condition0%0/3
$area and $area > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$area and $area > 0
$area $area > 0
Truth table0%0/3
A and B
A= $areaB= $area > 0
ABresult
0X0
100
111
144 }
145 0 return $point_inside, $ray;
146 }
147  
148 0 ▶sub addHole {
Subroutine addHole: not called CC=7 SCAR=40.3
Pod documented
149 0 my $self = shift;
150 0 my $poly = shift;
151 0 ▶ my $point_inside = @_ ? shift : undef; # not expected, but we'll use it if available
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
152  
153 0 ▶ if (@{$poly}==1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$poly;} == 1) { } 0 0 0
elsif (@{$poly;} == 2 and not ref $poly->[0]) { } 0 0 0
154 0 carp "first arg to addHole should be a polygon, or point";
155 0 return;
156 }
157 0 ▶ elsif (@{$poly}==2 && !ref($poly->[0])) { # it's really the hole identifying point
Condition0%0/3
@{$poly;} == 2 and not ref $poly->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@{$poly;} == 2 and not ref $poly->[0]
@{$poly;} == 2 not ref $poly->[0]
Truth table0%0/3
A and not(B)
A= @{$poly;} == 2B= not ref $poly->[0]
ABresult
0X0
100
111
158 0 $point_inside = $poly;
159 }
160 else {
161 0 $self->addPolygon($poly);
162 }
163  
164 0 my $ray; # return ray used for $point_inside calc for debugging, for now
165  
166 0 ▶ if (!$point_inside) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($point_inside) 0 0 0
167 0 ($point_inside, $ray) = get_point_in_polygon($poly);
168 }
169 0 ▶ if (defined $point_inside) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $point_inside) 0 0 0
170 0 push @{$self->{poly}->{holes}}, $point_inside;
171 }
172 0 return $point_inside, $ray;
173 }
174  
175 3 ▶sub addPolygon {
Subroutine addPolygon: called CC=2 SCAR=7.1
Pod documented
176 3 my $self = shift;
177 3 my $poly = shift;
178 0 ▶ if (@{$poly} == 1 ) {return $self->addPoints([$poly->[0]]);}
Branch: 1 branch
BranchTrueFalseTotal
if (@{$poly;} == 1) 0 3 3
179 3 push @{$self->{poly}->{polylines}}, ['polygon',$poly];
180 3 return;
181 }
182  
183 0 ▶sub addPolyline {
Subroutine addPolyline: not called CC=2 SCAR=17.9
Pod documented
184 0 my $self = shift;
185 0 my $poly = shift;
186 0 ▶ if (@{$poly} == 1 ) {return $self->addPoints([$poly->[0]]);}
Branch: 1 branch
BranchTrueFalseTotal
if (@{$poly;} == 1) 0 0 0
187 0 push @{$self->{poly}->{polylines}}, ['polyline',$poly];
188 0 return;
189 }
190  
191 2 ▶sub addSegments {
Subroutine addSegments: called CC=1 SCAR=0.0
Pod documented
192 2 my $self = shift;
193 2 my $segments = shift;
194 2 push @{$self->{poly}->{segments}}, @{$segments};
195 2 return;
196 }
197  
198 2 ▶sub addPoints { # points unaffiliated with PLSG segments
Subroutine addPoints: called CC=1 SCAR=0.0
Pod documented
199 2 my $self = shift;
200 2 my $points = shift;
201 2 push @{$self->{poly}->{points}}, @{$points};
202 2 return;
203 }
204  
205 # compile all the input geometry in to Triangle-format lists
206 # set up option strings
207 # and initialize output lists
208  
209 21 ▶sub prepPoly {
Subroutine prepPoly: called CC=32 SCAR=41.8
Pod undocumented
210 21 my $self = shift;
211 21 my $optstr = shift;
212 21 $self->{optstr} = '';
213 # option string options:
214 # prq__a__uAcDjevngBPNEIOXzo_YS__iFlsCQVh
215 # where __ is an optional number
216 $self->{optstr} .= ''.
217 $optstr.
218 ($self->{q} > -1?'q'.$self->{q}:'').
219 ($self->{a} > -1?'a'.$self->{a}:'').
220 ($self->{e} ?'e':'').
221 ($self->{v} ?'v':'').
222 ($self->{n} ?'n':'').
223 'z'. # always number everything starting with zero
224 ($self->{o2} ?'o2':'').
225 ($self->{Q} ?'Q':'').
226 21 ▶ ($self->{V} > 0?(($self->{V} > 2) ? 'VVV' : ($self->{V} x 'V')) : '')
Branch: 9 branches
BranchTrueFalseTotal
$self->{'q'} > -1 ? : 0 21 21
$self->{'a'} > -1 ? : 9 12 21
$self->{'e'} ? : 0 21 21
$self->{'v'} ? : 0 21 21
$self->{'n'} ? : 0 21 21
$self->{'o2'} ? : 0 21 21
$self->{'Q'} ? : 7 14 21
$self->{'V'} > 0 ? : 0 21 21
$self->{'V'} > 2 ? : 0 0 0
227 ;
228 21 my @allpts;
229 my @allsegs;
230  
231 21 ▶ if (@{$self->{poly}->{segments}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"poly"}{"segments"};}) 2 19 21
232  
233 # The list of segments is the most likely to have duplicate points.
234 # Some algorithms in this space result in lists of segments,
235 # perhaps listing subsegments of intersecting segments,
236 # or representing a boundary or polygon with out-of-order,
237 # non-contiguous segment lists, where shared vertices are
238 # repeated in each segment's record.
239  
240 # addSegments() is meant for that kind of data
241 # and this is where we boil the duplicate points down,
242 # so Triangle doesn't have to.
243  
244 # We look both for duplicate point references and duplicate coordinates.
245 # The coordinate check could collapse points that are topologically
246 # unique, or it could fail to merge points that should be considered
247 # duplicates - but we hope most of the time it does the best thing.
248  
249 2 foreach my $seg (@{$self->{poly}->{segments}}) {
250 12 ▶ if ( !defined($self->{segptrefs}->{$seg->[0]})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"segptrefs"}{$seg->[0]} or defined $self->{"segptrefs"}{$seg->[0][0] . ',' . $seg->[0][1]}) 8 4 12
Condition66%2/3
defined $self->{"segptrefs"}{$seg->[0]} or defined $self->{"segptrefs"}{$seg->[0][0] . ',' . $seg->[0][1]}
l!l&&r!l&&!r
408
MC/DC50%1/2
defined $self->{"segptrefs"}{$seg->[0]} or defined $self->{"segptrefs"}{$seg->[0][0] . ',' . $seg->[0][1]}
defined $self->{"segptrefs"}{$seg->[0]} defined $self->{"segptrefs"}{$seg->[0][0] . ',' . $seg->[0][1]}
Truth table66%2/3
A or B
A= defined $self->{"segptrefs"}{$seg->[0]}B= defined $self->{"segptrefs"}{$seg->[0][0] . ',' . $seg->[0][1]}
ABresult
1X1
011
000
251 && !defined($self->{segptrefs}->{$seg->[0]->[0].','.$seg->[0]->[1]})
252 ) {
253 8 push @allpts, $seg->[0];
254 8 $self->{segptrefs}->{$seg->[0]} = $#allpts;
255 8 $self->{segptrefs}->{$seg->[0]->[0].','.$seg->[0]->[1]} = $#allpts;
256 }
257 push @allsegs, defined($self->{segptrefs}->{$seg->[0]})
258 ? $self->{segptrefs}->{$seg->[0]}
259 12 ▶ : $self->{segptrefs}->{$seg->[0]->[0].','.$seg->[0]->[1]};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'segptrefs'}{$seg->[0]} ? : 12 0 12
260 12 ▶ if ( !defined($self->{segptrefs}->{$seg->[1]})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"segptrefs"}{$seg->[1]} or defined $self->{"segptrefs"}{$seg->[1][0] . ',' . $seg->[1][1]}) 4 8 12
Condition100%3/3
defined $self->{"segptrefs"}{$seg->[1]} or defined $self->{"segptrefs"}{$seg->[1][0] . ',' . $seg->[1][1]}
l!l&&r!l&&!r
624
MC/DC100%2/2
defined $self->{"segptrefs"}{$seg->[1]} or defined $self->{"segptrefs"}{$seg->[1][0] . ',' . $seg->[1][1]}
defined $self->{"segptrefs"}{$seg->[1]} defined $self->{"segptrefs"}{$seg->[1][0] . ',' . $seg->[1][1]}
Truth table100%3/3
A or B
A= defined $self->{"segptrefs"}{$seg->[1]}B= defined $self->{"segptrefs"}{$seg->[1][0] . ',' . $seg->[1][1]}
ABresult
1X1
011
000
261 && !defined($self->{segptrefs}->{$seg->[1]->[0].','.$seg->[1]->[1]})
262 ) {
263 4 push @allpts, $seg->[1];
264 4 $self->{segptrefs}->{$seg->[1]} = $#allpts;
265 4 $self->{segptrefs}->{$seg->[1]->[0].','.$seg->[1]->[1]} = $#allpts;
266 }
267 push @allsegs, defined($self->{segptrefs}->{$seg->[1]})
268 ? $self->{segptrefs}->{$seg->[1]}
269 12 ▶ : $self->{segptrefs}->{$seg->[1]->[0].','.$seg->[1]->[1]};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'segptrefs'}{$seg->[1]} ? : 10 2 12
270 }
271 }
272 21 $self->{segptrefs} = {};
273  
274 21 ▶ if (@{$self->{poly}->{polylines}} || @allsegs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"poly"}{"polylines"};} or @allsegs) 5 16 21
Condition100%3/3
@{$self->{"poly"}{"polylines"};} or @allsegs
l!l&&r!l&&!r
3216
MC/DC100%2/2
@{$self->{"poly"}{"polylines"};} or @allsegs
@{$self->{"poly"}{"polylines"};} @allsegs
Truth table100%3/3
A or B
A= @{$self->{"poly"}{"polylines"};}B= @allsegs
ABresult
1X1
011
000
275 # doing PSLG - add poly flag to options
276 5 $self->{optstr} = 'p'.$self->{optstr};
277 #set up points and segments lists for each polygon and polyline
278 5 foreach my $polycont (@{$self->{poly}->{polylines}}) {
279 3 my $poly = $polycont->[1];
280 3 push @allpts, $poly->[0];
281 3 my $startind=$#allpts;
282 3 foreach my $thispt (@{$poly}[1..@{$poly}-1]) {
283 11 push(@allsegs, $#allpts, $#allpts + 1);
284 11 push(@allpts, $thispt);
285 }
286 3 ▶ if ($polycont->[0] eq 'polygon') { # add segment to close it
Branch: 1 branch
BranchTrueFalseTotal
if ($polycont->[0] eq "polygon") 3 0 3
287 3 push(@allsegs, $#allpts, $startind);
288 }
289  
290 }
291 # add segments to C struct
292 5 my $segs_added_count = $self->in->segmentlist(@allsegs);
293  
294 # Add region mark points and any attributes and area constraints to C struct
295 5 ▶ if (@{$self->{poly}->{regions}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"poly"}{"regions"};}) 0 5 5
296 0 my $regions_added_count = $self->in->regionlist(map {grep defined, @{$_->[0]},$_->[1],$_->[2]} @{$self->{poly}->{regions}});
297 }
298 # Add hole mark points to C struct
299 5 ▶ if (@{$self->{poly}->{holes}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"poly"}{"holes"};}) 0 5 5
300 0 my $holes_added_count = $self->in->holelist(map {@{$_}} @{$self->{poly}->{holes}});
301 }
302 }
303  
304 # add all points from PSLG, (possibly none)
305 # and then any other points (not associated with segments)
306 # into the C struct
307 21 my $points_added_count = $self->in->pointlist(map {$_->[0],$_->[1]} (@allpts, @{$self->{poly}->{points}}));
308  
309 # set up attribute array if any points have more than 2 items (the coordinates) in list
310 21 my $coords_plus_attrs = 2; # 2 for the coords - we'll skip over them when it's time
311 21 foreach my $point (@allpts, @{$self->{poly}->{points}}) {
312 0 ▶ if ($coords_plus_attrs < @{$point}) {$coords_plus_attrs = @{$point}}
Branch: 1 branch
BranchTrueFalseTotal
if ($coords_plus_attrs < @{$point;}) 0 34 34
313 }
314 21 ▶ if ($coords_plus_attrs > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($coords_plus_attrs > 2) 0 21 21
315 # Extend / fill in the attribute lists for any points
316 # that don't have the full set of attributes defined.
317 # Set missing/undefined attributes to zero.
318 0 foreach my $point (@allpts, @{$self->{poly}->{points}}) {
319 0 ▶ if (@{$point} < $coords_plus_attrs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$point;} < $coords_plus_attrs) 0 0 0
320 0 foreach (2 .. $coords_plus_attrs - 1) {
321 0 ▶ if (!defined($point->[$_])) {$point->[$_]=0;}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $point->[$_]) 0 0 0
322 }
323 }
324 }
325 # put attributes into C struct
326 0 $self->in->numberofpointattributes($coords_plus_attrs - 2);
327 my $attributes_added_count = $self->in->pointattributelist(
328 0 map {@{$_}[2 .. $coords_plus_attrs - 1]} (@allpts, @{$self->{poly}->{points}}));
329 }
330  
331 # discard intermediate data now that it's been loaded into C arrays
332 21 $self->reset();
333  
334 # set up new triangulateio C structs to receive output
335 21 $self->{out} = Math::Geometry::Delaunay::Triangulateio->new();
336 21 $self->{vorout} = Math::Geometry::Delaunay::Triangulateio->new();
337  
338 21 return;
339 }
340  
341  
342 21 ▶sub triangulate() {
Subroutine triangulate: called CC=6 SCAR=19.1
Pod documented
343 21 my $self = shift;
344 21 ▶ my $dotopo = defined wantarray && !wantarray; # scalar or array return context
Condition66%2/3
defined wantarray && !wantarray
!ll&&!rl&&r
1803
MC/DC50%1/2
defined wantarray && !wantarray
defined wantarray !wantarray
Truth table66%2/3
A && not(B)
A= defined wantarrayB= !wantarray
ABresult
0X0
100
111
345 21 ▶ my $optstr = @_ ? join('',@_):'';
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 21 0 21
346 21 $self->prepPoly($optstr);
347 21 Math::Geometry::Delaunay::_triangulate($self->{optstr},$self->in->to_ptr,$self->out->to_ptr,$self->vorout->to_ptr);
348 21 ▶ if (defined wantarray) { # else don't do expensive topology stuff if undef/void context
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) 3 18 21
349 3 ▶ if (wantarray && index($self->{optstr},'v') != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray and index($self->{"optstr"}, "v") != -1) 0 3 3
Condition33%1/3
wantarray and index($self->{"optstr"}, "v") != -1
!ll&&!rl&&r
300
MC/DC0%0/2
wantarray and index($self->{"optstr"}, "v") != -1
wantarray index($self->{"optstr"}, "v") != -1
Truth table33%1/3
A and B
A= wantarrayB= index($self->{"optstr"}, "v") != -1
ABresult
0X0
100
111
350 0 return topology($self->out), topology($self->vorout);
351 }
352 3 return topology($self->out);
353 }
354 18 return;
355 }
356  
357 # This probably performs well, but it does show up high enough in profiler
358 # reports that it's worth looking into speed-up. Consider something with unpack maybe.
359 28 ▶sub ltolol {($#_<$_[0])?():map [@_[$_*$_[0]+1..$_*$_[0]+$_[0]]],0..$#_/$_[0]-1}#perl.
Subroutine ltolol: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$#_ < $_[0] ? : 6 22 28
360  
361 14 ▶sub nodes {
Subroutine nodes: called CC=9 SCAR=22.3
Pod documented
362 14 my $self = shift;
363 14 ▶ my $fromVouty = @_ ? shift : 0;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 5 9 14
364 14 ▶ my $triio = $fromVouty ? $self->vorout : $self->out;
Branch: 1 branch
BranchTrueFalseTotal
$fromVouty ? : 2 12 14
365 14 ▶ my $cachetarg = $fromVouty ? 'voutnodes' : 'outnodes';
Branch: 1 branch
BranchTrueFalseTotal
$fromVouty ? : 2 12 14
366 14 ▶ if (@{$self->{poly}->{$cachetarg}} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"poly"}{$cachetarg};} == 0) 4 10 14
367 4 my @nodeattributes;
368 4 ▶ if ($triio->numberofpointattributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($triio->numberofpointattributes) 0 4 4
369 0 @nodeattributes = ltolol($triio->numberofpointattributes,$triio->pointattributelist);
370 }
371 4 @{$self->{poly}->{$cachetarg}} = ltolol(2,$triio->pointlist);
372 4 ▶ for (my $i=0;$i<@nodeattributes;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @nodeattributes) 0 4 4
373 0 push @{$self->{poly}->{$cachetarg}->[$i]}, @{$nodeattributes[$i]};
374 }
375 4 ▶ if (!$fromVouty) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fromVouty) 3 1 4
376 3 my @nodemarkers = $triio->pointmarkerlist;
377 3 ▶ for (my $i=0;$i<@nodemarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @nodemarkers) 18 3 21
378 18 push @{$self->{poly}->{$cachetarg}->[$i]}, $nodemarkers[$i];
379 }
380 }
381 }
382 14 return $self->{poly}->{$cachetarg};
383 }
384  
385 1 ▶sub elements {
Subroutine elements: called CC=3 SCAR=11.9
Pod documented
386 1 my $self = shift;
387 1 my $triio = $self->out;
388 1 my $nodes = $self->nodes;
389 1 my @outelements;
390 my @triangleattributes;
391 1 ▶ if ($triio->numberoftriangleattributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($triio->numberoftriangleattributes) 0 1 1
392 0 @triangleattributes = ltolol($triio->numberoftriangleattributes,$triio->triangleattributelist);
393 }
394 1 @outelements = map {[map {$nodes->[$_]} @{$_}]} ltolol($triio->numberofcorners,$triio->trianglelist);
395 1 ▶ for (my $i=0;$i<@triangleattributes;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @triangleattributes) 0 1 1
396 0 push @{$outelements[$i]}, @{$triangleattributes[$i]};
397 }
398 1 return \@outelements;
399 }
400  
401 3 ▶sub segments {
Subroutine segments: called CC=2 SCAR=6.9
Pod documented
402 3 my $self = shift;
403 3 my $triio = $self->out;
404 3 my $nodes = $self->nodes;
405 3 my @outsegments;
406 3 my @segmentmarkers = $triio->segmentmarkerlist;
407 3 @outsegments = map {[$nodes->[$_->[0]],$nodes->[$_->[1]]]} ltolol(2,$triio->segmentlist);
408 3 ▶ for (my $i=0;$i<@segmentmarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @segmentmarkers) 18 3 21
409 18 push @{$outsegments[$i]}, $segmentmarkers[$i];
410 }
411 3 return \@outsegments;
412 }
413
414 4 ▶sub edges {
Subroutine edges: called CC=6 SCAR=17.9
Pod documented
415 4 my $self = shift;
416 4 ▶ my $fromVouty = @_ ? shift : 0;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 3 4
417 4 ▶ my $triio = $fromVouty ? $self->vorout : $self->out;
Branch: 1 branch
BranchTrueFalseTotal
$fromVouty ? : 1 3 4
418 4 my $nodes = $self->nodes($fromVouty);
419 4 my @outedges;
420 4 ▶ @outedges = map {[map { $_==-1?0:$nodes->[$_]} @{$_}]} ltolol(2,$triio->edgelist);
Branch: 1 branch
BranchTrueFalseTotal
$_ == -1 ? : 6 66 72
421 4 ▶ if (!$fromVouty) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fromVouty) 3 1 4
422 3 my @edgemarkers = $triio->edgemarkerlist;
423 3 ▶ for (my $i=0;$i<@edgemarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @edgemarkers) 27 3 30
424 27 push @{$outedges[$i]}, $edgemarkers[$i];
425 }
426 }
427 4 return \@outedges;
428 }
429  
430 1 ▶sub vnodes {return $_[0]->nodes(1);}
Subroutine vnodes: called CC=1 SCAR=0.0
Pod documented
431  
432 1 ▶sub vedges {
Subroutine vedges: called CC=4 SCAR=14.0
Pod documented
433 1 my $self = shift;
434 1 my $vedges = $self->edges(1);
435 1 my $triio = $self->vorout;
436 1 my @outrays;
437 1 @outrays = ltolol(2,$triio->normlist);
438 1 ▶ for (my $i=0;$i<@{$vedges};$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$vedges;}) 9 1 10
439 # if one end was a ray (missing node ref)
440 # look up the direction vector and use that as missing point
441 # and set third element in edge array to true
442 # as a flag to identify this edge as a ray
443 9 ▶ if (!$vedges->[$i]->[0]) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $vedges->[$i][0]) { } 0 9 9
elsif (not $vedges->[$i][1]) { } 6 3 9
444 0 $vedges->[$i]->[0] = $outrays[$i];
445 0 $vedges->[$i]->[2] = 1;
446 }
447 elsif (!$vedges->[$i]->[1]) {
448 6 $vedges->[$i]->[1] = $outrays[$i];
449 6 $vedges->[$i]->[2] = 2;
450 }
451 else {
452 3 $vedges->[$i]->[2] = 0;
453 }
454 }
455 1 return $vedges;
456 }
457  
458 3 ▶sub topology {
Subroutine topology: called CC=23 SCAR=32.4
Pod undocumented
459 3 my $triio = shift;
460  
461 3 my $isVoronoi = 0; # we'll detect this when reading edges
462  
463 3 my $pcnt = 0; # In Voronoi diagram node index corresponds to dual Delaunay element.
464 3 my @nodes = map {{ point => $_, attributes => [], marker => undef, elements => [], edges => [] , segments => [], index => $pcnt++}} ltolol(2,$triio->pointlist);
465 3 my $tcnt = 0; # In Delaunay triangulation element index corresponds to dual Voronoi node.
466 3 my @eles = map {my $ele={ nodes=>[map {$nodes[$_]} @{$_}], marker => undef, edges => [], neighbors => [], attributes => [], index => $tcnt++ }; foreach (@{$ele->{nodes}}) {push(@{$_->{elements}},$ele)};$ele} ltolol($triio->numberofcorners,$triio->trianglelist);
467 3 my $ecnt = 0; # Corresponding edges in the Delaunay and Voronoi topologies will have the same index.
468 0 ▶ my @edges = map {my $edg={ nodes=>[map {$nodes[$_]} grep {$_>-1} @{$_}], marker => undef, elements => [], vector => undef, index => $ecnt++}; foreach (@{$edg->{nodes}}) {push @{$_->{edges} },$edg};if (!$isVoronoi && ($_->[0] == -1 || $_->[1] == -1)) {$isVoronoi = 1};$edg} ltolol(2,$triio->edgelist);
Branch: 1 branch
BranchTrueFalseTotal
if (not $isVoronoi and $_->[0] == -1 || $_->[1] == -1) 0 8 8
Condition33%2/6
not $isVoronoi and $_->[0] == -1 || $_->[1] == -1
!ll&&!rl&&r
080
$_->[0] == -1 or $_->[1] == -1
l!l&&r!l&&!r
008
MC/DC0%0/3
not $isVoronoi and $_->[0] == -1 || $_->[1] == -1
not $isVoronoi $_->[0] == -1 $_->[1] == -1
Truth table25%1/4
not(A) and B or C
A= not $isVoronoiB= $_->[0] == -1C= $_->[1] == -1
ABCresult
0XX0
1000
11X1
1011
469 3 my @segs = map {my $edg={ nodes=>[map {$nodes[$_]} @{$_}], marker => undef, elements => [] }; foreach (@{$edg->{nodes}}) {push @{$_->{segments}},$edg}; $edg} ltolol(2,$triio->segmentlist);
470  
471 3 my @elementattributes;
472 3 ▶ if ($triio->numberoftriangleattributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($triio->numberoftriangleattributes) 0 3 3
473 0 @elementattributes = ltolol($triio->numberoftriangleattributes,$triio->triangleattributelist);
474 }
475 3 ▶ for (my $i=0;$i<@elementattributes;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @elementattributes) 0 3 3
476 0 $eles[$i]->{attributes} = $elementattributes[$i];
477 }
478 3 my @nodeattributes;
479 3 ▶ if ($triio->numberofpointattributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($triio->numberofpointattributes) 0 3 3
480 0 @nodeattributes = ltolol($triio->numberofpointattributes,$triio->pointattributelist);
481 }
482 3 my @nodemarkers = $triio->pointmarkerlist; # always there for pslg, unlike attributes
483 3 ▶ for (my $i=0;$i<@nodemarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @nodemarkers) 15 3 18
484 15 ▶ if ($triio->numberofpointattributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($triio->numberofpointattributes) 0 15 15
485 0 $nodes[$i]->{attributes} = $nodeattributes[$i];
486 }
487 15 $nodes[$i]->{marker} = $nodemarkers[$i];
488 }
489 3 my @edgemarkers = $triio->edgemarkerlist;
490 3 ▶ for (my $i=0;$i<@edgemarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @edgemarkers) 8 3 11
491 8 $edges[$i]->{marker} = $edgemarkers[$i];
492 }
493 3 my @segmentmarkers = $triio->segmentmarkerlist; # because some can be internal to boundaries
494 3 ▶ for (my $i=0;$i<@segmentmarkers;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @segmentmarkers) 4 3 7
495 4 $segs[$i]->{marker} = $segmentmarkers[$i];
496 }
497 3 my @neighs = ltolol(3,$triio->neighborlist);
498 3 ▶ for (my $i=0;$i<@neighs;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @neighs) 4 3 7
499 4 $eles[$i]->{neighbors} = [map {$eles[$_]} grep {$_ != -1} @{$neighs[$i]}];
500 }
501 3 ▶ if ($isVoronoi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isVoronoi) 0 3 3
502 0 my @edgevectors = ltolol(2,$triio->normlist); # voronoi ray vectors
503 0 ▶ for (my $i=0;$i<@edgevectors;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @edgevectors) 0 0 0
504 0 $edges[$i]->{vector} = $edgevectors[$i];
505 }
506 }
507  
508 # cross reference elements and edges
509 3 ▶ if (@edges) { # but only if edges were generated
Branch: 1 branch
BranchTrueFalseTotal
if (@edges) 1 2 3
510 1 foreach my $ele (@eles) {
511 4 ▶ for (my $i=-1;$i<@{$ele->{nodes}}-1;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$ele->{"nodes"};} - 1) 12 4 16
512 12 foreach my $edge (@{$ele->{nodes}->[$i]->{edges}}) {
513 26 ▶ if ($ele->{nodes}->[$i+1] == $edge->{nodes}->[0] || $ele->{nodes}->[$i+1] == $edge->{nodes}->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[0] or $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[1]) 12 14 26
Condition100%3/3
$ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[0] or $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[1]
l!l&&r!l&&!r
4814
MC/DC100%2/2
$ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[0] or $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[1]
$ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[0] $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[1]
Truth table100%3/3
A or B
A= $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[0]B= $ele->{"nodes"}[$i + 1] == $edge->{"nodes"}[1]
ABresult
1X1
011
000
514 12 push @{$ele->{edges}}, $edge;
515 12 push @{$edge->{elements}}, $ele;
516 12 last;
517 }
518 }
519 }
520 }
521 }
522  
523 3 my $ret = {
524 nodes => \@nodes,
525 edges => \@edges,
526 segments => \@segs,
527 elements => \@eles
528 };
529 3 bless $ret, 'mgd_topo'; # gives the hash a DESTROY method that helps with garbage collection
530 3 return $ret;
531 }
532  
533 0 ▶sub get_point_in_polygon {
Subroutine get_point_in_polygon: not called CC=15 SCAR=54.8
Pod undocumented
534 0 my $poly = shift;
535 0 my $point_inside;
536  
537 0 my $bottom_left_index=0;
538 0 my $maxy = $poly->[$bottom_left_index]->[1];
539 0 ▶ for (my $i=1;$i<@{$poly};$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$poly;}) 0 0 0
540 0 ▶ if ($poly->[$i]->[1] <= $poly->[$bottom_left_index]->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poly->[$i][1] <= $poly->[$bottom_left_index][1]) 0 0 0
541 0 ▶ if ($poly->[$i]->[1] < $poly->[$bottom_left_index]->[1] ||
Branch: 1 branch
BranchTrueFalseTotal
if ($poly->[$i][1] < $poly->[$bottom_left_index][1] or $poly->[$i][0] < $poly->[$bottom_left_index][0]) 0 0 0
Condition0%0/3
$poly->[$i][1] < $poly->[$bottom_left_index][1] or $poly->[$i][0] < $poly->[$bottom_left_index][0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$poly->[$i][1] < $poly->[$bottom_left_index][1] or $poly->[$i][0] < $poly->[$bottom_left_index][0]
$poly->[$i][1] < $poly->[$bottom_left_index][1] $poly->[$i][0] < $poly->[$bottom_left_index][0]
Truth table0%0/3
A or B
A= $poly->[$i][1] < $poly->[$bottom_left_index][1]B= $poly->[$i][0] < $poly->[$bottom_left_index][0]
ABresult
1X1
011
000
542 $poly->[$i]->[0] < $poly->[$bottom_left_index]->[0]
543 ) {
544 0 $bottom_left_index = $i;
545 }
546 }
547 0 ▶ if ($maxy < $poly->[$i]->[1]) { $maxy = $poly->[$i]->[1] }
Branch: 1 branch
BranchTrueFalseTotal
if ($maxy < $poly->[$i][1]) 0 0 0
548 }
549 0 my $prev_index = $bottom_left_index;
550 0 my $next_index = -1 * @{$poly} + $bottom_left_index;
551 0 ▶ --$prev_index
Branch: 1 branch
BranchTrueFalseTotal
$poly->[$prev_index][0] == $poly->[$bottom_left_index][0] and $poly->[$prev_index][1] == $poly->[$bottom_left_index][1] and do { --$prev_index } 0 0 0
Condition0%0/3
$poly->[$prev_index][0] == $poly->[$bottom_left_index][0] and $poly->[$prev_index][1] == $poly->[$bottom_left_index][1]
!ll&&!rl&&r
000
MC/DC0%0/2
$poly->[$prev_index][0] == $poly->[$bottom_left_index][0] and $poly->[$prev_index][1] == $poly->[$bottom_left_index][1]
$poly->[$prev_index][0] == $poly->[$bottom_left_index][0] $poly->[$prev_index][1] == $poly->[$bottom_left_index][1]
Truth table0%0/3
A and B
A= $poly->[$prev_index][0] == $poly->[$bottom_left_index][0]B= $poly->[$prev_index][1] == $poly->[$bottom_left_index][1]
ABresult
0X0
100
111
552 while ($poly->[$prev_index]->[0] == $poly->[$bottom_left_index]->[0] &&
553 $poly->[$prev_index]->[1] == $poly->[$bottom_left_index]->[1]
554 );
555 0 ▶ ++$next_index
Branch: 1 branch
BranchTrueFalseTotal
$poly->[$next_index][0] == $poly->[$bottom_left_index][0] and $poly->[$next_index][1] == $poly->[$bottom_left_index][1] and do { ++$next_index } 0 0 0
Condition0%0/3
$poly->[$next_index][0] == $poly->[$bottom_left_index][0] and $poly->[$next_index][1] == $poly->[$bottom_left_index][1]
!ll&&!rl&&r
000
MC/DC0%0/2
$poly->[$next_index][0] == $poly->[$bottom_left_index][0] and $poly->[$next_index][1] == $poly->[$bottom_left_index][1]
$poly->[$next_index][0] == $poly->[$bottom_left_index][0] $poly->[$next_index][1] == $poly->[$bottom_left_index][1]
Truth table0%0/3
A and B
A= $poly->[$next_index][0] == $poly->[$bottom_left_index][0]B= $poly->[$next_index][1] == $poly->[$bottom_left_index][1]
ABresult
0X0
100
111
556 while ($poly->[$next_index]->[0] == $poly->[$bottom_left_index]->[0] &&
557 $poly->[$next_index]->[1] == $poly->[$bottom_left_index]->[1]
558 );
559  
560 0 my @vec1 = ($poly->[$bottom_left_index]->[0] - $poly->[$prev_index]->[0],
561 $poly->[$bottom_left_index]->[1] - $poly->[$prev_index]->[1]);
562 0 my @vec2 = ($poly->[$next_index]->[0] - $poly->[$bottom_left_index]->[0],
563 $poly->[$next_index]->[1] - $poly->[$bottom_left_index]->[1]);
564 0 ▶ my $orient = (($vec1[0]*$vec2[1] - $vec2[0]*$vec1[1])>=0) ? 1:0;
Branch: 1 branch
BranchTrueFalseTotal
$vec1[0] * $vec2[1] - $vec2[0] * $vec1[1] >= 0 ? : 0 0 0
565
566 0 my $angle1 = atan2($poly->[$prev_index]->[1] - $poly->[$bottom_left_index]->[1], $poly->[$prev_index]->[0] - $poly->[$bottom_left_index]->[0]);
567 0 my $angle2 = atan2($poly->[$next_index]->[1] - $poly->[$bottom_left_index]->[1], $poly->[$next_index]->[0] - $poly->[$bottom_left_index]->[0]);
568 0 my $angle;
569 0 ▶ if ($orient) {$angle = $angle2 + ($angle1 - $angle2)/2;}
Branch: 1 branch
BranchTrueFalseTotal
if ($orient) { } 0 0 0
570 0 else {$angle = $angle1 + ($angle2 - $angle1)/2;}
571 0 my $cosangle = cos($angle);
572 0 my $sinangle = sin($angle);
573 0 my $tanangle = $sinangle/$cosangle;
574  
575 0 ▶ my $adequate_distance = 1.1 * ($maxy - $poly->[$bottom_left_index]->[1]) *
Branch: 1 branch
BranchTrueFalseTotal
abs $cosangle < 1e-08 ? : 0 0 0
576 ((abs($cosangle) < 0.00000001) ? 1 : 1/$sinangle);
577 0 my $point_wayout = [$poly->[$bottom_left_index]->[0] + $adequate_distance * $cosangle,
578 $poly->[$bottom_left_index]->[1] + $adequate_distance * $sinangle];
579  
580 0 my @intersections = sort {$a->[2] <=> $b->[2]} ray_from_index_poly_intersections($bottom_left_index,$point_wayout,$poly,1);
581  
582 0 ▶ if (!@intersections) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @intersections) { } 0 0 0
elsif ($#intersections % 2 != 0) { } 0 0 0
583 0 print "Warning: Failed to calculate hole or region indicator point.";
584 }
585 elsif ($#intersections % 2 != 0) {
586 0 print "Warning: Calculated hole or region indicator point is not inside its polygon.";
587 }
588 else {
589 0 my $closest_intersection = $intersections[0];
590 0 $point_inside = [($poly->[$bottom_left_index]->[0] + $closest_intersection->[0])/2,
591 ($poly->[$bottom_left_index]->[1] + $closest_intersection->[1])/2];
592 }
593 0 return $point_inside;
594 }
595  
596 0 ▶sub ray_from_index_poly_intersections {
Subroutine ray_from_index_poly_intersections: not called CC=60 SCAR=82.1
Pod undocumented
597 0 my $vertind = shift;
598 0 my $raypt = shift;
599 0 my $poly = shift;
600 0 ▶ my $doDists = @_ ? shift : 0;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
601  
602 0 my $seg1 = [$poly->[$vertind],$raypt];
603 0 my $x1= $seg1->[0]->[0];
604 0 my $y1= $seg1->[0]->[1];
605 0 my $x2= $seg1->[1]->[0];
606 0 my $y2= $seg1->[1]->[1];
607 0 ▶ my @lowhix=($x2>$x1)?($x1,$x2):($x2,$x1);
Branch: 1 branch
BranchTrueFalseTotal
$x2 > $x1 ? : 0 0 0
608 0 ▶ my @lowhiy=($y2>$y1)?($y1,$y2):($y2,$y1);
Branch: 1 branch
BranchTrueFalseTotal
$y2 > $y1 ? : 0 0 0
609  
610 0 my @intersections;
611  
612 0 ▶ for (my $i = -1; $i < $#$poly; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $poly->$#*) 0 0 0
613  
614 # skip the segs on either side of the ray base point
615 0 ▶ next if $i == $vertind || ($i + 1) == $vertind || ($vertind == $#$poly && $i == -1);
Branch: 1 branch
BranchTrueFalseTotal
if $i == $vertind or $i + 1 == $vertind or $vertind == $poly->$#* and $i == -1 0 0 0
Condition0%0/9
$i == $vertind or $i + 1 == $vertind or $vertind == $poly->$#* and $i == -1
l!l&&r!l&&!r
000
$i == $vertind or $i + 1 == $vertind
l!l&&r!l&&!r
000
$vertind == $poly->$#* and $i == -1
!ll&&!rl&&r
000
MC/DC0%0/4
$i == $vertind or $i + 1 == $vertind or $vertind == $poly->$#* and $i == -1
$i == $vertind $i + 1 == $vertind $vertind == $poly->$#* $i == -1
Truth table0%0/5
A or B or C and D
A= $i == $vertindB= $i + 1 == $vertindC= $vertind == $poly->$#*D= $i == -1
ABCDresult
1XXX1
01XX1
00111
000X0
00100
616  
617 0 my $seg2 = [$poly->[$i],$poly->[$i+1]];
618 0 my @segsegret;
619  
620 0 my $u1= $seg2->[0]->[0];
621 0 my $v1= $seg2->[0]->[1];
622 0 my $u2= $seg2->[1]->[0];
623 0 my $v2= $seg2->[1]->[1];
624  
625 ##to maybe optimize for the case where segments are
626 ##expected NOT to intersect most of the time
627 #my @lowhix=($x2>$x1)?($x1,$x2):($x2,$x1);
628 #my @lowhiu=($u2>$u1)?($u1,$u2):($u2,$u1);
629 #if (
630 # $lowhix[0]>$lowhiu[1]
631 # ||
632 # $lowhix[1]<$lowhiu[0]
633 # ) {
634 # return;
635 # }
636 #my @lowhiy=($y2>$y1)?($y1,$y2):($y2,$y1);
637 #my @lowhiv=($v2>$v1)?($v1,$v2):($v2,$v1);
638 #if (
639 # $lowhiy[0]>$lowhiv[1]
640 # ||
641 # $lowhiy[1]<$lowhiv[0]
642 # ) {
643 # return;
644 # }
645  
646 0 ▶ my $m1 = ($x2 eq $x1)?'Inf':($y2 - $y1)/($x2 - $x1);
Branch: 1 branch
BranchTrueFalseTotal
$x2 eq $x1 ? : 0 0 0
647 0 ▶ my $m2 = ($u2 eq $u1)?'Inf':($v2 - $v1)/($u2 - $u1);
Branch: 1 branch
BranchTrueFalseTotal
$u2 eq $u1 ? : 0 0 0
648  
649 0 my $b1;
650 my $b2;
651 0 my $xi;
652  
653 # Arranged like this to avoid m1-m2 with infinity involved, which works
654 # in other contexts, but can trigger a floating point exception here.
655 # Turns out the exception happens when we let Triangle set the FPU
656 # control word, but not when we use XPFPA.h to take care of that, but
657 # leaving it this as it is in case that doesn't fix that everywhere.
658 0 my $dm;
659 0 ▶ if ($m1 != 'Inf' && $m2 != 'Inf') {$dm = $m1 - $m2;}
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m1 == 'Inf' and $m2 == 'Inf') { } 0 0 0
Condition0%0/3
$m1 != "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 != "Inf" and $m2 != "Inf"
$m1 != "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 != "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
660 0 ▶ elsif ($m1 == 'Inf' && $m2 == 'Inf') {return;}
Condition0%0/3
$m1 == "Inf" and $m2 == "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 == "Inf"
$m1 == "Inf" $m2 == "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 == "Inf"
ABresult
0X0
100
111
661 0 else {$dm='Inf';}
662 0 ▶ if ($m1 == 'Inf' && $m2 != 'Inf') {$xi = $x1;$b2 = $v1 - ($m2 * $u1);}
Branch: 3 branches
BranchTrueFalseTotal
if ($m1 == 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m2 == 'Inf' and $m1 != 'Inf') { } 0 0 0
elsif (abs $dm > 1e-12) { } 0 0 0
Condition0%0/3
$m1 == "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 != "Inf"
$m1 == "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
663 0 ▶ elsif ($m2 == 'Inf' && $m1 != 'Inf') {$xi = $u1;$b1 = $y1 - ($m1 * $x1);}
Condition0%0/3
$m2 == "Inf" and $m1 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m2 == "Inf" and $m1 != "Inf"
$m2 == "Inf" $m1 != "Inf"
Truth table0%0/3
A and B
A= $m2 == "Inf"B= $m1 != "Inf"
ABresult
0X0
100
111
664 elsif (abs($dm) > 0.000000000001) {
665 0 $b1 = $y1 - ($m1 * $x1);
666 0 $b2 = $v1 - ($m2 * $u1);
667 0 $xi=($b2-$b1)/$dm;
668 }
669 0 ▶ my @lowhiu=($u2>$u1)?($u1,$u2):($u2,$u1);
Branch: 1 branch
BranchTrueFalseTotal
$u2 > $u1 ? : 0 0 0
670 0 ▶ if ($m1 != 'Inf') {
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf') { } 0 0 0
elsif ($m2 != 'Inf') { } 0 0 0
671 0 ▶ if ($m2 == 'Inf' && ($u2<$lowhix[0] || $u2>$lowhix[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]) 0 0 0
Condition0%0/6
$m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]
!ll&&!rl&&r
000
$u2 < $lowhix[0] or $u2 > $lowhix[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
$m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]
$m2 == "Inf" $u2 < $lowhix[0] $u2 > $lowhix[1]
Truth table0%0/4
A and B or C
A= $m2 == "Inf"B= $u2 < $lowhix[0]C= $u2 > $lowhix[1]
ABCresult
0XX0
1000
11X1
1011
672 0 next;
673 }
674 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]) 0 0 0
Condition0%0/24
defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]
!ll&&!rl&&r
000
defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1]
!ll&&!rl&&r
000
defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0]
!ll&&!rl&&r
000
defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1]
!ll&&!rl&&r
000
$xi < $lowhix[1] or $xi eq $lowhix[1]
l!l&&r!l&&!r
000
$xi > $lowhix[0] or $xi eq $lowhix[0]
l!l&&r!l&&!r
000
$xi < $lowhiu[1] or $xi eq $lowhiu[1]
l!l&&r!l&&!r
000
$xi > $lowhiu[0] or $xi eq $lowhiu[0]
l!l&&r!l&&!r
000
MC/DC0%0/9
defined $xi and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]
defined $xi $xi < $lowhix[1] $xi eq $lowhix[1] $xi > $lowhix[0] $xi eq $lowhix[0] $xi < $lowhiu[1] $xi eq $lowhiu[1] $xi > $lowhiu[0] $xi eq $lowhiu[0]
Truth table0%0/32
A and B or C and D or E and F or G and H or I
A= defined $xiB= $xi < $lowhix[1]C= $xi eq $lowhix[1]D= $xi > $lowhix[0]E= $xi eq $lowhix[0]F= $xi < $lowhiu[1]G= $xi eq $lowhiu[1]H= $xi > $lowhiu[0]I= $xi eq $lowhiu[0]
ABCDEFGHIresult
0XXXXXXXX0
100XXXXXX0
11X00XXXX0
10100XXXX0
11X1X00XX0
11X0100XX0
1011X00XX0
1010100XX0
11X1X1X000
11X1X01000
11X011X000
11X0101000
1011X1X000
1011X01000
101011X000
1010101000
11X1X1X1X1
11X1X1X011
11X1X011X1
11X1X01011
11X011X1X1
11X011X011
11X01011X1
11X0101011
1011X1X1X1
1011X1X011
1011X011X1
1011X01011
101011X1X1
101011X011
10101011X1
1010101011
675 defined $xi &&
676 ($xi < $lowhix[1] || $xi eq $lowhix[1]) &&
677 ($xi > $lowhix[0] || $xi eq $lowhix[0]) &&
678 ($xi < $lowhiu[1] || $xi eq $lowhiu[1]) &&
679 ($xi > $lowhiu[0] || $xi eq $lowhiu[0])
680 ) {
681 0 my $y=($m1*$xi)+$b1;
682 0 ▶ my @lowhiv=($v2>$v1)?($v1,$v2):($v2,$v1);
Branch: 1 branch
BranchTrueFalseTotal
$v2 > $v1 ? : 0 0 0
683 0 ▶ if ($m2 == 'Inf' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($m2 == 'Inf' and $y < $lowhiv[0] || $y > $lowhiv[1]) { } 0 0 0
Condition0%0/6
$m2 == "Inf" and $y < $lowhiv[0] || $y > $lowhiv[1]
!ll&&!rl&&r
000
$y < $lowhiv[0] or $y > $lowhiv[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
$m2 == "Inf" and $y < $lowhiv[0] || $y > $lowhiv[1]
$m2 == "Inf" $y < $lowhiv[0] $y > $lowhiv[1]
Truth table0%0/4
A and B or C
A= $m2 == "Inf"B= $y < $lowhiv[0]C= $y > $lowhiv[1]
ABCresult
0XX0
1000
11X1
1011
684 ($y<$lowhiv[0] || $y>$lowhiv[1])
685 ) {
686 0 next;
687 }
688 else {
689 0 push(@intersections,[$xi,$y]);
690 0 ▶ if ($y eq $v1 || $y eq $v2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y eq $v1 or $y eq $v2) 0 0 0
Condition0%0/3
$y eq $v1 or $y eq $v2
l!l&&r!l&&!r
000
MC/DC0%0/2
$y eq $v1 or $y eq $v2
$y eq $v1 $y eq $v2
Truth table0%0/3
A or B
A= $y eq $v1B= $y eq $v2
ABresult
1X1
011
000
691 0 $i++; # avoid duplicates at endpoints
692 }
693 }
694 }
695 }
696 elsif ($m2 != 'Inf') {#so $m1 is Inf
697 0 ▶ if (($x1 < $lowhiu[0] || $x1 > $lowhiu[1]) && ! ($x1 eq $lowhiu[0] || $x1 eq $lowhiu[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x1 < $lowhiu[0] || $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]) 0 0 0
Condition0%0/9
$x1 < $lowhiu[0] || $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
!ll&&!rl&&r
000
$x1 < $lowhiu[0] or $x1 > $lowhiu[1]
l!l&&r!l&&!r
000
$x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
l!l&&r!l&&!r
000
MC/DC0%0/4
$x1 < $lowhiu[0] || $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
$x1 < $lowhiu[0] $x1 > $lowhiu[1] $x1 eq $lowhiu[0] $x1 eq $lowhiu[1]
Truth table0%0/7
A or B and not(C || D)
A= $x1 < $lowhiu[0]B= $x1 > $lowhiu[1]C= $x1 eq $lowhiu[0]D= $x1 eq $lowhiu[1]
ABCDresult
00XX0
1X1X0
1X010
011X0
01010
1X001
01001
698 0 next;
699 }
700 0 ▶ my @lowhiv=($v2>$v1)?($v1,$v2):($v2,$v1);
Branch: 1 branch
BranchTrueFalseTotal
$v2 > $v1 ? : 0 0 0
701 0 my $yi = ($m2*$xi)+$b2;
702 0 ▶ if (($yi || $yi eq 0) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]) 0 0 0
Condition0%0/27
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1]
!ll&&!rl&&r
000
$yi or $yi eq 0
l!l&&r!l&&!r
000
$yi < $lowhiy[1] or $yi eq $lowhiy[1]
l!l&&r!l&&!r
000
$yi > $lowhiy[0] or $yi eq $lowhiy[0]
l!l&&r!l&&!r
000
$yi < $lowhiv[1] or $yi eq $lowhiv[1]
l!l&&r!l&&!r
000
$yi > $lowhiv[0] or $yi eq $lowhiv[0]
l!l&&r!l&&!r
000
MC/DC0%0/10
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]
$yi $yi eq 0 $yi < $lowhiy[1] $yi eq $lowhiy[1] $yi > $lowhiy[0] $yi eq $lowhiy[0] $yi < $lowhiv[1] $yi eq $lowhiv[1] $yi > $lowhiv[0] $yi eq $lowhiv[0]
Truth table0%0/63
A or B and C or D and E or F and G or H and I or J
A= $yiB= $yi eq 0C= $yi < $lowhiy[1]D= $yi eq $lowhiy[1]E= $yi > $lowhiy[0]F= $yi eq $lowhiy[0]G= $yi < $lowhiv[1]H= $yi eq $lowhiv[1]I= $yi > $lowhiv[0]J= $yi eq $lowhiv[0]
ABCDEFGHIJresult
00XXXXXXXX0
1X00XXXXXX0
0100XXXXXX0
1X1X00XXXX0
1X0100XXXX0
011X00XXXX0
010100XXXX0
1X1X1X00XX0
1X1X0100XX0
1X011X00XX0
1X010100XX0
011X1X00XX0
011X0100XX0
01011X00XX0
01010100XX0
1X1X1X1X000
1X1X1X01000
1X1X011X000
1X1X0101000
1X011X1X000
1X011X01000
1X01011X000
1X010101000
011X1X1X000
011X1X01000
011X011X000
011X0101000
01011X1X000
01011X01000
0101011X000
01010101000
1X1X1X1X1X1
1X1X1X1X011
1X1X1X011X1
1X1X1X01011
1X1X011X1X1
1X1X011X011
1X1X01011X1
1X1X0101011
1X011X1X1X1
1X011X1X011
1X011X011X1
1X011X01011
1X01011X1X1
1X01011X011
1X0101011X1
1X010101011
011X1X1X1X1
011X1X1X011
011X1X011X1
011X1X01011
011X011X1X1
011X011X011
011X01011X1
011X0101011
01011X1X1X1
01011X1X011
01011X011X1
01011X01011
0101011X1X1
0101011X011
010101011X1
01010101011
703 ($yi < $lowhiy[1] || $yi eq $lowhiy[1]) &&
704 ($yi > $lowhiy[0] || $yi eq $lowhiy[0]) &&
705 ($yi < $lowhiv[1] || $yi eq $lowhiv[1]) &&
706 ($yi > $lowhiv[0] || $yi eq $lowhiv[0])
707 ) {
708 0 push(@intersections,[$xi,$yi]);
709 0 ▶ if ($xi eq $u1 || $xi eq $u2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xi eq $u1 or $xi eq $u2) 0 0 0
Condition0%0/3
$xi eq $u1 or $xi eq $u2
l!l&&r!l&&!r
000
MC/DC0%0/2
$xi eq $u1 or $xi eq $u2
$xi eq $u1 $xi eq $u2
Truth table0%0/3
A or B
A= $xi eq $u1B= $xi eq $u2
ABresult
1X1
011
000
710 0 $i++; # avoid duplicates at endpoints
711 }
712 }
713 }
714 }
715 0 ▶ if ($doDists) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doDists) 0 0 0
716 0 foreach my $int (@intersections) {
717 0 push(@{$int}, sqrt( ($int->[0]-$seg1->[0]->[0])**2 + ($int->[1]-$seg1->[0]->[1])**2 ) );
718 }
719 }
720 0 return @intersections;
721 }
722  
723 # Adjust location of nodes in voronoi diagram so they become
724 # centers of maximum inscribed circles, and store MIC radius in each node.
725 # This is a first step towards a better medial axis approximation.
726 # It straightens out the initial MA approx. derived from the Voronoi diagram.
727  
728 0 ▶sub mic_adjust {
Subroutine mic_adjust: not called CC=78 SCAR=87.3
Pod documented
729 0 my $topo = shift;
730 0 my $vtopo = shift;
731  
732 0 my @new_vnode_points; # voronoi vertices moved to MIC center points
733 my @new_vnode_radii; # will be calculated and added to node data
734 0 my @new_vnode_tangents; # where the MIC touches the boundary PSLG
735  
736 0 my $vnc=-1; # will use to look up triangle that corresponds to the voronoi node
737 # $vnc can probably be replaced with $vnode->{index}
738  
739 0 foreach my $vnode (@{$vtopo->{nodes}}) {
740 0 $vnc++;
741  
742 0 push(@new_vnode_points,$vnode->{point});
743 0 push(@new_vnode_radii,undef);
744 0 push(@new_vnode_tangents,[]);
745  
746 0 my $boundary_edge;
747  
748 0 ▶ if (@{$vnode->{edges}} == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$vnode->{"edges"};} == 3) 0 0 0
749 0 my @all_edges = map {$topo->{edges}->[$_->{index}]} @{$vnode->{edges}};
750 0 my @boundary_edges = grep {$_->{marker}} @all_edges;
751  
752 0 my @opposite_boundary_edges;
753 my @opposite_boundary_feet;
754  
755 0 my $branch_node_edge_index1;
756 0 my $branch_node_edge_index2;
757 0 my $branch_node_third_tan;
758  
759 # BRANCH NODE
760 # The corresponding Delaunay triangle has no edges on the PSLG boundary,
761 # but touches the boundary at its vertices. This corresponds to a
762 # node with three edges in the medial axis approximation.
763 0 ▶ if (@boundary_edges == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@boundary_edges == 0) 0 0 0
764 0 $vnode->{isbranchnode} = 1;
765  
766 # Orient nodes in edges emanating from this branch node so that
767 # the first node is always the branch node.
768 # The notion is that direction is always outward from a branch node.
769 # This will be a problem if two branch nodes link to each other.
770 0 ▶ $_->{nodes} = [$vnode,$_->{nodes}->[0]!=$vnode?$_->{nodes}->[0]:$_->{nodes}->[1]] for @{$vnode->{edges}};
Branch: 1 branch
BranchTrueFalseTotal
$_->{'nodes'}[0] != $vnode ? : 0 0 0
771  
772 # Make sure corners are sorted so they are opposite the Voronoi edges in order.
773 # They may have already been that way, but couldn't determine from Triangle docs.
774 0 my @corners;
775 0 ▶ for (my $i=0;$i<@{$vnode->{edges}};$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$vnode->{"edges"};}) 0 0 0
776 push @corners, +(grep $_ != $topo->{edges}->[$vnode->{edges}->[$i]->{index}]->{nodes}->[0]
777 && $_ != $topo->{edges}->[$vnode->{edges}->[$i]->{index}]->{nodes}->[1],
778 0 ▶ @{$topo->{elements}->[$vnc]->{nodes}}
Condition0%0/3
$_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[0] && $_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[0] && $_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[1]
$_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[0] $_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[1]
Truth table0%0/3
A && B
A= $_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[0]B= $_ != $topo->{'edges'}[$vnode->{'edges'}[$i]{'index'}]{'nodes'}[1]
ABresult
0X0
100
111
779 )[0];
780 }
781  
782 0 my @corner_boundary_edges = grep $_->{marker}, map @{$_->{edges}}, @corners;
783 0 my @corner_boundary_feet = map {getFoot([$_->{nodes}->[0]->{point},$_->{nodes}->[1]->{point}],$vnode->{point}->[0],$vnode->{point}->[1])} @corner_boundary_edges;
784  
785 # Handle the case where the three corners are probably the three MIC tangents.
786 0 ▶ if (! grep $_, @corner_boundary_feet) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep $_, @corner_boundary_feet) 0 0 0
787 0 $new_vnode_radii[-1] = dist2d($vnode->{point},$topo->{edges}->[$vnode->{edges}->[0]->{index}]->{nodes}->[0]->{point});
788 $new_vnode_tangents[-1] = [[$corners[2]->{point},
789 $corners[1]->{point}],
790 [$corners[0]->{point},
791 $corners[2]->{point}],
792 [$corners[1]->{point},
793 0 $corners[0]->{point}]];
794 0 next;
795 }
796  
797 # Otherwise, set up a case similar to the non-branch node case
798 # by designating feet, a boundary edge, and an opposite edge.
799 0 my @boundary_feet_edges;
800 0 ▶ for (my $i=0;$i<@corner_boundary_feet;$i+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @corner_boundary_feet) 0 0 0
801 0 my $foot;
802 my $edge;
803 # if no foot was found on the two edges meeting at
804 # one of the triangle's vertices, make the vertex a "fake foot"
805 0 ▶ if (!$corner_boundary_feet[$i] && !$corner_boundary_feet[$i+1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1]) { } 0 0 0
Condition0%0/3
$corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1]
$corner_boundary_feet[$i] $corner_boundary_feet[$i + 1]
Truth table0%0/3
A || B
A= $corner_boundary_feet[$i]B= $corner_boundary_feet[$i + 1]
ABresult
1X1
011
000
806 my $foot = ( $corner_boundary_edges[$i]->{nodes}->[0] == $corner_boundary_edges[$i+1]->{nodes}->[0]
807 || $corner_boundary_edges[$i]->{nodes}->[0] == $corner_boundary_edges[$i+1]->{nodes}->[1] )
808 ? $corner_boundary_edges[$i]->{nodes}->[0]->{point}
809 0 ▶ : $corner_boundary_edges[$i]->{nodes}->[1]->{point};
Branch: 1 branch
BranchTrueFalseTotal
$corner_boundary_edges[$i]{'nodes'}[0] == $corner_boundary_edges[$i + 1]{'nodes'}[0] || $corner_boundary_edges[$i]{'nodes'}[0] == $corner_boundary_edges[$i + 1]{'nodes'}[1] ? : 0 0 0
Condition0%0/3
$corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[0] or $corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[0] or $corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[1]
$corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[0] $corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[1]
Truth table0%0/3
A or B
A= $corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[0]B= $corner_boundary_edges[$i]{"nodes"}[0] == $corner_boundary_edges[$i + 1]{"nodes"}[1]
ABresult
1X1
011
000
810 # edge evaluates to "false" to signal this case
811 0 push @boundary_feet_edges, [$foot,undef,$i/2];
812 }
813 # otherwise keep foot and edge ref
814 else {
815 0 ▶ if ($corner_boundary_feet[$i] ) {push @boundary_feet_edges, [$corner_boundary_feet[$i], $corner_boundary_edges[$i] ,$i/2];}
Branch: 1 branch
BranchTrueFalseTotal
if ($corner_boundary_feet[$i]) 0 0 0
816 0 ▶ if ($corner_boundary_feet[$i+1]
Branch: 1 branch
BranchTrueFalseTotal
if ($corner_boundary_feet[$i + 1] and !$corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] && $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]) 0 0 0
Condition0%0/9
$corner_boundary_feet[$i + 1] and !$corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] && $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
!ll&&!rl&&r
000
not $corner_boundary_feet[$i] or $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] and $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
l!l&&r!l&&!r
000
$corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] and $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
!ll&&!rl&&r
000
MC/DC0%0/4
$corner_boundary_feet[$i + 1] and !$corner_boundary_feet[$i] || $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] && $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
$corner_boundary_feet[$i + 1] not $corner_boundary_feet[$i] $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0] $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
Truth table0%0/5
A and not(B) or C and D
A= $corner_boundary_feet[$i + 1]B= not $corner_boundary_feet[$i]C= $corner_boundary_feet[$i + 1][0] ne $corner_boundary_feet[$i][0]D= $corner_boundary_feet[$i + 1][1] ne $corner_boundary_feet[$i][1]
ABCDresult
0XXX0
100X0
10100
11XX1
10111
817 && ( !$corner_boundary_feet[$i] ||
818 # screen out duplicates
819 ( $corner_boundary_feet[$i+1]->[0] ne $corner_boundary_feet[$i]->[0]
820 && $corner_boundary_feet[$i+1]->[1] ne $corner_boundary_feet[$i]->[1]
821 )
822 )
823 0 ) {push @boundary_feet_edges, [$corner_boundary_feet[$i+1],$corner_boundary_edges[$i+1],$i/2];}
824 }
825 }
826  
827 0 @boundary_feet_edges = sort {dist2d($a->[0],$vnode->{point}) <=> dist2d($b->[0],$vnode->{point})} @boundary_feet_edges;
828  
829 # closest edge treated as boundary edge, similar to non-branch node handling
830 0 my $first_with_edge = +(grep {$_->[1]} @boundary_feet_edges)[0];
831  
832 0 $boundary_edge = {nodes=>[$first_with_edge->[1]->{nodes}->[0],$first_with_edge->[1]->{nodes}->[1]]};
833  
834 # next closest edge treated as opposite boundary edge, similar to non-branch node handling
835 # (that is, next closest that's also not connected to the same
836 # corner as the closest)
837 0 ▶ my $first_not_first_with_edge = +(grep {$_ != $first_with_edge && $_->[2] != $first_with_edge->[2]} @boundary_feet_edges)[0];
Condition0%0/3
$_ != $first_with_edge && $_->[2] != $first_with_edge->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
$_ != $first_with_edge && $_->[2] != $first_with_edge->[2]
$_ != $first_with_edge $_->[2] != $first_with_edge->[2]
Truth table0%0/3
A && B
A= $_ != $first_with_edgeB= $_->[2] != $first_with_edge->[2]
ABresult
0X0
100
111
838  
839 0 $opposite_boundary_feet[0] = $first_not_first_with_edge->[0];
840 0 $opposite_boundary_edges[0] = $first_not_first_with_edge->[1];
841  
842 # Use these later to match up tangent point pairs with Voronoi edges.
843 0 $branch_node_edge_index1 = $first_with_edge->[2];
844 0 $branch_node_edge_index2 = $first_not_first_with_edge->[2];
845  
846 0 ▶ my @threst = grep { $_ != $first_with_edge
Condition0%0/9
$_ != $first_with_edge && $_ != $first_not_first_with_edge && $_->[2] != $first_with_edge->[2] && $_->[2] != $first_not_first_with_edge->[2]
!ll&&!rl&&r
000
$_ != $first_with_edge and $_ != $first_not_first_with_edge and $_->[2] != $first_with_edge->[2]
!ll&&!rl&&r
000
$_ != $first_with_edge and $_ != $first_not_first_with_edge
!ll&&!rl&&r
000
MC/DC0%0/4
$_ != $first_with_edge && $_ != $first_not_first_with_edge && $_->[2] != $first_with_edge->[2] && $_->[2] != $first_not_first_with_edge->[2]
$_ != $first_with_edge $_ != $first_not_first_with_edge $_->[2] != $first_with_edge->[2] $_->[2] != $first_not_first_with_edge->[2]
Truth table0%0/5
A and B and C && D
A= $_ != $first_with_edgeB= $_ != $first_not_first_with_edgeC= $_->[2] != $first_with_edge->[2]D= $_->[2] != $first_not_first_with_edge->[2]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
847 && $_ != $first_not_first_with_edge
848 && $_->[2] != $first_with_edge->[2]
849 && $_->[2] != $first_not_first_with_edge->[2]
850 } @boundary_feet_edges;
851 # Not completely thought out, but results look good so far -
852 # This "tangent point" is not (generally) touched by the approximate
853 # MIC, but it might be worth trying to shift the approx MIC in
854 # a later step to come closer to this, when possible.
855 # Even without that extra shift attempt, it's useful to have
856 # this when reconstructing a polygon from the approximate
857 # medial axis enabled by mic_adjust().
858 0 $branch_node_third_tan = $threst[0]->[0];
859 }
860  
861 # NON-BRANCH NODE
862 # The corresponding Delaunay triangle has one or two edges
863 # on the PSLG boundary. This corresponds to a node with two edges
864 # in the medial axis approximation.
865 0 ▶ if (@boundary_edges == 1 || @boundary_edges == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@boundary_edges == 1 or @boundary_edges == 2) 0 0 0
Condition0%0/3
@boundary_edges == 1 or @boundary_edges == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@boundary_edges == 1 or @boundary_edges == 2
@boundary_edges == 1 @boundary_edges == 2
Truth table0%0/3
A or B
A= @boundary_edges == 1B= @boundary_edges == 2
ABresult
1X1
011
000
866  
867 0 $boundary_edge = $boundary_edges[0];
868  
869 0 my $bef = getFoot([$boundary_edge->{nodes}->[0]->{point},$boundary_edge->{nodes}->[1]->{point}],$vnode->{point}->[0],$vnode->{point}->[1]);
870 0 my $ber = sqrt(($vnode->{point}->[0]-$bef->[0])**2 + ($vnode->{point}->[1]-$bef->[1])**2);
871  
872 0 ▶ if (@boundary_edges == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@boundary_edges == 2) 0 0 0
873 # If the other boundary edge is closer, make that the boundary edge.
874 0 my $obef = getFoot([$boundary_edges[1]->{nodes}->[0]->{point},$boundary_edges[1]->{nodes}->[1]->{point}],$vnode->{point}->[0],$vnode->{point}->[1]);
875 0 ▶ next if (!$obef);
Branch: 1 branch
BranchTrueFalseTotal
unless $obef 0 0 0
876 0 my $ober = sqrt(($vnode->{point}->[0]-$obef->[0])**2 + ($vnode->{point}->[1]-$obef->[1])**2);
877 0 ▶ if ($ober < $ber) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ober < $ber) 0 0 0
878 0 $boundary_edge = $boundary_edges[1];
879 0 $bef=$obef;
880 0 $ber=$ober;
881 }
882 }
883  
884 0 my @other_edges = grep $_ != $boundary_edge, map $topo->{edges}->[$_->{index}], @{$vnode->{edges}};
885 0 ▶ my $opposite_node = +(grep {$_ != $boundary_edge->{nodes}->[0] && $_ != $boundary_edge->{nodes}->[1]} @{$other_edges[1]->{nodes}})[0];
Condition0%0/3
$_ != $boundary_edge->{'nodes'}[0] && $_ != $boundary_edge->{'nodes'}[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$_ != $boundary_edge->{'nodes'}[0] && $_ != $boundary_edge->{'nodes'}[1]
$_ != $boundary_edge->{'nodes'}[0] $_ != $boundary_edge->{'nodes'}[1]
Truth table0%0/3
A && B
A= $_ != $boundary_edge->{'nodes'}[0]B= $_ != $boundary_edge->{'nodes'}[1]
ABresult
0X0
100
111
886 0 @opposite_boundary_edges = grep {$_->{marker}} @{$opposite_node->{edges}};
887 0 @opposite_boundary_feet = map {getFoot([$_->{nodes}->[0]->{point},$_->{nodes}->[1]->{point}],$vnode->{point}->[0],$vnode->{point}->[1])} @opposite_boundary_edges;
888  
889 0 ▶ if (@boundary_edges == 1
Branch: 1 branch
BranchTrueFalseTotal
if (@boundary_edges == 1) 0 0 0
890 # || @boundary_edges == 2
891 ) { # should apply to ==2 too, maybe, but should screen out the "opposite" that is also "adjacent" in that case
892 0 ▶ my @adjacent_boundary_edges = grep {$_->{marker} && $_ != $boundary_edge} map @{$_->{edges}}, @{$boundary_edge->{nodes}};
Condition0%0/3
$_->{'marker'} && $_ != $boundary_edge
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{'marker'} && $_ != $boundary_edge
$_->{'marker'} $_ != $boundary_edge
Truth table0%0/3
A && B
A= $_->{'marker'}B= $_ != $boundary_edge
ABresult
0X0
100
111
893 0 my @adjacent_boundary_feet = map {getFoot([$_->{nodes}->[0]->{point},$_->{nodes}->[1]->{point}],$vnode->{point}->[0],$vnode->{point}->[1])} @adjacent_boundary_edges;
894 # if any adjacent bounds closer, replace $boundary_edge with closest
895 0 ▶ for (my $i = 0; $i < @adjacent_boundary_feet; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @adjacent_boundary_feet) 0 0 0
896 0 ▶ next if (!$adjacent_boundary_feet[$i]);
Branch: 1 branch
BranchTrueFalseTotal
unless $adjacent_boundary_feet[$i] 0 0 0
897 0 my $newfootdist = sqrt(($vnode->{point}->[0] - $adjacent_boundary_feet[$i]->[0])**2 + ($vnode->{point}->[1]-$adjacent_boundary_feet[$i]->[1])**2);
898 0 ▶ if ($newfootdist < $ber) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newfootdist < $ber) 0 0 0
899 0 $boundary_edge = $adjacent_boundary_edges[$i];
900 0 $bef = $adjacent_boundary_feet[$i];
901 0 $ber = $newfootdist;
902 }
903 }
904 }
905  
906 0 ▶ if (grep $_, @opposite_boundary_feet) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep $_, @opposite_boundary_feet) 0 0 0
907 0 my @sortind = sort {dist2d($vnode->{point},$opposite_boundary_feet[$a]) <=> dist2d($vnode->{point},$opposite_boundary_feet[$b])} grep {$opposite_boundary_feet[$_]} (0..$#opposite_boundary_feet);
908 0 @opposite_boundary_feet = map $opposite_boundary_feet[$_], @sortind;
909 0 @opposite_boundary_edges = map $opposite_boundary_edges[$_], @sortind;
910 0 @opposite_boundary_feet = ($opposite_boundary_feet[0]);
911 0 @opposite_boundary_edges = ($opposite_boundary_edges[0]);
912 0 my $obr = dist2d($opposite_boundary_feet[0],$vnode->{point});
913 0 ▶ if ($ber>$obr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ber > $obr) 0 0 0
914 0 my $tmp = $opposite_boundary_edges[0];
915 0 $opposite_boundary_edges[0] = $boundary_edge;
916 0 $boundary_edge = $tmp;
917 0 $opposite_boundary_feet[0] = $bef;
918 }
919 }
920  
921 0 ▶ if (!grep $_, @opposite_boundary_feet) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep $_, @opposite_boundary_feet) 0 0 0
922 # make the foot just the opposite point
923 0 @opposite_boundary_feet = ($opposite_node->{point});
924 # make edge eval to false to signal this fake foot case
925 0 @opposite_boundary_edges = map {0} @opposite_boundary_edges;
926 }
927  
928 }
929  
930 # FIND THE TWO TANGENT POINTS, RADIUS, AND SHIFT POINT TO MIC CENTER
931
932 # Only one defined unique foot should be in @opposite_boundary_feet
933 # at this point, though that wasn't always the case in the past.
934 # When we're satisfied that it will be the case in the future, we'll
935 # remove the for loop.
936  
937 0 ▶ for (my $i = 0; $i < @opposite_boundary_feet; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @opposite_boundary_feet) 0 0 0
938 0 ▶ next if !$opposite_boundary_feet[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $opposite_boundary_feet[$i] 0 0 0
939 0 my $foot = $opposite_boundary_feet[$i];
940 0 my $opp_edge = $opposite_boundary_edges[$i];
941  
942 0 my $a1;
943 0 ▶ if ($opp_edge) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opp_edge) { } 0 0 0
944 $a1 = atan2($opp_edge->{nodes}->[0]->{point}->[1] - $opp_edge->{nodes}->[1]->{point}->[1],
945 0 $opp_edge->{nodes}->[0]->{point}->[0] - $opp_edge->{nodes}->[1]->{point}->[0]);
946 }
947 else { # the "fake foot" case, where opposite edge is just a point
948 $a1 = atan2($foot->[1] - $vnode->{point}->[1],
949 0 $foot->[0] - $vnode->{point}->[0]);
950 0 $a1 -= $pi / 2;
951 }
952  
953 my $a2 = atan2($boundary_edge->{nodes}->[1]->{point}->[1] - $boundary_edge->{nodes}->[0]->{point}->[1],
954 0 $boundary_edge->{nodes}->[1]->{point}->[0] - $boundary_edge->{nodes}->[0]->{point}->[0]);
955  
956 0 $a1 = angle_reduce_pi($a1);
957  
958 0 my $amid = ($a1 + $a2) / 2;
959 0 my $amidnorm = $amid + $pi / 2;
960  
961 my $boundtanpt = line_line_intersection(
962 0 [ $boundary_edge->{nodes}->[0]->{point}, $boundary_edge->{nodes}->[1]->{point} ],
963 [ $foot, [$foot->[0] + 100 * cos($amidnorm), $foot->[1] + (100 * sin($amidnorm))] ],
964 );
965  
966 0 ▶ if ($boundtanpt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boundtanpt) 0 0 0
967 0 my $midpt=[($foot->[0]+$boundtanpt->[0])/2,($foot->[1]+$boundtanpt->[1])/2];
968 0 my $nother_mid_pt=[$midpt->[0]-100*cos($amid),$midpt->[1]-100*sin($amid)];
969 0 my $center = line_line_intersection([$vnode->{point},$foot],[$midpt,$nother_mid_pt]);
970 0 ▶ if ($center) {
Branch: 1 branch
BranchTrueFalseTotal
if ($center) 0 0 0
971 0 $new_vnode_points[-1] = $center;
972 0 $new_vnode_radii[-1] = dist2d($center,$foot);
973 # assign the three tangent pairs to a branch node
974 0 ▶ if (defined $branch_node_edge_index1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch_node_edge_index1) { } 0 0 0
975 0 ▶ my $gets_both_found = +(grep $_ != $branch_node_edge_index1 && $_ != $branch_node_edge_index2, (0..2))[0];
Condition0%0/3
$_ != $branch_node_edge_index1 && $_ != $branch_node_edge_index2
!ll&&!rl&&r
000
MC/DC0%0/2
$_ != $branch_node_edge_index1 && $_ != $branch_node_edge_index2
$_ != $branch_node_edge_index1 $_ != $branch_node_edge_index2
Truth table0%0/3
A && B
A= $_ != $branch_node_edge_index1B= $_ != $branch_node_edge_index2
ABresult
0X0
100
111
976 0 $new_vnode_tangents[-1]->[( $gets_both_found ) % 3] = [$foot, $boundtanpt];
977 0 $new_vnode_tangents[-1]->[( $branch_node_edge_index1 ) % 3] = [$branch_node_third_tan, $foot];
978 0 $new_vnode_tangents[-1]->[( $branch_node_edge_index2 ) % 3] = [$boundtanpt, $branch_node_third_tan];
979 }
980 # assign the two tangent pairs for non-branch nodes
981 else {
982 0 foreach my $edge (@{$vnode->{edges}}) {
983 0 ▶ next if defined($edge->{vector}) && ($edge->{vector}->[0] != 0 || $edge->{vector}->[1] != 0); # a ray
Branch: 1 branch
BranchTrueFalseTotal
if defined $edge->{"vector"} and $edge->{"vector"}[0] != 0 || $edge->{"vector"}[1] != 0 0 0 0
Condition0%0/6
defined $edge->{"vector"} and $edge->{"vector"}[0] != 0 || $edge->{"vector"}[1] != 0
!ll&&!rl&&r
000
$edge->{"vector"}[0] != 0 or $edge->{"vector"}[1] != 0
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $edge->{"vector"} and $edge->{"vector"}[0] != 0 || $edge->{"vector"}[1] != 0
defined $edge->{"vector"} $edge->{"vector"}[0] != 0 $edge->{"vector"}[1] != 0
Truth table0%0/4
A and B or C
A= defined $edge->{"vector"}B= $edge->{"vector"}[0] != 0C= $edge->{"vector"}[1] != 0
ABCresult
0XX0
1000
11X1
1011
984 0 push @{$new_vnode_tangents[-1]}, [$foot, $boundtanpt];
985 }
986 }
987 }
988 }
989 }
990 }
991  
992 0 ▶ if (!defined $new_vnode_radii[-1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $new_vnode_radii[-1]) 0 0 0
993 # This would be a branch node that had feet, but didn't end up
994 # getting adjusted. This is either an okay edge case or a failure.
995 # Let's watch for a while and see if we end up here.
996 0 $new_vnode_radii[-1] = dist2d($vnode->{point},$topo->{edges}->[$vnode->{edges}->[0]->{index}]->{nodes}->[0]->{point});
997 0 print "\nFailure to find radius in Math::Geometery::Delaunay::mic_adjust().\nThe developer would like to know if you come across this.\n";
998 }
999  
1000 }
1001  
1002 # Can probably integrate the node point, radius, and tangents assignments
1003 # directly into the above section, and get rid of this temp array stuff.
1004 # On the other hand, if we move this toward using matched index lists (more
1005 # like Triangle's native output) might just export the lists we made, and not
1006 # update the crossref'ed hash structure.
1007 0 ▶ for (my $i = 0; $i < @{$vtopo->{nodes}}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$vtopo->{"nodes"};}) 0 0 0
1008 0 $vtopo->{nodes}->[$i]->{point} = $new_vnode_points[$i];
1009 0 $vtopo->{nodes}->[$i]->{radius} = $new_vnode_radii[$i];
1010 0 $vtopo->{nodes}->[$i]->{tangents} = $new_vnode_tangents[$i];
1011 }
1012  
1013 # Fixup left-right ordering of tangent points, now that
1014 # vnodes and their edges should all be nicely centered between them.
1015  
1016 0 ▶ for (my $i = 0; $i < @{$vtopo->{nodes}}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$vtopo->{"nodes"};}) 0 0 0
1017 0 my $vnode = $vtopo->{nodes}->[$i];
1018  
1019 # first pass - could you do iswithin for vnode in its corresponding triangle
1020 # and if not, shift toward next/previous vnode until it is within
1021 # like to intersection of line between tri apex and bound edge
1022 # and line between point and next/prev point... or is there trajectory
1023 # based on two (usually) boundary edges where the tangents are?
1024 #
1025  
1026 0 my @fixtangents;
1027 0 ▶ my @edges = grep !defined($_->{vector}) || ($_->{vector}->[0] == 0 && $_->{vector}->[1] == 0), @{$vnode->{edges}};
Condition0%0/6
!defined($_->{'vector'}) || $_->{'vector'}[0] == 0 && $_->{'vector'}[1] == 0
l!l&&r!l&&!r
000
$_->{"vector"}[0] == 0 and $_->{"vector"}[1] == 0
!ll&&!rl&&r
000
MC/DC0%0/3
!defined($_->{'vector'}) || $_->{'vector'}[0] == 0 && $_->{'vector'}[1] == 0
!defined($_->{'vector'}) $_->{"vector"}[0] == 0 $_->{"vector"}[1] == 0
Truth table0%0/4
not(A) || B and C
A= !defined($_->{'vector'})B= $_->{"vector"}[0] == 0C= $_->{"vector"}[1] == 0
ABCresult
1XX1
0111
00X0
0100
1028  
1029 0 ▶ for (my $j = 0; $j < @edges; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < @edges) 0 0 0
1030 0 my $edge = $edges[$j];
1031  
1032 0 my $tangents = $vnode->{tangents}->[$j]; # tangent pairs correspond to non-ray edges, in order
1033 0 ▶ my $other_node = ($edge->{nodes}->[0] != $vnode) ? $edge->{nodes}->[0] : $edge->{nodes}->[1];
Branch: 1 branch
BranchTrueFalseTotal
$edge->{'nodes'}[0] != $vnode ? : 0 0 0
1034 0 my $start_node = $vnode;
1035  
1036 # Duplicate node points can happen for common reasons, so go out
1037 # to the next node if we got a duplicate. (Three-in-a-row duplicates
1038 # shouldn't happen.)
1039 0 ▶ if ($vnode->{point}->[0] eq $other_node->{point}->[0] && $vnode->{point}->[1] eq $other_node->{point}->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vnode->{"point"}[0] eq $other_node->{"point"}[0] and $vnode->{"point"}[1] eq $other_node->{"point"}[1]) 0 0 0
Condition0%0/3
$vnode->{"point"}[0] eq $other_node->{"point"}[0] and $vnode->{"point"}[1] eq $other_node->{"point"}[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$vnode->{"point"}[0] eq $other_node->{"point"}[0] and $vnode->{"point"}[1] eq $other_node->{"point"}[1]
$vnode->{"point"}[0] eq $other_node->{"point"}[0] $vnode->{"point"}[1] eq $other_node->{"point"}[1]
Truth table0%0/3
A and B
A= $vnode->{"point"}[0] eq $other_node->{"point"}[0]B= $vnode->{"point"}[1] eq $other_node->{"point"}[1]
ABresult
0X0
100
111
1040 0 ▶ my $other_edge = +(grep $_ != $edge && !(defined $_->{vector} && ($_->{vector}->[0] != 0 || $_->{vector}->[1] != 0)), @{$other_node->{edges}})[0];
Condition0%0/9
$_ != $edge && !(defined $_->{'vector'} && ($_->{'vector'}[0] != 0 || $_->{'vector'}[1] != 0))
!ll&&!rl&&r
000
defined $_->{'vector'} && ($_->{'vector'}[0] != 0 || $_->{'vector'}[1] != 0)
!ll&&!rl&&r
000
$_->{"vector"}[0] != 0 or $_->{"vector"}[1] != 0
l!l&&r!l&&!r
000
MC/DC0%0/4
$_ != $edge && !(defined $_->{'vector'} && ($_->{'vector'}[0] != 0 || $_->{'vector'}[1] != 0))
$_ != $edge defined $_->{'vector'} $_->{"vector"}[0] != 0 $_->{"vector"}[1] != 0
Truth table0%0/5
A && not(B && C or D)
A= $_ != $edgeB= defined $_->{'vector'}C= $_->{"vector"}[0] != 0D= $_->{"vector"}[1] != 0
ABCDresult
0XXX0
111X0
11010
10XX1
11001
1041 0 ▶ if ($other_edge) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other_edge) { } 0 0 0
1042 0 ▶ $other_node = $other_edge->{nodes}->[0] != $other_node ? $other_edge->{nodes}->[0] : $other_edge->{nodes}->[1];
Branch: 1 branch
BranchTrueFalseTotal
$other_edge->{'nodes'}[0] != $other_node ? : 0 0 0
1043 }
1044 else {
1045 # Well, then, if this is a non-branch node, set up a test line
1046 # using the previous node, heading into this one.
1047 0 ▶ if (@{$vnode->{tangents}} == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$vnode->{"tangents"};} == 2) 0 0 0
1048 0 ▶ my $other_edge = $edges[$j == 0 ? 1 : 0];
Branch: 1 branch
BranchTrueFalseTotal
$j == 0 ? : 0 0 0
1049 0 ▶ $start_node = ($other_edge->{nodes}->[0] != $vnode) ? $other_edge->{nodes}->[0] : $other_edge->{nodes}->[1];
Branch: 1 branch
BranchTrueFalseTotal
$other_edge->{'nodes'}[0] != $vnode ? : 0 0 0
1050 0 $other_node = $vnode;
1051 }
1052 #else { die "Couldn't get other edge in duplicate point case\n\n;" }
1053 }
1054 }
1055  
1056 # Heading out from the start node to the other node, the first tangent associated
1057 # with this edge should be on the left (a counterclockwise turn), and the
1058 # other tangent on the right. We've got Triangle's adaptave robust
1059 # orientation code backing up counterclockwise(), for the really close cases.
1060 0 my $ccwl = counterclockwise($start_node->{point}, $other_node->{point}, $tangents->[0]);
1061 0 my $ccwr = counterclockwise($start_node->{point}, $other_node->{point}, $tangents->[1]);
1062  
1063 0 ▶ if ($ccwl < 0) { # first tangent wasn't on the left
Branch: 2 branches
BranchTrueFalseTotal
if ($ccwl < 0) { } 0 0 0
elsif ($ccwr > 0) { } 0 0 0
1064 0 ▶ if ($ccwr > 0) { # but the second was, so we just need to swap them
Branch: 1 branch
BranchTrueFalseTotal
if ($ccwr > 0) { } 0 0 0
1065 0 @{$tangents} = reverse @{$tangents};
1066 }
1067 else { # But if both were on the right, something's wrong.
1068 # If this is a branch node, and the other two tangent pairs
1069 # don't have the same problem, we can fix up the bad one later.
1070 #push @fixtangents, $j;
1071 0 ▶ $vnode->{fixtangents} = [] if !defined $vnode->{fixtangents};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $vnode->{"fixtangents"} 0 0 0
1072 0 push @{$vnode->{fixtangents}}, $j;
1073 }
1074 }
1075 elsif ($ccwr > 0) { # Both were on the left. Maybe fix up later.
1076 #push @fixtangents, $j;
1077 0 ▶ $vnode->{fixtangents} = [] if !defined $vnode->{fixtangents};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $vnode->{"fixtangents"} 0 0 0
1078 0 push @{$vnode->{fixtangents}}, $j;
1079 }
1080 #elsif ($ccwl eq 0) { die "zero" } # Shouldn't happen. Leave it alone if it does.
1081 }
1082 }
1083 0 ▶ for (my $i = 0; $i < @{$vtopo->{nodes}}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$vtopo->{"nodes"};}) 0 0 0
1084 0 ▶ if (@{$vtopo->{nodes}->[$i]->{tangents}} == 3 && defined $vtopo->{nodes}->[$i]->{fixtangents} && @{$vtopo->{nodes}->[$i]->{fixtangents}} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$vtopo->{"nodes"}[$i]{"tangents"};} == 3 and defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1) 0 0 0
Condition0%0/6
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 3 and defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
!ll&&!rl&&r
000
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 3 and defined $vtopo->{"nodes"}[$i]{"fixtangents"}
!ll&&!rl&&r
000
MC/DC0%0/3
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 3 and defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 3 defined $vtopo->{"nodes"}[$i]{"fixtangents"} @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
Truth table0%0/4
A and B and C
A= @{$vtopo->{"nodes"}[$i]{"tangents"};} == 3B= defined $vtopo->{"nodes"}[$i]{"fixtangents"}C= @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
ABCresult
0XX0
10X0
1100
1111
1085 #print "FIXUP TANGENT PAIR FOR ONE BRANCH AT BRANCH NODE\n";
1086 #$vtopo->{nodes}->[$i]->{color} = 'orange';
1087 # one bad tangent pair out of three for a branch node
1088 # infer that it just needs to be reversed if other two pairs were good
1089  
1090 # debug stuff
1091 #my @edges = grep !defined($_->{vector}) || ($_->{vector}->[0] == 0 && $_->{vector}->[1] == 0), @{$vtopo->{nodes}->[$i]->{edges}};
1092 #my $reconsider_edge = $edges[$vtopo->{nodes}->[$i]->{fixtangents}->[0]];
1093 #my $reconsider_node = $reconsider_edge->{nodes}->[0] != $vtopo->{nodes}->[$i] ? $reconsider_edge->{nodes}->[0]:$reconsider_edge->{nodes}->[1];
1094 #$reconsider_node->{color} = 'green';
1095  
1096 $vtopo->{nodes}->[$i]->{tangents}->[$vtopo->{nodes}->[$i]->{fixtangents}->[0]] =
1097 [$vtopo->{nodes}->[$i]->{tangents}->[($vtopo->{nodes}->[$i]->{fixtangents}->[0] + 1) % 3]->[1],
1098 0 $vtopo->{nodes}->[$i]->{tangents}->[($vtopo->{nodes}->[$i]->{fixtangents}->[0] - 1) ]->[0]];
1099  
1100 }
1101 #if (@{$vtopo->{nodes}->[$i]->{tangents}} == 3 && defined $vtopo->{nodes}->[$i]->{fixtangents} && @{$vtopo->{nodes}->[$i]->{fixtangents}} != 1) {
1102 #print " MORE NEEDED FIXUP: ",scalar(@{$vtopo->{nodes}->[$i]->{fixtangents}}),"\n";
1103 # if more than one branch had tangents mixed up...
1104 # maybe the other one or two wrong ones are really right?
1105 # ambiguous.
1106 # $vtopo->{nodes}->[$i]->{color} = 'orange';
1107 # }
1108 0 ▶ if ( @{$vtopo->{nodes}->[$i]->{tangents}} == 2
Branch: 1 branch
BranchTrueFalseTotal
if (@{$vtopo->{"nodes"}[$i]{"tangents"};} == 2 and $vtopo->{"nodes"}[$i]{"tangents"}[0][0] == $vtopo->{"nodes"}[$i]{"tangents"}[1][0]) 0 0 0
Condition0%0/3
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 2 and $vtopo->{"nodes"}[$i]{"tangents"}[0][0] == $vtopo->{"nodes"}[$i]{"tangents"}[1][0]
!ll&&!rl&&r
000
MC/DC0%0/2
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 2 and $vtopo->{"nodes"}[$i]{"tangents"}[0][0] == $vtopo->{"nodes"}[$i]{"tangents"}[1][0]
@{$vtopo->{"nodes"}[$i]{"tangents"};} == 2 $vtopo->{"nodes"}[$i]{"tangents"}[0][0] == $vtopo->{"nodes"}[$i]{"tangents"}[1][0]
Truth table0%0/3
A and B
A= @{$vtopo->{"nodes"}[$i]{"tangents"};} == 2B= $vtopo->{"nodes"}[$i]{"tangents"}[0][0] == $vtopo->{"nodes"}[$i]{"tangents"}[1][0]
ABresult
0X0
100
111
1109 && $vtopo->{nodes}->[$i]->{tangents}->[0]->[0] == $vtopo->{nodes}->[$i]->{tangents}->[1]->[0]
1110 ) {
1111 #print "non-branch maybe needs fixup.\n";
1112 # not sure if this a good way to approach this -
1113 # doesn't definitively capture all that can go
1114 # wrong with non-branch node orientations.
1115 0 $vtopo->{nodes}->[$i]->{color} = 'green';
1116 0 ▶ if (defined $vtopo->{nodes}->[$i]->{fixtangents} && @{$vtopo->{nodes}->[$i]->{fixtangents}} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1) 0 0 0
Condition0%0/3
defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $vtopo->{"nodes"}[$i]{"fixtangents"} and @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
defined $vtopo->{"nodes"}[$i]{"fixtangents"} @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
Truth table0%0/3
A and B
A= defined $vtopo->{"nodes"}[$i]{"fixtangents"}B= @{$vtopo->{"nodes"}[$i]{"fixtangents"};} == 1
ABresult
0X0
100
111
1117 $vtopo->{nodes}->[$i]->{tangents}->[$vtopo->{nodes}->[$i]->{fixtangents}->[0]] =
1118 [$vtopo->{nodes}->[$i]->{tangents}->[$vtopo->{nodes}->[$i]->{fixtangents}->[0] - 1]->[1],
1119 0 $vtopo->{nodes}->[$i]->{tangents}->[$vtopo->{nodes}->[$i]->{fixtangents}->[0] - 1]->[0]];
1120 }
1121 }
1122 }
1123 }
1124  
1125 0 ▶sub getFoot {
Subroutine getFoot: not called CC=14 SCAR=53.5
Pod undocumented
1126 0 my $seg = shift;
1127 0 my $x = shift;
1128 0 my $y = shift;
1129 0 my $foot;
1130 0 ▶ my $m = ($seg->[1]->[0] - $seg->[0]->[0] == 0) ? 'inf' : ($seg->[1]->[1] - $seg->[0]->[1])/($seg->[1]->[0] - $seg->[0]->[0]);
Branch: 1 branch
BranchTrueFalseTotal
$seg->[1][0] - $seg->[0][0] == 0 ? : 0 0 0
1131 0 ▶ my @sortx = $seg->[0]->[0] < $seg->[1]->[0] ? ($seg->[0]->[0], $seg->[1]->[0]) : ($seg->[1]->[0], $seg->[0]->[0]);
Branch: 1 branch
BranchTrueFalseTotal
$seg->[0][0] < $seg->[1][0] ? : 0 0 0
1132 0 ▶ my @sorty = $seg->[0]->[1] < $seg->[1]->[1] ? ($seg->[0]->[1], $seg->[1]->[1]) : ($seg->[1]->[1], $seg->[0]->[1]);
Branch: 1 branch
BranchTrueFalseTotal
$seg->[0][1] < $seg->[1][1] ? : 0 0 0
1133 0 ▶ if ($m == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m == 0) { } 0 0 0
elsif ($m == 'inf') { } 0 0 0
1134 0 ▶ if ($x >= $sortx[0] && $x <= $sortx[1]) {$foot=[$x, $seg->[0]->[1]];}
Branch: 1 branch
BranchTrueFalseTotal
if ($x >= $sortx[0] and $x <= $sortx[1]) 0 0 0
Condition0%0/3
$x >= $sortx[0] and $x <= $sortx[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$x >= $sortx[0] and $x <= $sortx[1]
$x >= $sortx[0] $x <= $sortx[1]
Truth table0%0/3
A and B
A= $x >= $sortx[0]B= $x <= $sortx[1]
ABresult
0X0
100
111
1135 }
1136 elsif ($m == 'inf') {
1137 0 ▶ if ($y >= $sorty[0] && $y <= $sorty[1]) {$foot=[$seg->[0]->[0], $y];}
Branch: 1 branch
BranchTrueFalseTotal
if ($y >= $sorty[0] and $y <= $sorty[1]) 0 0 0
Condition0%0/3
$y >= $sorty[0] and $y <= $sorty[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$y >= $sorty[0] and $y <= $sorty[1]
$y >= $sorty[0] $y <= $sorty[1]
Truth table0%0/3
A and B
A= $y >= $sorty[0]B= $y <= $sorty[1]
ABresult
0X0
100
111
1138 }
1139 else {
1140 0 my $intersect_x = (($m*$seg->[0]->[0])-($seg->[0]->[1])+((1/$m)*$x)+($y))/($m+(1/$m));
1141 0 ▶ if ($intersect_x >= $sortx[0] && $intersect_x <= $sortx[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intersect_x >= $sortx[0] and $intersect_x <= $sortx[1]) 0 0 0
Condition0%0/3
$intersect_x >= $sortx[0] and $intersect_x <= $sortx[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$intersect_x >= $sortx[0] and $intersect_x <= $sortx[1]
$intersect_x >= $sortx[0] $intersect_x <= $sortx[1]
Truth table0%0/3
A and B
A= $intersect_x >= $sortx[0]B= $intersect_x <= $sortx[1]
ABresult
0X0
100
111
1142 0 my $intersect_y = -($seg->[0]->[0] - $intersect_x) * $m + $seg->[0]->[1];
1143 0 ▶ if ($intersect_y >= $sorty[0] && $intersect_y <= $sorty[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intersect_y >= $sorty[0] and $intersect_y <= $sorty[1]) 0 0 0
Condition0%0/3
$intersect_y >= $sorty[0] and $intersect_y <= $sorty[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$intersect_y >= $sorty[0] and $intersect_y <= $sorty[1]
$intersect_y >= $sorty[0] $intersect_y <= $sorty[1]
Truth table0%0/3
A and B
A= $intersect_y >= $sorty[0]B= $intersect_y <= $sorty[1]
ABresult
0X0
100
111
1144 0 $foot = [$intersect_x, $intersect_y];
1145 }
1146 }
1147 }
1148 0 return $foot;
1149 }
1150  
1151 0 ▶sub angle_reduce {
Subroutine angle_reduce: not called CC=3 SCAR=24.8
Pod undocumented
1152 0 my $a=shift;
1153 0 ▶ while($a > $pi / 2) { $a -= $pi; }
Branch: 1 branch
BranchTrueFalseTotal
if ($a > $pi / 2) 0 0 0
1154 0 ▶ while($a <= -$pi / 2) { $a += $pi; }
Branch: 1 branch
BranchTrueFalseTotal
if ($a <= -$pi / 2) 0 0 0
1155 0 return $a;
1156 }
1157  
1158 0 ▶sub angle_reduce_pi {
Subroutine angle_reduce_pi: not called CC=3 SCAR=24.8
Pod undocumented
1159 0 my $a=shift;
1160 0 ▶ while($a > $pi) { $a -= $pi * 2; }
Branch: 1 branch
BranchTrueFalseTotal
if ($a > $pi) 0 0 0
1161 0 ▶ while($a <= -$pi) { $a += $pi * 2; }
Branch: 1 branch
BranchTrueFalseTotal
if ($a <= -$pi) 0 0 0
1162 0 return $a;
1163 }
1164  
1165 0 ▶sub seg_seg_intersection {
Subroutine seg_seg_intersection: not called CC=49 SCAR=78.0
Pod undocumented
1166 0 my $seg1 = shift;
1167 0 my $seg2 = shift;
1168 0 my $int;
1169  
1170 0 my $x1= $seg1->[0]->[0]; my $y1= $seg1->[0]->[1];
1171 0 my $x2= $seg1->[1]->[0]; my $y2= $seg1->[1]->[1];
1172 0 my $u1= $seg2->[0]->[0]; my $v1= $seg2->[0]->[1];
1173 0 my $u2= $seg2->[1]->[0]; my $v2= $seg2->[1]->[1];
1174  
1175 0 ▶ my $m1 = ($x2 eq $x1)?'Inf':($y2 - $y1)/($x2 - $x1);
Branch: 1 branch
BranchTrueFalseTotal
$x2 eq $x1 ? : 0 0 0
1176 0 ▶ my $m2 = ($u2 eq $u1)?'Inf':($v2 - $v1)/($u2 - $u1);
Branch: 1 branch
BranchTrueFalseTotal
$u2 eq $u1 ? : 0 0 0
1177  
1178 0 my $b1;
1179 my $b2;
1180 0 my $xi;
1181  
1182 # Arranged like this to avoid m1-m2 with infinity involved, which works
1183 # in other contexts, but can trigger a floating point exception here.
1184 0 my $dm;
1185 0 ▶ if ($m1 != 'Inf' && $m2 != 'Inf') {$dm = $m1 - $m2;}
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m1 == 'Inf' and $m2 == 'Inf') { } 0 0 0
Condition0%0/3
$m1 != "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 != "Inf" and $m2 != "Inf"
$m1 != "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 != "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
1186 0 ▶ elsif ($m1 == 'Inf' && $m2 == 'Inf') {return;}
Condition0%0/3
$m1 == "Inf" and $m2 == "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 == "Inf"
$m1 == "Inf" $m2 == "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 == "Inf"
ABresult
0X0
100
111
1187 0 else {$dm='Inf';}
1188  
1189 0 ▶ if ($m1 == 'Inf' && $m2 != 'Inf') {$xi = $x1;$b2 = $v1 - ($m2 * $u1);}
Branch: 3 branches
BranchTrueFalseTotal
if ($m1 == 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m2 == 'Inf' and $m1 != 'Inf') { } 0 0 0
elsif (abs $dm > 1e-12) { } 0 0 0
Condition0%0/3
$m1 == "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 != "Inf"
$m1 == "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
1190 0 ▶ elsif ($m2 == 'Inf' && $m1 != 'Inf') {$xi = $u1;$b1 = $y1 - ($m1 * $x1);}
Condition0%0/3
$m2 == "Inf" and $m1 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m2 == "Inf" and $m1 != "Inf"
$m2 == "Inf" $m1 != "Inf"
Truth table0%0/3
A and B
A= $m2 == "Inf"B= $m1 != "Inf"
ABresult
0X0
100
111
1191 elsif (abs($dm) > 0.000000000001) {
1192 0 $b1 = $y1 - ($m1 * $x1);
1193 0 $b2 = $v1 - ($m2 * $u1);
1194 0 $xi=($b2-$b1)/$dm;
1195 }
1196 0 ▶ my @lowhiu=($u2>$u1)?($u1,$u2):($u2,$u1);
Branch: 1 branch
BranchTrueFalseTotal
$u2 > $u1 ? : 0 0 0
1197 0 ▶ if ($m1 != 'Inf') {
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf') { } 0 0 0
elsif ($m2 != 'Inf') { } 0 0 0
1198 0 ▶ my @lowhix=($x2>$x1)?($x1,$x2):($x2,$x1);
Branch: 1 branch
BranchTrueFalseTotal
$x2 > $x1 ? : 0 0 0
1199 0 ▶ if ($m2 == 'Inf' && ($u2<$lowhix[0] || $u2>$lowhix[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]) 0 0 0
Condition0%0/6
$m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]
!ll&&!rl&&r
000
$u2 < $lowhix[0] or $u2 > $lowhix[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
$m2 == "Inf" and $u2 < $lowhix[0] || $u2 > $lowhix[1]
$m2 == "Inf" $u2 < $lowhix[0] $u2 > $lowhix[1]
Truth table0%0/4
A and B or C
A= $m2 == "Inf"B= $u2 < $lowhix[0]C= $u2 > $lowhix[1]
ABCresult
0XX0
1000
11X1
1011
1200 0 return;
1201 }
1202 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]) 0 0 0
Condition0%0/27
$xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]
!ll&&!rl&&r
000
$xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1]
!ll&&!rl&&r
000
$xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0]
!ll&&!rl&&r
000
$xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1]
!ll&&!rl&&r
000
$xi or $xi eq 0
l!l&&r!l&&!r
000
$xi < $lowhix[1] or $xi eq $lowhix[1]
l!l&&r!l&&!r
000
$xi > $lowhix[0] or $xi eq $lowhix[0]
l!l&&r!l&&!r
000
$xi < $lowhiu[1] or $xi eq $lowhiu[1]
l!l&&r!l&&!r
000
$xi > $lowhiu[0] or $xi eq $lowhiu[0]
l!l&&r!l&&!r
000
MC/DC0%0/10
$xi || $xi eq 0 and $xi < $lowhix[1] || $xi eq $lowhix[1] and $xi > $lowhix[0] || $xi eq $lowhix[0] and $xi < $lowhiu[1] || $xi eq $lowhiu[1] and $xi > $lowhiu[0] || $xi eq $lowhiu[0]
$xi $xi eq 0 $xi < $lowhix[1] $xi eq $lowhix[1] $xi > $lowhix[0] $xi eq $lowhix[0] $xi < $lowhiu[1] $xi eq $lowhiu[1] $xi > $lowhiu[0] $xi eq $lowhiu[0]
Truth table0%0/63
A or B and C or D and E or F and G or H and I or J
A= $xiB= $xi eq 0C= $xi < $lowhix[1]D= $xi eq $lowhix[1]E= $xi > $lowhix[0]F= $xi eq $lowhix[0]G= $xi < $lowhiu[1]H= $xi eq $lowhiu[1]I= $xi > $lowhiu[0]J= $xi eq $lowhiu[0]
ABCDEFGHIJresult
00XXXXXXXX0
1X00XXXXXX0
0100XXXXXX0
1X1X00XXXX0
1X0100XXXX0
011X00XXXX0
010100XXXX0
1X1X1X00XX0
1X1X0100XX0
1X011X00XX0
1X010100XX0
011X1X00XX0
011X0100XX0
01011X00XX0
01010100XX0
1X1X1X1X000
1X1X1X01000
1X1X011X000
1X1X0101000
1X011X1X000
1X011X01000
1X01011X000
1X010101000
011X1X1X000
011X1X01000
011X011X000
011X0101000
01011X1X000
01011X01000
0101011X000
01010101000
1X1X1X1X1X1
1X1X1X1X011
1X1X1X011X1
1X1X1X01011
1X1X011X1X1
1X1X011X011
1X1X01011X1
1X1X0101011
1X011X1X1X1
1X011X1X011
1X011X011X1
1X011X01011
1X01011X1X1
1X01011X011
1X0101011X1
1X010101011
011X1X1X1X1
011X1X1X011
011X1X011X1
011X1X01011
011X011X1X1
011X011X011
011X01011X1
011X0101011
01011X1X1X1
01011X1X011
01011X011X1
01011X01011
0101011X1X1
0101011X011
010101011X1
01010101011
1203 ($xi || $xi eq 0) &&
1204 ($xi < $lowhix[1] || $xi eq $lowhix[1]) &&
1205 ($xi > $lowhix[0] || $xi eq $lowhix[0]) &&
1206 ($xi < $lowhiu[1] || $xi eq $lowhiu[1]) &&
1207 ($xi > $lowhiu[0] || $xi eq $lowhiu[0])
1208 ) {
1209 0 my $y=($m1*$xi)+$b1;
1210 0 ▶ my @lowhiv=($v2>$v1)?($v1,$v2):($v2,$v1);
Branch: 1 branch
BranchTrueFalseTotal
$v2 > $v1 ? : 0 0 0
1211 0 ▶ if ($m2 == 'Inf' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($m2 == 'Inf' and $y < $lowhiv[0] || $y > $lowhiv[1]) { } 0 0 0
Condition0%0/6
$m2 == "Inf" and $y < $lowhiv[0] || $y > $lowhiv[1]
!ll&&!rl&&r
000
$y < $lowhiv[0] or $y > $lowhiv[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
$m2 == "Inf" and $y < $lowhiv[0] || $y > $lowhiv[1]
$m2 == "Inf" $y < $lowhiv[0] $y > $lowhiv[1]
Truth table0%0/4
A and B or C
A= $m2 == "Inf"B= $y < $lowhiv[0]C= $y > $lowhiv[1]
ABCresult
0XX0
1000
11X1
1011
1212 ($y<$lowhiv[0] || $y>$lowhiv[1])
1213 ) {
1214 0 return;
1215 }
1216 else {
1217 0 $int = [$xi,$y];
1218 }
1219 }
1220 }
1221 elsif ($m2 != 'Inf') { #so $m1 is Inf
1222  
1223 0 ▶ if ($x1 < $lowhiu[0] || $x1 > $lowhiu[1] && ! ($x1 eq $lowhiu[0] || $x1 eq $lowhiu[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x1 < $lowhiu[0] or $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]) 0 0 0
Condition0%0/9
$x1 < $lowhiu[0] or $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
l!l&&r!l&&!r
000
$x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
!ll&&!rl&&r
000
$x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
l!l&&r!l&&!r
000
MC/DC0%0/4
$x1 < $lowhiu[0] or $x1 > $lowhiu[1] and not $x1 eq $lowhiu[0] || $x1 eq $lowhiu[1]
$x1 < $lowhiu[0] $x1 > $lowhiu[1] $x1 eq $lowhiu[0] $x1 eq $lowhiu[1]
Truth table0%0/5
A or B and not(C || D)
A= $x1 < $lowhiu[0]B= $x1 > $lowhiu[1]C= $x1 eq $lowhiu[0]D= $x1 eq $lowhiu[1]
ABCDresult
1XXX1
01001
00XX0
011X0
01010
1224 0 return;
1225 }
1226 0 ▶ my @lowhiy=($y2>$y1)?($y1,$y2):($y2,$y1);
Branch: 1 branch
BranchTrueFalseTotal
$y2 > $y1 ? : 0 0 0
1227 0 ▶ my @lowhiv=($v2>$v1)?($v1,$v2):($v2,$v1);
Branch: 1 branch
BranchTrueFalseTotal
$v2 > $v1 ? : 0 0 0
1228 0 my $yi = ($m2*$xi)+$b2;
1229 0 ▶ if (($yi || $yi eq 0) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]) 0 0 0
Condition0%0/27
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0]
!ll&&!rl&&r
000
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1]
!ll&&!rl&&r
000
$yi or $yi eq 0
l!l&&r!l&&!r
000
$yi < $lowhiy[1] or $yi eq $lowhiy[1]
l!l&&r!l&&!r
000
$yi > $lowhiy[0] or $yi eq $lowhiy[0]
l!l&&r!l&&!r
000
$yi < $lowhiv[1] or $yi eq $lowhiv[1]
l!l&&r!l&&!r
000
$yi > $lowhiv[0] or $yi eq $lowhiv[0]
l!l&&r!l&&!r
000
MC/DC0%0/10
$yi || $yi eq 0 and $yi < $lowhiy[1] || $yi eq $lowhiy[1] and $yi > $lowhiy[0] || $yi eq $lowhiy[0] and $yi < $lowhiv[1] || $yi eq $lowhiv[1] and $yi > $lowhiv[0] || $yi eq $lowhiv[0]
$yi $yi eq 0 $yi < $lowhiy[1] $yi eq $lowhiy[1] $yi > $lowhiy[0] $yi eq $lowhiy[0] $yi < $lowhiv[1] $yi eq $lowhiv[1] $yi > $lowhiv[0] $yi eq $lowhiv[0]
Truth table0%0/63
A or B and C or D and E or F and G or H and I or J
A= $yiB= $yi eq 0C= $yi < $lowhiy[1]D= $yi eq $lowhiy[1]E= $yi > $lowhiy[0]F= $yi eq $lowhiy[0]G= $yi < $lowhiv[1]H= $yi eq $lowhiv[1]I= $yi > $lowhiv[0]J= $yi eq $lowhiv[0]
ABCDEFGHIJresult
00XXXXXXXX0
1X00XXXXXX0
0100XXXXXX0
1X1X00XXXX0
1X0100XXXX0
011X00XXXX0
010100XXXX0
1X1X1X00XX0
1X1X0100XX0
1X011X00XX0
1X010100XX0
011X1X00XX0
011X0100XX0
01011X00XX0
01010100XX0
1X1X1X1X000
1X1X1X01000
1X1X011X000
1X1X0101000
1X011X1X000
1X011X01000
1X01011X000
1X010101000
011X1X1X000
011X1X01000
011X011X000
011X0101000
01011X1X000
01011X01000
0101011X000
01010101000
1X1X1X1X1X1
1X1X1X1X011
1X1X1X011X1
1X1X1X01011
1X1X011X1X1
1X1X011X011
1X1X01011X1
1X1X0101011
1X011X1X1X1
1X011X1X011
1X011X011X1
1X011X01011
1X01011X1X1
1X01011X011
1X0101011X1
1X010101011
011X1X1X1X1
011X1X1X011
011X1X011X1
011X1X01011
011X011X1X1
011X011X011
011X01011X1
011X0101011
01011X1X1X1
01011X1X011
01011X011X1
01011X01011
0101011X1X1
0101011X011
010101011X1
01010101011
1230 ($yi < $lowhiy[1] || $yi eq $lowhiy[1]) &&
1231 ($yi > $lowhiy[0] || $yi eq $lowhiy[0]) &&
1232 ($yi < $lowhiv[1] || $yi eq $lowhiv[1]) &&
1233 ($yi > $lowhiv[0] || $yi eq $lowhiv[0])
1234 ) {
1235 0 $int = [$xi,$yi];
1236 }
1237 }
1238 0 return $int;
1239 }
1240  
1241 0 ▶sub line_line_intersection {
Subroutine line_line_intersection: not called CC=17 SCAR=57.2
Pod undocumented
1242 0 my $seg1 = shift;
1243 0 my $seg2 = shift;
1244 0 my $int;
1245  
1246 0 my $x1= $seg1->[0]->[0]; my $y1= $seg1->[0]->[1];
1247 0 my $x2= $seg1->[1]->[0]; my $y2= $seg1->[1]->[1];
1248 0 my $u1= $seg2->[0]->[0]; my $v1= $seg2->[0]->[1];
1249 0 my $u2= $seg2->[1]->[0]; my $v2= $seg2->[1]->[1];
1250  
1251 0 ▶ my $m1 = ($x2 eq $x1)?'Inf':($y2 - $y1)/($x2 - $x1);
Branch: 1 branch
BranchTrueFalseTotal
$x2 eq $x1 ? : 0 0 0
1252 0 ▶ my $m2 = ($u2 eq $u1)?'Inf':($v2 - $v1)/($u2 - $u1);
Branch: 1 branch
BranchTrueFalseTotal
$u2 eq $u1 ? : 0 0 0
1253  
1254 0 my $b1;
1255 my $b2;
1256  
1257 0 my $xi;
1258  
1259 # Arranged like this to avoid m1-m2 with infinity involved, which works
1260 # in other contexts, but can trigger a floating point exception here.
1261 0 my $dm;
1262 0 ▶ if ($m1 != 'Inf' && $m2 != 'Inf') {$dm = $m1 - $m2;}
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m1 == 'Inf' and $m2 == 'Inf') { } 0 0 0
Condition0%0/3
$m1 != "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 != "Inf" and $m2 != "Inf"
$m1 != "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 != "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
1263 0 ▶ elsif ($m1 == 'Inf' && $m2 == 'Inf') {return;}
Condition0%0/3
$m1 == "Inf" and $m2 == "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 == "Inf"
$m1 == "Inf" $m2 == "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 == "Inf"
ABresult
0X0
100
111
1264 0 else {$dm='Inf';}
1265  
1266 0 ▶ if ($m1 == 'Inf' && $m2 != 'Inf') {$xi = $x1;$b2 = $v1 - ($m2 * $u1);}
Branch: 3 branches
BranchTrueFalseTotal
if ($m1 == 'Inf' and $m2 != 'Inf') { } 0 0 0
elsif ($m2 == 'Inf' and $m1 != 'Inf') { } 0 0 0
elsif (abs $dm > 1e-12) { } 0 0 0
Condition0%0/3
$m1 == "Inf" and $m2 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m1 == "Inf" and $m2 != "Inf"
$m1 == "Inf" $m2 != "Inf"
Truth table0%0/3
A and B
A= $m1 == "Inf"B= $m2 != "Inf"
ABresult
0X0
100
111
1267 0 ▶ elsif ($m2 == 'Inf' && $m1 != 'Inf') {$xi = $u1;$b1 = $y1 - ($m1 * $x1);}
Condition0%0/3
$m2 == "Inf" and $m1 != "Inf"
!ll&&!rl&&r
000
MC/DC0%0/2
$m2 == "Inf" and $m1 != "Inf"
$m2 == "Inf" $m1 != "Inf"
Truth table0%0/3
A and B
A= $m2 == "Inf"B= $m1 != "Inf"
ABresult
0X0
100
111
1268 elsif (abs($dm) > 0.000000000001) {
1269 0 $b1 = $y1 - ($m1 * $x1);
1270 0 $b2 = $v1 - ($m2 * $u1);
1271 0 $xi=($b2-$b1)/$dm;
1272 }
1273 0 ▶ if ($m1 != 'Inf') {
Branch: 2 branches
BranchTrueFalseTotal
if ($m1 != 'Inf') { } 0 0 0
elsif ($m2 != 'Inf') { } 0 0 0
1274 0 ▶ if (defined $xi) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xi) 0 0 0
1275 0 my $y=($m1*$xi)+$b1;
1276 0 $int = [$xi,$y];
1277 }
1278 }
1279 elsif ($m2 != 'Inf') { # so $m1 is Inf
1280 0 my $yi = ($m2*$xi)+$b2;
1281 0 ▶ if ($yi || $yi eq 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yi or $yi eq 0) 0 0 0
Condition0%0/3
$yi or $yi eq 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$yi or $yi eq 0
$yi $yi eq 0
Truth table0%0/3
A or B
A= $yiB= $yi eq 0
ABresult
1X1
011
000
1282 0 $int = [$xi,$yi];
1283 }
1284 }
1285 0 return $int;
1286 }
1287  
1288 0 ▶sub to_svg {
Subroutine to_svg: not called CC=102 SCAR=92.6
Pod documented
1289 0 my %spec = @_;
1290 0 ▶ my $triios = [defined($spec{topo}) ? delete $spec{topo} : undef, defined($spec{vtopo}) ? delete $spec{vtopo} : undef];
Branch: 2 branches
BranchTrueFalseTotal
defined $spec{'topo'} ? : 0 0 0
defined $spec{'vtopo'} ? : 0 0 0
1291 0 ▶ my $fn = defined($spec{file}) ? delete $spec{file} : '-';
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'file'} ? : 0 0 0
1292 0 ▶ my $dispsize = defined($spec{size}) ? delete $spec{size} : [800, 600];
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'size'} ? : 0 0 0
1293 0 my $triio = $triios->[0];
1294 0 ▶ my $vorio = @{$triios}?$triios->[1]:undef;
Branch: 1 branch
BranchTrueFalseTotal
@{$triios;} ? : 0 0 0
1295 0 my @edges;
1296 my @segs;
1297 0 my @pts;
1298 0 my @vpts;
1299 0 my @vedges;
1300 0 my @vrays;
1301 0 my @circles;
1302 0 my @elements;
1303 0 my $maxx;
1304 0 my $maxy;
1305 0 my $minx;
1306 0 my $miny;
1307 0 ▶ if (!$triio) {carp "no geometry provided";return;}
Branch: 1 branch
BranchTrueFalseTotal
unless ($triio) 0 0 0
1308 0 ▶ foreach my $key ( keys %spec ) { if (ref($spec{$key}) !~ /ARRAY/) { carp("style config for '$key' should be a reference to an array"); return; } }
Branch: 1 branch
BranchTrueFalseTotal
unless (ref($spec{$key}) =~ /ARRAY/) 0 0 0
1309  
1310 # make copies of points, because we'll be moving and scaling them
1311  
1312 0 ▶ if (ref($triio) =~ /HASH|mgd_topo/ && defined $triio->{nodes}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{'nodes'}) { } 0 0 0
Condition0%0/3
ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{"nodes"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{"nodes"}
ref($triio) =~ /HASH|mgd_topo/ defined $triio->{"nodes"}
Truth table0%0/3
A and B
A= ref($triio) =~ /HASH|mgd_topo/B= defined $triio->{"nodes"}
ABresult
0X0
100
111
1313 0 ▶ push @pts, map [$_,defined $spec{nodes} ? @{$spec{nodes}} : undef], map [@{$_->{point}}], @{$triio->{nodes}};
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'nodes'} ? : 0 0 0
1314 }
1315 else {
1316 0 ▶ push @pts, map [[@{$_}],defined $spec{nodes} ? @{$spec{nodes}} : undef], ltolol(2,$triio->pointlist);
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'nodes'} ? : 0 0 0
1317 }
1318 0 ▶ if ($vorio) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vorio) 0 0 0
1319 0 ▶ if (ref($vorio) =~ /HASH|mgd_topo/ && defined $vorio->{nodes}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{'nodes'}) { } 0 0 0
Condition0%0/3
ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{"nodes"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{"nodes"}
ref($vorio) =~ /HASH|mgd_topo/ defined $vorio->{"nodes"}
Truth table0%0/3
A and B
A= ref($vorio) =~ /HASH|mgd_topo/B= defined $vorio->{"nodes"}
ABresult
0X0
100
111
1320 0 ▶ push @vpts, map [$_,defined $spec{vnodes} ? @{$spec{vnodes}} : undef], map [@{$_->{point}}], @{$vorio->{nodes}};
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'vnodes'} ? : 0 0 0
1321 }
1322 else {
1323 0 ▶ push @vpts, map [[@{$_}],defined $spec{vnodes} ? @{$spec{vnodes}} : undef], ltolol(2,$vorio->pointlist);
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'vnodes'} ? : 0 0 0
1324 }
1325 }
1326  
1327 0 $maxx = $pts[0]->[0]->[0];
1328 0 $minx = $pts[0]->[0]->[0];
1329 0 $maxy = $pts[0]->[0]->[1];
1330 0 $miny = $pts[0]->[0]->[1];
1331 0 foreach my $pt (@pts,@vpts) {
1332 0 ▶ if ($maxx < $pt->[0]->[0]) {$maxx = $pt->[0]->[0]}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxx < $pt->[0][0]) 0 0 0
1333 0 ▶ if ($maxy < $pt->[0]->[1]) {$maxy = $pt->[0]->[1]}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxy < $pt->[0][1]) 0 0 0
1334 0 ▶ if ($minx > $pt->[0]->[0]) {$minx = $pt->[0]->[0]}
Branch: 1 branch
BranchTrueFalseTotal
if ($minx > $pt->[0][0]) 0 0 0
1335 0 ▶ if ($miny > $pt->[0]->[1]) {$miny = $pt->[0]->[1]}
Branch: 1 branch
BranchTrueFalseTotal
if ($miny > $pt->[0][1]) 0 0 0
1336 }
1337  
1338 # offset and scale to avoid limitations of svg renderers
1339  
1340 0 my $dispsizex = '640';
1341 0 my $dispsizey = '480';
1342
1343 0 ▶ if (ref($dispsize) =~ /ARRAY/ && @{$dispsize} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($dispsize) =~ /ARRAY/ and @{$dispsize;} > 1) 0 0 0
Condition0%0/3
ref($dispsize) =~ /ARRAY/ and @{$dispsize;} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref($dispsize) =~ /ARRAY/ and @{$dispsize;} > 1
ref($dispsize) =~ /ARRAY/ @{$dispsize;} > 1
Truth table0%0/3
A and B
A= ref($dispsize) =~ /ARRAY/B= @{$dispsize;} > 1
ABresult
0X0
100
111
1344 0 $dispsizex = $dispsize->[0];
1345 0 $dispsizey = $dispsize->[1];
1346 }
1347
1348 # used to scale lines and point circle radii
1349 # so they stay visible in different viewports dimensions
1350 0 my $scale=(sqrt($dispsizex**2+$dispsizey**2))/sqrt(($maxx-$minx)**2+($maxy-$miny)**2);
1351  
1352 0 foreach (@pts,@vpts) {
1353 0 $_->[0]->[0] -= $minx;
1354 0 $_->[0]->[0] *= $scale;
1355 0 $_->[0]->[1] -= $miny;
1356 0 $_->[0]->[1] *= $scale;
1357 }
1358  
1359 0 my $scaled_maxx = ($maxx - $minx) * $scale;
1360 0 my $scaled_maxy = ($maxy - $miny) * $scale;
1361 0 my $scaled_minx = 0;
1362 0 my $scaled_miny = 0;
1363  
1364 0 ▶ if (ref($triio) =~ /HASH|mgd_topo/ && defined $triio->{nodes}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{'nodes'}) { } 0 0 0
Condition0%0/3
ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{"nodes"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref($triio) =~ /HASH|mgd_topo/ and defined $triio->{"nodes"}
ref($triio) =~ /HASH|mgd_topo/ defined $triio->{"nodes"}
Truth table0%0/3
A and B
A= ref($triio) =~ /HASH|mgd_topo/B= defined $triio->{"nodes"}
ABresult
0X0
100
111
1365 0 ▶ if ($spec{edges}) {push @edges, map {[$_,@{$spec{edges}}]} map [$pts[$_->{nodes}->[0]->{index}]->[0],$pts[$_->{nodes}->[1]->{index}]->[0]], @{$triio->{edges}};}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"edges"}) 0 0 0
1366 0 ▶ if ($spec{segments}) {push @segs, map {[$_,@{$spec{segments}}]} map [$pts[$_->{nodes}->[0]->{index}]->[0],$pts[$_->{nodes}->[1]->{index}]->[0]], @{$triio->{segments}};}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"segments"}) 0 0 0
1367 #ignoring any subparametric points for elements
1368 0 ▶ if ($spec{elements}) {push @elements, map [[map $pts[$_->{index}]->[0], @{$_->{nodes}}[0..2]], (ref($spec{elements}->[0]) =~ /CODE/ ? &{$spec{elements}->[0]}($_) : $spec{elements}->[0]), defined($spec{elements}->[1]) ? $spec{elements}->[1] : ''], @{$triio->{elements}};} #/
Branch: 3 branches
BranchTrueFalseTotal
if ($spec{"elements"}) 0 0 0
ref($spec{'elements'}[0]) =~ /CODE/ ? : 0 0 0
defined $spec{'elements'}[1] ? : 0 0 0
1369 }
1370 else {
1371 0 ▶ if ($spec{edges}) {push @edges, map {[[$pts[$_->[0]]->[0],$pts[$_->[1]]->[0]],@{$spec{edges}}]} ltolol(2,$triio->edgelist);}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"edges"}) 0 0 0
1372 0 ▶ if ($spec{segments}) {push @segs, map {[[$pts[$_->[0]]->[0],$pts[$_->[1]]->[0]],@{$spec{segments}}]} ltolol(2,$triio->segmentlist);}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"segments"}) 0 0 0
1373 #ignoring any subparametric points for elements
1374 0 ▶ if ($spec{elements}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"elements"}) 0 0 0
1375 0 ▶ push @elements, map {[[$pts[$_->[0]]->[0],$pts[$_->[1]]->[0],$pts[$_->[2]]->[0]],$spec{elements}->[0], defined($spec{elements}->[1]) ? $spec{elements}->[1] : '']} ltolol($triio->numberofcorners,$triio->trianglelist); #/
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'elements'}[1] ? : 0 0 0
1376 #read triangle attribute list, so at least those are available for choosing fill color in this case
1377 0 ▶ if (ref($spec{elements}->[0]) =~ /CODE/ && $triio->numberoftriangleattributes > 0 && $triio->numberofregions > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($spec{"elements"}[0]) =~ /CODE/ and $triio->numberoftriangleattributes > 0 and $triio->numberofregions > 0) 0 0 0
Condition0%0/6
ref($spec{"elements"}[0]) =~ /CODE/ and $triio->numberoftriangleattributes > 0 and $triio->numberofregions > 0
!ll&&!rl&&r
000
ref($spec{"elements"}[0]) =~ /CODE/ and $triio->numberoftriangleattributes > 0
!ll&&!rl&&r
000
MC/DC0%0/3
ref($spec{"elements"}[0]) =~ /CODE/ and $triio->numberoftriangleattributes > 0 and $triio->numberofregions > 0
ref($spec{"elements"}[0]) =~ /CODE/ $triio->numberoftriangleattributes > 0 $triio->numberofregions > 0
Truth table0%0/4
A and B and C
A= ref($spec{"elements"}[0]) =~ /CODE/B= $triio->numberoftriangleattributes > 0C= $triio->numberofregions > 0
ABCresult
0XX0
10X0
1100
1111
1378 0 my @eleattrs = ltolol($triio->numberoftriangleattributes,$triio->triangleattributes);
1379 0 ▶ for (my $i=0;$i<@elements;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @elements) 0 0 0
1380 # topologically-linked triangle not available here
1381 # but we'll fake it at least for the attributes list
1382 # so the color callback can still color according to region id
1383 # or whatever is in the triangle attribute list
1384 0 $elements[$i]->[1] = &{$spec{elements}->[0]}({attributes=>$eleattrs[$i]});
1385 }
1386 }
1387 }
1388 }
1389  
1390 0 ▶ if ($vorio) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vorio) 0 0 0
1391 0 ▶ if (ref($vorio) =~ /HASH|mgd_topo/ && defined $vorio->{nodes}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{'nodes'}) { } 0 0 0
Condition0%0/3
ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{"nodes"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref($vorio) =~ /HASH|mgd_topo/ and defined $vorio->{"nodes"}
ref($vorio) =~ /HASH|mgd_topo/ defined $vorio->{"nodes"}
Truth table0%0/3
A and B
A= ref($vorio) =~ /HASH|mgd_topo/B= defined $vorio->{"nodes"}
ABresult
0X0
100
111
1392 # circles only available in this case
1393 0 ▶ if (defined $spec{circles}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $spec{"circles"}) 0 0 0
1394 push @circles, map {
1395 [
1396 [ # this is point and radius: [x,y,r]
1397 0 ▶ @{$vpts[$_->{index}]->[0]},
Branch: 1 branch
BranchTrueFalseTotal
defined $_->{'radius'} ? : 0 0 0
1398 defined $_->{radius}
1399 ? $_->{radius} * $scale
1400 : dist2d($vpts[$_->{index}]->[0],$edges[$_->{edges}->[0]->{index}]->[0]->[0])
1401 ],
1402 0 @{$spec{circles}}
1403 ]
1404 0 } @{$vorio->{nodes}};
1405 }
1406 0 ▶ if ($spec{vedges}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"vedges"}) 0 0 0
1407 0 ▶ @vedges = map [[$vpts[$_->{nodes}->[0]->{index}]->[0],$vpts[$_->{nodes}->[1]->{index}]->[0]],@{$spec{vedges}}], grep $_->{vector}->[0] eq 0 && $_->{vector}->[1] eq 0, @{$vorio->{edges}};
Condition0%0/3
$_->{'vector'}[0] eq 0 && $_->{'vector'}[1] eq 0
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{'vector'}[0] eq 0 && $_->{'vector'}[1] eq 0
$_->{'vector'}[0] eq 0 $_->{'vector'}[1] eq 0
Truth table0%0/3
A && B
A= $_->{'vector'}[0] eq 0B= $_->{'vector'}[1] eq 0
ABresult
0X0
100
111
1408 }
1409 0 ▶ if (defined $spec{vrays}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $spec{"vrays"}) 0 0 0
1410 0 ▶ @vrays = map [[$vpts[$_->{nodes}->[0]->{index}]->[0],[@{$_->{vector}}]],(defined($spec{vrays}) ? @{$spec{vrays}} : @{$spec{vedges}})], grep $_->{vector}->[0] ne 0 || $_->{vector}->[1] ne 0, @{$vorio->{edges}};
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'vrays'} ? : 0 0 0
Condition0%0/3
$_->{'vector'}[0] ne 0 || $_->{'vector'}[1] ne 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{'vector'}[0] ne 0 || $_->{'vector'}[1] ne 0
$_->{'vector'}[0] ne 0 $_->{'vector'}[1] ne 0
Truth table0%0/3
A || B
A= $_->{'vector'}[0] ne 0B= $_->{'vector'}[1] ne 0
ABresult
1X1
011
000
1411 0 foreach my $ray (@vrays) {
1412 0 $ray->[0]->[1]->[0] *= $scale;
1413 0 $ray->[0]->[1]->[1] *= $scale;
1414 0 $ray->[0]->[1]->[0] += $ray->[0]->[0]->[0];
1415 0 $ray->[0]->[1]->[1] += $ray->[0]->[0]->[1];
1416 }
1417 }
1418 }
1419 else {
1420 0 ▶ if ($spec{vedges}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"vedges"}) 0 0 0
1421 0 my @ves =ltolol(2,$vorio->edgelist);
1422 0 my @vnorms=ltolol(2,$vorio->normlist);
1423 0 ▶ for (my $i=0;$i<@ves;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @ves) 0 0 0
1424 0 ▶ if ($ves[$i]->[0] > -1 && $ves[$i]->[1] > -1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ves[$i][0] > -1 and $ves[$i][1] > -1) { } 0 0 0
elsif (defined $spec{'vrays'}) { } 0 0 0
Condition0%0/3
$ves[$i][0] > -1 and $ves[$i][1] > -1
!ll&&!rl&&r
000
MC/DC0%0/2
$ves[$i][0] > -1 and $ves[$i][1] > -1
$ves[$i][0] > -1 $ves[$i][1] > -1
Truth table0%0/3
A and B
A= $ves[$i][0] > -1B= $ves[$i][1] > -1
ABresult
0X0
100
111
1425 0 push @vedges, [[$vpts[$ves[$i]->[0]]->[0],$vpts[$ves[$i]->[1]]->[0]],@{$spec{vedges}}];
1426 }
1427 elsif (defined $spec{vrays}) {
1428 0 ▶ my $baseidx = ($ves[$i]->[0] != -1)?0:1;
Branch: 1 branch
BranchTrueFalseTotal
$ves[$i][0] != -1 ? : 0 0 0
1429 0 my $basept = $vpts[$ves[$i]->[$baseidx]]->[0];
1430 0 my $vec = $vnorms[$i];
1431 0 my $h = sqrt($vec->[0]**2 + $vec->[1]**2);
1432 0 $vec = [$vec->[0]/$h,$vec->[1]/$h];
1433 push @vrays, [
1434 [$basept,[$basept->[0]+$vec->[0]*$maxx,$basept->[1]+$vec->[1]*$maxx]],
1435 0 ▶ (defined($spec{vrays}) ? @{$spec{vrays}} : @{$spec{vedges}})];
Branch: 1 branch
BranchTrueFalseTotal
defined $spec{'vrays'} ? : 0 0 0
1436 }
1437 }
1438 }
1439 0 ▶ if ($spec{circles}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"circles"}) 0 0 0
1440 0 ▶ for (my $i=0;$i<@vpts;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @vpts) 0 0 0
1441 0 push @circles, [[@{$vpts[$i]->[0]},dist2d($vpts[$i]->[0],$elements[$i]->[0])],@{$spec{circles}}];
1442 }
1443 }
1444 }
1445 }
1446  
1447 0 my $margin_x_hi = 5;
1448 0 my $margin_x_lo = 5;
1449 0 my $margin_y_hi = 5;
1450 0 my $margin_y_lo = 5;
1451  
1452 # extend margins to account for the radius of any circles or points
1453 0 ▶ my @round_things = (@circles, (map {[[$_->[0]->[0], $_->[0]->[1], $_->[2]]]} ( ($spec{nodes} ? @pts : () ), ($spec{vnodes} ? @vpts : () ))));
Branch: 2 branches
BranchTrueFalseTotal
$spec{'nodes'} ? : 0 0 0
$spec{'vnodes'} ? : 0 0 0
1454 0 ▶ if (scalar(@round_things) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @round_things > 0) 0 0 0
1455 0 my $cir_maxx = $round_things[0]->[0]->[0] + $round_things[0]->[0]->[2];
1456 0 my $cir_maxy = $round_things[0]->[0]->[1] + $round_things[0]->[0]->[2];
1457 0 my $cir_minx = $round_things[0]->[0]->[0] - $round_things[0]->[0]->[2];
1458 0 my $cir_miny = $round_things[0]->[0]->[1] - $round_things[0]->[0]->[2];
1459 0 foreach my $cir (@round_things) {
1460 0 ▶ if ($cir_maxx < $cir->[0]->[0] + $cir->[0]->[2]) {$cir_maxx = $cir->[0]->[0] + $cir->[0]->[2]}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_maxx < $cir->[0][0] + $cir->[0][2]) 0 0 0
1461 0 ▶ if ($cir_maxy < $cir->[0]->[1] + $cir->[0]->[2]) {$cir_maxy = $cir->[0]->[1] + $cir->[0]->[2]}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_maxy < $cir->[0][1] + $cir->[0][2]) 0 0 0
1462 0 ▶ if ($cir_minx > $cir->[0]->[0] - $cir->[0]->[2]) {$cir_minx = $cir->[0]->[0] - $cir->[0]->[2]}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_minx > $cir->[0][0] - $cir->[0][2]) 0 0 0
1463 0 ▶ if ($cir_miny > $cir->[0]->[1] - $cir->[0]->[2]) {$cir_miny = $cir->[0]->[1] - $cir->[0]->[2]}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_miny > $cir->[0][1] - $cir->[0][2]) 0 0 0
1464 }
1465 0 ▶ if ($cir_maxx-$scaled_maxx > $margin_x_hi) {$margin_x_hi = ($cir_maxx - $scaled_maxx) + 5;}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_maxx - $scaled_maxx > $margin_x_hi) 0 0 0
1466 0 ▶ if ($scaled_minx-$cir_minx > $margin_x_lo) {$margin_x_lo = ($scaled_minx - $cir_minx) + 5;}
Branch: 1 branch
BranchTrueFalseTotal
if ($scaled_minx - $cir_minx > $margin_x_lo) 0 0 0
1467 0 ▶ if ($cir_maxy-$scaled_maxy > $margin_y_hi) {$margin_y_hi = ($cir_maxy - $scaled_maxy) + 5;}
Branch: 1 branch
BranchTrueFalseTotal
if ($cir_maxy - $scaled_maxy > $margin_y_hi) 0 0 0
1468 0 ▶ if ($scaled_miny-$cir_miny > $margin_y_lo) {$margin_y_lo = ($scaled_miny - $cir_miny) + 5;}
Branch: 1 branch
BranchTrueFalseTotal
if ($scaled_miny - $cir_miny > $margin_y_lo) 0 0 0
1469 }
1470  
1471 0 open(SVGO,'>'.$fn);
1472 0 print SVGO sprintf <<"EOS", $dispsizex, $dispsizey, -$margin_x_lo, -$margin_y_hi, $scaled_maxx + ($margin_x_lo + $margin_x_hi), $scaled_maxy + ($margin_y_lo + $margin_y_hi), $scaled_maxy;
1473 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1474 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
1475 <svg width="%s" height="%s" viewBox="%s %s %s %s" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg">
1476 <g transform="scale(1,-1) translate(0,-%s)">
1477 EOS
1478  
1479 0 ▶ if ($spec{elements}) {print SVGO "\n<!-- elements -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"elements"}) 0 0 0
1480 0 foreach my $ele (@elements) {
1481 0 ▶ print SVGO '<path d="M',join('L',map $_->[0].','.$_->[1], @{$ele->[0]}),'" style="fill:',(defined($ele->[1]) ? $ele->[1] : 'none'),';',(defined($ele->[2])?$ele->[2]:''),'"/>',"\n"
Branch: 2 branches
BranchTrueFalseTotal
defined $ele->[1] ? : 0 0 0
defined $ele->[2] ? : 0 0 0
1482 }
1483 0 ▶ if ($spec{edges}) {print SVGO "\n<!-- edges -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"edges"}) 0 0 0
1484 0 foreach my $edge (@edges) {
1485 0 ▶ print SVGO '<line x1="',$edge->[0]->[0]->[0],'" y1="',$edge->[0]->[0]->[1],'" x2="',$edge->[0]->[1]->[0],'" y2="',$edge->[0]->[1]->[1],'" style="stroke:',$edge->[1],';stroke-width:',$edge->[2],';',(defined($edge->[3])?$edge->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $edge->[3] ? : 0 0 0
1486 }
1487 0 ▶ if ($spec{segments}) {print SVGO "\n<!-- segments -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"segments"}) 0 0 0
1488 0 foreach my $edge (@segs) {
1489 0 ▶ print SVGO '<line x1="',$edge->[0]->[0]->[0],'" y1="',$edge->[0]->[0]->[1],'" x2="',$edge->[0]->[1]->[0],'" y2="',$edge->[0]->[1]->[1],'" style="stroke:',$edge->[1],';stroke-width:',$edge->[2],';',(defined($edge->[3])?$edge->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $edge->[3] ? : 0 0 0
1490 }
1491 0 ▶ if ($spec{vedges} && $vorio) {print SVGO "\n<!-- vor edges -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"vedges"} and $vorio) 0 0 0
Condition0%0/3
$spec{"vedges"} and $vorio
!ll&&!rl&&r
000
MC/DC0%0/2
$spec{"vedges"} and $vorio
$spec{"vedges"} $vorio
Truth table0%0/3
A and B
A= $spec{"vedges"}B= $vorio
ABresult
0X0
100
111
1492 0 foreach my $edge (@vedges) {
1493 0 ▶ print SVGO '<line x1="',$edge->[0]->[0]->[0],'" y1="',$edge->[0]->[0]->[1],'" x2="',$edge->[0]->[1]->[0],'" y2="',$edge->[0]->[1]->[1],'" style="stroke:',$edge->[1],';stroke-width:',$edge->[2],';',(defined($edge->[3])?$edge->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $edge->[3] ? : 0 0 0
1494 }
1495 0 ▶ if ($spec{vrays} && $vorio) {print SVGO "\n<!-- vor rays -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"vrays"} and $vorio) 0 0 0
Condition0%0/3
$spec{"vrays"} and $vorio
!ll&&!rl&&r
000
MC/DC0%0/2
$spec{"vrays"} and $vorio
$spec{"vrays"} $vorio
Truth table0%0/3
A and B
A= $spec{"vrays"}B= $vorio
ABresult
0X0
100
111
1496 0 foreach my $edge (@vrays) {
1497 0 ▶ print SVGO '<line x1="',$edge->[0]->[0]->[0],'" y1="',$edge->[0]->[0]->[1],'" x2="',$edge->[0]->[1]->[0],'" y2="',$edge->[0]->[1]->[1],'" style="stroke:',$edge->[1],';stroke-width:',$edge->[2],';',(defined($edge->[3])?$edge->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $edge->[3] ? : 0 0 0
1498 }
1499 0 ▶ if ($spec{nodes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"nodes"}) 0 0 0
1500 0 print SVGO "\n<!-- pts -->\n";
1501 0 foreach my $pt (@pts) {
1502 0 ▶ print SVGO '<circle cx="',$pt->[0]->[0],'" cy="',$pt->[0]->[1],'" r="', $pt->[2] ,'" style="fill:',$pt->[1],';',(defined($pt->[3])?$pt->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $pt->[3] ? : 0 0 0
1503 }
1504 }
1505 0 ▶ if ($spec{vnodes} && $vorio) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"vnodes"} and $vorio) 0 0 0
Condition0%0/3
$spec{"vnodes"} and $vorio
!ll&&!rl&&r
000
MC/DC0%0/2
$spec{"vnodes"} and $vorio
$spec{"vnodes"} $vorio
Truth table0%0/3
A and B
A= $spec{"vnodes"}B= $vorio
ABresult
0X0
100
111
1506 0 print SVGO "\n<!-- vor pts -->\n";
1507 0 foreach my $pt (@vpts) {
1508 0 ▶ print SVGO '<circle cx="',$pt->[0]->[0],'" cy="',$pt->[0]->[1],'" r="', $pt->[2] ,'" style="fill:',$pt->[1],';',(defined($pt->[3])?$pt->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $pt->[3] ? : 0 0 0
1509 }
1510 }
1511 0 ▶ if ($spec{circles}) {print SVGO "\n<!-- circles -->\n";}
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"circles"}) 0 0 0
1512 0 foreach my $circle (@circles) {
1513 0 ▶ print SVGO '<circle cx="',$circle->[0]->[0],'" cy="',$circle->[0]->[1],'" r="', $circle->[0]->[2] ,'" style="stroke-width:',$circle->[2],';stroke:',$circle->[1],';fill:none;',(defined($circle->[3])?$circle->[3]:''),'"/>',"\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $circle->[3] ? : 0 0 0
1514 }
1515  
1516 0 ▶ if ($spec{raw}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec{"raw"}) 0 0 0
1517 0 print SVGO "\n<!-- raw svg -->\n";
1518 0 print SVGO join("\n",map { s/ (c?x[12]?)="([0-9\.eE\-]+)"/' '.$1.'="'.(($2-$minx)*$scale).'"'/ge;
1519 0 s/ (c?y[12]?)="([0-9\.eE\-]+)"/' '.$1.'="'.(($2-$miny)*$scale).'"'/ge;
1520 0 $_;
1521 0 } @{$spec{raw}});
1522 }
1523 0 print SVGO "\n</g></svg>";
1524 0 close(SVGO);
1525 }
1526  
1527 0 ▶sub dist2d {sqrt(($_[0]->[0]-$_[1]->[0])**2+($_[0]->[1]-$_[1]->[1])**2)}
Subroutine dist2d: not called CC=1 SCAR=6.9
Pod undocumented
1528  
1529 0 ▶sub counterclockwise {
Subroutine counterclockwise: not called CC=1 SCAR=6.9
Pod undocumented
1530 0 my ($pa, $pb, $pc) = @_;
1531 0 return _counterclockwise($pa->[0],$pa->[1],$pb->[0],$pb->[1],$pc->[0],$pc->[1]);
1532 }
1533  
1534 package mgd_topo;
1535  
1536 3 ▶sub DESTROY {
Subroutine DESTROY: called CC=7 SCAR=19.9
1537 # circular references in the topology data seem to thwart garbage collection
1538 # so we'll undo some of the cross references to help with that
1539 3 my $self = shift;
1540 3 ▶ if (exists $self->{elements}) { undef $_->{nodes} for @{$self->{elements}};}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"elements"}) 3 0 3
1541 3 ▶ if (exists $self->{edges}) { undef $_->{nodes} for @{$self->{edges}}; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"edges"}) 3 0 3
1542 3 ▶ if (exists $self->{segments}) { undef $_->{nodes} for @{$self->{segments}};}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"segments"}) 3 0 3
1543 }
1544  
1545 =head1 NAME
1546  
1547 Math::Geometry::Delaunay - Quality Mesh Generator and Delaunay Triangulator
1548  
1549 =head1 VERSION
1550  
1551 Version 0.21
1552  
1553 =cut
1554  
1555 =head1 SYNOPSIS
1556  
1557 =for html <div style="width:30%;float:right;display:inline-block;text-align:center;">
1558 <svg viewBox="0 0 8 6" height="75px" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" version="1.1">
1559 <g transform="scale(1,-1) translate(0,-6)">
1560 <circle r="0.15" cx="1" cy="1" style="fill:blue"/>
1561 <circle r="0.15" cx="7" cy="1" style="fill:blue"/>
1562 <circle r="0.15" cx="7" cy="3" style="fill:blue"/>
1563 <circle r="0.15" cx="3" cy="3" style="fill:blue"/>
1564 <circle r="0.15" cx="3" cy="5" style="fill:blue"/>
1565 <circle r="0.15" cx="1" cy="5" style="fill:blue"/>
1566 </g></svg><br/>
1567 <br/><small>input vertices</small><br/>
1568 <svg viewBox="0 0 8 6" height="75px" preservAspectRatio="minXminY meet" xmlns="http://www.w3.org/2000/svg" version="1.1">
1569 <g transform="scale(1,-1) translate(0,-6)">
1570 <line x1="1" y1="1" x2="3" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1571 <line x1="3" y1="3" x2="1" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1572 <line x1="1" y1="5" x2="1" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1573 <line x1="1" y1="1" x2="7" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1574 <line x1="7" y1="1" x2="3" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1575 <line x1="3" y1="3" x2="3" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1576 <line x1="3" y1="5" x2="1" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1577 <line x1="3" y1="3" x2="7" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1578 <line x1="7" y1="3" x2="3" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1579 <line x1="7" y1="1" x2="7" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1580 <circle cx="1" cy="1" r="0.150" style="fill:blue;"/>
1581 <circle cx="7" cy="1" r="0.150" style="fill:blue;"/>
1582 <circle cx="7" cy="3" r="0.150" style="fill:blue;"/>
1583 <circle cx="3" cy="3" r="0.150" style="fill:blue;"/>
1584 <circle cx="3" cy="5" r="0.150" style="fill:blue;"/>
1585 <circle cx="1" cy="5" r="0.150" style="fill:blue;"/>
1586 </g></svg>
1587 <br/><small>Delaunay triangulation</small><br/>
1588 <svg viewBox="0 0 8 6" height="75px" preservAspectRatio="minXminY meet" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:slic3r="http://slic3r.org/namespaces/slic3r">
1589 <g transform="scale(1,-1) translate(0,-5)">
1590 <line x1="1" y1="3" x2="4" y2="0" style="stroke:gray;stroke-width:0.1;"/>
1591 <line x1="1" y1="3" x2="2" y2="4" style="stroke:gray;stroke-width:0.1;"/>
1592 <line x1="4" y1="0" x2="5" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1593 <line x1="2" y1="4" x2="5" y2="4" style="stroke:gray;stroke-width:0.1;"/>
1594 <line x1="5" y1="4" x2="5" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1595 <line x1="1" y1="3" x2="-139" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1596 <line x1="4" y1="0" x2="4" y2="-210" style="stroke:gray;stroke-width:0.1;"/>
1597 <line x1="2" y1="4" x2="2" y2="74" style="stroke:gray;stroke-width:0.1;"/>
1598 <line x1="5" y1="4" x2="75" y2="144" style="stroke:gray;stroke-width:0.1;"/>
1599 <line x1="5" y1="2" x2="75" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1600 <circle cx="1" cy="3" r="0.15" style="fill:blue;"/>
1601 <circle cx="4" cy="0" r="0.15" style="fill:blue;"/>
1602 <circle cx="2" cy="4" r="0.15" style="fill:blue;"/>
1603 <circle cx="5" cy="4" r="0.15" style="fill:blue;"/>
1604 <circle cx="5" cy="2" r="0.15" style="fill:blue;"/>
1605 </g></svg>
1606 <br/><small>Voronoi diagram</small>
1607 </div>
1608  
1609 use Math::Geometry::Delaunay qw(TRI_CCDT);
1610  
1611 # generate Delaunay triangulation
1612 # and Voronoi diagram for a point set
1613  
1614 my $point_set = [ [1,1], [7,1], [7,3],
1615 [3,3], [3,5], [1,5] ];
1616  
1617 my $tri = new Math::Geometry::Delaunay();
1618 $tri->addPoints($point_set);
1619 $tri->doEdges(1);
1620 $tri->doVoronoi(1);
1621
1622 # called in void context
1623 $tri->triangulate();
1624 # populates the following lists
1625  
1626 $tri->elements(); # triangles
1627 $tri->nodes(); # points
1628 $tri->edges(); # triangle edges
1629 $tri->vnodes(); # Voronoi diagram points
1630 $tri->vedges(); # Voronoi edges and rays
1631  
1632  
1633 =for html <br clear="all"/><div style="margin-top:30px;width:30%;float:right;display:inline-block;text-align:center;">
1634 <svg viewBox="0 0 8 6" height="75px" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" version="1.1">
1635 <g transform="scale(1,-1) translate(0,-6)">
1636 <line x1="7" y1="1" x2="1" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1637 <line x1="7" y1="3" x2="7" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1638 <line x1="3" y1="3" x2="7" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1639 <line x1="3" y1="3" x2="3" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1640 <line x1="1" y1="5" x2="3" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1641 <line x1="1" y1="1" x2="1" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1642 <circle cx="1" cy="1" r="0.15" style="fill:black;"/>
1643 <circle cx="7" cy="1" r="0.15" style="fill:black;"/>
1644 <circle cx="7" cy="3" r="0.15" style="fill:black;"/>
1645 <circle cx="3" cy="3" r="0.15" style="fill:black;"/>
1646 <circle cx="3" cy="5" r="0.15" style="fill:black;"/>
1647 <circle cx="1" cy="5" r="0.15" style="fill:black;"/>
1648 </g></svg>
1649 <br/><small>input PSLG</small><br/>
1650 <svg viewBox="0 0 8 6" height="75px" preserveAspectRatio="xMinYMin meet" style="margin-top:23px;" xmlns="http://www.w3.org/2000/svg" version="1.1">
1651 <g transform="scale(1,-1) translate(0,-6)">
1652 <line x1="1.55" y1="2.5" x2="1" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1653 <line x1="1" y1="3" x2="1" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1654 <line x1="1" y1="2" x2="1.55" y2="2.5" style="stroke:gray;stroke-width:0.1;"/>
1655 <line x1="4.75" y1="1.72322767215881" x2="4" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1656 <line x1="4" y1="1" x2="5.5" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1657 <line x1="5.5" y1="1" x2="4.75" y2="1.72322767215881" style="stroke:gray;stroke-width:0.1;"/>
1658 <line x1="3" y1="5" x2="2" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1659 <line x1="2" y1="5" x2="2.25" y2="4.25" style="stroke:gray;stroke-width:0.1;"/>
1660 <line x1="2.25" y1="4.25" x2="3" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1661 <line x1="3" y1="4" x2="2.25" y2="4.25" style="stroke:gray;stroke-width:0.1;"/>
1662 <line x1="2.25" y1="4.25" x2="2" y2="3.5" style="stroke:gray;stroke-width:0.1;"/>
1663 <line x1="2" y1="3.5" x2="3" y2="4" style="stroke:gray;stroke-width:0.1;"/>
1664 <line x1="2.25" y1="2.75" x2="3" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1665 <line x1="3" y1="3" x2="2" y2="3.5" style="stroke:gray;stroke-width:0.1;"/>
1666 <line x1="2" y1="3.5" x2="2.25" y2="2.75" style="stroke:gray;stroke-width:0.1;"/>
1667 <line x1="2.93181818181818" y1="1.95454545454545" x2="3.71892953370153" y2="1.8730674509337" style="stroke:gray;stroke-width:0.1;"/>
1668 <line x1="3.71892953370153" y1="1.8730674509337" x2="3.5" y2="2.52618854085072" style="stroke:gray;stroke-width:0.1;"/>
1669 <line x1="3.5" y1="2.52618854085072" x2="2.93181818181818" y2="1.95454545454545" style="stroke:gray;stroke-width:0.1;"/>
1670 <line x1="3" y1="3" x2="3" y2="4" style="stroke:gray;stroke-width:0.1;"/>
1671 <line x1="2.25" y1="4.25" x2="1.33333333333333" y2="4.13888888888889" style="stroke:gray;stroke-width:0.1;"/>
1672 <line x1="1.33333333333333" y1="4.13888888888889" x2="2" y2="3.5" style="stroke:gray;stroke-width:0.1;"/>
1673 <line x1="3" y1="4" x2="3" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1674 <line x1="2" y1="5" x2="1.33333333333333" y2="4.13888888888889" style="stroke:gray;stroke-width:0.1;"/>
1675 <line x1="2" y1="5" x2="1" y2="5" style="stroke:gray;stroke-width:0.1;"/>
1676 <line x1="1" y1="5" x2="1.33333333333333" y2="4.13888888888889" style="stroke:gray;stroke-width:0.1;"/>
1677 <line x1="1" y1="5" x2="1" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1678 <line x1="1" y1="3" x2="1.33333333333333" y2="4.13888888888889" style="stroke:gray;stroke-width:0.1;"/>
1679 <line x1="1" y1="3" x2="2" y2="3.5" style="stroke:gray;stroke-width:0.1;"/>
1680 <line x1="2.93181818181818" y1="1.95454545454545" x2="1.8375" y2="1.63125" style="stroke:gray;stroke-width:0.1;"/>
1681 <line x1="1.8375" y1="1.63125" x2="2.5" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1682 <line x1="2.5" y1="1" x2="2.93181818181818" y2="1.95454545454545" style="stroke:gray;stroke-width:0.1;"/>
1683 <line x1="2.25" y1="2.75" x2="1.8375" y2="1.63125" style="stroke:gray;stroke-width:0.1;"/>
1684 <line x1="2.93181818181818" y1="1.95454545454545" x2="2.25" y2="2.75" style="stroke:gray;stroke-width:0.1;"/>
1685 <line x1="2.5" y1="1" x2="3.25" y2="1.23566017316017" style="stroke:gray;stroke-width:0.1;"/>
1686 <line x1="3.25" y1="1.23566017316017" x2="2.93181818181818" y2="1.95454545454545" style="stroke:gray;stroke-width:0.1;"/>
1687 <line x1="1.8375" y1="1.63125" x2="1" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1688 <line x1="1" y1="1" x2="2.5" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1689 <line x1="1.55" y1="2.5" x2="2" y2="3.5" style="stroke:gray;stroke-width:0.1;"/>
1690 <line x1="2.25" y1="2.75" x2="1.55" y2="2.5" style="stroke:gray;stroke-width:0.1;"/>
1691 <line x1="1.55" y1="2.5" x2="1.8375" y2="1.63125" style="stroke:gray;stroke-width:0.1;"/>
1692 <line x1="1.8375" y1="1.63125" x2="1" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1693 <line x1="1" y1="2" x2="1" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1694 <line x1="2.5" y1="1" x2="4" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1695 <line x1="4" y1="1" x2="3.25" y2="1.23566017316017" style="stroke:gray;stroke-width:0.1;"/>
1696 <line x1="2.93181818181818" y1="1.95454545454545" x2="3" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1697 <line x1="3.71892953370153" y1="1.8730674509337" x2="4.75" y2="1.72322767215881" style="stroke:gray;stroke-width:0.1;"/>
1698 <line x1="4.75" y1="1.72322767215881" x2="4.5" y2="2.43504117935408" style="stroke:gray;stroke-width:0.1;"/>
1699 <line x1="4.5" y1="2.43504117935408" x2="3.71892953370153" y2="1.8730674509337" style="stroke:gray;stroke-width:0.1;"/>
1700 <line x1="7" y1="2" x2="6.5096079838992" y2="2.5" style="stroke:gray;stroke-width:0.1;"/>
1701 <line x1="6.5096079838992" y1="2.5" x2="6.36316415068211" y2="1.5" style="stroke:gray;stroke-width:0.1;"/>
1702 <line x1="6.36316415068211" y1="1.5" x2="7" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1703 <line x1="4" y1="3" x2="3" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1704 <line x1="3" y1="3" x2="3.5" y2="2.52618854085072" style="stroke:gray;stroke-width:0.1;"/>
1705 <line x1="3.5" y1="2.52618854085072" x2="4" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1706 <line x1="3.25" y1="1.23566017316017" x2="3.71892953370153" y2="1.8730674509337" style="stroke:gray;stroke-width:0.1;"/>
1707 <line x1="3.71892953370153" y1="1.8730674509337" x2="4" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1708 <line x1="5" y1="3" x2="4.5" y2="2.43504117935408" style="stroke:gray;stroke-width:0.1;"/>
1709 <line x1="4.5" y1="2.43504117935408" x2="5.42596576190246" y2="1.67372070106296" style="stroke:gray;stroke-width:0.1;"/>
1710 <line x1="5.42596576190246" y1="1.67372070106296" x2="5" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1711 <line x1="5.42596576190246" y1="1.67372070106296" x2="4.75" y2="1.72322767215881" style="stroke:gray;stroke-width:0.1;"/>
1712 <line x1="5.5" y1="1" x2="5.42596576190246" y2="1.67372070106296" style="stroke:gray;stroke-width:0.1;"/>
1713 <line x1="4" y1="3" x2="4.5" y2="2.43504117935408" style="stroke:gray;stroke-width:0.1;"/>
1714 <line x1="5" y1="3" x2="4" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1715 <line x1="4.5" y1="2.43504117935408" x2="3.5" y2="2.52618854085072" style="stroke:gray;stroke-width:0.1;"/>
1716 <line x1="5.5" y1="1" x2="6.36316415068211" y2="1.5" style="stroke:gray;stroke-width:0.1;"/>
1717 <line x1="6.36316415068211" y1="1.5" x2="5.42596576190246" y2="1.67372070106296" style="stroke:gray;stroke-width:0.1;"/>
1718 <line x1="5" y1="3" x2="5.89643888151886" y2="2.16160972037971" style="stroke:gray;stroke-width:0.1;"/>
1719 <line x1="5.89643888151886" y1="2.16160972037971" x2="6.5096079838992" y2="2.5" style="stroke:gray;stroke-width:0.1;"/>
1720 <line x1="6.5096079838992" y1="2.5" x2="5" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1721 <line x1="7" y1="1" x2="7" y2="2" style="stroke:gray;stroke-width:0.1;"/>
1722 <line x1="6.36316415068211" y1="1.5" x2="7" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1723 <line x1="5.42596576190246" y1="1.67372070106296" x2="5.89643888151886" y2="2.16160972037971" style="stroke:gray;stroke-width:0.1;"/>
1724 <line x1="6.5096079838992" y1="2.5" x2="7" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1725 <line x1="7" y1="3" x2="5" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1726 <line x1="7" y1="2" x2="7" y2="3" style="stroke:gray;stroke-width:0.1;"/>
1727 <line x1="5.89643888151886" y1="2.16160972037971" x2="6.36316415068211" y2="1.5" style="stroke:gray;stroke-width:0.1;"/>
1728 <line x1="5.5" y1="1" x2="7" y2="1" style="stroke:gray;stroke-width:0.1;"/>
1729 <line x1="7" y1="1" x2="5.5" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1730 <line x1="7" y1="3" x2="7" y2="2" style="stroke:blue;stroke-width:0.1;"/>
1731 <line x1="3" y1="3" x2="4" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1732 <line x1="3" y1="4" x2="3" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1733 <line x1="1" y1="5" x2="2" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1734 <line x1="1" y1="1" x2="1" y2="2" style="stroke:blue;stroke-width:0.1;"/>
1735 <line x1="3" y1="4" x2="3" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1736 <line x1="2" y1="5" x2="3" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1737 <line x1="1" y1="3" x2="1" y2="5" style="stroke:blue;stroke-width:0.1;"/>
1738 <line x1="1" y1="2" x2="1" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1739 <line x1="4" y1="1" x2="2.5" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1740 <line x1="2.5" y1="1" x2="1" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1741 <line x1="5" y1="3" x2="7" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1742 <line x1="4" y1="3" x2="5" y2="3" style="stroke:blue;stroke-width:0.1;"/>
1743 <line x1="5.5" y1="1" x2="4" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1744 <line x1="7" y1="2" x2="7" y2="1" style="stroke:blue;stroke-width:0.1;"/>
1745 <circle cx="1" cy="1" r="0.15" style="fill:black;"/>
1746 <circle cx="7" cy="1" r="0.15" style="fill:black;"/>
1747 <circle cx="7" cy="3" r="0.15" style="fill:black;"/>
1748 <circle cx="3" cy="3" r="0.15" style="fill:black;"/>
1749 <circle cx="3" cy="5" r="0.15" style="fill:black;"/>
1750 <circle cx="1" cy="5" r="0.15" style="fill:black;"/>
1751 <circle cx="1" cy="3" r="0.15" style="fill:black;"/>
1752 <circle cx="3" cy="4" r="0.15" style="fill:black;"/>
1753 <circle cx="2" cy="5" r="0.15" style="fill:black;"/>
1754 <circle cx="2" cy="3.5" r="0.15" style="fill:black;"/>
1755 <circle cx="2.25" cy="4.25" r="0.15" style="fill:black;"/>
1756 <circle cx="1.33" cy="4.138" r="0.15" style="fill:black;"/>
1757 <circle cx="2.9318" cy="1.95" r="0.15" style="fill:black;"/>
1758 <circle cx="4" cy="1" r="0.15" style="fill:black;"/>
1759 <circle cx="2.25" cy="2.75" r="0.15" style="fill:black;"/>
1760 <circle cx="1" cy="2" r="0.15" style="fill:black;"/>
1761 <circle cx="1.55" cy="2.5" r="0.15" style="fill:black;"/>
1762 <circle cx="1.8375" cy="1.63125" r="0.15" style="fill:black;"/>
1763 <circle cx="2.5" cy="1" r="0.15" style="fill:black;"/>
1764 <circle cx="3.25" cy="1.235" r="0.15" style="fill:black;"/>
1765 <circle cx="5.5" cy="1" r="0.15" style="fill:black;"/>
1766 <circle cx="4" cy="3" r="0.15" style="fill:black;"/>
1767 <circle cx="5" cy="3" r="0.15" style="fill:black;"/>
1768 <circle cx="3.7189" cy="1.873" r="0.15" style="fill:black;"/>
1769 <circle cx="4.75" cy="1.723" r="0.15" style="fill:black;"/>
1770 <circle cx="3.5" cy="2.526" r="0.15" style="fill:black;"/>
1771 <circle cx="5.896" cy="2.1616" r="0.15" style="fill:black;"/>
1772 <circle cx="4.5" cy="2.435" r="0.15" style="fill:black;"/>
1773 <circle cx="5.4259" cy="1.6737" r="0.15" style="fill:black;"/>
1774 <circle cx="7" cy="2" r="0.15" style="fill:black;"/>
1775 <circle cx="6.5096" cy="2.5" r="0.15" style="fill:black;"/>
1776 <circle cx="6.36316" cy="1.5" r="0.15" style="fill:black;"/>
1777 </g></svg>
1778 <br/><small>output mesh</small><br/>
1779 <svg viewBox="0 0 8 6" height="75px" preserveAspectRatio="xMinYMin meet" style="margin-top:23px;" xmlns="http://www.w3.org/2000/svg" version="1.1">
1780 <g transform="scale(1,-1) translate(0,-6)">
1781 <g style="fill:black">
1782 <polygon points="1.55,2.5,1,3,1,2"/>
1783 <polygon points="4.75,1.723,4,1,5.5,1"/>
1784 <polygon points="3,5,2,5,2.25,4.25"/>
1785 <polygon points="3,3,3,4,2,3.5"/>
1786 <polygon points="3,5,2.25,4.25,3,4"/>
1787 <polygon points="1.333,4.139,2,5,1,5"/>
1788 <polygon points="1,5,1,3,1.333,4.139"/>
1789 <polygon points="1.837,1.631,1,1,2.5,1"/>
1790 <polygon points="1,1,1.837,1.631,1,2"/>
1791 <polygon points="2.5,1,4,1,3.25,1.236"/>
1792 <polygon points="4,3,3,3,3.5,2.526"/>
1793 <polygon points="4,3,4.5,2.435,5,3"/>
1794 <polygon points="7,1,7,2,6.363,1.5"/>
1795 <polygon points="5,3,6.51,2.5,7,3"/>
1796 <polygon points="7,3,6.51,2.5,7,2"/>
1797 <polygon points="5.5,1,7,1,6.363,1.5"/>
1798 </g>
1799 <g style="fill:gray">
1800 <polygon points="3,4,2.25,4.25,2,3.5"/>
1801 <polygon points="2.25,2.75,3,3,2,3.5"/>
1802 <polygon points="2,5,1.333,4.139,2.25,4.25"/>
1803 <polygon points="1,3,2,3.5,1.333,4.139"/>
1804 <polygon points="2.932,1.955,1.837,1.631,2.5,1"/>
1805 <polygon points="2.5,1,3.25,1.236,2.932,1.955"/>
1806 <polygon points="1.55,2.5,2,3.5,1,3"/>
1807 <polygon points="2.25,2.75,2.932,1.955,3,3"/>
1808 <polygon points="1.55,2.5,1,2,1.837,1.631"/>
1809 <polygon points="7,2,6.51,2.5,6.363,1.5"/>
1810 <polygon points="4,1,4.75,1.723,3.719,1.873"/>
1811 <polygon points="4,1,3.719,1.873,3.25,1.236"/>
1812 <polygon points="5,3,4.5,2.435,5.426,1.674"/>
1813 <polygon points="5.426,1.674,4.75,1.723,5.5,1"/>
1814 <polygon points="2.932,1.955,3.5,2.526,3,3"/>
1815 <polygon points="5.5,1,6.363,1.5,5.426,1.674"/>
1816 <polygon points="5,3,5.896,2.162,6.51,2.5"/>
1817 <polygon points="4.5,2.435,4,3,3.5,2.526"/>
1818 <polygon points="5.426,1.674,5.896,2.162,5,3"/>
1819 </g>
1820 </g></svg>
1821 <br/><small>something interesting<br/>extracted from topology</small>
1822 </div>
1823  
1824 # quality mesh of a planar straight line graph
1825 # with cross-referenced topological output
1826  
1827 my $tri = new Math::Geometry::Delaunay();
1828 $tri->addPolygon($point_set);
1829 $tri->minimum_angle(23);
1830 $tri->doEdges(1);
1831  
1832 # called in scalar context
1833 my $mesh_topology = $tri->triangulate(TRI_CCDT);
1834 # returns cross-referenced topology
1835  
1836 # make two lists of triangles that touch boundary segments
1837  
1838 my @tris_with_boundary_segment;
1839 my @tris_with_boundary_point;
1840  
1841 foreach my $triangle (@{$mesh_topology->{elements}}) {
1842 my $nodes_on_boundary_count = (
1843 grep $_->{marker} == 1,
1844 @{$triangle->{nodes}}
1845 );
1846 if ($nodes_on_boundary_count == 2) {
1847 push @tris_with_boundary_segment, $triangle;
1848 }
1849 elsif ($nodes_on_boundary_count == 1) {
1850 push @tris_with_boundary_point, $triangle;
1851 }
1852 }
1853
1854  
1855 =for html <br clear="all"/>
1856  
1857 =head1 DESCRIPTION
1858  
1859 This is a Perl interface to the Jonathan Shewchuk's Triangle library.
1860  
1861 "Triangle generates exact Delaunay triangulations, constrained Delaunay
1862 triangulations, conforming Delaunay triangulations, Voronoi diagrams, and
1863 high-quality triangular meshes. The latter can be generated with no small or
1864 large angles, and are thus suitable for finite element analysis."
1865 -- from L<http://www.cs.cmu.edu/~quake/triangle.html>
1866  
1867 =head1 EXPORTS
1868  
1869 Triangle has several option switches that can be used in different combinations
1870 to choose a class of triangulation and then configure options within that class.
1871 To clarify the composition of option strings, or just to give you a head start,
1872 a few constants are supplied to configure different classes of mesh output.
1873  
1874 TRI_CONSTRAINED = 'Y' for "Constrained Delaunay"
1875 TRI_CONFORMING = 'Dq0' for "Conforming Delaunay"
1876 TRI_CCDT = 'q' for "Constrained Conforming Delaunay"
1877 TRI_VORONOI = 'v' to generate the Voronoi diagram
1878  
1879 For an illustration of these terms, see:
1880 L<http://www.cs.cmu.edu/~quake/triangle.defs.html>
1881  
1882 =head1 CONSTRUCTOR
1883  
1884 =head2 new
1885  
1886 The constructor returns a Math::Geometry::Delaunay object.
1887  
1888 my $tri = Math::Geometry::Delaunay->new();
1889  
1890 =head1 MESH GENERATION
1891  
1892 =head2 triangulate
1893  
1894 Run the triangulation with specified options, and either populate the object's
1895 output lists, or return a hash reference giving access to a cross-referenced
1896 representation of the mesh topology.
1897  
1898 Common options can be set prior to calling C<triangulate>. The full range of
1899 Triangle's options can also be passed to C<triangulate> as a string, or list
1900 of strings. For example:
1901  
1902 my $tri = Math::Geometry::Delaunay->new('pzq0eQ');
1903  
1904 my $tri = Math::Geometry::Delaunay->new(TRI_CCDT, 'q15', 'a3.5');
1905  
1906 Triangle's command line switches are documented here:
1907 L<http://www.cs.cmu.edu/~quake/triangle.switch.html>
1908  
1909 =head3 list output
1910  
1911 After triangulate is invoked in void context, the output mesh data can be
1912 retrieved from the following methods, all of which return a reference to an
1913 array.
1914  
1915 $tri->triangulate(); # void context - no return value requested
1916 # output lists now available
1917 $points = $tri->nodes(); # array of vertices
1918 $tris = $tri->elements(); # array of triangles
1919 $edges = $tri->edges(); # all the triangle edges
1920 $segs = $tri->segments(); # the PSLG segments
1921 $vpoints = $tri->vnodes(); # points in the voronoi diagram
1922 $vedges = $tri->vedges(); # edges in the voronoi diagram
1923  
1924 Data may not be available for all lists, depending on which option switches were
1925 used. By default, nodes and elements are generated, while edges are not.
1926  
1927 The members of the lists returned have these formats:
1928  
1929 nodes: [x, y, < zero or more attributes >, < boundary marker >]
1930  
1931 elements: [[x0, y0], [x1, y1], [x2, y2],
1932 < another three vertices, if "o2" switch used >,
1933 < zero or more attributes >
1934 ]
1935 edges: [[x0, y0], [x1, y1], < boundary marker >]
1936  
1937 segments: [[x0, y0], [x1, y1], < boundary marker >]
1938  
1939 vnodes: [x, y, < zero or more attributes >]
1940  
1941 vedges: [< vertex or vector >, < vertex or vector >, < ray flag >]
1942  
1943 Boundary markers are 1 or 0. An edge or segment with only one end on a boundary
1944 has boundary marker 0.
1945  
1946 The ray flag is 0 if the edge is not a ray, or 1 or 2, to indicate
1947 which vertex is actually a unit vector indicating the direction of the ray.
1948  
1949 Import of the mesh data from the C data structures will be deferred until
1950 actually requested from the list fetching methods above. For speed and
1951 lower memory footprint, access only what you need, and consider suppressing
1952 output you don't need with option switches.
1953  
1954 =head3 topological output
1955  
1956 When triangulate is invoked in scalar or array context, it returns a hash ref
1957 containing the cross-referenced nodes, elements, edges, and PSLG segments of the
1958 triangulation. In array context, with the "v" switch enabled, the Voronoi
1959 topology is the second item returned.
1960  
1961 my $topology = $tri->triangulate();
1962  
1963 $topology now looks like this:
1964
1965 {
1966 nodes => [
1967 { # a node
1968 point => [x0, x1],
1969 edges => [edgeref, ...],
1970 segments => [edgeref, ...], # a subset of edges
1971 elements => [elementref, ...],
1972 marker => 1 or 0 or undefined, # boundary marker
1973 attributes => [attr0, ...]
1974 },
1975 ... more nodes like that
1976
1977 ],
1978 elements => [
1979 { # a triangle
1980 nodes => [noderef0, noderef1, noderef2],
1981 edges => [edgeref0, edgeref1, edgeref2],
1982 neighbors => [neighref0, neighref1, neighref2],
1983 attributes => [attrib0, ...]
1984 },
1985 ... more triangles like that
1986 ],
1987 edges => [
1988 {
1989 nodes => [noderef0, noderef1], # only one for a ray
1990 elements => [elemref0, elemref1], # one if on boundary
1991 vector => undefined or [x, y], # ray direction
1992 marker => 1 or 0 or undefined, # boundary marker
1993 index => <integer> # edge's index in edge list
1994 },
1995 ... more edges like that
1996
1997 ],
1998 segments => [
1999 {
2000 nodes => [noderef0, noderef1],
2001 elements => [elemref0, elemref1], # one if on boundary
2002 marker => 1 or 0 or undefined # boundary marker
2003 },
2004 ... more segments
2005 ]
2006 }
2007  
2008 =head3 cross-referencing Delaunay and Voronoi
2009  
2010 Corresponding Delaunay triangles and Voronoi nodes have the same index number
2011 in their respective lists.
2012  
2013 In the topological output, any element in a triangulation has a record of its
2014 own index number that can by used to look up the corresponding node in the
2015 Voronoi diagram topology, or vice versa, like so:
2016  
2017 ($topo, $voronoi_topo) = $tri->triangulate('v');
2018  
2019 # get a triangle reference where the index is not obvious
2020
2021 $element = $topo->{nodes}->[-1]->{elements}->[-1];
2022
2023 # this gets a reference to the corresponding node in the Voronoi diagram
2024
2025 $voronoi_node = $voronoi_topo->{nodes}->[$element->{index}];
2026  
2027  
2028 Corresponding edges in the Delaunay and Voronoi outputs have the same index
2029 number in their respective edge lists.
2030  
2031 In the topological output, any edge in a triangulation has a record of its own
2032 index number that can by used to look up the corresponding edge in the Voronoi
2033 diagram topology, or vice versa, like so:
2034  
2035 ($topo, $voronoi_topo) = $tri->triangulate('ev');
2036
2037 # get an edge reference where it's not obvious what the edge's index is
2038
2039 $delaunay_edge = $topo->{nodes}->[-1]->{edges}->[-1];
2040
2041 # this gets a reference to the corresponding edge in the Voronoi diagram
2042
2043 $voronoi_edge = $voronoi_topo->{edges}->[$delaunay_edge->{index}];
2044  
2045 =head1 METHODS TO SET SOME Triangle OPTIONS
2046  
2047 =head2 area_constraint
2048  
2049 Corresponds to the "a" switch.
2050  
2051 With one argument, sets the maximum triangle area constraint for the
2052 triangulation. Returns the value supplied. With no argument, returns the
2053 current area constraint.
2054  
2055 Passing -1 to C<area_constraint()> will disable the global area constraint.
2056  
2057 =head2 minimum_angle
2058  
2059 Corresponds to the "q" switch.
2060  
2061 With one argument, sets the minimum angle allowed for triangles added in the
2062 triangulation. Returns the value supplied. With no argument, returns the
2063 current minimum angle constraint.
2064  
2065 Passing -1 to C<minimum_angle()> will cause the "q" switch to be omitted from
2066 the option string.
2067  
2068 =head2 doEdges, doVoronoi, doNeighbors
2069  
2070 These methods simply add or remove the corresponding letters from the
2071 option string. Pass in a true or false value to enable or disable.
2072 Invoke with no argument to read the current state.
2073  
2074 =head2 quiet, verbose
2075  
2076 Triangle prints a basic summary of the meshing operation to STDOUT unless
2077 the "Q" switch is present. This module includes the "Q" switch by default, but
2078 you can override this by passing a false value to C<quiet()>.
2079  
2080 If you would like to see even more output regarding the triangulation process,
2081 there are are three levels of verbosity configurable with repeated "V"
2082 switches. Passing a number from 1 to 3 to the C<verbose()> method will enable
2083 the corresponding level of verbosity.
2084  
2085 =head1 METHODS TO ADD VERTICES AND SEGMENTS
2086  
2087 =head2 addVertices, addPoints
2088  
2089 Takes a reference to an array of vertices, each vertex itself an reference to
2090 an array containing two coordinates and zero or more attributes. Attributes
2091 are floating point numbers.
2092
2093 # vertex format
2094 # [x, y, < zero or more attributes as floating point numbers >]
2095  
2096 $tri->addPoints([[$x0, $y0], [$x1, $y1], ... ]);
2097  
2098 Use addVertices to add vertices that are not part of a PSLG.
2099 Use addPoints to add points that are not part of a polygon or polyline.
2100 In other words, they do the same thing.
2101  
2102 =head2 addSegments
2103  
2104 Takes a reference to an array of segments.
2105  
2106 # segment format
2107 # [[$x0, $y0], [$x1, $y1]]
2108  
2109 $tri->addSegments([ $segment0, $segment1, ... ]);
2110  
2111 If your segments are contiguous, it's better to use addPolyline, or addPolygon.
2112  
2113 This method is provided because some point and polygon processing algorithms
2114 result in segments that represent polygons, but list the segments in a
2115 non-contiguous order, and have shared vertices repeated in each segment's record.
2116  
2117 The segments added with this method will be checked for duplicate vertices, and
2118 references to these will be merged.
2119  
2120 Triangle can handle duplicate vertices, but we would rather not feed them in on
2121 purpose.
2122  
2123 =head2 addPolyline
2124  
2125 Takes a reference to an array of vertices describing a curve.
2126 Creates PSLG segments for each pair of adjacent vertices. Adds the
2127 new segments and vertices to the triangulation input.
2128  
2129 $tri->addPolyline([$vertex0, $vertex1, $vertex2, ...]);
2130  
2131 =head2 addPolygon
2132  
2133 Takes a reference to an array of vertices describing a polygon.
2134 Creates PSLG segments for each pair of adjacent vertices
2135 and creates and additional segment linking the last vertex to
2136 the first,to close the polygon. Adds the new segments and vertices
2137 to the triangulation input.
2138  
2139 $tri->addPolygon([$vertex0, $vertex1, $vertex2, ...]);
2140  
2141 =head2 addHole
2142  
2143 Like addPolygon, but describing a hole or concavity - an area of the output mesh
2144 that should not be triangulated.
2145  
2146 There are two ways to specify a hole. Either provide a list of vertices, like
2147 for addPolygon, or provide a single vertex that lies inside of a polygon, to
2148 identify that polygon as a hole.
2149  
2150 # first way
2151 $tri->addHole([$vertex0, $vertex1, $vertex2, ...]);
2152  
2153 # second way
2154 $tri->addPolygon( [ [0,0], [1,0], [1,1], [0,1] ] );
2155 $tri->addHole( [0.5,0.5] );
2156  
2157 Hole marker points can also be used, in combination with the "c" option, to
2158 cause or preserve concavities in a boundary when Triangle would otherwise
2159 enclose a PSLG in a convex hull.
2160  
2161 =head2 addRegion
2162  
2163 Takes a polygon describing a region, and an attribute or area constraint. With
2164 both the "A" and "a" switches in effect, three arguments allow you to specify
2165 both an attribute and an optional area constraint.
2166  
2167 The first argument may alternately be a single vertex that lies inside of
2168 another polygon, to identify that polygon as a region.
2169  
2170 To be used in conjunction with the "A" and "a" switches.
2171  
2172 # with the "A" switch
2173 $tri->addRegion(\@polygon, < attribute > );
2174
2175 # with the "a" switch
2176 $tri->addRegion(\@polygon, < area constraint > );
2177  
2178 # with both "Aa"
2179 $tri->addRegion(\@polygon, < attribute >, < area constraint > );
2180  
2181 If the "A" switch is used, each triangle generated within the bounds of a region
2182 will have that region's attribute added to the end of the triangle's
2183 attributes list, while each triangle not within a region will have a "0" added
2184 to the end of its attribute list.
2185  
2186 If the "a" switch is used without a number following, each triangle generated
2187 within the bounds of a region will be subject to that region's area
2188 constraint.
2189  
2190 If the "A" or "a" switches are not in effect, addRegion has the same effect as
2191 addPolygon.
2192  
2193 =head1 METHODS TO ACCESS OUTPUT LISTS
2194  
2195 The following methods retrieve the output lists after the triangulate method has
2196 been invoked in void context.
2197  
2198 Triangle's output data is not imported from C to Perl until one of these methods
2199 is invoked, and then only what's needed to construct the list requested. So
2200 there may be a speed or memory advantage to accessing the output in this way -
2201 only what you need, when you need it.
2202  
2203 The methods prefixed with "v" access the Voronoi diagram nodes and edges, if one
2204 was generated.
2205  
2206 =head2 nodes
2207  
2208 Returns a reference to a list of nodes (vertices or points).
2209  
2210 my $pointlist = $tri->nodes(); # retrieve nodes/vertices/points
2211
2212 The nodes in the list have this structure:
2213  
2214 [x, y, < zero or more attributes >, < boundary marker >]
2215  
2216 =head2 elements
2217  
2218 Returns a reference to a list of elements.
2219  
2220 $triangles = $tri->elements(); # retrieve triangle list
2221  
2222 The elements in the list have this structure:
2223  
2224 [[x0, y0], [x1, y1], [x2, y2],
2225 < another three vertices, if "o2" switch used >
2226 < zero or more attributes >
2227 ]
2228  
2229 =head2 segments
2230  
2231 Returns a reference to a list of segments.
2232  
2233 $segs = $tri->segments(); # retrieve the PSLG segments
2234  
2235 The segments in the list have this structure:
2236  
2237 [[x0, y0], [x1, y1], < boundary marker >]
2238  
2239 =head2 edges
2240  
2241 Returns a reference to a list of edges.
2242  
2243 $edges = $tri->edges(); # retrieve all the triangle edges
2244  
2245 The edges in the list have this structure:
2246  
2247 [[x0, y0], [x1, y1], < boundary marker >]
2248  
2249 Note that the edge list is not produced by default. Request that it be generated
2250 by invoking C<doEdges(1)>, or passing the 'e' switch to C<triangulate()>.
2251  
2252 =head2 vnodes
2253  
2254 Returns a reference to a list of nodes in the Voronoi diagram.
2255  
2256 $vpointlist = $tri->vnodes(); # retrieve Voronoi vertices
2257  
2258 The Voronoi diagram nodes in the list have this structure:
2259  
2260 [x, y, < zero or more attributes >]
2261  
2262 =head2 vedges
2263  
2264 Returns a reference to a list of edges in the Voronoi diagram. Some of these
2265 edges are actually rays.
2266  
2267 $vedges = $tri->vedges(); # retrieve Voronoi diagram edges and rays
2268  
2269 The Voronoi diagram edges in the list have this structure:
2270  
2271 [< vertex or vector >, < vertex or vector >, < ray flag >]
2272  
2273 If the edge is a true edge, the ray flag will be 0.
2274 If the edge is actually a ray, the ray flag will either be 1 or 2,
2275 to indicate whether the the first, or second vertex should be interpreted as
2276 a direction vector for the ray.
2277  
2278 =head1 UTILITY FUNCTIONS
2279  
2280 =head2 to_svg
2281  
2282 This function is meant as a development and debugging aid, to "dump" the
2283 geometric data structures specific to this package to a graphical
2284 representation. Takes key-value pairs to specify topology hashes, output file,
2285 image dimensions, and styles for the elements in the various output lists.
2286  
2287 The topology hash input for the C<topo> or C<vtopo> keys is just the hash
2288 returned by C<triangulate>. The value for the C<file> key is a file name string.
2289 Omit C<file> to print to STDOUT. For C<size>, provide and array ref with width
2290 and height, in pixels. For output list styles, keys correspond to the output
2291 list names, and values consist of references to arrays containing style
2292 configurations, as demonstrated below.
2293  
2294 Only geometry that has a style configuration will be displayed. The following
2295 example includes everything. To display a subset, just omit any of the style
2296 configuration key-value pairs.
2297  
2298 ($topo, $vtopo) = $tri->triangulate('ve');
2299  
2300 to_svg( topo => $topo,
2301 vtopo => $vtopo,
2302
2303 file => "enchilada.svg", # omit for STDOUT
2304 size => [800, 600], # width, height in pixels
2305
2306 # line width or optional
2307 # svg color point radius extra CSS
2308
2309 nodes => ['black' , 0.3],
2310 edges => ['#CCCCCC', 0.7],
2311 segments => ['blue' , 0.9, 'stroke-dasharray:1 1;'],
2312 elements => ['pink'] , # string or callback; see below
2313  
2314 # these require Voronoi input (vtopo)
2315  
2316 vnodes => ['purple' , 0.3],
2317 vedges => ['#FF0000', 0.7],
2318 vrays => ['purple' , 0.6],
2319 circles => ['orange' , 0.6],
2320
2321 );
2322  
2323 Note that for display purposes C<vedges> does not include the infinite rays in
2324 the Voronoi diagram. To see the complete Voronoi diagram, including segments
2325 representing the infinite rays, you should include style configuration for the
2326 C<vrays> key, as in the example above.
2327  
2328 Elements (triangles) only need one style config entry, for color. (An optional
2329 second entry would be a string for additional CSS.) In this case,
2330 the first entry can also be a reference to a callback function. A reference to
2331 the triangle being processed for display will be passed to the callback
2332 function. Therefore the callback function can determine a color based on any
2333 features or relationships of that triangle.
2334  
2335 Typically you might color each triangle according to the region it's in, by
2336 using Triangle's 'A' switch, and then reading the region attribute from the
2337 last item in the triangle's attribute list.
2338  
2339 my $region_colors_callback = sub {
2340 my $tri_ref = shift;
2341 return ('gray','blue','green')[$tri_ref->{attributes}->[-1]];
2342 };
2343  
2344 But any other data accessible through the triangle reference can be used to
2345 calculate a color. For instance, the triangle's three nodes can carry any
2346 number of attributes, which are interpolated during mesh generation. You
2347 might shade each triangle according to the average of a node attribute.
2348  
2349 my $tri_nodes_average_callback = sub {
2350 my $tri_ref = shift;
2351 my $sum = 0;
2352 # calculate average of the eighth attribute in all nodes
2353 foreach my $node (@{$tri_ref->{nodes}}) {
2354 $sum += $node->{attributes}->[7];
2355 }
2356 return &attrib_val_to_grayscale_hexcode( $sum / 3 );
2357 };
2358  
2359 =head2 mic_adjust
2360  
2361 =for html <div style="width:30%;float:right;display:inline-block;text-align:center;">
2362 <svg viewBox="-23 -11 204 165" width="57%" preserveAspectRatio="xMinYMin meet" style="margin-top:15px;" xmlns="http://www.w3.org/2000/svg" version="1.1">
2363 <style type="text/css"> .edge {stroke:gray;stroke-width:2;} .seg {stroke:black;stroke-width:1;} .vedge {stroke:blue;stroke-width:2;} .vcirc {stroke-width:0.8;stroke:blue;fill:none;opacity:0.7;} </style>
2364 <g transform="scale(1,-1) translate(0,-117.66968108291)">
2365 <line x1="0" y1="0" x2="58.835" y2="58.835" class="edge"/>
2366 <line x1="58.835" y1="58.835" x2="0" y2="58.835" class="edge"/>
2367 <line x1="0" y1="58.835" x2="0" y2="0" class="edge"/>
2368 <line x1="0" y1="0" x2="88.252" y2="0" class="edge"/>
2369 <line x1="88.252" y1="0" x2="58.835" y2="58.835" class="edge"/>
2370 <line x1="58.835" y1="58.835" x2="58.835" y2="88.252" class="edge"/>
2371 <line x1="58.835" y1="88.252" x2="0" y2="58.835" class="edge"/>
2372 <line x1="0" y1="58.835" x2="29.417" y2="117.67" class="edge"/>
2373 <line x1="29.417" y1="117.67" x2="0" y2="117.67" class="edge"/>
2374 <line x1="0" y1="117.67" x2="0" y2="58.835" class="edge"/>
2375 <line x1="58.835" y1="88.252" x2="29.417" y2="117.67" class="edge"/>
2376 <line x1="58.835" y1="88.252" x2="58.835" y2="117.67" class="edge"/>
2377 <line x1="58.835" y1="117.67" x2="29.417" y2="117.67" class="edge"/>
2378 <line x1="88.252" y1="0" x2="176.505" y2="0" class="edge"/>
2379 <line x1="176.505" y1="0" x2="176.505" y2="29.417" class="edge"/>
2380 <line x1="176.505" y1="29.417" x2="88.252" y2="0" class="edge"/>
2381 <line x1="176.505" y1="29.417" x2="117.67" y2="58.835" class="edge"/>
2382 <line x1="117.67" y1="58.835" x2="88.252" y2="0" class="edge"/>
2383 <line x1="176.505" y1="58.835" x2="117.67" y2="58.835" class="edge"/>
2384 <line x1="176.505" y1="29.417" x2="176.505" y2="58.835" class="edge"/>
2385 <line x1="117.67" y1="58.835" x2="58.835" y2="58.835" class="edge"/>
2386 <line x1="0" y1="0" x2="0" y2="58.835" class="seg"/>
2387 <line x1="88.252" y1="0" x2="0" y2="0" class="seg"/>
2388 <line x1="176.505" y1="0" x2="88.252" y2="0" class="seg"/>
2389 <line x1="176.505" y1="29.417" x2="176.505" y2="0" class="seg"/>
2390 <line x1="176.505" y1="58.835" x2="176.505" y2="29.417" class="seg"/>
2391 <line x1="117.67" y1="58.835" x2="176.505" y2="58.835" class="seg"/>
2392 <line x1="58.835" y1="58.835" x2="117.67" y2="58.835" class="seg"/>
2393 <line x1="58.835" y1="58.835" x2="58.835" y2="88.252" class="seg"/>
2394 <line x1="58.835" y1="88.252" x2="58.835" y2="117.67" class="seg"/>
2395 <line x1="29.417" y1="117.67" x2="58.835" y2="117.67" class="seg"/>
2396 <line x1="0" y1="117.67" x2="29.417" y2="117.67" class="seg"/>
2397 <line x1="0" y1="58.835" x2="0" y2="117.67" class="seg"/>
2398 <line x1="29.417" y1="29.417" x2="44.126" y2="14.709" class="vedge"/>
2399 <line x1="29.417" y1="29.417" x2="29.417" y2="73.544" class="vedge"/>
2400 <line x1="44.126" y1="14.709" x2="88.252" y2="36.772" class="vedge"/>
2401 <line x1="29.417" y1="73.544" x2="24.515" y2="83.349" class="vedge"/>
2402 <line x1="14.709" y1="88.252" x2="24.515" y2="83.349" class="vedge"/>
2403 <line x1="24.515" y1="83.349" x2="44.126" y2="102.961" class="vedge"/>
2404 <line x1="132.378" y1="14.709" x2="132.378" y2="14.709" class="vedge"/>
2405 <line x1="132.378" y1="14.709" x2="147.087" y2="44.126" class="vedge"/>
2406 <line x1="132.378" y1="14.709" x2="88.252" y2="36.772" class="vedge"/>
2407 <circle cx="0" cy="58.835" r="3" style="fill:black;"/>
2408 <circle cx="0" cy="0" r="3" style="fill:black;"/>
2409 <circle cx="88.252" cy="0" r="3" style="fill:black;"/>
2410 <circle cx="176.505" cy="0" r="3" style="fill:black;"/>
2411 <circle cx="176.505" cy="29.417" r="3" style="fill:black;"/>
2412 <circle cx="176.505" cy="58.835" r="3" style="fill:black;"/>
2413 <circle cx="117.67" cy="58.835" r="3" style="fill:black;"/>
2414 <circle cx="58.835" cy="58.835" r="3" style="fill:black;"/>
2415 <circle cx="58.835" cy="88.252" r="3" style="fill:black;"/>
2416 <circle cx="58.835" cy="117.67" r="3" style="fill:black;"/>
2417 <circle cx="29.417" cy="117.67" r="3" style="fill:black;"/>
2418 <circle cx="0" cy="117.67" r="3" style="fill:black;"/>
2419 <circle cx="29.417" cy="29.417" r="3" style="fill:blue;"/>
2420 <circle cx="44.126" cy="14.709" r="3" style="fill:blue;"/>
2421 <circle cx="29.417" cy="73.544" r="3" style="fill:blue;"/>
2422 <circle cx="14.709" cy="88.252" r="3" style="fill:blue;"/>
2423 <circle cx="24.515" cy="83.349" r="3" style="fill:blue;"/>
2424 <circle cx="44.126" cy="102.961" r="3" style="fill:blue;"/>
2425 <circle cx="132.378" cy="14.709" r="3" style="fill:blue;"/>
2426 <circle cx="132.378" cy="14.709" r="3" style="fill:blue;"/>
2427 <circle cx="147.087" cy="44.126" r="3" style="fill:blue;"/>
2428 <circle cx="88.252" cy="36.772" r="3" style="fill:blue;"/>
2429 <circle cx="29.417" cy="29.417" r="41.601" class="vcirc"/>
2430 <circle cx="44.126" cy="14.709" r="46.512" class="vcirc"/>
2431 <circle cx="29.417" cy="73.544" r="32.890" class="vcirc"/>
2432 <circle cx="14.709" cy="88.252" r="32.889" class="vcirc"/>
2433 <circle cx="24.515" cy="83.349" r="34.668" class="vcirc"/>
2434 <circle cx="44.126" cy="102.961" r="20.801" class="vcirc"/>
2435 <circle cx="132.378" cy="14.709" r="46.512" class="vcirc"/>
2436 <circle cx="132.378" cy="14.709" r="46.513" class="vcirc"/>
2437 <circle cx="147.087" cy="44.126" r="32.890" class="vcirc"/>
2438 <circle cx="88.252" cy="36.772" r="36.772" class="vcirc"/>
2439 </g></svg>
2440 <br/><small>Voronoi edges (blue)<br/> as a poor medial<br/>axis approximation</small><br/>
2441 <svg viewBox="-5 -5 186 127" width="50%" preserveAspectRatio="xMinYMin meet" style="margin-top:23px;" xmlns="http://www.w3.org/2000/svg" version="1.1">
2442 <style type="text/css"> .edge {stroke:gray;stroke-width:2;} .seg {stroke:black;stroke-width:1;} .vedge {stroke:blue;stroke-width:2;} .vcirc {stroke-width:0.8;stroke:blue;fill:none;opacity:0.7;} </style>
2443 <g transform="scale(1,-1) translate(0,-117.66968108291)">
2444 <line x1="0" y1="0" x2="58.835" y2="58.835" class="edge"/>
2445 <line x1="58.835" y1="58.835" x2="0" y2="58.835" class="edge"/>
2446 <line x1="0" y1="58.835" x2="0" y2="0" class="edge"/>
2447 <line x1="0" y1="0" x2="88.252" y2="0" class="edge"/>
2448 <line x1="88.252" y1="0" x2="58.835" y2="58.835" class="edge"/>
2449 <line x1="58.835" y1="58.835" x2="58.835" y2="88.252" class="edge"/>
2450 <line x1="58.835" y1="88.252" x2="0" y2="58.835" class="edge"/>
2451 <line x1="0" y1="58.835" x2="29.417" y2="117.67" class="edge"/>
2452 <line x1="29.417" y1="117.67" x2="0" y2="117.67" class="edge"/>
2453 <line x1="0" y1="117.67" x2="0" y2="58.835" class="edge"/>
2454 <line x1="58.835" y1="88.252" x2="29.417" y2="117.67" class="edge"/>
2455 <line x1="58.835" y1="88.252" x2="58.835" y2="117.67" class="edge"/>
2456 <line x1="58.835" y1="117.67" x2="29.417" y2="117.67" class="edge"/>
2457 <line x1="88.252" y1="0" x2="176.505" y2="0" class="edge"/>
2458 <line x1="176.505" y1="0" x2="176.505" y2="29.417" class="edge"/>
2459 <line x1="176.505" y1="29.417" x2="88.252" y2="0" class="edge"/>
2460 <line x1="176.505" y1="29.417" x2="117.67" y2="58.835" class="edge"/>
2461 <line x1="117.67" y1="58.835" x2="88.252" y2="0" class="edge"/>
2462 <line x1="176.505" y1="58.835" x2="117.67" y2="58.835" class="edge"/>
2463 <line x1="176.505" y1="29.417" x2="176.505" y2="58.835" class="edge"/>
2464 <line x1="117.67" y1="58.835" x2="58.835" y2="58.835" class="edge"/>
2465 <line x1="0" y1="0" x2="0" y2="58.835" class="seg"/>
2466 <line x1="88.252" y1="0" x2="0" y2="0" class="seg"/>
2467 <line x1="176.505" y1="0" x2="88.252" y2="0" class="seg"/>
2468 <line x1="176.505" y1="29.417" x2="176.505" y2="0" class="seg"/>
2469 <line x1="176.505" y1="58.835" x2="176.505" y2="29.417" class="seg"/>
2470 <line x1="117.67" y1="58.835" x2="176.505" y2="58.835" class="seg"/>
2471 <line x1="58.835" y1="58.835" x2="117.67" y2="58.835" class="seg"/>
2472 <line x1="58.835" y1="58.835" x2="58.835" y2="88.252" class="seg"/>
2473 <line x1="58.835" y1="88.252" x2="58.835" y2="117.67" class="seg"/>
2474 <line x1="29.417" y1="117.67" x2="58.835" y2="117.67" class="seg"/>
2475 <line x1="0" y1="117.67" x2="29.417" y2="117.67" class="seg"/>
2476 <line x1="0" y1="58.835" x2="0" y2="117.67" class="seg"/>
2477 <line x1="34.465" y1="34.465" x2="49.287" y2="30.192" class="vedge"/>
2478 <line x1="34.465" y1="34.465" x2="29.417" y2="73.544" class="vedge"/>
2479 <line x1="49.287" y1="30.192" x2="88.252" y2="29.417" class="vedge"/>
2480 <line x1="29.417" y1="73.544" x2="29.417" y2="83.349" class="vedge"/>
2481 <line x1="14.709" y1="102.961" x2="29.417" y2="83.349" class="vedge"/>
2482 <line x1="29.417" y1="83.349" x2="44.126" y2="102.961" class="vedge"/>
2483 <line x1="161.796" y1="14.709" x2="132.378" y2="29.417" class="vedge"/>
2484 <line x1="132.378" y1="29.417" x2="161.796" y2="44.126" class="vedge"/>
2485 <line x1="132.378" y1="29.417" x2="88.252" y2="29.417" class="vedge"/>
2486 <circle cx="0" cy="58.835" r="3" style="fill:black;"/>
2487 <circle cx="0" cy="0" r="3" style="fill:black;"/>
2488 <circle cx="88.252" cy="0" r="3" style="fill:black;"/>
2489 <circle cx="176.505" cy="0" r="3" style="fill:black;"/>
2490 <circle cx="176.505" cy="29.417" r="3" style="fill:black;"/>
2491 <circle cx="176.505" cy="58.835" r="3" style="fill:black;"/>
2492 <circle cx="117.67" cy="58.835" r="3" style="fill:black;"/>
2493 <circle cx="58.835" cy="58.835" r="3" style="fill:black;"/>
2494 <circle cx="58.835" cy="88.252" r="3" style="fill:black;"/>
2495 <circle cx="58.835" cy="117.67" r="3" style="fill:black;"/>
2496 <circle cx="29.417" cy="117.67" r="3" style="fill:black;"/>
2497 <circle cx="0" cy="117.67" r="3" style="fill:black;"/>
2498 <circle cx="34.465" cy="34.465" r="3" style="fill:blue;"/>
2499 <circle cx="49.287" cy="30.192" r="3" style="fill:blue;"/>
2500 <circle cx="29.417" cy="73.544" r="3" style="fill:blue;"/>
2501 <circle cx="14.709" cy="102.961" r="3" style="fill:blue;"/>
2502 <circle cx="29.417" cy="83.349" r="3" style="fill:blue;"/>
2503 <circle cx="44.126" cy="102.961" r="3" style="fill:blue;"/>
2504 <circle cx="161.796" cy="14.709" r="3" style="fill:blue;"/>
2505 <circle cx="132.378" cy="29.417" r="3" style="fill:blue;"/>
2506 <circle cx="161.796" cy="44.126" r="3" style="fill:blue;"/>
2507 <circle cx="88.252" cy="29.417" r="3" style="fill:blue;"/>
2508 <circle cx="34.465" cy="34.465" r="34.464" class="vcirc"/>
2509 <circle cx="49.287" cy="30.192" r="30.192" class="vcirc"/>
2510 <circle cx="29.417" cy="73.544" r="29.417" class="vcirc"/>
2511 <circle cx="14.709" cy="102.961" r="14.708" class="vcirc"/>
2512 <circle cx="29.417" cy="83.349" r="29.417" class="vcirc"/>
2513 <circle cx="44.126" cy="102.961" r="14.708" class="vcirc"/>
2514 <circle cx="161.796" cy="14.709" r="14.708" class="vcirc"/>
2515 <circle cx="132.378" cy="29.417" r="29.417" class="vcirc"/>
2516 <circle cx="161.796" cy="44.126" r="14.708" class="vcirc"/>
2517 <circle cx="88.252" cy="29.417" r="29.417" class="vcirc"/>
2518 </g></svg>
2519 <br/><small>improved approximation<br/>after calling mic_adust()</small><br/>
2520 </div>
2521  
2522 Warning: not yet thoroughly tested; may move elsewhere
2523  
2524 One use of the Voronoi diagram of a tessellated polygon is to derive an
2525 approximation of the polygon's medial axis by pruning infinite rays and perhaps
2526 trimming or refining remaining branches. The approximation improves as
2527 intervals between sample points on the polygon become shorter. But it's not
2528 always desirable to multiply the number of polygon points to achieve short
2529 intervals.
2530  
2531 At any point on the true medial axis, there is a maximum inscribed circle,
2532 with it's center on the medial axis, and tangent to the polygon in at least
2533 two places.
2534  
2535 The C<mic_adjust()> function moves each Voronoi node so that it becomes the
2536 center of a circle that is tangent to the polygon at two points. In simple
2537 cases this is a maximum inscribed circle, and the point is on the medial axis.
2538 And when it's not, it still should be a much better approximation than the
2539 original point location. The radius to the tangent on the polygon is stored
2540 with the updated Voronoi node.
2541  
2542 After calling C<mic_adjust()>, the modified Voronoi topology can be used as a
2543 list of maximum inscribed circles, from which can be derive a straighter,
2544 better medial axis approximation, without having to increase the number of
2545 sample points on the polygon.
2546  
2547 ($topo, $voronoi_topo) = $tri->triangulate('e');
2548  
2549 mic_adjust($topo, $voronoi_topo); # modifies $voronoi_topo in place
2550
2551 foreach my $node (@{$voronoi_topo->{nodes}}) {
2552 $mic_center = $node->{point};
2553 $mic_radius = $node->{radius};
2554 ...
2555 }
2556  
2557 Constructing a true medial axis is much more involved - a subject for a
2558 different module. Until that module appears, running topology through
2559 C<mic_adjust()> and then walking and pruning the Voronoi topology might help
2560 fill the gap.
2561  
2562 =head1 API STATUS
2563  
2564 Currently Triangle's option strings are exposed to give more complete access to
2565 its features. More of these options, and perhaps certain common combinations of
2566 them, will likely be wrapped in method-call getter-setters. I would prefer to
2567 preserve the ability to use the option strings directly, but it may be better
2568 at some point to hide them completely behind a more descriptive interface.
2569  
2570  
2571 =head1 AUTHOR
2572  
2573 Michael E. Sheldrake, C<< <sheldrake at cpan.org> >>
2574  
2575 Triangle's author is Jonathan Richard Shewchuk
2576  
2577  
2578 =head1 BUGS
2579  
2580 Please report any bugs or feature requests to
2581  
2582 C<bug-math-geometry-delaunay at rt.cpan.org>
2583  
2584 or through the web interface at
2585  
2586 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-Geometry-Delaunay>
2587  
2588 I will be notified, and then you'll automatically be notified of progress on
2589 your bug as I make changes.
2590  
2591  
2592 =head1 SUPPORT
2593  
2594 You can find documentation for this module with the perldoc command.
2595  
2596 perldoc Math::Geometry::Delaunay
2597  
2598  
2599 You can also look for information at:
2600  
2601 =over 4
2602  
2603 =item * RT: CPAN's request tracker
2604  
2605 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Geometry-Delaunay>
2606  
2607 =item * Search CPAN
2608  
2609 L<http://search.cpan.org/dist/Math-Geometry-Delaunay/>
2610  
2611 =back
2612  
2613  
2614 =head1 ACKNOWLEDGEMENTS
2615  
2616 Thanks go to Far Leaves Tea in Berkeley for providing oolongs and refuge,
2617 and a place for paths to intersect.
2618  
2619  
2620 =head1 LICENSE AND COPYRIGHT
2621  
2622 Copyright 2013 Micheal E. Sheldrake.
2623  
2624 This Perl binding to Triangle is free software;
2625 you can redistribute it and/or modify it under the terms of either:
2626 the GNU General Public License as published by the Free Software Foundation;
2627 or the Artistic License.
2628  
2629 See http://dev.perl.org/licenses/ for more information.
2630  
2631 =head2 Triangle license
2632  
2633 B<Triangle> by Jonathan Richard Shewchuk, copyright 2005, includes the following
2634 notice in the C source code. Please refer to the C source, included in with this
2635 Perl module distribution, for the full notice.
2636  
2637 This program may be freely redistributed under the condition that the
2638 copyright notices (including this entire header and the copyright
2639 notice printed when the `-h' switch is selected) are not removed, and
2640 no compensation is received. Private, research, and institutional
2641 use is free. You may distribute modified versions of this code UNDER
2642 THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE
2643 SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE
2644 AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR
2645 NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as
2646 part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT
2647 WITH THE AUTHOR. (If you are not directly supplying this code to a
2648 customer, and you are instead telling them how they can obtain it for
2649 free, then you are not required to make any arrangement with me.)
2650  
2651 =cut
2652  
2653 8 1;
↑ Summary src/triangle.c »