r357: Conversion to CTSimText shell
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 7 Jan 2001 22:19:44 +0000 (22:19 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 7 Jan 2001 22:19:44 +0000 (22:19 +0000)
tools/ctsimtext.cpp [new file with mode: 0644]
tools/phm2if.cpp
tools/phm2pj.cpp
tools/pjrec.cpp

diff --git a/tools/ctsimtext.cpp b/tools/ctsimtext.cpp
new file mode 100644 (file)
index 0000000..2e17cd3
--- /dev/null
@@ -0,0 +1,112 @@
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          ctsimtext.cpp
+**   Purpose:       Text mode shell for CTSim
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  Jan 2001
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: ctsimtext.cpp,v 1.1 2001/01/07 22:19:44 kevin Exp $
+**
+**  This program is free software; you can redistribute it and/or modify
+**  it under the terms of the GNU General Public License (version 2) as
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+#include "ct.h"
+
+static const char* g_szIdStr = "$Id: ctsimtext.cpp,v 1.1 2001/01/07 22:19:44 kevin Exp $";
+
+extern if1_main (int argc, char* const argv[]);
+extern if2_main (int argc, char* const argv[]);
+extern ifexport_main (int argc, char* const argv[]);
+extern ifinfo_main (int argc, char* const argv[]);
+extern phm2if_main (int argc, char* const argv[]);
+extern phm2pj_main (int argc, char* const argv[]);
+extern pj2if_main (int argc, char* const argv[]);
+extern pjinfo_main (int argc, char* const argv[]);
+extern pjrec_main (int argc, char* const argv[]);
+
+
+void 
+ctsimtext_usage (const char *program)
+{
+  std::cout << "usage: " << fileBasename(program) << " ctsim-function-name ctstim-function-parameters...\n";
+  std::cout << "CTSim text shell\n\n";
+  std::cout << "  ifinfo        Image file information\n";
+  std::cout << "  if1           Single image file conversion\n";
+  std::cout << "  if2           Dual image file conversions\n";
+  std::cout << "  pjrec         Projection reconstruction\n";
+  std::cout << "  pjinfo        Projection file information\n";
+  std::cout << "  phm2if        Convert a geometric phantom into an imagefile\n";
+  std::cout << "  phm2pj        Take projections of a phantom object\n";
+  std::cout << "  ifexport      Export an imagefile to a graphics file\n";
+  std::cout << "  pj2if         Convert an projection file into an imagefile\n";
+}
+
+
+int 
+ctsimtext_main (int argc, char * argv[])
+{
+  if (argc < 2) {
+    ctsimtext_usage (argv[0]);
+    return (1);
+  }
+
+  const char* const pszFunction = argv[1];
+  argv = &argv[1];
+  argc--;
+
+  if (strcasecmp (pszFunction, "if1") == 0)
+    return if1_main (argc, argv);
+  else if (strcasecmp (pszFunction, "if2") == 0)
+    return if2_main (argc, argv);
+  else if (strcasecmp (pszFunction, "ifexport") == 0)
+    return ifexport_main (argc, argv);
+  else if (strcasecmp (pszFunction, "ifinfo") == 0)
+    return ifinfo_main (argc, argv);
+  else if (strcasecmp (pszFunction, "phm2if") == 0)
+    return phm2if_main (argc, argv);
+  else if (strcasecmp (pszFunction, "phm2pj") == 0)
+    return phm2pj_main (argc, argv);
+  else if (strcasecmp (pszFunction, "pj2if") == 0)
+    return pj2if_main (argc, argv);
+  else if (strcasecmp (pszFunction, "pjinfo") == 0)
+    return pjinfo_main (argc, argv);
+  else if (strcasecmp (pszFunction, "pjrec") == 0)
+    return pjrec_main (argc, argv);
+  else {
+    std::cout << "Unknown function name" << pszFunction << "\n\n";
+    ctsimtext_usage (argv[0]);
+    return 1;
+  }
+}
+
+int 
+main (int argc, char* argv[])
+{
+  int retval = 1;
+
+  try {
+    retval = ctsimtext_main(argc, argv);
+  } catch (exception e) {
+         std::cerr << "Exception: " << e.what() << std::endl;
+  } catch (...) {
+         std::cerr << "Unknown exception\n";
+  }
+
+  return (retval);
+}
+
index f7f9551d62505bc5f7447df0b8f69cc5492a5d7d..8d5e403d997452803c4c81df671281a54d3a04c6 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2if.cpp,v 1.19 2001/01/02 13:57:52 kevin Exp $
+**  $Id: phm2if.cpp,v 1.20 2001/01/07 22:19:44 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -50,7 +50,7 @@ static struct option my_options[] =
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: phm2if.cpp,v 1.19 2001/01/02 13:57:52 kevin Exp $";
+static const char* g_szIdStr = "$Id: phm2if.cpp,v 1.20 2001/01/07 22:19:44 kevin Exp $";
 
 void 
 phm2if_usage (const char *program)
@@ -104,7 +104,7 @@ void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* pImGlobal, ImageFile* pImL
 #endif
 
 int 
-phm2if_main (int argc, char* argv[])
+phm2if_main (int argc, char* const argv[])
 {
   ImageFile* pImGlobal = NULL;
   Phantom phm;
index 9d53148f53868764d3641e4eb3cad8b74211fd15..4e4463da9bec97b6e9690b73ad55f57b155c9dbb 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phm2pj.cpp,v 1.20 2001/01/02 05:34:57 kevin Exp $
+**  $Id: phm2pj.cpp,v 1.21 2001/01/07 22:19:44 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -50,7 +50,7 @@ static struct option phm2pj_options[] =
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: phm2pj.cpp,v 1.20 2001/01/02 05:34:57 kevin Exp $";
+static const char* g_szIdStr = "$Id: phm2pj.cpp,v 1.21 2001/01/07 22:19:44 kevin Exp $";
 
 
 void 
@@ -98,7 +98,7 @@ void GatherProjectionsMPI (MPIWorld& mpiWorld, Projections& pjGlobal, Projection
 #endif
 
 int 
-phm2pj_main (int argc, char* argv[])
+phm2pj_main (int argc, char* const argv[])
 {
   Phantom phm;
   std::string optGeometryName = Scanner::convertGeometryIDToName(Scanner::GEOMETRY_PARALLEL);
index 7426f47125117b48c16a152b6262403808e7fbeb..bee46c31b7128b4bcbf96425de48e1dfeed77549 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pjrec.cpp,v 1.20 2000/12/17 22:30:34 kevin Exp $
+**  $Id: pjrec.cpp,v 1.21 2001/01/07 22:19:44 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -48,7 +48,7 @@ static struct option my_options[] =
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: pjrec.cpp,v 1.20 2000/12/17 22:30:34 kevin Exp $";
+static const char* g_szIdStr = "$Id: pjrec.cpp,v 1.21 2001/01/07 22:19:44 kevin Exp $";
 
 void 
 pjrec_usage (const char *program)
@@ -122,7 +122,7 @@ static void ReduceImageMPI (MPIWorld& mpiWorld, ImageFile* imLocal, ImageFile* i
 
 
 int 
-pjrec_main (int argc, char * argv[])
+pjrec_main (int argc, char * const argv[])
 {
   Projections projGlobal;
   ImageFile* imGlobal = NULL;