#include <lstio.h>
Inheritance diagram for EMAN::LstIO:


Public Member Functions | |
| LstIO (const string &filename, IOMode rw_mode=READ_ONLY) | |
| ~LstIO () | |
| bool | is_single_image_format () const |
| Is this image format only storing 1 image or not. | |
| int | get_nimg () |
| Return the number of images in this image file. | |
Static Public Member Functions | |
| bool | is_valid (const void *first_block) |
Public Attributes | |
| DEFINE_IMAGEIO_FUNC | |
Private Member Functions | |
| int | calc_ref_image_index (int image_index) |
Private Attributes | |
| string | filename |
| IOMode | rw_mode |
| FILE * | lst_file |
| bool | is_big_endian |
| bool | initialized |
| int | nimg |
| ImageIO * | imageio |
| string | ref_filename |
| int | last_lst_index |
| int | last_ref_index |
Static Private Attributes | |
| const char * | MAGIC = "#LST" |
Each line of a LST file has the following format: reference_image_index reference-image-filename comments
Definition at line 49 of file lstio.h.
|
||||||||||||
|
Definition at line 56 of file lstio.cpp. References imageio, initialized, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), last_lst_index, last_ref_index, nimg, and ref_filename. 00057 : filename(file), rw_mode(rw), lst_file(0) 00058 { 00059 is_big_endian = ByteOrder::is_host_big_endian(); 00060 initialized = false; 00061 nimg = 0; 00062 imageio = 0; 00063 ref_filename = ""; 00064 last_lst_index = -1; 00065 last_ref_index = -1; 00066 }
|
|
|
Definition at line 68 of file lstio.cpp. References imageio, lst_file, and ref_filename. 00069 {
00070 if (lst_file) {
00071 fclose(lst_file);
00072 lst_file = 0;
00073 }
00074 ref_filename = "";
00075 if(imageio) {
00076 delete imageio;
00077 imageio = 0;
00078 }
00079 }
|
|
|
Definition at line 131 of file lstio.cpp. References filename, EMAN::EMUtil::get_imageio(), imageio, last_lst_index, last_ref_index, LOGERR, lst_file, ref_filename, and rw_mode. 00132 {
00133 if (image_index == last_lst_index) {
00134 return last_ref_index;
00135 }
00136 else {
00137 char buf[MAXPATHLEN];
00138 int step = image_index - last_lst_index;
00139
00140 if (step < 0) {
00141 rewind(lst_file);
00142 step = image_index + 1;
00143 }
00144
00145 for (int i = 0; i < step; i++) {
00146 if (!fgets(buf, MAXPATHLEN, lst_file)) {
00147 LOGERR("reach EOF in file '%s' before reading %dth image",
00148 filename.c_str(), image_index);
00149 return 1;
00150 }
00151 if (buf[0] == '#') {
00152 i--;
00153 }
00154 }
00155 int ref_image_index = 0;
00156 char ref_image_path[MAXPATHLEN];
00157 char unused[256];
00158 sscanf(buf, " %d %s %[ .,0-9-]", &ref_image_index, ref_image_path, unused);
00159
00160 char fullpath[MAXPATHLEN];
00161
00162 char sep = '/';
00163 #ifdef WIN32
00164 sep = '\\';
00165 #endif
00166 if (ref_image_path[0] == sep) {
00167 strcpy(fullpath, ref_image_path);
00168 }
00169 else {
00170 if (strrchr(filename.c_str(), sep)) {
00171 strcpy(fullpath, filename.c_str());
00172 }
00173 else {
00174 #ifndef WIN32
00175 getcwd(fullpath, MAXPATHLEN);
00176 #else
00177 //GetCurrentDirectory(MAXPATHLEN, fullpath);
00178 #endif
00179 }
00180
00181 char *p_basename = strrchr(fullpath, sep);
00182 if (p_basename) {
00183 //p_basename++;
00184 //*p_basename = '\0';
00185 char ssep[2];
00186 ssep[0] = sep;
00187 ssep[1] = '\0';
00188 strcat(fullpath, ssep);
00189 strcat(fullpath, ref_image_path);
00190 }
00191 }
00192
00193 ref_filename = string(fullpath);
00194 imageio = EMUtil::get_imageio(ref_filename, rw_mode);
00195
00196 last_ref_index = ref_image_index;
00197 }
00198
00199 last_lst_index = image_index;
00200
00201 return last_ref_index;
00202 }
|
|
|
Return the number of images in this image file.
Reimplemented from EMAN::ImageIO. Definition at line 257 of file lstio.cpp. References EMAN::ImageIO::init(). 00258 {
00259 init();
00260 return nimg;
00261 }
|
|
|
Is this image format only storing 1 image or not. Some image formats like MRC only store 1 image in a file, so this function returns 'true' for them. Other image formats like IMAGIC/HDF5 may store mutliple images, so this function returns 'false' for them. Reimplemented from EMAN::ImageIO. Definition at line 58 of file lstio.h. 00059 {
00060 return false;
00061 }
|
|
|
Definition at line 115 of file lstio.cpp. References EMAN::Util::check_file_by_magic(), and MAGIC. Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type(). 00116 {
00117 ENTERFUNC;
00118 bool result = false;
00119
00120 if (!first_block) {
00121 result = false;
00122 }
00123 else {
00124 result = Util::check_file_by_magic(first_block, MAGIC);
00125 }
00126
00127 EXITFUNC;
00128 return result;
00129 }
|
|
|
|
|
|
Definition at line 64 of file lstio.h. Referenced by calc_ref_image_index(). |
|
|
Definition at line 72 of file lstio.h. Referenced by calc_ref_image_index(), LstIO(), and ~LstIO(). |
|
|
Definition at line 69 of file lstio.h. Referenced by LstIO(). |
|
|
Definition at line 68 of file lstio.h. Referenced by LstIO(). |
|
|
Definition at line 75 of file lstio.h. Referenced by calc_ref_image_index(), and LstIO(). |
|
|
Definition at line 76 of file lstio.h. Referenced by calc_ref_image_index(), and LstIO(). |
|
|
Definition at line 66 of file lstio.h. Referenced by calc_ref_image_index(), and ~LstIO(). |
|
|
Definition at line 54 of file lstio.cpp. Referenced by is_valid(). |
|
|
Definition at line 70 of file lstio.h. Referenced by LstIO(). |
|
|
Definition at line 73 of file lstio.h. Referenced by calc_ref_image_index(), LstIO(), and ~LstIO(). |
|
|
Definition at line 65 of file lstio.h. Referenced by calc_ref_image_index(). |
1.3.9.1