Public Member Functions | Private Member Functions | Private Attributes
vil_dicom_header_format Class Reference

A class to read and write the header part of a dicom file. More...

#include <vil_dicom_header.h>

List of all members.

Public Member Functions

 vil_dicom_header_format ()
 ~vil_dicom_header_format ()
bool isDicomFormat (vil_stream &)
 True if it is known DICOM format.
vil_dicom_header_info readHeader (vil_stream &fs)
 Read the dicom header into a header struct.
vil_dicom_header_info lastHeader (void)
 Method to return the last struct of header info set.
bool headerValid (void)
 Method to indicate if the header info held is valid or not.
vil_dicom_header_endian systemEndian (void)
 Return the current system endian.
vil_dicom_header_endian fileEndian (void)
 Return the endian of the header being read.
vil_dicom_header_image_type imageType (void)
 Return any encapsulated image type.

Private Member Functions

vil_dicom_header_type determineFileType (vil_stream &fs)
 Method to determine the file type.
void readHeaderElements (vil_stream &fs)
 Method to read the elements from the header.
void readIdentifyingElements (short element, int dblock_size, vil_stream &fs)
 Method to read the identifying group's details.
void readPatientElements (short element, int dblock_size, vil_stream &fs)
 Method to read the patient details.
void readAcquisitionElements (short element, int dblock_size, vil_stream &fs)
 Method to read the acquisition group's details.
void readRelationshipElements (short element, int dblock_size, vil_stream &fs)
 Method to read the relationship group's details.
void readImageElements (short element, int dblock_size, vil_stream &fs)
 Method to read the image group's details.
void readDelimiterElements (short element, int dblock_size, vil_stream &fs)
 Method to read the delimiter group's details.
bool convertValueRepresentation (unsigned int &dblock_size, vil_stream &ifs)
 Method to convert the Value Representation (VR) (if it exists).
bool pixelDataFound (short group, short element)
 Method to determine whether or not the actual pixel data has been reached.
void clearInfo (void)
vil_dicom_header_endian calculateEndian (void)
 Work out whether the current architecture is big or little endian.
vil_dicom_header_endian determineMetaInfo (vil_stream &fs)
 Initialise all the necessary meta-file stuff.
vxl_uint_16 shortSwap (vxl_uint_16 short_in)
 Method to byte swap an unsigned short int if necessary.
vxl_uint_32 intSwap (vxl_uint_32 int_in)
 Method to byte swap an unsigned int if necessary.
void charSwap (char *char_in, int val_size)
 Method to swap a number inside a char array.

Private Attributes

vil_dicom_header_info last_read_
 Holds the info from the last header read.
bool info_valid_
 TRUE if the header info is valid (i.e. has been read) otherwise FALSE.
vil_dicom_header_endian endian_
 A variable to hold the discovered architecture endian.
vil_dicom_header_endian file_endian_
 A variable to hold the current header file's endian.
vil_dicom_header_image_type image_type_
 A variable to hole the current encapsulate file type (if any).

Detailed Description

A class to read and write the header part of a dicom file.

This class reads and writes the header section of a dicom file, determining the type and storing the information in a dicom structure.

Definition at line 463 of file vil_dicom_header.h.


Constructor & Destructor Documentation

vil_dicom_header_format::vil_dicom_header_format ( )
vil_dicom_header_format::~vil_dicom_header_format ( )

Member Function Documentation

vil_dicom_header_endian vil_dicom_header_format::calculateEndian ( void  ) [private]

Work out whether the current architecture is big or little endian.

Returns:
The system endian value calculated
See also:
systemEndian() and endian_()
void vil_dicom_header_format::charSwap ( char *  char_in,
int  val_size 
) [private]

Method to swap a number inside a char array.

Parameters:
char_inThe char array to swap - on exit contains the result
val_sizeThe size of the var to swap
void vil_dicom_header_format::clearInfo ( void  ) [private]
bool vil_dicom_header_format::convertValueRepresentation ( unsigned int &  dblock_size,
vil_stream ifs 
) [private]

Method to convert the Value Representation (VR) (if it exists).

Parameters:
data_blockContains the VR or data block size (always holds the data block size on exit
fsThe file stream to read from
See also:
readHeaderElements()
vil_dicom_header_type vil_dicom_header_format::determineFileType ( vil_stream fs) [private]

Method to determine the file type.

Parameters:
fsThe file stream for the image to test
Returns:
The dicom file type or unknown
vil_dicom_header_endian vil_dicom_header_format::determineMetaInfo ( vil_stream fs) [private]

Initialise all the necessary meta-file stuff.

Returns:
The endian of the file
See also:
fileEndian(), file_endian_(), imageType(), and image_type_();
vil_dicom_header_endian vil_dicom_header_format::fileEndian ( void  )

Return the endian of the header being read.

Returns:
The endian of the file currently being read.
See also:
determineMetaInfo() and file_endian_()
bool vil_dicom_header_format::headerValid ( void  )

Method to indicate if the header info held is valid or not.

Returns:
TRUE if the header info is valid, otherwise false
vil_dicom_header_image_type vil_dicom_header_format::imageType ( void  )

Return any encapsulated image type.

Returns:
The encapsulated image type of the file currently being read.
vxl_uint_32 vil_dicom_header_format::intSwap ( vxl_uint_32  int_in) [private]

Method to byte swap an unsigned int if necessary.

Parameters:
int_inThe unsigned int to swap
Returns:
The swapped unsigned int
See also:
shortSwap() and charSwap()
bool vil_dicom_header_format::isDicomFormat ( vil_stream )

True if it is known DICOM format.

vil_dicom_header_info vil_dicom_header_format::lastHeader ( void  )

Method to return the last struct of header info set.

The class holds a dicom header info struct containing the info from the last dicom file read.

Returns:
A dicom header struct containing the info gained from the last header read
bool vil_dicom_header_format::pixelDataFound ( short  group,
short  element 
) [private]

Method to determine whether or not the actual pixel data has been reached.

Parameters:
groupThe current group to test
elementThe element within that group
Returns:
TRUE if it is the pixel data, otherwise false
See also:
readHeaderElements()
void vil_dicom_header_format::readAcquisitionElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the acquisition group's details.

Fills the acquisition details in the last_read_ structure from the file header

Parameters:
elementThe element being read in the acquisition group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()
void vil_dicom_header_format::readDelimiterElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the delimiter group's details.

Certain field in the delimiter group have no data block, and so should not be skipped. This method takes the appropriate action - to skip or not to skip

Parameters:
elementThe element being read in the delimiter group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements() and last_read_()
vil_dicom_header_info vil_dicom_header_format::readHeader ( vil_stream fs)

Read the dicom header into a header struct.

Reads the header section of the dicom file and stores the result in a header struct, which it returns. When finished, the file stream should be pointing at the start of the image data

Parameters:
fsThe file stream to read - on exit points to the start of the image data
Returns:
A dicom header struct containing the info gained from the header
See also:
lastHeader(), headerValid(), last_read_() and info_valid_()
void vil_dicom_header_format::readHeaderElements ( vil_stream fs) [private]

Method to read the elements from the header.

This method fills the last_read_ header structure with the necessary fields

Parameters:
fsThe file stream to read from
See also:
readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements, readDelimiterElements(), readHeader() and last_read_()
void vil_dicom_header_format::readIdentifyingElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the identifying group's details.

Fills the identifying details in the last_read_ structure from the file header

Parameters:
elementThe element being read in the identifying group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()
void vil_dicom_header_format::readImageElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the image group's details.

Fills the image details in the last_read_ structure from the file header

Parameters:
elementThe element being read in the image group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readRelationshipElements(), readDelimiterElements() and last_read_()
void vil_dicom_header_format::readPatientElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the patient details.

Fills the patient details in the last_read_ structure from the file header

Parameters:
elementThe element being read in the patient group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readIdentifyingElements(), readAcquisitionElements(), readRelationshipElements(), readImageElements(), readDelimiterElements() and last_read_()
void vil_dicom_header_format::readRelationshipElements ( short  element,
int  dblock_size,
vil_stream fs 
) [private]

Method to read the relationship group's details.

Fills the relationship details in the last_read_ structure from the file header

Parameters:
elementThe element being read in the relationship group
dblock_sizeThe size of the data block for this element
fsThe file stream to read from
See also:
readHeaderElements(), readIdentifyingElements(), readPatientElements(), readAcquisitionElements(), readImageElements(), readDelimiterElements() and last_read_()
vxl_uint_16 vil_dicom_header_format::shortSwap ( vxl_uint_16  short_in) [private]

Method to byte swap an unsigned short int if necessary.

Parameters:
short_inThe unsigned short to swap
Returns:
The swapped unsigned short
See also:
intSwap() and charSwap()
vil_dicom_header_endian vil_dicom_header_format::systemEndian ( void  )

Return the current system endian.

Returns:
The system endian for the architecture running the application

Member Data Documentation

A variable to hold the discovered architecture endian.

See also:
calculateEndian() and systemEndian()

Definition at line 691 of file vil_dicom_header.h.

A variable to hold the current header file's endian.

See also:
determineMetaInfo() and fileEndian()

Definition at line 696 of file vil_dicom_header.h.

A variable to hole the current encapsulate file type (if any).

See also:
determineMetaInfo() and imageType()

Definition at line 701 of file vil_dicom_header.h.

TRUE if the header info is valid (i.e. has been read) otherwise FALSE.

See also:
readHeader(), lastHeader(), headerValid(), clearInfo() and last_read_()

Definition at line 686 of file vil_dicom_header.h.

Holds the info from the last header read.

See also:
readHeader(), lastHeader(), headerValid(), clearInfo(), readHeaderElements() and info_valid_()

Definition at line 681 of file vil_dicom_header.h.


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