X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=tools%2Flinogram.cpp;h=81e610492ad3594a7cfc523708a26c05350f759a;hp=af5a9cf0c96dc82b191f2007f09ca284284d31fd;hb=1a050c98763fbbc0662731b0b76953acede6f5d7;hpb=c8b19dfaffba9f06d8b6c40cb1bb83a8964867f7 diff --git a/tools/linogram.cpp b/tools/linogram.cpp index af5a9cf..81e6104 100644 --- a/tools/linogram.cpp +++ b/tools/linogram.cpp @@ -43,7 +43,7 @@ static struct option my_options[] = static const char* g_szIdStr = "$Id$"; -void +void linogram_usage (const char *program) { std::cout << "usage: " << fileBasename(program) << " n d [OPTIONS]\n"; @@ -59,7 +59,7 @@ linogram_usage (const char *program) std::cout << " --help Print this help message\n"; } -int +int linogram_main (int argc, char *const argv[]) { int opt_polar_rt = 0; @@ -70,46 +70,46 @@ linogram_main (int argc, char *const argv[]) while (1) { int c = getopt_long (argc, argv, "", my_options, NULL); - + if (c == -1) - break; - + break; + 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; - case O_DEBUG: - opt_debug = 0; - break; + { + case O_XY: + opt_xy = 1; + break; + case O_POLAR_RT: + opt_polar_rt = 1; + break; + 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; + 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); - } + 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); } - + const char* in_n = argv[optind]; const char* in_d = argv[optind+1]; @@ -120,7 +120,7 @@ linogram_main (int argc, char *const argv[]) int min = -max; double theta_base = PI/4; // theta_base = 0; - + double theta_vec [size]; for (int i = 0; i < size; i++) { int m = i - (2 * n + 1); @@ -132,21 +132,21 @@ linogram_main (int argc, char *const argv[]) 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); + 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"); } - + 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); + 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"); } @@ -154,34 +154,34 @@ linogram_main (int argc, char *const argv[]) int m; for (m = 0; m < size; m++) { if (! opt_polar_rt) - printf ("%lf: ", theta_vec[m] + theta_base); + 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); + 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); + 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); + if (opt_polar_rt) + printf ("%lf,", theta_vec[m] + PI/2 + theta_base); + printf ("%lf ", id * step); } printf ("\n"); } } - + return (0); } #ifndef NO_MAIN -int +int main (int argc, char *const argv[]) { int retval = 1; @@ -189,9 +189,9 @@ main (int argc, char *const argv[]) try { retval = linogram_main(argc, argv); } catch (exception e) { - std::cerr << "Exception: " << e.what() << std::endl; + std::cerr << "Exception: " << e.what() << std::endl; } catch (...) { - std::cerr << "Unknown exception\n"; + std::cerr << "Unknown exception\n"; } return (retval);