00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef eman__pifio_h__
00037 #define eman__pifio_h__ 1
00038
00039 #include "imageio.h"
00040
00041 namespace EMAN
00042 {
00056 class PifIO:public ImageIO
00057 {
00058 public:
00059 explicit PifIO(const string & filename, IOMode rw_mode = READ_ONLY);
00060 ~PifIO();
00061
00062 DEFINE_IMAGEIO_FUNC;
00063 static bool is_valid(const void *first_block);
00064
00065 bool is_single_image_format() const
00066 {
00067 return false;
00068 }
00069 int get_nimg();
00070
00071 private:
00072 enum
00073 {
00074 PIF_MAGIC_NUM = 8
00075 };
00076
00077 enum PifDataMode
00078 {
00079 PIF_CHAR = 0,
00080 PIF_SHORT = 1,
00081 PIF_FLOAT_INT = 2,
00082 PIF_SHORT_COMPLEX = 3,
00083 PIF_FLOAT_INT_COMPLEX = 4,
00084 PIF_BOXED_DATA = 6,
00085 PIF_SHORT_FLOAT = 7,
00086 PIF_SHORT_FLOAT_COMPLEX = 8,
00087 PIF_FLOAT = 9,
00088 PIF_FLOAT_COMPLEX = 10,
00089 PIF_MAP_FLOAT_SHORT = 20,
00090 PIF_MAP_FLOAT_INT = 21,
00091 PIF_INVALID
00092 };
00093
00094
00095
00096 struct PifFileHeader
00097 {
00098 int magic[2];
00099 char scalefactor[16];
00100 int nimg;
00101 int endian;
00102 char program[32];
00103 int htype;
00104 int nx;
00105 int ny;
00106 int nz;
00107 int mode;
00108 int pad[107];
00109 };
00110
00111 struct PifColorMap
00112 {
00113 short r[256];
00114 short g[256];
00115 short b[256];
00116 };
00117
00118 struct PifImageHeader
00119 {
00120 int nx;
00121 int ny;
00122 int nz;
00123 int mode;
00124 int bkg;
00125 int radius;
00126 int xstart;
00127 int ystart;
00128 int zstart;
00129 int mx;
00130 int my;
00131 int mz;
00132 int xlen;
00133 int ylen;
00134 int zlen;
00135 int alpha;
00136 int beta;
00137 int gamma;
00138 int mapc;
00139 int mapr;
00140 int maps;
00141 int min;
00142 int max;
00143 int mean;
00144 int sigma;
00145 int ispg;
00146 int nsymbt;
00147 int xorigin;
00148 int yorigin;
00149 char title[80];
00150 char time[32];
00151 char imagenum[16];
00152 char scannum[8];
00153 int aoverb;
00154 int mapabang;
00155 int pad[63];
00156 };
00157
00158 int get_mode_size(PifDataMode mode);
00159 bool is_float_int(int mode);
00160 void fseek_to(int image_index);
00161 int to_em_datatype(int pif_datatype);
00162 int to_pif_datatype(int em_datatype);
00163
00164 string filename;
00165 IOMode rw_mode;
00166 PifFileHeader pfh;
00167 FILE *pif_file;
00168 int mode_size;
00169 bool is_big_endian;
00170 bool initialized;
00171 bool is_new_file;
00172 float real_scale_factor;
00173 };
00174
00175 }
00176
00177
00178 #endif //eman__pifio_h__