From e9c20d8b9cf2a0f49d0086e50bd6a4eb2c6c2dac Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 7 Jan 2001 22:19:44 +0000 Subject: [PATCH] r357: Conversion to CTSimText shell --- tools/ctsimtext.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++ tools/phm2if.cpp | 6 +-- tools/phm2pj.cpp | 6 +-- tools/pjrec.cpp | 6 +-- 4 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 tools/ctsimtext.cpp diff --git a/tools/ctsimtext.cpp b/tools/ctsimtext.cpp new file mode 100644 index 0000000..2e17cd3 --- /dev/null +++ b/tools/ctsimtext.cpp @@ -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); +} + diff --git a/tools/phm2if.cpp b/tools/phm2if.cpp index f7f9551..8d5e403 100644 --- a/tools/phm2if.cpp +++ b/tools/phm2if.cpp @@ -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; diff --git a/tools/phm2pj.cpp b/tools/phm2pj.cpp index 9d53148..4e4463d 100644 --- a/tools/phm2pj.cpp +++ b/tools/phm2pj.cpp @@ -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); diff --git a/tools/pjrec.cpp b/tools/pjrec.cpp index 7426f47..bee46c3 100644 --- a/tools/pjrec.cpp +++ b/tools/pjrec.cpp @@ -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; -- 2.34.1