r109: reorganized header files
[ctsim.git] / include / ct.h
index 0ad813e2f5f189982d7d3b53ca98e8077f3080f7..016a4f89e7ceddf7ab3eaeb771c3b7808ae64922 100644 (file)
-/*---------------------------------------------------------------------*/\r
-/*                 HEADER FILE FOR TOMOGRAPY SYSTEM                   */\r
-/*---------------------------------------------------------------------*/\r
-\r
-#ifndef CT_H\r
-#define CT_H\r
-\r
-#ifdef HAVE_CONFIG_H\r
-#include <config.h>\r
-#endif\r
-#ifdef HAVE_PNG\r
-#include "png.h"\r
-#endif\r
-#ifdef HAVE_STDIO_H\r
-#include <stdio.h>\r
-#endif\r
-#ifdef HAVE_STRING_H\r
-#include <string.h>\r
-#endif\r
-#ifdef HAVE_STDDEF_H\r
-#include <stddef.h>\r
-#endif\r
-#include <stdlib.h>\r
-#ifdef HAVE_STDARG_H\r
-#include <stdarg.h>\r
-#endif\r
-#ifdef  HAVE_SYS_TYPES_H\r
-#include <sys/types.h>\r
-#endif\r
-#ifdef HAVE_SYS_STAT_H\r
-#include <sys/stat.h>\r
-#endif\r
-#ifdef HAVE_CTYPE_H\r
-#include <ctype.h>\r
-#endif\r
-#ifdef HAVE_MATH_H\r
-#include <math.h>\r
-#endif\r
-#ifdef HAVE_SYS_FCNTL_H\r
-#include <sys/fcntl.h>\r
-#endif\r
-#ifdef HAVE_FCNTL_H\r
-#include <fcntl.h>\r
-#endif\r
-#if defined(HAVE_GETOPT_H) || defined(HAVE_GETOPT_LONG)\r
-#include <getopt.h>\r
-#endif\r
-#ifdef HAVE_UNISTD_H\r
-#include <unistd.h>\r
-#endif\r
-#ifdef HAVE_SETJMP_H\r
-#include <setjmp.h>\r
-#endif\r
-\r
-#ifdef MPI_CT\r
-#include "mpi.h"\r
-#endif\r
-\r
-#include "kstddef.h"\r
-#include "kmath.h"\r
-#include "sgp.h"\r
-#include "sdf.h"\r
-#include "ir.h"\r
-#include "getargs.h"\r
-#include "keyboard.h"\r
-#include "cio.h"\r
-#include "ezplot.h"\r
-\r
-#ifndef basename\r
-extern char *basename (__const char *__filename);\r
-#endif\r
-\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          ct.h
+**   Purpose:       Master header file for CTSim
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  Aug 1984
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: ct.h,v 1.19 2000/06/19 19:04:05 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
+******************************************************************************/
+
+#ifndef CT_H
+#define CT_H
+
+#ifdef _WIN32
+  typedef long off_t;
+  #define HAVE_STRING_H 1
+  #include <fcntl.h>
+  #define snprintf _snprintf
+  #define vsnprintf _vsnprintf
+  #define strcasecmp stricmp
+  #define strncasecmp strnicmp
+#endif
+
+#ifdef HAVE_CONFIG_H
+  #include <config.h>
+#endif
+#ifdef HAVE_PNG
+  #include "png.h"
+#endif
+#ifdef HAVE_G2_H
+extern "C" { 
+#include "g2.h" 
+}
+#ifdef HAVE_X11
+extern "C" {
+#include "g2_X11.h"
+}
+#endif
+#endif
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+#ifdef  HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_SYS_FCNTL_H
+#include <sys/fcntl.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if defined(HAVE_GETOPT_H) || defined(HAVE_GETOPT_LONG)
+#include <getopt.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SETJMP_H
+#include <setjmp.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>          /* for htonl on FreeBSD */
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>         /* for htonl on Linux/Solaris */
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>           /* for htonl on Solaris */
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>             /* Standard ints on Linux */
+#endif
+
+#ifdef HAVE_MPI
+#include "mpi++.h"
+#include "mpiworld.h"
+#endif
+
+#include "ctsupport.h"
+#include "byteorder.h"
+
+#ifdef HAVE_SGP
+  #include "ezplot.h"
+  #include "sgp.h"
+#endif
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <iterator>
+#include <algorithm>
+#include <exception>
+#include <stdexcept>
+
+using namespace std;
+
+#include "array2d.h"
+#include "imagefile.h"
+#include "phantom.h"
+#include "projections.h"
+#include "scanner.h"
+
+//----------------------------------------------------------------------//
+//                             USER SYMBOLS                            //
+//----------------------------------------------------------------------//
+
+// Filter types
+static const char O_FILTER_ABS_BANDLIMIT_STR[]= "abs_bandlimit";
+static const char O_FILTER_ABS_SINC_STR[]=      "abs_sinc";
+static const char O_FILTER_ABS_COS_STR[]=       "abs_cos";
+static const char O_FILTER_ABS_HAMMING_STR[]=   "abs_hamming";
+static const char O_FILTER_SHEPP_STR[]=         "shepp";
+static const char O_FILTER_BANDLIMIT_STR[]=     "bandlimit";
+static const char O_FILTER_SINC_STR[]=          "sinc";
+static const char O_FILTER_COS_STR[]=           "cos";
+static const char O_FILTER_HAMMING_STR[]=       "hamming";
+static const char O_FILTER_TRIANGLE_STR[]=      "triangle";
+
+typedef enum {            
+  FILTER_BANDLIMIT, 
+  FILTER_SINC,
+  FILTER_G_HAMMING,
+  FILTER_COSINE,
+  FILTER_TRIANGLE,
+  FILTER_ABS_BANDLIMIT,        // filter times |x| 
+  FILTER_ABS_SINC, 
+  FILTER_ABS_G_HAMMING,
+  FILTER_ABS_COSINE,
+  FILTER_SHEPP
+} FilterType;
+
+
+// Function domains 
+static const char D_FREQ_STR[]=    "freq";
+static const char D_SPATIAL_STR[]= "spatial";
+typedef enum {
+  D_FREQ = 1,
+  D_SPATIAL 
+} DomainType;
+
+
+/* interpolation methods */
+static const char O_INTERP_NEAREST_STR[]=  "nearest";
+static const char O_INTERP_LINEAR_STR[]=   "linear";
+static const char O_INTERP_BSPLINE_STR[]=  "bspline";
+
+#undef HAVE_BSPLINE_INTERP
+typedef enum {          // Interpolation methods
+    I_NEAREST = 1,      // Nearest neighbor
+#if HAVE_BSPLINE_INTERP
+    I_BSPLINE,
+    I_1BSPLINE,      // 1st order B-Spline 
+    I_2BSPLINE,
+    I_3BSPLINE,
+#endif
+    I_LINEAR        // Linear interpolation 
+} InterpolationType;
+
+
+// Trace levels
+static const char O_TRACE_NONE_STR[]=     "none";
+static const char O_TRACE_TEXT_STR[]=     "text";
+static const char O_TRACE_PHM_STR[]=      "phm";
+static const char O_TRACE_RAYS_STR[]=     "rays";
+static const char O_TRACE_PLOT_STR[]=     "plot";
+static const char O_TRACE_CLIPPING_STR[]= "clipping";
+
+enum {
+  TRACE_NONE,          /* No tracing */
+  TRACE_TEXT,          /* Minimal status */
+  TRACE_PHM,           /* Show phantom */
+  TRACE_RAYS,          /* Show all rays */
+  TRACE_PLOT,          /* Plot raysums */
+  TRACE_CLIPPING       /* Plot clipping */
+};
+
+// Standard phantomsa
+static const char O_PHM_HERMAN_STR[]=    "herman";
+static const char O_PHM_ROWLAND_STR[]=   "rowland";
+static const char O_PHM_BROWLAND_STR[]=  "browland";
+static const char O_PHM_UNITPULSE_STR[]= "unitpulse";
+typedef enum {
+  O_PHM_HERMAN,               /* Herman head phantom */
+  O_PHM_ROWLAND,              /* Rowland head phantom */
+  O_PHM_BROWLAND,             /* Bordered Rowland head phantom */
+  O_PHM_UNITPULSE             /* Unit pulse phantom */
+} PhantomType;
+
+// Backproject types
+static const char O_BPROJ_TRIG_STR[]=     "trig";
+static const char O_BPROJ_TABLE_STR[]=    "table";
+static const char O_BPROJ_DIFF_STR[]=     "diff";
+static const char O_BPROJ_DIFF2_STR[]=    "diff2";
+static const char O_BPROJ_IDIFF2_STR[]=   "idiff2";
+
+typedef  enum {
+  O_BPROJ_TRIG,
+  O_BPROJ_TABLE,
+  O_BPROJ_DIFF,
+  O_BPROJ_DIFF2,
+  O_BPROJ_IDIFF2
+} BackprojType;
+
+// Convolution symmetries
+typedef enum {
+    FUNC_EVEN = 1,    // function types, f[-n] = f[n] 
+    FUNC_ODD,         // f[-n] = -f[n] 
+    FUNC_BOTH         // function has both odd & even components 
+} FunctionSymmetry;
+
+
+
+#include "backprojectors.h"
+
+
+/*************************************************************************
+ *  FUNCTION DECLARATIONS
+ ************************************************************************/
+
+// convolve.cpp
+double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
+
+// dialogs.cpp 
+bool phm_add_pelem_kb (Phantom& phm);
+const Phantom& phm_select (Phantom& phm);
+int interpolation_select (void);
+int filter_select (double *filter_param);
+
+// filter.cpp 
+double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
+double filter_spatial_response_calc (int filt_type, double x, double bw, double param, int n);
+double filter_spatial_response_analytic (int filt_type, double x, double bw, double param);
+double filter_frequency_response (int filt_type, double u, double bw, double param);
+double sinc (double x, double mult);
+double integral_abscos(double u, double w);
+
+// options.cpp 
+int opt_set_trace(const char *optarg);
+const char *name_of_phantom(const int phmid);
+int opt_set_phantom(const char *optarg);
+InterpolationType opt_set_interpolation(const char *optarg);
+const char *name_of_interpolation(int interp_type);
+FilterType opt_set_filter(const char *optarg);
+const char *name_of_filter(const int filter);
+DomainType opt_set_filter_domain(const char *optarg);
+const char *name_of_filter_domain(const DomainType domain);
+BackprojType opt_set_backproj(const char *optarg);
+const char *name_of_backproj(const BackprojType backproj);
+
+// From phm2image.cpp 
+void phm_to_imagefile (const Phantom& phm, ImageFile& im, const int col_start, const int col_count, const int nsample, const int trace);
+
+// image.cpp 
+void image_filter_response(ImageFile& im, const DomainType domain, double bw, const FilterType filt_type, double filt_param, const int opt_trace);
+int image_display (const ImageFile& im);
+int image_display_scale (const ImageFile& im, const int scale, const double pmin, const double pmax);
+
+// From reconstr.cpp 
+ImageFile& proj_reconst (ImageFile& im, Projections& rs, const FilterType filt_type, double filt_param, InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace);
+
+#endif
+