DCMTK
Version 3.6.1 20120515
OFFIS DICOM Toolkit
|
a class representing the DICOM file meta information header More...
Public Member Functions | |
DcmMetaInfo () | |
default constructor | |
DcmMetaInfo (const DcmMetaInfo &old) | |
copy constructor | |
DcmMetaInfo & | operator= (const DcmMetaInfo &obj) |
assignment operator. | |
virtual | ~DcmMetaInfo () |
destructor | |
virtual DcmObject * | clone () const |
clone method | |
virtual OFCondition | copyFrom (const DcmObject &rhs) |
Virtual object copying. | |
virtual DcmEVR | ident () const |
get type identifier | |
virtual void | removeInvalidGroups () |
remove all elements with an invalid group number, i.e. | |
E_TransferSyntax | getOriginalXfer () const |
return the transfer syntax in which this dataset was originally read. | |
virtual void | print (STD_NAMESPACE ostream &out, const size_t flags=0, const int level=0, const char *pixelFileName=NULL, size_t *pixelCounter=NULL) |
print meta information header to a stream | |
virtual void | transferInit () |
initialize the transfer state of this object. | |
virtual void | transferEnd () |
finalize the transfer state of this object. | |
virtual Uint32 | calcElementLength (const E_TransferSyntax xfer, const E_EncodingType enctype) |
calculate the length of this DICOM element when encoded with the given transfer syntax and the given encoding type for sequences. | |
virtual OFCondition | read (DcmInputStream &inStream, const E_TransferSyntax xfer=EXS_Unknown, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength) |
read object from a stream. | |
virtual OFCondition | write (DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache) |
write meta information header to a stream | |
virtual OFCondition | writeXML (STD_NAMESPACE ostream &out, const size_t flags=0) |
write object in XML format | |
virtual OFCondition | loadFile (const OFFilename &fileName, const E_TransferSyntax readXfer=EXS_Unknown, const E_GrpLenEncoding groupLength=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength) |
load object from a DICOM file. | |
Private Member Functions | |
void | setPreamble () |
initialize the preamble buffer with 128 zero bytes followed by "DICM" | |
OFBool | checkAndReadPreamble (DcmInputStream &inStream, E_TransferSyntax &newxfer) |
check if the next 132 bytes in the input stream are a preamble followed by the DICOM "magic word" DICM. | |
OFBool | nextTagIsMeta (DcmInputStream &inStream) |
peeks into the input stream and checks whether the next element is group 0002, i.e. | |
OFCondition | readGroupLength (DcmInputStream &inStream, const E_TransferSyntax xfer, const DcmTagKey &xtag, const E_GrpLenEncoding glenc, Uint32 &headerLen, Uint32 &bytesRead, const Uint32 maxReadLength=DCM_MaxReadLength) |
read meta-header group length element which is important because it tells us where to switch from meta-header transfer syntax to dataset transfer syntax. | |
Private Attributes | |
char | filePreamble [DCM_PreambleLen+DCM_MagicLen] |
buffer for 132 byte DICOM file preamble | |
OFBool | preambleUsed |
true if the preamble was read from stream | |
E_TransferState | fPreambleTransferState |
transfer state of the preamble | |
E_TransferSyntax | Xfer |
transfer syntax in which the meta-header was read |
a class representing the DICOM file meta information header
DcmMetaInfo::DcmMetaInfo | ( | const DcmMetaInfo & | old | ) |
copy constructor
old | item to be copied |
virtual Uint32 DcmMetaInfo::calcElementLength | ( | const E_TransferSyntax | xfer, |
const E_EncodingType | enctype | ||
) | [virtual] |
calculate the length of this DICOM element when encoded with the given transfer syntax and the given encoding type for sequences.
For elements, the length includes the length of the tag, length field, VR field and the value itself, for items and sequences it returns the length of the complete item or sequence including delimitation tags if applicable. Never returns undefined length.
xfer | transfer syntax for length calculation |
enctype | sequence encoding type for length calculation |
Reimplemented from DcmItem.
OFBool DcmMetaInfo::checkAndReadPreamble | ( | DcmInputStream & | inStream, |
E_TransferSyntax & | newxfer | ||
) | [private] |
check if the next 132 bytes in the input stream are a preamble followed by the DICOM "magic word" DICM.
If so, try to determine the transfer syntax of the meta-header and return in parameter newxfer. If not, reset stream to start position.
inStream | input stream, should be at start position |
newxfer | as input parameter contains the expected transfer syntax, as output parameter returns the real transfer syntax of the meta-header as determined heuristically |
virtual DcmObject* DcmMetaInfo::clone | ( | ) | const [inline, virtual] |
virtual OFCondition DcmMetaInfo::copyFrom | ( | const DcmObject & | rhs | ) | [virtual] |
Virtual object copying.
This method can be used for DcmObject and derived classes to get a deep copy of an object. Internally the assignment operator is called if the given DcmObject parameter is of the same type as "this" object instance. If not, an error is returned. This function permits copying an object by value in a virtual way which therefore is different to just calling the assignment operator of DcmElement which could result in slicing the object.
rhs | - [in] The instance to copy from. Has to be of the same class type as "this" object |
Reimplemented from DcmItem.
E_TransferSyntax DcmMetaInfo::getOriginalXfer | ( | ) | const |
return the transfer syntax in which this dataset was originally read.
virtual DcmEVR DcmMetaInfo::ident | ( | ) | const [virtual] |
virtual OFCondition DcmMetaInfo::loadFile | ( | const OFFilename & | fileName, |
const E_TransferSyntax | readXfer = EXS_Unknown , |
||
const E_GrpLenEncoding | groupLength = EGL_noChange , |
||
const Uint32 | maxReadLength = DCM_MaxReadLength |
||
) | [virtual] |
load object from a DICOM file.
If the file preamble is missing, an error is returned.
fileName | name of the file to load (may contain wide chars if support enabled). Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
readXfer | transfer syntax used to read the data (auto detection if EXS_Unknown) |
groupLength | flag, specifying how to handle the group length tags |
maxReadLength | maximum number of bytes to be read for an element value. Element values with a larger size are not loaded until their value is retrieved (with getXXX()) or loadAllDataElements() is called. |
OFBool DcmMetaInfo::nextTagIsMeta | ( | DcmInputStream & | inStream | ) | [private] |
peeks into the input stream and checks whether the next element is group 0002, i.e.
belongs to the meta-header
DcmMetaInfo& DcmMetaInfo::operator= | ( | const DcmMetaInfo & | obj | ) |
assignment operator.
the | metainfo to be copied |
virtual void DcmMetaInfo::print | ( | STD_NAMESPACE ostream & | out, |
const size_t | flags = 0 , |
||
const int | level = 0 , |
||
const char * | pixelFileName = NULL , |
||
size_t * | pixelCounter = NULL |
||
) | [virtual] |
print meta information header to a stream
out | output stream |
flags | optional flag used to customize the output (see DCMTypes::PF_xxx) |
level | current level of nested items. Used for indentation. |
pixelFileName | not used |
pixelCounter | not used |
Reimplemented from DcmItem.
virtual OFCondition DcmMetaInfo::read | ( | DcmInputStream & | inStream, |
const E_TransferSyntax | xfer = EXS_Unknown , |
||
const E_GrpLenEncoding | glenc = EGL_noChange , |
||
const Uint32 | maxReadLength = DCM_MaxReadLength |
||
) | [virtual] |
read object from a stream.
inStream | DICOM input stream |
xfer | transfer syntax to use when parsing |
glenc | handling of group length parameters |
maxReadLength | attribute values larger than this value are skipped while parsing and read later upon first access if the stream type supports this. |
Reimplemented from DcmItem.
OFCondition DcmMetaInfo::readGroupLength | ( | DcmInputStream & | inStream, |
const E_TransferSyntax | xfer, | ||
const DcmTagKey & | xtag, | ||
const E_GrpLenEncoding | glenc, | ||
Uint32 & | headerLen, | ||
Uint32 & | bytesRead, | ||
const Uint32 | maxReadLength = DCM_MaxReadLength |
||
) | [private] |
read meta-header group length element which is important because it tells us where to switch from meta-header transfer syntax to dataset transfer syntax.
Insert element into dataset
inStream | input stream |
xfer | transfer syntax of meta-header |
xtag | attribute tag for group length |
glenc | handling of group length encoding element in dataset |
headerLen | output parameter; length of meta-header as encoded in group length element |
bytesRead | output parameter; number of bytes read when reading group length (for counting the remaining number of meta-header bytes) |
maxReadLength | max read length for elements |
virtual void DcmMetaInfo::removeInvalidGroups | ( | ) | [virtual] |
remove all elements with an invalid group number, i.e.
everything but 0x0002
virtual void DcmMetaInfo::transferEnd | ( | ) | [virtual] |
finalize the transfer state of this object.
This method must be called when reading/writing this object from/to a stream has been completed.
Reimplemented from DcmItem.
virtual void DcmMetaInfo::transferInit | ( | ) | [virtual] |
initialize the transfer state of this object.
This method must be called before this object is written to a stream or read (parsed) from a stream.
Reimplemented from DcmItem.
virtual OFCondition DcmMetaInfo::write | ( | DcmOutputStream & | outStream, |
const E_TransferSyntax | oxfer, | ||
const E_EncodingType | enctype, | ||
DcmWriteCache * | wcache | ||
) | [virtual] |
write meta information header to a stream
outStream | DICOM output stream |
oxfer | output transfer syntax |
enctype | encoding types (undefined or explicit length) |
wcache | pointer to write cache object, may be NULL |
Reimplemented from DcmItem.
virtual OFCondition DcmMetaInfo::writeXML | ( | STD_NAMESPACE ostream & | out, |
const size_t | flags = 0 |
||
) | [virtual] |
write object in XML format
out | output stream to which the XML document is written |
flags | optional flag used to customize the output (see DCMTypes::XF_xxx) |
Reimplemented from DcmItem.