From 44988be2820a83554d63ba264383c9e87807abc8 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 7 Jun 2000 02:30:27 +0000 Subject: [PATCH] r73: Added C++ image files --- include/array2d.h | 2 +- include/ct.h | 7 +++-- include/imagefile.h | 70 +++++++++++++++++++++++++++++++-------------- include/ir.h | 46 +++++++++++++++-------------- 4 files changed, 78 insertions(+), 47 deletions(-) diff --git a/include/array2d.h b/include/array2d.h index 8d7cf4e..01c2729 100644 --- a/include/array2d.h +++ b/include/array2d.h @@ -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]; } diff --git a/include/ct.h b/include/ct.h index c3fe3a0..656a684 100644 --- a/include/ct.h +++ b/include/ct.h @@ -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 ** @@ -143,7 +146,7 @@ using namespace std; #include "array2d.h" - #include "idf.h" + #include "imagefile.h" #endif #endif diff --git a/include/imagefile.h b/include/imagefile.h index 0c2f8b5..098d0c7 100644 --- a/include/imagefile.h +++ b/include/imagefile.h @@ -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::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::labelRead (Array2dFileLabel& label, unsigned int label_num) template -bool +void Array2dFile::labelAdd (const char* const lstr, double calc_time=0.) { labelAdd (Array2dFileLabel::L_HISTORY, lstr, calc_time); } template -bool +void Array2dFile::labelAdd (int type, const char* const lstr, double calc_time=0.) { Array2dFileLabel label (type, lstr, calc_time); + labelAdd (label); +} + +template +void +Array2dFile::labelAdd (const Array2dFileLabel& label) +{ labelSeek (num_labels); write_nint16 (&label.label_type, file_id); @@ -535,49 +544,66 @@ Array2dFile::labelAdd (int type, const char* const lstr, double calc_time=0.) #endif +#ifdef MPI_CT +#include +#endif class F32Image { public: - Array2dFile idf; + Array2dFile 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::FLOAT32; + adf.pixel_type = Array2dFile::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::FLOAT32; + adf.pixel_type = Array2dFile::FLOAT32; } - F32Image (const char* const fname) : idf (fname) + F32Image (const char* const fname) : adf (fname) { - idf.pixel_type = Array2dFile::FLOAT32; + adf.pixel_type = Array2dFile::FLOAT32; } + +#ifdef MPI_CT + MPI_Datatype getMPIDataType (void) const + { return MPI_FLOAT; } +#endif }; class F64Image { public: - Array2dFile idf; + Array2dFile 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::FLOAT64; + adf.pixel_type = Array2dFile::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::FLOAT64; + adf.pixel_type = Array2dFile::FLOAT64; } - F64Image (const char* const fname) : idf (fname) + F64Image (const char* const fname) : adf (fname) { - idf.pixel_type = Array2dFile::FLOAT64; + adf.pixel_type = Array2dFile::FLOAT64; } }; -typedef F64Image ImageFile; +typedef F64Image ImageFile; +typedef kfloat64 ImageFileValue; +typedef kfloat64* ImageFileColumn; +typedef kfloat64** ImageFileArray; + diff --git a/include/ir.h b/include/ir.h index 0a04c79..5cbc9e2 100644 --- a/include/ir.h +++ b/include/ir.h @@ -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 ** @@ -85,23 +88,6 @@ #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 */ -- 2.34.1