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

EMAN::EmimIO Class Reference

EMIM image format = 1 EmimFileHeader + n x (EmimImageHeader + data). More...

#include <emimio.h>

Inheritance diagram for EMAN::EmimIO:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EmimIO (const string &filename, IOMode rw_mode=READ_ONLY)
 ~EmimIO ()
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 Types

enum  { EMIM_COMPLEX = 1, PARM_NONE = 0, PARM_NORM = 1, NUM_INT_IN_FILE_HEADER = 16 }

Private Attributes

string filename
IOMode rw_mode
EmimFileHeader efh
FILE * emim_file
bool is_big_endian
bool initialized

Static Private Attributes

const char * MAGIC = "EMIM"

Detailed Description

EMIM image format = 1 EmimFileHeader + n x (EmimImageHeader + data).

EmimFileHeader defines the number of images 'n' in the file. All following images have the same dimensions:nx x ny x nz.

Definition at line 48 of file emimio.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
EMIM_COMPLEX 
PARM_NONE 
PARM_NORM 
NUM_INT_IN_FILE_HEADER 

Definition at line 66 of file emimio.h.

00067                 {
00068                         EMIM_COMPLEX = 1,
00069                         PARM_NONE = 0,
00070                         PARM_NORM = 1,
00071                         NUM_INT_IN_FILE_HEADER = 16
00072                 };


Constructor & Destructor Documentation

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

Definition at line 44 of file emimio.cpp.

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

00045 :       filename(file), rw_mode(rw), emim_file(0), initialized(false)
00046 {
00047         is_big_endian = ByteOrder::is_host_big_endian();
00048         memset(&efh, 0, sizeof(EmimFileHeader));
00049 }

EmimIO::~EmimIO  ) 
 

Definition at line 51 of file emimio.cpp.

References emim_file.

00052 {
00053         if (emim_file) {
00054                 fclose(emim_file);
00055                 emim_file = 0;
00056         }
00057 }


Member Function Documentation

int EmimIO::get_nimg  )  [virtual]
 

Return the number of images in this image file.

Reimplemented from EMAN::ImageIO.

Definition at line 212 of file emimio.cpp.

References EMAN::EmimIO::EmimFileHeader::count, efh, and EMAN::ImageIO::init().

00213 {
00214         init();
00215         return efh.count;
00216 }

bool EMAN::EmimIO::is_single_image_format  )  const [inline, virtual]
 

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 emimio.h.

00059                 {
00060                         return false;
00061                 }

bool EmimIO::is_valid const void *  first_block  )  [static]
 

Definition at line 86 of file emimio.cpp.

References data, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), MAGIC, and EMAN::ByteOrder::swap_bytes().

00087 {
00088         ENTERFUNC;
00089 
00090         if (!first_block) {
00091                 return false;
00092         }
00093 
00094         const char *data = static_cast < const char *>(first_block);
00095         const int *idata = static_cast < const int *>(first_block);
00096         int count = idata[2];
00097 
00098         if (strncmp(data, MAGIC, sizeof(MAGIC)) == 0) {
00099                 bool data_big_endian = ByteOrder::is_data_big_endian(&count);
00100 
00101                 if (data_big_endian != ByteOrder::is_host_big_endian()) {
00102                         ByteOrder::swap_bytes(&count);
00103                 }
00104 
00105                 if (count >= 0 && count <= 1 << 20) {
00106                         return true;
00107                 }
00108         }
00109         EXITFUNC;
00110         return false;
00111 }


Member Data Documentation

EMAN::EmimIO::DEFINE_IMAGEIO_FUNC
 

Definition at line 54 of file emimio.h.

EmimFileHeader EMAN::EmimIO::efh [private]
 

Definition at line 108 of file emimio.h.

Referenced by EmimIO(), and get_nimg().

FILE* EMAN::EmimIO::emim_file [private]
 

Definition at line 109 of file emimio.h.

Referenced by ~EmimIO().

string EMAN::EmimIO::filename [private]
 

Definition at line 106 of file emimio.h.

bool EMAN::EmimIO::initialized [private]
 

Definition at line 111 of file emimio.h.

bool EMAN::EmimIO::is_big_endian [private]
 

Definition at line 110 of file emimio.h.

Referenced by EmimIO().

const char * EmimIO::MAGIC = "EMIM" [static, private]
 

Definition at line 42 of file emimio.cpp.

Referenced by is_valid().

IOMode EMAN::EmimIO::rw_mode [private]
 

Definition at line 107 of file emimio.h.


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