r4311: *** empty log message ***
[ctsim.git] / tools / linogram.cpp
diff --git a/tools/linogram.cpp b/tools/linogram.cpp
new file mode 100644 (file)
index 0000000..a244c0d
--- /dev/null
@@ -0,0 +1,138 @@
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          linogram.cpp
+**   Purpose:       Display linogram sampling
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  April 2003
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: linogram.cpp,v 1.1 2003/04/01 18:34:42 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"
+
+enum { O_LABELS,, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
+
+static struct option my_options[] =
+{
+   {"debug", 0, 0, O_DEBUG},
+  {"verbose", 0, 0, O_VERBOSE},
+  {"help", 0, 0, O_HELP},
+  {"version", 0, 0, O_VERSION},
+  {0, 0, 0, 0}
+};
+
+static const char* g_szIdStr = "$Id: linogram.cpp,v 1.1 2003/04/01 18:34:42 kevin Exp $";
+
+
+void 
+linogram_usage (const char *program)
+{
+  std::cout << "usage: " << fileBasename(program) << " n d [OPTIONS]\n";
+  std::cout << "Imagefile information\n";
+  std::cout << std::endl;
+  std::cout << "     infile       Name of input IF file\n";
+   std::cout << "     --debug      Debug mode\n";
+  std::cout << "     --verbose    Verbose mode\n";
+  std::cout << "     --version    Print version\n";
+  std::cout << "     --help       Print this help message\n";
+}
+
+int 
+linogram_main (int argc, char *const argv[])
+{
+  std::string in_n;
+  int opt_verbose = 0;
+  int opt_debug = 0;
+
+  while (1)
+    {
+      int c = getopt_long (argc, argv, "", my_options, NULL);
+      
+      if (c == -1)
+       break;
+      
+      switch (c)
+       {
+       case O_VERBOSE:
+         opt_verbose = 1;
+         break;
+       case O_DEBUG:
+         opt_debug = 0;
+         break;
+        case O_VERSION:
+#ifdef VERSION
+         std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
+#else
+          std::cout << "Unknown version number\n";
+#endif
+         return (0);
+       case O_HELP:
+       case '?':
+         linogram_usage(argv[0]);
+         return (0);
+       default:
+         linogram_usage(argv[0]);
+         return (1);
+       }
+    }
+
+  if (optind + 2 != argc) {
+    linogram_usage (argv[0]);
+    return (1);
+  }
+  
+  in_n = argv[optind];
+  in_d = argv[optind+1];
+
+  int n = atol (in_n);
+  double n = atof (in_d);
+  int size = 2 * (2 * n - 1) + 1;
+  double divisor = 4 * n + 3;
+  
+  for (int itheta = 0; itheta < size; itheta++) {
+    double theta = atan (2 * itheta / division);
+    printf ("%lf: ", theta);
+    double step = d * cos(theta);
+    for (int id = 0; id < size; id++) {
+      printf ("%lf ", id * step);
+    }
+    printf ("\n");
+  }
+  
+  return (0);
+}
+
+#ifndef NO_MAIN
+int 
+main (int argc, char *const argv[])
+{
+  int retval = 1;
+
+  try {
+    retval = linogram_main(argc, argv);
+  } catch (exception e) {
+         std::cerr << "Exception: " << e.what() << std::endl;
+  } catch (...) {
+         std::cerr << "Unknown exception\n";
+  }
+
+  return (retval);
+}
+#endif