r654: *** empty log message ***
[ctsim.git] / cgi-bin / ctsim.cgi.in
index a497dd908502f1dcc3988137fc196b99161bf5b7..4ead487c68ac565c3806fbb42266ccddb62497f5 100755 (executable)
@@ -28,17 +28,14 @@ CGI::ReadParse(\%in);
 my $error = "";
 
 if ($::single_process_only > 0) {
-  my @processes = '/bin/ps -A';
+  my @processes = `/bin/ps -A`;
   my $running = 0;
-  foreach $p (@processes) {
-    if ($p ~= /ctsimtext/) {
-      $running = 1;
-      break;
-    }
-    if ($running > 0) {
-      $error .= "Another online simulation is currently running.<p>Click your browser's <i>Refresh</i> button to resubmit your simulation<br>";
-      exit(0);
+  foreach my $p (@processes) {
+    if ($p =~ m/ctsimtext/) {
+      $error .= "Another online simulation is currently running.<br>You may wait a moment and then click your browser's <b>Refresh</b> button to resubmit your simulation<br>";
+      last;
     }
+  }
 }
 
 my $Phantom_Name = FilterMetaChars($in{'Phantom_Name'});
@@ -49,14 +46,17 @@ $error .= "Phantom name must not be blank<br>" if ($Phantom_Name eq "");
 $error .= "Phantom NX and NY must be between 5 and 512<br>" if ($Phantom_Nx < 5 || $Phantom_Nx > 512 || $Phantom_Ny < 5 || $Phantom_Ny > 512);
 $error .= "Phantom NSample must be between 1 and 5<br>" if ($Phantom_NSample < 1 || $Phantom_NSample > 5);
 
+my $PJ_Geometry = FilterMetaChars($in{'PJ_Geometry'});
 my $PJ_NDet = FilterToNumber($in{'PJ_NDet'});
 my $PJ_NRot = FilterToNumber($in{'PJ_NRot'});
+my $PJ_FocalLength = FilterToNumber($in{'PJ_FocalLength'});
 my $PJ_NRay = FilterToNumber($in{'PJ_NRay'});
 my $PJ_RotAngle = FilterToNumber($in{'PJ_RotAngle'});
 $error .= "Projection NDet must be between 5 and 1000<br>" if ($PJ_NDet < 5 || $PJ_NDet > 1000);
 $error .= "Projection NRot must be between 5 and 1000<br>" if ($PJ_NRot < 5 || $PJ_NRot > 1000);
 $error .= "Projection NRay must be between 1 and 5<br>" if ($PJ_NRay < 1 || $PJ_NRay > 5);
 $error .= "Projection RotAngle must be between 0.1 and 2<br>" if ($PJ_RotAngle < 0.1 || $PJ_RotAngle > 2);
+$error .= "Focal length must be between 1.01 and 10<b>" if ($PJ_FocalLength <= 1 || $PJ_FocalLength > 10);
 
 #my $IR_Nx = FilterToNumber($in{'IR_Nx'});
 #my $IR_Ny = FilterToNumber($in{'IR_Ny'});
@@ -111,17 +111,17 @@ my $ir_png_url = "$::url_datadir/ir-$tmpid.png";
 my $pj_png_url = "$::url_datadir/pj-$tmpid.png";
 my $sub_png_url = "$::url_datadir/sub-$tmpid.png";
 
-my $pjrec_ver = "$::bindir/pjrec";
-my $phm2pj_ver = "$::bindir/phm2pj";
-my $phm2if_ver = "$::bindir/phm2if";
-my $diff_ver = "$::bindir/if2";
+my $pjrec_ver = "$::bindir/ctsimtext pjrec";
+my $phm2pj_ver = "$::bindir/ctsimtext phm2pj";
+my $phm2if_ver = "$::bindir/ctsimtext phm2if";
+my $diff_ver = "$::bindir/ctsimtext if2";
 
 $pjrec_ver = "/opt/lam/bin/mpirun N N $::lamrundir/pjrec-lam" if $MPI;
 $phm2pj_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2pj-lam" if $MPI;
 $phm2if_ver = "/opt/lam/bin/mpirun N N $::lamrundir/phm2if-lam" if $MPI;
 
 my $gp_cmd = "$phm2if_ver $phantom_fname $Phantom_Nx $Phantom_Ny --phantom $Phantom_Name --nsample $Phantom_NSample";
-my $pj_cmd = "$phm2pj_ver $pj_fname $PJ_NDet $PJ_NRot --phantom $Phantom_Name --nray $PJ_NRay --rotangle $PJ_RotAngle";
+my $pj_cmd = "$phm2pj_ver $pj_fname $PJ_NDet $PJ_NRot --phantom $Phantom_Name --nray $PJ_NRay --rotangle $PJ_RotAngle --geometry $PJ_Geometry --focal-length $PJ_FocalLength";
 my $pj_if_cmd = "$::bindir/pj2if $pj_fname $pj_if_fname";
 my $pjrec_cmd = "$pjrec_ver $pj_fname $ir_fname $IR_Nx $IR_Ny --filter $IR_Filter --filter-param $IR_Filter_Param --interp $IR_Interp --backproj $IR_Backproj --filter-method $IR_FilterMethod --zeropad $IR_Zeropad";
 my $sub_cmd = "$diff_ver $phantom_fname $ir_fname $sub_fname --sub";
@@ -185,6 +185,12 @@ if ($error ne "") {
       }
     }
   }
+  # Delete image files and projection files
+  unlink($phantom_fname);
+  unlink($ir_fname);
+  unlink($pj_fname);
+  unlink($pj_if_fname);
+  unlink($sub_fname);
 
   $cmdout = "$gp_cmd\n $gp_out $pj_cmd\n $pj_out $pj_if_cmd\n $pj_if_out $pjrec_cmd\n $pjrec_out $diff_cmd\n $diff_out $png1_cmd\n $png_gp_out $png2_cmd\n $png_pjrec_out $png3_cmd\n $png_pj_out $png4_cmd\n $png_sub_out";
   if (open(LOGFILE,">> $logfile")) {
@@ -222,8 +228,7 @@ if ($error ne "") {
 }
 
 $out .= "<HR>\n";
-$out .= "Return to <A HREF=\"/ctsim/index.html\">CT Simulation Designer</a>.<br>\n";
-$out .= "Return to <A HREF=\"www.med-info.com\">Med-Info</a>.\n";
+$out .= "Return to <A HREF=\"http://www.ctsim.org\">CTSim</a>.<br>\n";
 $out .= "</BODY> </HTML>";
 $out .= "\n";