| 1 | package Qhull::Util; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Various bits and pieces | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use experimental 'signatures', 'lexical_subs', 'declared_refs', 'refaliasing'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Ref::Util qw( is_arrayref is_hashref ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Log::Any '$log'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 6 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use Qhull::Util::Options ':all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use Exporter::Shiny qw( parse_output supported_output_format ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 6 | our @CARP_NOT = qw( Qhull::PP Qhull::Options ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my sub croak { | ||||||||||||||||||||||||||
|
Subroutine
croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 21 | 0 | require Carp; | |||||||||||||||||||||||||||
| 22 | 0 | goto \&Carp::croak; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | my sub parse_output_facets; | ||||||||||||||||||||||||||||
| 26 | my sub parse_output_vertices; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 6 | my %Parser = ( | |||||||||||||||||||||||||||
| 29 | f => { | ||||||||||||||||||||||||||||
| 30 | func => \&parse_output_facets, | ||||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||
| 32 | p => { | ||||||||||||||||||||||||||||
| 33 | func => \&parse_output_vertices, | ||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | Fx => { | ||||||||||||||||||||||||||||
| 36 | func => \&parse_extreme_points, | ||||||||||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||||||||||
| 38 | FS => { | ||||||||||||||||||||||||||||
| 39 | func => \&parse_size, | ||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | ▶ | sub supported_output_format( $format ) { | ||||||||||||||||||||||||||
|
Subroutine
supported_output_format: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 4 | return defined $Parser{$format}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 11 | ▶ | sub parse_output( $options, $output, @output_args ) { | ||||||||||||||||||||||||||
|
Subroutine
parse_output: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 11 | my $line_no = 1; | |||||||||||||||||||||||||||
| 85 | 11 | my @output; | |||||||||||||||||||||||||||
| 86 | 11 | for my $arg ( @output_args ) { | |||||||||||||||||||||||||||
| 87 | 11 | ▶ | my $parser = $Parser{$arg} // croak( "unsupported output format: $arg" ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$Parser{$arg} // croak("unsupported output format: $arg")
MC/DC0%0/2
$Parser{$arg} // croak("unsupported output format: $arg")
$Parser{$arg}
croak("unsupported output format: $arg")
Truth table33%1/3
A // B
A= $Parser{$arg}B= croak("unsupported output format: $arg")
| |||||||||||||||||||||||||||||
| 88 | 11 | ( $line_no, my $results ) = $parser->{func}->( $options, \$output, $line_no ); | |||||||||||||||||||||||||||
| 89 | 11 | push @output, $results; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 11 | return @output; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | ## no critic( RegularExpressions::ProhibitEscapedMetacharacters ) | ||||||||||||||||||||||||||||
| 95 | 6 | my $qr_Record = qr/\G\n*([^\n]*?)$/mx; | |||||||||||||||||||||||||||
| 96 | 6 | my $qr_Point = qr/ p(\d+) \(v (\d+) \) /mx; | |||||||||||||||||||||||||||
| 97 | 6 | my $qr_PointRecord = qr/\G\n*- \h* $qr_Point \h* : \h+ ($Num) \h+ ($Num) \h* $ /mx; | |||||||||||||||||||||||||||
| 98 | 6 | my $qr_Facet = qr/f(\d+)/mx; | |||||||||||||||||||||||||||
| 99 | 6 | my $qr_FacetHeader = qr/\G\n*- \h $qr_Facet \h* $/mx; | |||||||||||||||||||||||||||
| 100 | 6 | my $qr_FacetAttr = qr/\G\n* \h+ - \h (?<attr>[^:]+) : \h+ /x; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 6 | my %qr_FacetAttr = ( | |||||||||||||||||||||||||||
| 103 | 'flags' => qr/\G \h* (\w+) \h*/mx, | ||||||||||||||||||||||||||||
| 104 | 'normal' => qr/\G \h* ($Num) \h*/mx, | ||||||||||||||||||||||||||||
| 105 | 'offset' => qr/\G \h* ($Num) \h*/mx, | ||||||||||||||||||||||||||||
| 106 | 'vertices' => qr/\G \h* $qr_Point \h*/mx, | ||||||||||||||||||||||||||||
| 107 | 'neighboring facets' => qr/\G \h* $qr_Facet \h*/mx, | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 1 | ▶ | sub parse_output_facets ( $option, $buf_ref, $line_no ) { | ||||||||||||||||||||||||||
|
Subroutine
parse_output_facets: called CC=12 SCAR=25.7
| |||||||||||||||||||||||||||||
| 156 | 1 | my \$buffer = $buf_ref; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 1 | ▶ | croak( "end of data in qhull output at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | if $buffer !~ /$qr_Record/g; | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 1 | ▶ | if ( ( my $contents = $1 ) !~ /^Vertices and facets/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | croak( | |||||||||||||||||||||||||||
| 163 | "out of sync in qhull output at line $line_no;" . " expected 'Vertices and facets', got: $contents", | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # read vertices | ||||||||||||||||||||||||||||
| 168 | 1 | ++$line_no; | |||||||||||||||||||||||||||
| 169 | 1 | my ( @vertices, @facets ); | |||||||||||||||||||||||||||
| 170 | 1 | ▶ | while ( $buffer =~ m/$qr_PointRecord/gc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 100 | my ( $point, $vertex, @coords ) = @{^CAPTURE}; | |||||||||||||||||||||||||||
| 172 | push @vertices, | ||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||
| 174 | 100 | ▶ | ( $option->{trace} ? ( line_no => $line_no ) : () ), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | point => $point, | ||||||||||||||||||||||||||||
| 176 | vertex => $vertex, | ||||||||||||||||||||||||||||
| 177 | coords => \@coords, | ||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | continue { | ||||||||||||||||||||||||||||
| 181 | 100 | ++$line_no; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 1 | ▶ | croak( "missing vertices at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | if !@vertices; | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 1 | ▶ | while ( $buffer =~ m/$qr_FacetHeader/gc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 100 | my $id = $1; | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 100 | my %line_no = ( id => $line_no ); | |||||||||||||||||||||||||||
| 192 | 100 | my %facet = ( id => $id, ); | |||||||||||||||||||||||||||
| 193 | 100 | ▶ | $facet{line_no} = \%line_no if $option->{trace}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 100 | ++$line_no; | |||||||||||||||||||||||||||
| 196 | 100 | ▶ | while ( $buffer =~ m/$qr_FacetAttr/gc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 500 | my $attr = $+{attr}; | |||||||||||||||||||||||||||
| 199 | 500 | ▶ | my $qr = $qr_FacetAttr{$attr} // croak( "unknown facet attribute at line $line_no: $attr" ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$qr_FacetAttr{$attr} // croak("unknown facet attribute at line ${line_no}: $attr")
MC/DC0%0/2
$qr_FacetAttr{$attr} // croak("unknown facet attribute at line ${line_no}: $attr")
$qr_FacetAttr{$attr}
croak("unknown facet attribute at line ${line_no}: $attr")
Truth table33%1/3
A // B
A= $qr_FacetAttr{$attr}B= croak("unknown facet attribute at line ${line_no}: $attr")
| |||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 500 | my @values = $buffer =~ m/$qr/gc; | |||||||||||||||||||||||||||
| 202 | 500 | ▶ | @values || croak( "unparseable facet attribute value at line $line_no" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 500 | $facet{$attr} = \@values; | |||||||||||||||||||||||||||
| 205 | 500 | $line_no{$attr} = $line_no; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | continue { | ||||||||||||||||||||||||||||
| 208 | 500 | ++$line_no; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 100 | push @facets, \%facet; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 1 | ▶ | croak( "missing facets at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | if !@vertices; | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 1 | return $line_no, { vertices => \@vertices, facets => \@facets }; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | sub parse_output_vertices( $option, $buf_ref, $line_no ) { | ||||||||||||||||||||||||||
|
Subroutine
parse_output_vertices: called CC=8 SCAR=21.5
| |||||||||||||||||||||||||||||
| 236 | 1 | my \$buffer = $buf_ref; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 1 | my @results; | |||||||||||||||||||||||||||
| 239 | 1 | for ( 0, 1 ) { | |||||||||||||||||||||||||||
| 240 | 2 | ▶ | croak( "end of data in qhull output at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | if $buffer !~ /$qr_Record \n/gx; | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 2 | ▶ | if ( ( my $contents = $1 ) !~ /\h* ($Int) \h*/x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | croak( "out of sync in qhull output at line $line_no;" . " expected an integer, got: $contents", ); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||
| 247 | 2 | push @results, $1; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | continue { | ||||||||||||||||||||||||||||
| 250 | 2 | ++$line_no; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 1 | my $nelem = $results[-1]; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | # read vertices | ||||||||||||||||||||||||||||
| 256 | 1 | my ( @vertices ); | |||||||||||||||||||||||||||
| 257 | 1 | ▶ | while ( $nelem-- and my @coords = $buffer =~ m/\G \h* ($Num) \h*?/xmgc ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nelem-- and my(@coords) = $buffer =~ /\G \h* ($Qhull::Util::Num) \h*?/cgmux
MC/DC50%1/2
$nelem-- and my(@coords) = $buffer =~ /\G \h* ($Qhull::Util::Num) \h*?/cgmux
$nelem--
my(@coords) = $buffer =~ /\G \h* ($Qhull::Util::Num) \h*?/cgmux
Truth table66%2/3
A and B
A= $nelem--B= my(@coords) = $buffer =~ /\G \h* ($Qhull::Util::Num) \h*?/cgmux
| |||||||||||||||||||||||||||||
| 258 | 100 | ▶ | push @vertices, [ ( $option->{trace} ? $line_no : () ), ( map 0+ $_, @coords ), ]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 100 | $buffer =~ /\n+/gc; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | continue { | ||||||||||||||||||||||||||||
| 262 | 100 | ++$line_no; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 1 | ▶ | croak( "missing vertices at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | if !@vertices; | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 1 | return $line_no, \@vertices; | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 8 | ▶ | sub parse_extreme_points( $option, $buf_ref, $line_no ) { | ||||||||||||||||||||||||||
|
Subroutine
parse_extreme_points: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||
| 288 | 8 | my \$buffer = $buf_ref; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 8 | ▶ | croak( "end of data in qhull output at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | if $buffer !~ /$qr_Record \n/gx; | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 8 | ▶ | if ( ( my $contents = $1 ) !~ /\h* ($Int) \h*/x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | croak( "out of sync in qhull output at line $line_no;" . " expected an integer, got: $contents", ); | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||
| 298 | 8 | my $nelem = $1; | |||||||||||||||||||||||||||
| 299 | 8 | ++$line_no; | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | # read vertex indices | ||||||||||||||||||||||||||||
| 302 | 8 | my ( @vertices ); | |||||||||||||||||||||||||||
| 303 | 8 | ▶ | while ( $nelem-- and $buffer =~ m/\G \h* ($Int) \h*?\n/xgm ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nelem-- and $buffer =~ /\G \h* ($Qhull::Util::Int) \h*?\n/gmux
MC/DC50%1/2
$nelem-- and $buffer =~ /\G \h* ($Qhull::Util::Int) \h*?\n/gmux
$nelem--
$buffer =~ /\G \h* ($Qhull::Util::Int) \h*?\n/gmux
Truth table66%2/3
A and B
A= $nelem--B= $buffer =~ /\G \h* ($Qhull::Util::Int) \h*?\n/gmux
| |||||||||||||||||||||||||||||
| 304 | 800 | ▶ | push @vertices, $option->{trace} ? [ $line_no, $1 ] : $1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | continue { | ||||||||||||||||||||||||||||
| 307 | 800 | ++$line_no; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 8 | ▶ | croak( "missing vertices at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | if !@vertices; | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 8 | return $line_no, \@vertices; | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 1 | ▶ | sub parse_size( $option, $buf_ref, $line_no ) { | ||||||||||||||||||||||||||
|
Subroutine
parse_size: called CC=11 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||
| 349 | 1 | my \$buffer = $buf_ref; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 1 | ▶ | croak( "end of data in qhull output at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | if $buffer !~ /$qr_Record \n/gx; | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 1 | my %results; | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 1 | my $contents = $1; | |||||||||||||||||||||||||||
| 359 | 1 | my @ints = $contents =~ /\G\h* ($Int) \h*/gxc; | |||||||||||||||||||||||||||
| 360 | @ints | ||||||||||||||||||||||||||||
| 361 | 1 | ▶ | or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | croak( "out of sync in qhull output at line $line_no;" . " expected an integer, got: $contents", | ||||||||||||||||||||||||||||
| 363 | ); | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 1 | ▶ | $contents =~ /\G\h*$/gcx | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | or croak( "junk at end of line $line_no: " . substr( $contents, pos( $contents ) ) ); | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 1 | my $nints = shift @ints; | |||||||||||||||||||||||||||
| 369 | 1 | ▶ | $nints == @ints | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | or croak( "expected $nints integers; got " . @ints ); | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 1 | ++$line_no; | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 1 | ▶ | croak( "end of data in qhull output at line $line_no" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | if $buffer !~ /$qr_Record \n/gx; | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | ## no critic (RegularExpressions::ProhibitUnusedCapture) | ||||||||||||||||||||||||||||
| 378 | 1 | ▶ | if ( ( $contents = $1 ) !~ /\h* ($Int) \h*/gx ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | 0 | croak( "out of sync in qhull output at line $line_no;" . " expected an integer, got: $contents", ); | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 1 | my $nelem = $1; | |||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 1 | my @reals = $contents =~ /\G\h* ($Num) \h*/cgmx; | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 1 | ▶ | $contents =~ /\G\h*$/gcx | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | or croak( "junk at end of line $line_no: " . substr( $contents, pos( $contents ) ) ); | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | @reals | ||||||||||||||||||||||||||||
| 390 | 1 | ▶ | or croak( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | sprintf( | ||||||||||||||||||||||||||||
| 392 | 'out of sync in qhull output at line %d; expected %d real numbers, got: %s', | ||||||||||||||||||||||||||||
| 393 | $line_no, $nelem, substr( $contents, pos( $contents ) ) ) ); | ||||||||||||||||||||||||||||
| 394 | 1 | ▶ | $nelem == @reals | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | or croak( sprintf( 'expected %d real numbers at line %d; got %d', $nelem, $line_no, 0+ @reals ) ); | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 1 | @results{ 'area', 'volume' } = @reals; | |||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 1 | ▶ | if ( $option->{trace} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | $results{line_no} = { | ||||||||||||||||||||||||||||
| 401 | 0 | area => $line_no, | |||||||||||||||||||||||||||
| 402 | volume => $line_no, | ||||||||||||||||||||||||||||
| 403 | }; | ||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 1 | ++$line_no; | |||||||||||||||||||||||||||
| 407 | 1 | return $line_no, \%results; | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 6 | 1; | |||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | # | ||||||||||||||||||||||||||||
| 413 | # This file is part of Qhull | ||||||||||||||||||||||||||||
| 414 | # | ||||||||||||||||||||||||||||
| 415 | # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory. | ||||||||||||||||||||||||||||
| 416 | # | ||||||||||||||||||||||||||||
| 417 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 418 | # | ||||||||||||||||||||||||||||
| 419 | # The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||||||||||
| 420 | # | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | __END__ | ||||||||||||||||||||||||||||