#include <emio.h>
Inheritance diagram for EMAN::EmIO:
Public Member Functions | |
EmIO (const string &filename, IOMode rw_mode=READ_ONLY) | |
~EmIO () | |
Static Public Member Functions | |
bool | is_valid (const void *first_block, off_t file_size=0) |
size_t | get_mode_size (char data_type) |
int | get_machine_type () |
int | to_em_datatype (char t) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Private Types | |
enum | DataType { EM_EM_CHAR = 1, EM_EM_SHORT = 2, EM_EM_INT = 4, EM_EM_FLOAT = 5, EM_EM_COMPLEX = 8, EM_EM_DOUBLE = 9, EM_EM_UNKNOWN } |
enum | MachineType { EM_OS8 = 0, EM_VAX = 1, EM_CONVEX = 2, EM_SGI = 3, EM_MAC = 5, EM_PC = 6, EM_UNKNOWN_MACHINE } |
Private Attributes | |
string | filename |
IOMode | rw_mode |
FILE * | em_file |
EMHeader | emh |
size_t | mode_size |
DataType | mode |
bool | is_big_endian |
bool | initialized |
bool | is_new_file |
EM image = header + data with (data = nx * ny * nz).
An EM image file stores 1 single 2D or 3D image.
Definition at line 48 of file emio.h.
|
Definition at line 77 of file emio.h. Referenced by to_em_datatype(). 00078 { 00079 EM_EM_CHAR = 1, 00080 EM_EM_SHORT = 2, 00081 EM_EM_INT = 4, 00082 EM_EM_FLOAT = 5, 00083 EM_EM_COMPLEX = 8, 00084 EM_EM_DOUBLE = 9, 00085 EM_EM_UNKNOWN 00086 };
|
|
Definition at line 88 of file emio.h. 00089 { 00090 EM_OS8 = 0, 00091 EM_VAX = 1, 00092 EM_CONVEX = 2, 00093 EM_SGI = 3, 00094 EM_MAC = 5, 00095 EM_PC = 6, 00096 EM_UNKNOWN_MACHINE 00097 };
|
|
Definition at line 43 of file emio.cpp. References emh, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_file, mode, and mode_size. 00044 : filename(file), rw_mode(rw), em_file(0), initialized(false) 00045 { 00046 mode_size = 0; 00047 mode = EM_EM_UNKNOWN; 00048 is_big_endian = ByteOrder::is_host_big_endian(); 00049 is_new_file = false; 00050 memset(&emh, 0, sizeof(EMHeader)); 00051 }
|
|
Definition at line 53 of file emio.cpp. References em_file. 00054 { 00055 if (em_file) { 00056 fclose(em_file); 00057 em_file = 0; 00058 } 00059 }
|
|
Definition at line 331 of file emio.cpp. 00332 { 00333 int m = EM_UNKNOWN_MACHINE; 00334 #ifdef __sgi 00335 m = EM_SGI; 00336 #elif defined __linux__ 00337 m = EM_PC; 00338 #elif defined __CYGWIN__ 00339 m = EM_PC; 00340 #elif defined WIN32 00341 m = EM_PC; 00342 #elif defined MACOS 00343 m = EM_MAC; 00344 #elif defined macintosh 00345 m = EM_MAC; 00346 #elif defined __darwin__ 00347 m = EM_MAC; 00348 #elif defined __APPLE__ 00349 m = EM_MAC; 00350 #else 00351 m = EM_UNKNOWN_MACHINE; 00352 #endif 00353 return m; 00354 }
|
|
Definition at line 356 of file emio.cpp. References EM_EM_CHAR, EM_EM_COMPLEX, EM_EM_DOUBLE, EM_EM_FLOAT, EM_EM_INT, EM_EM_SHORT, and mode. Referenced by is_valid(). 00357 { 00358 int mode = (int) data_type; 00359 switch (mode) { 00360 case EM_EM_CHAR: 00361 return sizeof(char); 00362 case EM_EM_SHORT: 00363 return sizeof(short); 00364 case EM_EM_INT: 00365 case EM_EM_FLOAT: 00366 case EM_EM_COMPLEX: 00367 return sizeof(int); 00368 case EM_EM_DOUBLE: 00369 return sizeof(double); 00370 } 00371 return 0; 00372 }
|
|
Definition at line 100 of file emio.cpp. References data, EM_EM_CHAR, EM_OS8, get_mode_size(), EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), nx, ny, and EMAN::ByteOrder::swap_bytes(). Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type(). 00101 { 00102 ENTERFUNC; 00103 00104 if (!first_block) { 00105 return false; 00106 } 00107 00108 const char *data = static_cast < const char *>(first_block); 00109 char machine = data[0]; 00110 char is_new_ver = data[1]; 00111 char data_type = data[3]; 00112 00113 const int *data1 = static_cast < const int *>(first_block); 00114 int nx = data1[1]; 00115 int ny = data1[2]; 00116 int nz = data1[3]; 00117 00118 bool data_big_endian = ByteOrder::is_data_big_endian(&nz); 00119 if (data_big_endian != ByteOrder::is_host_big_endian()) { 00120 ByteOrder::swap_bytes(&nx); 00121 ByteOrder::swap_bytes(&ny); 00122 ByteOrder::swap_bytes(&nz); 00123 } 00124 00125 const int max_dim = 1 << 20; 00126 00127 if (((int) machine >= EM_OS8 && machine <= EM_PC) && 00128 (is_new_ver == 0 || is_new_ver == 1) && 00129 (data_type >= EM_EM_CHAR && data_type <= EM_EM_DOUBLE) && 00130 (nx > 1 && nx < max_dim) && (ny > 0 && ny < max_dim) && (nz > 0 && nz < max_dim)) { 00131 if (file_size > 0) { 00132 off_t file_size1 = (off_t)nx * (off_t)ny * (off_t)nz * (off_t)get_mode_size(data_type) + (off_t)sizeof(EMHeader); 00133 if (file_size == file_size1) { 00134 return true; 00135 } 00136 } 00137 else { 00138 return true; 00139 } 00140 } 00141 00142 return false; 00143 }
|
|
Definition at line 309 of file emio.cpp. References DataType, EM_EM_CHAR, EM_EM_COMPLEX, EM_EM_DOUBLE, EM_EM_FLOAT, EM_EM_INT, and EM_EM_SHORT. 00310 { 00311 DataType type = static_cast < DataType > (t); 00312 switch (type) { 00313 case EM_EM_CHAR: 00314 return EMUtil::EM_CHAR; 00315 case EM_EM_SHORT: 00316 return EMUtil::EM_SHORT; 00317 case EM_EM_INT: 00318 return EMUtil::EM_INT; 00319 case EM_EM_FLOAT: 00320 return EMUtil::EM_FLOAT; 00321 case EM_EM_DOUBLE: 00322 return EMUtil::EM_DOUBLE; 00323 case EM_EM_COMPLEX: 00324 return EMUtil::EM_FLOAT_COMPLEX; 00325 default: 00326 break; 00327 } 00328 return EMUtil::EM_UNKNOWN; 00329 }
|
|
|
|
Definition at line 102 of file emio.h. Referenced by ~EmIO(). |
|
Definition at line 103 of file emio.h. Referenced by EmIO(). |
|
|
|
|
|
Definition at line 107 of file emio.h. Referenced by EmIO(). |
|
Definition at line 109 of file emio.h. Referenced by EmIO(). |
|
Definition at line 106 of file emio.h. Referenced by EmIO(), and get_mode_size(). |
|
Definition at line 105 of file emio.h. Referenced by EmIO(). |
|
|