00001
00002
00003
00004
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 #include "io_template.h"
00033 #include "portable_fileio.h"
00034
00035 using namespace EMAN;
00036
00037 XYZIO::XYZIO(const string & file, IOMode rw)
00038 : filename(file), rw_mode(rw), xyz_file(0), initialized(false)
00039 {
00040 is_big_endian = ByteOrder::is_host_big_endian();
00041 }
00042
00043 XYZIO::~XYZIO()
00044 {
00045 if (xyz_file) {
00046 fclose(xyz_file);
00047 xyz_file = 0;
00048 }
00049 }
00050
00051 void XYZIO::init()
00052 {
00053 if (initialized) {
00054 return ;
00055 }
00056
00057 ENTERFUNC;
00058
00059 initialized = true;
00060 bool is_new_file = false;
00061 xyz_file = sfopen(filename, rw_mode, &is_new_file);
00062
00063 if (!is_new_file) {
00064
00065 }
00066
00067 EXITFUNC;
00068 }
00069
00070 bool XYZIO::is_valid(const void *first_block)
00071 {
00072 ENTERFUNC;
00073 bool result = false;
00074 if (!first_block) {
00075 result = false;
00076 }
00077
00078
00079
00080 EXITFUNC;
00081 return result;
00082 }
00083
00084 int XYZIO::read_header(Dict & , int image_index, const Region * , bool )
00085 {
00086 ENTERFUNC;
00087 check_read_access(image_index);
00088
00089
00090
00091 EXITFUNC;
00092 return 0;
00093 }
00094
00095 int XYZIO::write_header(const Dict & , int image_index, const Region *,
00096 EMUtil::EMDataType , bool)
00097 {
00098 ENTERFUNC;
00099 check_write_access(rw_mode, image_index);
00100
00101 EXITFUNC;
00102 return 0;
00103 }
00104
00105 int XYZIO::read_data(float *data, int image_index, const Region * , bool )
00106 {
00107 ENTERFUNC;
00108 check_read_access(image_index, data);
00109
00110
00111
00112 EXITFUNC;
00113 return 0;
00114 }
00115
00116 int XYZIO::write_data(float *data, int image_index, const Region *,
00117 EMUtil::EMDataType , bool)
00118 {
00119 ENTERFUNC;
00120 check_write_access(rw_mode, image_index, 0, data);
00121
00122
00123
00124 EXITFUNC;
00125 return 0;
00126 }
00127
00128 void XYZIO::flush()
00129 {
00130 if (xyz_file) {
00131 fflush(xyz_file);
00132 }
00133 }
00134
00135 bool XYZIO::is_complex_mode()
00136 {
00137 return false;
00138 }
00139
00140 bool XYZIO::is_image_big_endian()
00141 {
00142 return is_big_endian;
00143 }
00144
00145 int XYZIO::get_nimg()
00146 {
00147 init();
00148
00149 return 1;
00150 }