EMAN::Gatan2IO Class Reference

Gatan2 Image file = header + data. More...

#include <gatan2io.h>

Inheritance diagram for EMAN::Gatan2IO:

Inheritance graph
[legend]
Collaboration diagram for EMAN::Gatan2IO:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Gatan2IO (const string &filename, IOMode rw_mode=READ_ONLY)
 ~Gatan2IO ()

Static Public Member Functions

static bool is_valid (const void *first_block)

Public Attributes

 DEFINE_IMAGEIO_FUNC

Private Types

enum  DataType {
  GATAN2_SHORT = 1, GATAN2_FLOAT = 2, GATAN2_COMPLEX = 3, GATAN2_PACKED_COMPLEX = 5,
  GATAN2_CHAR = 6, GATAN2_INT = 7, GATAN2_INVALID
}

Private Member Functions

int to_em_datatype (int gatan_type)

Private Attributes

string filename
IOMode rw_mode
FILE * gatan2_file
Gatan2Header gatanh
bool is_big_endian
bool initialized

Classes

struct  Gatan2Header


Detailed Description

Gatan2 Image file = header + data.

header is defined in Gatan2Header. data is nx by ny. A Gatan2 file contains 1 2D image.

Definition at line 49 of file gatan2io.h.


Member Enumeration Documentation

enum EMAN::Gatan2IO::DataType [private]

Enumerator:
GATAN2_SHORT 
GATAN2_FLOAT 
GATAN2_COMPLEX 
GATAN2_PACKED_COMPLEX 
GATAN2_CHAR 
GATAN2_INT 
GATAN2_INVALID 

Definition at line 58 of file gatan2io.h.

00059                 {
00060                         GATAN2_SHORT = 1,
00061                         GATAN2_FLOAT = 2,
00062                         GATAN2_COMPLEX = 3,
00063                         GATAN2_PACKED_COMPLEX = 5,
00064                         GATAN2_CHAR = 6,
00065                         GATAN2_INT = 7,
00066                         GATAN2_INVALID
00067                 };


Constructor & Destructor Documentation

EMAN::Gatan2IO::Gatan2IO ( const string &  filename,
IOMode  rw_mode = READ_ONLY 
) [explicit]

Gatan2IO::~Gatan2IO (  ) 

Definition at line 50 of file gatan2io.cpp.

References gatan2_file.

00051 {
00052         if (gatan2_file) {
00053                 fclose(gatan2_file);
00054                 gatan2_file = 0;
00055         }
00056 }


Member Function Documentation

bool Gatan2IO::is_valid ( const void *  first_block  )  [static]

Definition at line 86 of file gatan2io.cpp.

References data, ENTERFUNC, EXITFUNC, GATAN2_INVALID, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().

Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().

00087 {
00088         ENTERFUNC;
00089         bool result = false;
00090         
00091         if (!first_block) {
00092                 result = false;
00093         }
00094         else {
00095                 const short *data = static_cast < const short *>(first_block);
00096                 short len = data[5];
00097                 short type = data[6];
00098 
00099                 bool data_big_endian = ByteOrder::is_data_big_endian(&len);
00100 
00101                 if (data_big_endian != ByteOrder::is_host_big_endian()) {
00102                         ByteOrder::swap_bytes(&len);
00103                         ByteOrder::swap_bytes(&type);
00104                 }
00105 
00106                 int double_size = sizeof(double);
00107                 if (len > 0 && len <= double_size && type > 0 && type <= GATAN2_INVALID) {
00108                         result = true;
00109                 }
00110         }
00111         EXITFUNC;
00112         return result;
00113 }

int Gatan2IO::to_em_datatype ( int  gatan_type  )  [private]

Definition at line 236 of file gatan2io.cpp.

References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_INT, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_UNKNOWN, GATAN2_CHAR, GATAN2_FLOAT, GATAN2_INT, and GATAN2_SHORT.

00237 {
00238         switch (gatan_type) {
00239         case GATAN2_SHORT:
00240                 return EMUtil::EM_SHORT;
00241 
00242         case GATAN2_FLOAT:
00243                 return EMUtil::EM_FLOAT;
00244 
00245         case GATAN2_CHAR:
00246                 return EMUtil::EM_CHAR;
00247 
00248         case GATAN2_INT:
00249                 return EMUtil::EM_INT;
00250         }
00251 
00252         return EMUtil::EM_UNKNOWN;
00253 }


Member Data Documentation

Definition at line 55 of file gatan2io.h.

string EMAN::Gatan2IO::filename [private]

Definition at line 83 of file gatan2io.h.

Definition at line 84 of file gatan2io.h.

FILE* EMAN::Gatan2IO::gatan2_file [private]

Definition at line 85 of file gatan2io.h.

Referenced by ~Gatan2IO().

Definition at line 86 of file gatan2io.h.

Definition at line 88 of file gatan2io.h.

Definition at line 89 of file gatan2io.h.


The documentation for this class was generated from the following files:

Generated on Sat Nov 21 02:20:21 2009 for EMAN2 by  doxygen 1.5.6