ltpict: Run perltidy -ce
authorAxel Jacobs <axel@jaloxa.eu>
Tue, 15 Apr 2014 21:54:44 +0100
changeset 790f5dabeed505
parent 78 32b004cb16a1
child 80 e97d9b1fb4f7
ltpict: Run perltidy -ce
bin/ltpict.pl
     1.1 --- a/bin/ltpict.pl	Tue Apr 15 21:54:21 2014 +0100
     1.2 +++ b/bin/ltpict.pl	Tue Apr 15 21:54:44 2014 +0100
     1.3 @@ -13,14 +13,14 @@
     1.4  use File::Temp qw/ tempdir /;
     1.5  my $td = tempdir( CLEANUP => 1 );
     1.6  
     1.7 -my $res     = 1024;            # Default output image dimensions. Same as objpict.
     1.8 +my $res     = 1024;     # Default output image dimensions. Same as objpict.
     1.9  my $tiny    = 0.01;
    1.10 -my $maxsize = 0.001;           # max luminaire size after scaling
    1.11 +my $maxsize = 0.001;    # max luminaire size after scaling
    1.12  my $is_ies  = 0;
    1.13  
    1.14  my $ies   = "$td/dist.ies";
    1.15 -my $lumi  = "$td/lumi.rad";    # Fitting given on cmd line, or generated by ies2rad
    1.16 -my $lumi2 = "$td/lumi2.rad";   # Fitting scaled to size
    1.17 +my $lumi  = "$td/lumi.rad";     # Fitting given on cmd line, or generated by ies2rad
    1.18 +my $lumi2 = "$td/lumi2.rad";    # Fitting scaled to size
    1.19  my $mat   = "$td/lt.mat";
    1.20  my $room1 = "$td/room1.rad";
    1.21  my $room2 = "$td/room2.rad";
    1.22 @@ -33,29 +33,31 @@
    1.23  
    1.24  # Parse command line arguments
    1.25  while (@ARGV) {
    1.26 -	$_ = $ARGV[0];
    1.27 -	if (m/-i/) {         # File is an IES file, not a Radiance luminaire
    1.28 -		$is_ies = 1;
    1.29 -	} elsif (m/-d/) {    # Resolution of the output HDR image
    1.30 -		$res = $ARGV[1];
    1.31 -		shift @ARGV;
    1.32 -    } elsif (m/^-\w/) { 	 # Oops! Illegal option
    1.33 +    $_ = $ARGV[0];
    1.34 +    if (m/-i/) {    # File is an IES file, not a Radiance luminaire
    1.35 +        $is_ies = 1;
    1.36 +    } elsif (m/-d/) {    # Resolution of the output HDR image
    1.37 +        $res = $ARGV[1];
    1.38 +        shift @ARGV;
    1.39 +    } elsif (m/^-\w/) {    # Oops! Illegal option
    1.40          die("ltpict: bad option '$_'\n");
    1.41      } else {
    1.42 -		last;    # No more options.  What's left is the actual file name.
    1.43 -	}
    1.44 +        last;    # No more options.  What's left is the actual file name.
    1.45 +    }
    1.46      shift @ARGV;
    1.47  }
    1.48  
    1.49  # We need exactly one Radiance luminaires or IES file
    1.50 -if (! $#ARGV == 0) {
    1.51 -	die("ltpict: Need one Radiance luminaire or IES file.\n");
    1.52 -} elsif ($is_ies == 0) {
    1.53 -	# Input file is a Radiance luminaire
    1.54 -	$lumi = $ARGV[0];
    1.55 +if ( !$#ARGV == 0 ) {
    1.56 +    die("ltpict: Need one Radiance luminaire or IES file.\n");
    1.57 +} elsif ( $is_ies == 0 ) {
    1.58 +
    1.59 +    # Input file is a Radiance luminaire
    1.60 +    $lumi = $ARGV[0];
    1.61  } else {
    1.62 -	# Input file is IES photometry
    1.63 -	system qq[ ies2rad -p $td -o lumi "$ARGV[0]" ];
    1.64 +
    1.65 +    # Input file is IES photometry
    1.66 +    system qq[ ies2rad -p $td -o lumi "$ARGV[0]" ];
    1.67  }
    1.68  
    1.69  my $res2 = $res / 2;    # Each rendering is half the size of final composite
    1.70 @@ -63,74 +65,73 @@
    1.71  # Scale luminaire and center at origin
    1.72  my $dimstr = `getbbox -h "$lumi"`;
    1.73  chomp $dimstr;
    1.74 +
    1.75  # Values returned by getbbox are indented and delimited with multiple spaces.
    1.76 -$dimstr =~ s/^\s+//;                # remove leading spaces
    1.77 -my @dims = split(/\s+/, $dimstr);   # convert to array
    1.78 +$dimstr =~ s/^\s+//;    # remove leading spaces
    1.79 +my @dims = split( /\s+/, $dimstr );    # convert to array
    1.80  
    1.81  # Find largest axes-aligned dimension
    1.82 -my @diffs = ($dims[1]-$dims[0], $dims[3]-$dims[2], $dims[5]-$dims[4]);
    1.83 +my @diffs = ( $dims[1] - $dims[0], $dims[3] - $dims[2], $dims[5] - $dims[4] );
    1.84  @diffs = reverse sort { $a <=> $b } @diffs;
    1.85  my $size = $diffs[0];
    1.86  
    1.87  # Move luminaire so centre is at origin, and scale
    1.88 -my $xtrans = -1.0 * ($dims[0] + $dims[1]) / 2;
    1.89 -my $ytrans = -1.0 * ($dims[2] + $dims[3]) / 2;
    1.90 -my $ztrans = -1.0 * ($dims[4] + $dims[5]) / 2;
    1.91 -my $scale = $maxsize / $size;
    1.92 +my $xtrans = -1.0 * ( $dims[0] + $dims[1] ) / 2;
    1.93 +my $ytrans = -1.0 * ( $dims[2] + $dims[3] ) / 2;
    1.94 +my $ztrans = -1.0 * ( $dims[4] + $dims[5] ) / 2;
    1.95 +my $scale  = $maxsize / $size;
    1.96  system qq[ xform -t $xtrans $ytrans $ztrans "$lumi" > $lumi2 ];
    1.97  
    1.98 -
    1.99  # Material for the room
   1.100 -open(FH, ">$mat") or
   1.101 -		die("ltpict: Cannot write to temporary file $mat");
   1.102 +open( FH, ">$mat" )
   1.103 +  or die("ltpict: Cannot write to temporary file $mat");
   1.104  print FH "void plastic wall_mat  0  0  5  .5 .5 .5  0 0";
   1.105  close FH;
   1.106  
   1.107 -
   1.108  # Different 'room' geometry for different views
   1.109 -my $o = 0.1;   # Offset
   1.110 +my $o = 0.1;    # Offset
   1.111  
   1.112  # C0-C180
   1.113 -open(FH, ">$room1") or
   1.114 -		die("ltpict: Cannot write to temporary file $room1");
   1.115 -print FH "wall_mat polygon box.4620  0  0  12  -$o -5 5  -$o 5 5  -$o 5 -5  -$o -5 -5";
   1.116 +open( FH, ">$room1" )
   1.117 +  or die("ltpict: Cannot write to temporary file $room1");
   1.118 +print FH
   1.119 +  "wall_mat polygon box.4620  0  0  12  -$o -5 5  -$o 5 5  -$o 5 -5  -$o -5 -5";
   1.120  close(FH);
   1.121  
   1.122  # C90-C270
   1.123 -open(FH, ">$room2") or
   1.124 -		die("ltpict: Cannot write to temporary file $room2");
   1.125 -print FH "wall_mat polygon box.1540  0  0  12  5 $o -5  5 $o 5  -5 $o 5  -5 $o -5";
   1.126 +open( FH, ">$room2" )
   1.127 +  or die("ltpict: Cannot write to temporary file $room2");
   1.128 +print FH
   1.129 +  "wall_mat polygon box.1540  0  0  12  5 $o -5  5 $o 5  -5 $o 5  -5 $o -5";
   1.130  close(FH);
   1.131  
   1.132  # Lower hemisphere
   1.133 -open(FH, ">$room3") or 
   1.134 -		die("ltpict: Cannot write to temporary file $room3");
   1.135 +open( FH, ">$room3" )
   1.136 +  or die("ltpict: Cannot write to temporary file $room3");
   1.137  print FH "wall_mat bubble lower  0  0  4 0 0 $dims[4] 5";
   1.138  close(FH);
   1.139  
   1.140  # Upper hemisphere
   1.141 -open(FH, ">$room4") or 
   1.142 -		die("ltpict: Cannot write to temporary file $room4");
   1.143 +open( FH, ">$room4" )
   1.144 +  or die("ltpict: Cannot write to temporary file $room4");
   1.145  print FH "wall_mat bubble upper  0  0  4 0 0 $dims[5] 5";
   1.146  close(FH);
   1.147  
   1.148 -
   1.149  # Call bbox again, for the translated and scaled luminaire.
   1.150  $dimstr = `getbbox -h $lumi2`;
   1.151  chomp $dimstr;
   1.152 +
   1.153  # Values returned by getbbox are indented and delimited with multiple spaces.
   1.154 -$dimstr =~ s/^\s+//;             # remove leading spaces
   1.155 -@dims = split(/\s+/, $dimstr);   # convert to array
   1.156 -
   1.157 +$dimstr =~ s/^\s+//;    # remove leading spaces
   1.158 +@dims = split( /\s+/, $dimstr );    # convert to array
   1.159  
   1.160  # Define the four views
   1.161 -my $vw1 = "-vtl -vp 4.5 0 0 -vd -1 0 0 -vh 10 -vv 10";
   1.162 -my $vw2 = "-vtl -vp 0 -4.5 0 -vd 0 1 0 -vh 10 -vv 10";
   1.163 +my $vw1    = "-vtl -vp 4.5 0 0 -vd -1 0 0 -vh 10 -vv 10";
   1.164 +my $vw2    = "-vtl -vp 0 -4.5 0 -vd 0 1 0 -vh 10 -vv 10";
   1.165  my $zcent3 = $dims[4] - $tiny;
   1.166 -my $vw3 = "-vta -vp 0 0 $zcent3 -vd 0 0 -1 -vu 0 1 0 -vh 180 -vv 180";
   1.167 +my $vw3    = "-vta -vp 0 0 $zcent3 -vd 0 0 -1 -vu 0 1 0 -vh 180 -vv 180";
   1.168  my $zcent4 = $dims[5] + $tiny;
   1.169 -my $vw4 = "-vta -vp 0 0 $zcent4 -vd 0 0 1 -vu 0 1 0 -vh 180 -vv 180";
   1.170 -
   1.171 +my $vw4    = "-vta -vp 0 0 $zcent4 -vd 0 0 1 -vu 0 1 0 -vh 180 -vv 180";
   1.172  
   1.173  # Compile octrees
   1.174  system "oconv $mat $room1 $lumi2 > $oct1";
   1.175 @@ -146,8 +147,8 @@
   1.176  system "$rpict_cmd $vw4 $oct4 > $td/up.hdr";
   1.177  
   1.178  # Compose the four views into one image
   1.179 -my $vtl = "$td/vtl.hdr";     # The two parallel views
   1.180 -my $vta = "$td/vta.hdr";     # The two fisheye views
   1.181 +my $vtl = "$td/vtl.hdr";    # The two parallel views
   1.182 +my $vta = "$td/vta.hdr";    # The two fisheye views
   1.183  
   1.184  # Auto-expose right/front and down/up pairs separately
   1.185  my $pcond_cmd = "pcond -l";