r73: Added C++ image files
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 02:30:27 +0000 (02:30 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 7 Jun 2000 02:30:27 +0000 (02:30 +0000)
include/array2d.h
include/ct.h
include/imagefile.h
include/ir.h

index 8d7cf4e3c4f3c577ebef27db3669ba17fb98cbc7..01c272982d031c373bc809410fe3fe8a7b5e22bb 100644 (file)
@@ -19,7 +19,7 @@ class Array2d {
            ny = y;
            array_data = new T*[nx];
            
-           for (int i = 0; i < nx; i++)
+           for (unsigned int i = 0; i < nx; i++)
                array_data[i] = new T[ny];
        }
 
index c3fe3a0fcc34833e86df73df24a08a8539ce4267..656a684d853f9d8bf7b04328148af64e031f6913 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ct.h,v 1.7 2000/06/07 00:59:38 kevin Exp $
+**  $Id: ct.h,v 1.8 2000/06/07 02:30:27 kevin Exp $
 **  $Log: ct.h,v $
+**  Revision 1.8  2000/06/07 02:30:27  kevin
+**  Added C++ image files
+**
 **  Revision 1.7  2000/06/07 00:59:38  kevin
 **  added imagefiles
 **
   using namespace std;
 
   #include "array2d.h"
-  #include "idf.h"
+  #include "imagefile.h"
 #endif
 
 #endif
index 0c2f8b5c990c0ce8c88d6a35c1ee290520fe42e2..098d0c7272c585291cbe9998c148786f06c067ad 100644 (file)
@@ -98,14 +98,16 @@ public:
   Array2dFile (const char* const filename, unsigned int nx, unsigned int ny);
   ~Array2dFile ();
 
-  virtual unsigned int getNumLabels (void) const
-  { return num_labels; }
+  unsigned int getNumLabels (void) const
+      { return num_labels; }
 
   bool labelRead (Array2dFileLabel& label, unsigned int label_num);
 
-  bool labelAdd (const char* const label_str, double calc_time=0.);
+  void labelAdd (const Array2dFileLabel& label);
 
-  bool labelAdd (int type, const char* const label_str, double calc_time=0.);
+  void labelAdd (const char* const label_str, double calc_time=0.);
+
+  void labelAdd (int type, const char* const label_str, double calc_time=0.);
 
   void fileClose (void);
 
@@ -382,7 +384,7 @@ Array2dFile<T>::arrayDataWrite (void)
   }
 
   lseek (file_id, headersize, SEEK_SET);
-  for (int ix = 0; ix < nx; ix++)
+  for (unsigned int ix = 0; ix < nx; ix++)
     {
       write (file_id, array->array_data[ix], ny * pixel_size);
     }
@@ -500,18 +502,25 @@ Array2dFile<T>::labelRead (Array2dFileLabel& label, unsigned int label_num)
 
 
 template<class T>
-bool
+void
 Array2dFile<T>::labelAdd (const char* const lstr, double calc_time=0.)
 {
   labelAdd (Array2dFileLabel::L_HISTORY, lstr, calc_time);
 }
 
 template<class T>
-bool
+void
 Array2dFile<T>::labelAdd (int type, const char* const lstr, double calc_time=0.)
 {
   Array2dFileLabel label (type, lstr, calc_time);
 
+  labelAdd (label);
+}
+
+template<class T>
+void
+Array2dFile<T>::labelAdd (const Array2dFileLabel& label)
+{
   labelSeek (num_labels);
   
   write_nint16 (&label.label_type, file_id);
@@ -535,49 +544,66 @@ Array2dFile<T>::labelAdd (int type, const char* const lstr, double calc_time=0.)
 
 #endif
 
+#ifdef MPI_CT
+#include <mpi.h>
+#endif
 
 class F32Image
 {
 public:
-  Array2dFile<kfloat32> idf;
+  Array2dFile<kfloat32> adf;
 
-  F32Image (const char* const fname, unsigned int nx, unsigned int ny) : idf (fname, nx, ny)
+  F32Image (const char* const fname, unsigned int nx, unsigned int ny) : adf (fname, nx, ny)
   {
-      idf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
+      adf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
   }
 
-  F32Image (unsigned int nx, unsigned int ny) : idf (nx, ny)
+  F32Image (unsigned int nx, unsigned int ny) : adf (nx, ny)
   {
-      idf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
+      adf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
   }
 
-  F32Image (const char* const fname) : idf (fname)
+  F32Image (const char* const fname) : adf (fname)
   {
-      idf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
+      adf.pixel_type = Array2dFile<kfloat32>::FLOAT32;
   }
+
+#ifdef MPI_CT
+  MPI_Datatype getMPIDataType (void) const
+      { return MPI_FLOAT; }
+#endif
 };
 
 class F64Image 
 {
 public:
-  Array2dFile<kfloat64> idf;
+  Array2dFile<kfloat64> adf;
+
+#ifdef MPI_CT
+  MPI_Datatype getMPIDataType (void) const
+      { return MPI_DOUBLE; }
+#endif
 
-  F64Image (const char* const fname, unsigned int nx, unsigned int ny) : idf (fname, nx, ny)
+  F64Image (const char* const fname, unsigned int nx, unsigned int ny) : adf (fname, nx, ny)
   {
-      idf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
+      adf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
   }
 
-  F64Image (unsigned int nx, unsigned int ny) : idf (nx, ny)
+  F64Image (unsigned int nx, unsigned int ny) : adf (nx, ny)
   {
-      idf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
+      adf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
   }
 
-  F64Image (const char* const fname) : idf (fname)
+  F64Image (const char* const fname) : adf (fname)
   {
-      idf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
+      adf.pixel_type = Array2dFile<kfloat64>::FLOAT64;
   }
 };
 
-typedef F64Image ImageFile;
+typedef F64Image   ImageFile;
+typedef kfloat64   ImageFileValue;
+typedef kfloat64*  ImageFileColumn;
+typedef kfloat64** ImageFileArray;
+
 
 
index 0a04c795d74bb149107c832af9b31cbf329711a5..5cbc9e21cfcb9be1d1164f79b6a74b89666e119c 100644 (file)
@@ -2,8 +2,11 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ir.h,v 1.19 2000/06/07 00:59:38 kevin Exp $
+**  $Id: ir.h,v 1.20 2000/06/07 02:30:27 kevin Exp $
 **  $Log: ir.h,v $
+**  Revision 1.20  2000/06/07 02:30:27  kevin
+**  Added C++ image files
+**
 **  Revision 1.19  2000/06/07 00:59:38  kevin
 **  added imagefiles
 **
 #ifndef IR_H
 #define IR_H
 
-#ifdef MPI_CT
-#define MPI_MAX_PROCESS 128 
-struct mpi_ct_st
-{
-  int my_rank;
-  int nproc;
-  int base_local_work_units;
-  int remainder_work_units;
-  int local_work_units[MPI_MAX_PROCESS];
-  int start_work_unit[MPI_MAX_PROCESS];
-  MPI_Comm comm;
-};
-
-extern struct mpi_ct_st mpi_ct;
-void mpi_ct_calc_work_units(const unsigned int global_work_units);
-#endif
-
 
 struct histo_st {
     int *b;                    /* Histogram array (# of elements in each bin) */
@@ -373,7 +359,23 @@ const static int RAYSUM_TRACE_ROW_ATTEN=18;
 extern "C" {
 #endif /* __cplusplus */
 
-void usage (const char *program);
+#ifdef MPI_CT
+#define MPI_MAX_PROCESS 128 
+struct mpi_ct_st
+{
+  int my_rank;
+  int nproc;
+  int base_local_work_units;
+  int remainder_work_units;
+  int local_work_units[MPI_MAX_PROCESS];
+  int start_work_unit[MPI_MAX_PROCESS];
+  MPI_Comm comm;
+};
+
+extern struct mpi_ct_st mpi_ct;
+void mpi_ct_calc_work_units(const unsigned int global_work_units);
+#endif
+
 
 /* From reconstr.c */
 IMAGE *image_reconst (IMAGE *im, RAYSUM *rs, const FilterType filt_type, double filt_param, InterpolationType interp_type, int interp_param, const BackprojType backproj_type, int const ir_trace);
@@ -443,13 +445,13 @@ int image_display_scale (const IMAGE *im, const int scale, const double pmin, co
 int opt_set_trace(const char *optarg);
 const char *name_of_phantom(const int phmid);
 int opt_set_phantom(const char *optarg);
-int opt_set_interpolation(const char *optarg);
+InterpolationType opt_set_interpolation(const char *optarg);
 const char *name_of_interpolation(int interp_type);
-int opt_set_filter(const char *optarg);
+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);
-int opt_set_backproj(const char *optarg);
+BackprojType opt_set_backproj(const char *optarg);
 const char *name_of_backproj(const BackprojType backproj);
 
 /* phm.c */