--- a/bin/ltpict.pl Tue Apr 08 22:55:23 2014 +0100
+++ b/bin/ltpict.pl Tue Apr 08 22:56:02 2014 +0100
@@ -12,48 +12,44 @@
use File::Temp qw/ tempdir /;
my $td = tempdir( CLEANUP => 1 );
-use File::Copy qw(copy);
-my $res = 1024; # Default output image dimensions
+my $res = 1024; # Default output image dimensions. Same as objpict.
my $tiny = 0.01;
my $maxsize = 0.001; # max luminaire size after scaling
my $is_ies = 0;
-my $ies = "$td/dist.ies";
-my $lumi = "$td/lumi.rad"; # Fitting as given on cmd line, or as generated by ies2rad
+my $ies = "$td/dist.ies";
+my $lumi = "$td/lumi.rad"; # Fitting given on cmd line, or generated by ies2rad
my $lumi2 = "$td/lumi2.rad"; # Fitting scaled to size
-my $mat = "$td/lt.mat";
+my $mat = "$td/lt.mat";
my $room1 = "$td/room1.rad";
my $room2 = "$td/room2.rad";
my $room3 = "$td/room3.rad";
my $room4 = "$td/room4.rad";
-my $oct1 = "$td/lt1.oct";
-my $oct2 = "$td/lt2.oct";
-my $oct3 = "$td/lt3.oct";
-my $oct4 = "$td/lt4.oct";
+my $oct1 = "$td/lt1.oct";
+my $oct2 = "$td/lt2.oct";
+my $oct3 = "$td/lt3.oct";
+my $oct4 = "$td/lt4.oct";
# Parse command line arguments
-while ($#ARGV >= 0) {
+while (@ARGV) {
$_ = $ARGV[0];
- if (m/-i/) { # File is an IES file, not Radiance luminaire
+ if (m/-i/) { # File is an IES file, not a Radiance luminaire
$is_ies = 1;
} elsif (m/-d/) { # Resolution of the output HDR image
$res = $ARGV[1];
shift @ARGV;
-
- } elsif (m/^-/) { # Oops! Illegal option
- die("ltpict: bad option \"$ARGV[0]\"\n");
+ } elsif (m/^-\w/) { # Oops! Illegal option
+ die("ltpict: bad option '$_'\n");
} else {
last; # No more options. What's left is the actual file name.
}
shift @ARGV;
}
-# We need one Radiance luminaire or an IES file
if ($is_ies == 0) {
# Input file is a Radiance luminaire
- copy $ARGV[0], $lumi or
- die("ltpict: Cannot copy file '$ARGV[0]' to $lumi\n");
+ $lumi = $ARGV[0];
} else {
# Input file is IES photometry
system "ies2rad -p $td -o lumi $ARGV[0]";
@@ -93,34 +89,38 @@
# Different 'room' geometry for different views
-my $offset = 0.1;
+my $o = 0.1; # Offset
# C0-C180
-open(FH, ">$room1") or die("ltpict: Cannot write to temporary file $room1");
-print FH "wall_mat polygon box.4620 0 0 12 -$offset -5 5 -$offset 5 5 -$offset 5 -5 -$offset -5 -5";
+open(FH, ">$room1") or
+ die("ltpict: Cannot write to temporary file $room1");
+print FH "wall_mat polygon box.4620 0 0 12 -$o -5 5 -$o 5 5 -$o 5 -5 -$o -5 -5";
close(FH);
# C90-C270
-open(FH, ">$room2") or die("ltpict: Cannot write to temporary file $room2");
-print FH "wall_mat polygon box.1540 0 0 12 5 $offset -5 5 $offset 5 -5 $offset 5 -5 $offset -5";
+open(FH, ">$room2") or
+ die("ltpict: Cannot write to temporary file $room2");
+print FH "wall_mat polygon box.1540 0 0 12 5 $o -5 5 $o 5 -5 $o 5 -5 $o -5";
close(FH);
# Lower hemisphere
-open(FH, ">$room3") or die("ltpict: Cannot write to temporary file $room3");
+open(FH, ">$room3") or
+ die("ltpict: Cannot write to temporary file $room3");
print FH "wall_mat bubble lower 0 0 4 0 0 $dims[4] 5";
close(FH);
# Upper hemisphere
-open(FH, ">$room4") or die("ltpict: Cannot write to temporary file $room4");
+open(FH, ">$room4") or
+ die("ltpict: Cannot write to temporary file $room4");
print FH "wall_mat bubble upper 0 0 4 0 0 $dims[5] 5";
close(FH);
-# Get bbox again, for the translated and scaled luminaire.
+# Call bbox again, for the translated and scaled luminaire.
$dimstr = `getbbox -h $lumi2`;
chomp $dimstr;
# Values returned by getbbox are indented and delimited with multiple spaces.
-$dimstr =~ s/^\s+//; # remove leading spaces
+$dimstr =~ s/^\s+//; # remove leading spaces
@dims = split(/\s+/, $dimstr); # convert to array
# Define the four views