summaryrefslogtreecommitdiff
path: root/bbox
blob: 6d58c05282fbd9a3ea2f602002df322cfc803b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
#         vertex 1.100000e+001 1.000000e+000 0.000000e+000

$num = '-?\d*(\.\d*)([Ee][-+]?\d+)?';

while (<>) {
	next unless /^\s*vertex\s+($num)\s+($num)\s+($num)\s*$/;
	($x, $y, $z) = ($1, $4, $7);
	$x0 = $x if $x < $x0 || !defined $x0;
	$y0 = $y if $y < $y0 || !defined $y0;
	$z0 = $z if $z < $z0 || !defined $z0;
	$x1 = $x if $x > $x1 || !defined $x1;
	$y1 = $y if $y > $y1 || !defined $y1;
	$z1 = $z if $z > $z1 || !defined $z1;
}

$dx = $x1-$x0;
$dy = $y1-$y0;
$dz = $z1-$z0;

printf("%.3f (%.3f..%.3f) x %.3f (%.3f..%.3f) x %.3f (%.3f..%.3f)\n",
    $dx, $x0, $x1, $dy, $y0, $y1, $dz, $z0, $z1);
printf("%.1f x %.1f x %.1f mm = %.1f ccm\n",
    $dx, $dy, $dz, $dx*$dy*$dz/1000);