Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

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

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]
 

Enumeration values:
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

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

Definition at line 43 of file gatan2io.cpp.

References gatanh, is_big_endian, and EMAN::ByteOrder::is_host_big_endian().

00044 :       filename(file), rw_mode(rw), gatan2_file(0), initialized(false)
00045 {
00046         is_big_endian = ByteOrder::is_host_big_endian();
00047         memset(&gatanh, 0, sizeof(Gatan2Header));
00048 }

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, 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 243 of file gatan2io.cpp.

References GATAN2_CHAR, GATAN2_FLOAT, GATAN2_INT, and GATAN2_SHORT.

00244 {
00245         switch (gatan_type) {
00246         case GATAN2_SHORT:
00247                 return EMUtil::EM_SHORT;
00248 
00249         case GATAN2_FLOAT:
00250                 return EMUtil::EM_FLOAT;
00251 
00252         case GATAN2_CHAR:
00253                 return EMUtil::EM_CHAR;
00254 
00255         case GATAN2_INT:
00256                 return EMUtil::EM_INT;
00257         }
00258 
00259         return EMUtil::EM_UNKNOWN;
00260 }


Member Data Documentation

EMAN::Gatan2IO::DEFINE_IMAGEIO_FUNC
 

Definition at line 55 of file gatan2io.h.

string EMAN::Gatan2IO::filename [private]
 

Definition at line 83 of file gatan2io.h.

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

Definition at line 85 of file gatan2io.h.

Referenced by ~Gatan2IO().

Gatan2Header EMAN::Gatan2IO::gatanh [private]
 

Definition at line 86 of file gatan2io.h.

Referenced by Gatan2IO().

bool EMAN::Gatan2IO::initialized [private]
 

Definition at line 89 of file gatan2io.h.

bool EMAN::Gatan2IO::is_big_endian [private]
 

Definition at line 88 of file gatan2io.h.

Referenced by Gatan2IO().

IOMode EMAN::Gatan2IO::rw_mode [private]
 

Definition at line 84 of file gatan2io.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:48:07 2013 for EMAN2 by  doxygen 1.3.9.1