EMAN2
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Attributes
EMAN::IcosIO Class Reference

ICOS file = header + data. More...

#include <icosio.h>

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

List of all members.

Classes

struct  IcosHeader

Public Member Functions

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

Static Public Member Functions

static bool is_valid (const void *first_block)

Public Attributes

 DEFINE_IMAGEIO_FUNC

Private Types

enum  { STAMP = 72, STAMP1 = 72, STAMP2 = 20, STAMP3 = 20 }

Private Attributes

string filename
IOMode rw_mode
IcosHeader icosh
FILE * icos_file
bool is_big_endian
bool initialized
bool is_new_file

Detailed Description

ICOS file = header + data.

1. header, defined in IcosHeader. 2. data: ny*nz of rows. Each row = n1 + row-data + n2 where n1: an integer. n1 = nx*sizeof(float). n2: an integer. n2 = n1. row-data: nx numbers of float points.

An Icos file stores 1 2D or 3D image.

Definition at line 54 of file icosio.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
STAMP 
STAMP1 
STAMP2 
STAMP3 

Definition at line 64 of file icosio.h.

                { STAMP = 72, STAMP1 = 72, STAMP2 = 20, STAMP3 = 20 };

Constructor & Destructor Documentation

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

Definition at line 44 of file icosio.cpp.

References icosh, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and is_new_file.

:       filename(file), rw_mode(rw), icos_file(0), initialized(false)
{
        is_big_endian = ByteOrder::is_host_big_endian();
        is_new_file = false;
        memset(&icosh, 0, sizeof(IcosHeader));
}
IcosIO::~IcosIO ( )

Definition at line 52 of file icosio.cpp.

References icos_file.

{
        if (icos_file) {
                fclose(icos_file);
                icos_file = 0;
        }
}

Member Function Documentation

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

Definition at line 84 of file icosio.cpp.

References data, ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), STAMP, STAMP1, STAMP2, STAMP3, and EMAN::ByteOrder::swap_bytes().

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

{
        ENTERFUNC;
        bool result = false;
        if (!first_block) {
                result = false;
        }
        else {
                const int *data = static_cast < const int *>(first_block);
                int stamp = data[0];
                int stamp1 = data[19];
                int stamp2 = data[20];
                int stamp3 = data[26];

                bool data_big_endian = ByteOrder::is_data_big_endian(&stamp);

                if (data_big_endian != ByteOrder::is_host_big_endian()) {
                        ByteOrder::swap_bytes(&stamp);
                        ByteOrder::swap_bytes(&stamp1);
                        ByteOrder::swap_bytes(&stamp2);
                        ByteOrder::swap_bytes(&stamp3);
                }

                if (stamp == STAMP && stamp1 == STAMP1 && stamp2 == STAMP2 && stamp3 == STAMP3) {
                        result = true;
                }
        }
        EXITFUNC;
        return result;
}

Member Data Documentation

Definition at line 60 of file icosio.h.

string EMAN::IcosIO::filename [private]

Definition at line 82 of file icosio.h.

FILE* EMAN::IcosIO::icos_file [private]

Definition at line 85 of file icosio.h.

Referenced by ~IcosIO().

Definition at line 84 of file icosio.h.

Referenced by IcosIO().

bool EMAN::IcosIO::initialized [private]

Definition at line 87 of file icosio.h.

Definition at line 86 of file icosio.h.

Referenced by IcosIO().

bool EMAN::IcosIO::is_new_file [private]

Definition at line 88 of file icosio.h.

Referenced by IcosIO().

Definition at line 83 of file icosio.h.


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