From e1046b19ed09745689c87bdf6f7af2ba9dce8d82 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 4 Apr 2003 20:08:10 +0000 Subject: [PATCH] r4390: *** empty log message *** --- tools/linogram.cpp | 91 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/tools/linogram.cpp b/tools/linogram.cpp index 31b3b56..c29cb83 100644 --- a/tools/linogram.cpp +++ b/tools/linogram.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: linogram.cpp,v 1.3 2003/04/01 19:49:41 kevin Exp $ +** $Id: linogram.cpp,v 1.4 2003/04/04 20:04: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 @@ -27,18 +27,20 @@ #include "ct.h" -enum { O_LABELS, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG }; +enum { O_XY, O_POLAR_RT, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG }; static struct option my_options[] = { - {"debug", 0, 0, O_DEBUG}, + {"xy", 0, 0, O_XY}, + {"polar-rt", 0, 0, O_POLAR_RT}, + {"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.3 2003/04/01 19:49:41 kevin Exp $"; +static const char* g_szIdStr = "$Id: linogram.cpp,v 1.4 2003/04/04 20:04:42 kevin Exp $"; void @@ -47,8 +49,11 @@ 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 << " n Linogram N\n"; + std::cout << " d Max detector spacing\n"; + std::cout << " --xy Output x,y pairs\n"; + std::cout << " --polar-rt Output r,t pairs\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"; @@ -57,6 +62,8 @@ linogram_usage (const char *program) int linogram_main (int argc, char *const argv[]) { + int opt_polar_rt = 0; + int opt_xy = 0; int opt_verbose = 0; int opt_debug = 0; @@ -69,6 +76,12 @@ linogram_main (int argc, char *const argv[]) switch (c) { + case O_XY: + opt_xy = 1; + break; + case O_POLAR_RT: + opt_polar_rt = 1; + break; case O_VERBOSE: opt_verbose = 1; break; @@ -103,7 +116,10 @@ linogram_main (int argc, char *const argv[]) int n = atol (in_n); double d = atof (in_d); int size = 4 * n + 3; - double theta_base = PI/8; + int max = 2 * n + 1; + int min = -max; + double theta_base = PI/4; + // theta_base = 0; double theta_vec [size]; for (int i = 0; i < size; i++) { @@ -111,23 +127,54 @@ linogram_main (int argc, char *const argv[]) theta_vec[i] = atan (static_cast(2 * m) / size); } - int m; - for (m = 0; m < size; m++) { - printf ("%lf: ", theta_vec[m] + theta_base); - double step = d * cos(theta_vec[m]); - for (int id = 0; id < size; id++) { - printf ("%lf ", id * step); + if (opt_xy) { + int m; + for (m = 0; m < size; m++) { + double step = d * cos(theta_vec[m]); + for (int id = min; id <= max; id++) { + double r = id * step; + double x = r * cos(theta_vec[m] + theta_base); + double y = r * sin(theta_vec[m] + theta_base); + printf ("%lf,%lf ", x, y); + } + printf ("\n"); } - printf ("\n"); - } - - for (m = 0; m < size; m++) { - printf ("%lf: ", theta_vec[m] + PI/2. + theta_base); - double step = d * cos(theta_vec[m]); - for (int id = 0; id < size; id++) { - printf ("%lf ", id * step); + + for (m = 0; m < size; m++) { + double step = d * cos(theta_vec[m]); + for (int id = min; id <= max; id++) { + double r = id * step; + double x = r * cos(theta_vec[m] + PI/2 + theta_base); + double y = r * sin(theta_vec[m] + PI/2 + theta_base); + printf ("%lf,%lf ", x, y); + } + printf ("\n"); + } + } else { + int m; + for (m = 0; m < size; m++) { + if (! opt_polar_rt) + printf ("%lf: ", theta_vec[m] + theta_base); + double step = d * cos(theta_vec[m]); + for (int id = min; id <= max; id++) { + if (opt_polar_rt) + printf ("%lf,", theta_vec[m] + theta_base); + printf ("%lf ", id * step); + } + printf ("\n"); + } + + for (m = 0; m < size; m++) { + if (! opt_polar_rt) + printf ("%lf: ", theta_vec[m] + PI/2 + theta_base); + double step = d * cos(theta_vec[m]); + for (int id = min; id <= max; id++) { + if (opt_polar_rt) + printf ("%lf,", theta_vec[m] + PI/2 + theta_base); + printf ("%lf ", id * step); + } + printf ("\n"); } - printf ("\n"); } return (0); -- 2.34.1