DCMTK
Version 3.6.1 20120515
OFFIS DICOM Toolkit
|
a class handling the DICOM dataset format (files without meta header) More...
Public Member Functions | |
DcmDataset () | |
default constructor | |
DcmDataset (const DcmDataset &old) | |
copy constructor | |
virtual | ~DcmDataset () |
destructor | |
DcmDataset & | operator= (const DcmDataset &obj) |
assignment operator | |
virtual DcmObject * | clone () const |
clone method | |
virtual OFCondition | copyFrom (const DcmObject &rhs) |
Virtual object copying. | |
virtual DcmEVR | ident () const |
get type identifier | |
virtual OFCondition | clear () |
clear (remove) attribute value | |
virtual void | removeInvalidGroups (const OFBool cmdSet=OFFalse) |
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 or created. | |
E_TransferSyntax | getCurrentXfer () const |
return the current transfer syntax, i.e. the one that was last used with chooseRepresentation() in order to select a specific representation or with write() or writeSignatureFormat() in order to create a byte stream according to the DICOM encoding rules. | |
virtual void | updateOriginalXfer () |
update the original transfer syntax, e.g. in case the dataset was created in memory and pixel data was added with a particular representation. | |
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 all elements of the dataset to a stream | |
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 OFBool | canWriteXfer (const E_TransferSyntax newXfer, const E_TransferSyntax oldXfer=EXS_Unknown) |
check if this DICOM object can be encoded in the given transfer syntax. | |
virtual OFCondition | read (DcmInputStream &inStream, const E_TransferSyntax xfer=EXS_Unknown, const E_GrpLenEncoding glenc=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength) |
This function reads the information of all attributes which are captured in the input stream and captures this information in this->elementList. | |
virtual OFCondition | write (DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache) |
write dataset to a stream | |
virtual OFCondition | write (DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache, const E_GrpLenEncoding glenc, const E_PaddingEncoding padenc=EPD_noChange, const Uint32 padlen=0, const Uint32 subPadlen=0, Uint32 instanceLength=0) |
This function writes data values which are contained in this DcmDataset object to the stream which is passed as first argument. | |
virtual OFCondition | writeSignatureFormat (DcmOutputStream &outStream, const E_TransferSyntax oxfer, const E_EncodingType enctype, DcmWriteCache *wcache) |
special write method for creation of digital signatures | |
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. | |
virtual OFCondition | saveFile (const OFFilename &fileName, const E_TransferSyntax writeXfer=EXS_Unknown, const E_EncodingType encodingType=EET_UndefinedLength, const E_GrpLenEncoding groupLength=EGL_recalcGL, const E_PaddingEncoding padEncoding=EPD_noChange, const Uint32 padLength=0, const Uint32 subPadLength=0) |
save object to a DICOM file. | |
OFCondition | chooseRepresentation (const E_TransferSyntax repType, const DcmRepresentationParameter *repParam) |
select a specific representation (compressed or uncompressed) of the dataset and create the representation if needed. | |
OFBool | hasRepresentation (const E_TransferSyntax repType, const DcmRepresentationParameter *repParam) |
check if all PixelData elements in this dataset have a representation conforming to the given transfer syntax and representation parameters (see dcpixel.h for definition of "conforming"). | |
void | removeAllButOriginalRepresentations () |
removes all but the original representation in all pixel data elements | |
void | removeAllButCurrentRepresentations () |
removes all but the current representation and sets the original representation to current | |
Protected Member Functions | |
virtual OFBool | checkForSpecificCharacterSet () const |
mode specifying whether the SpecificCharacterSet (0008,0005) element should be checked by convertCharacterSet() or not | |
Private Attributes | |
E_TransferSyntax | OriginalXfer |
original transfer syntax of the dataset | |
E_TransferSyntax | CurrentXfer |
current transfer syntax of the dataset |
a class handling the DICOM dataset format (files without meta header)
DcmDataset::DcmDataset | ( | const DcmDataset & | old | ) |
copy constructor
old | dataset to be copied |
Uint32 DcmDataset::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.
virtual OFBool DcmDataset::canWriteXfer | ( | const E_TransferSyntax | newXfer, |
const E_TransferSyntax | oldXfer = EXS_Unknown |
||
) | [virtual] |
check if this DICOM object can be encoded in the given transfer syntax.
newXfer | transfer syntax in which the DICOM object is to be encoded |
oldXfer | transfer syntax in which the DICOM object was read or created (optional). If EXS_Unknown, the return value of getOriginalXfer() is used. |
Reimplemented from DcmItem.
virtual OFBool DcmDataset::checkForSpecificCharacterSet | ( | ) | const [inline, protected, virtual] |
mode specifying whether the SpecificCharacterSet (0008,0005) element should be checked by convertCharacterSet() or not
Reimplemented from DcmItem.
OFCondition DcmDataset::chooseRepresentation | ( | const E_TransferSyntax | repType, |
const DcmRepresentationParameter * | repParam | ||
) |
select a specific representation (compressed or uncompressed) of the dataset and create the representation if needed.
This may cause compression or decompression to be applied to the pixel data in the dataset.
repType | desired transfer syntax |
repParam | desired representation parameter (e.g. quality factor for lossy compression) |
virtual OFCondition DcmDataset::clear | ( | ) | [virtual] |
clear (remove) attribute value
Reimplemented from DcmItem.
virtual DcmObject* DcmDataset::clone | ( | ) | const [inline, virtual] |
virtual OFCondition DcmDataset::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 DcmDataset::getCurrentXfer | ( | ) | const |
return the current transfer syntax, i.e. the one that was last used with chooseRepresentation() in order to select a specific representation or with write() or writeSignatureFormat() in order to create a byte stream according to the DICOM encoding rules.
The default value is the transfer syntax in which this dataset was originally read (see getOriginalXfer()) or, if this dataset was created from memory, the explicit VR with local endianness. Please note that the current transfer syntax might also change after calling updateOriginalXfer().
E_TransferSyntax DcmDataset::getOriginalXfer | ( | ) | const |
return the transfer syntax in which this dataset was originally read or created.
See updateOriginalXfer() on how to update this value when created in memory.
OFBool DcmDataset::hasRepresentation | ( | const E_TransferSyntax | repType, |
const DcmRepresentationParameter * | repParam | ||
) |
check if all PixelData elements in this dataset have a representation conforming to the given transfer syntax and representation parameters (see dcpixel.h for definition of "conforming").
repType | desired transfer syntax |
repParam | desired representation parameter (e.g. quality factor for lossy compression) |
virtual DcmEVR DcmDataset::ident | ( | ) | const [virtual] |
virtual OFCondition DcmDataset::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.
This method only supports DICOM objects stored as a dataset, i.e. without meta header. Use DcmFileFormat::loadFile() to load files with meta header.
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. |
DcmDataset& DcmDataset::operator= | ( | const DcmDataset & | obj | ) |
assignment operator
obj | the dataset to be copied |
virtual void DcmDataset::print | ( | STD_NAMESPACE ostream & | out, |
const size_t | flags = 0 , |
||
const int | level = 0 , |
||
const char * | pixelFileName = NULL , |
||
size_t * | pixelCounter = NULL |
||
) | [virtual] |
print all elements of the dataset 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 | optional filename used to write the raw pixel data file |
pixelCounter | optional counter used for automatic pixel data filename creation |
Reimplemented from DcmItem.
virtual OFCondition DcmDataset::read | ( | DcmInputStream & | inStream, |
const E_TransferSyntax | xfer = EXS_Unknown , |
||
const E_GrpLenEncoding | glenc = EGL_noChange , |
||
const Uint32 | maxReadLength = DCM_MaxReadLength |
||
) | [virtual] |
This function reads the information of all attributes which are captured in the input stream and captures this information in this->elementList.
Each attribute is represented as an element in this list. Having read all information for this particular data set or command, this function will also take care of group length (according to what is specified in glenc) and padding elements (don't change anything).
inStream | The stream which contains the information. |
xfer | The transfer syntax which was used to encode the information in inStream. |
glenc | Encoding type for group length; specifies what will be done with group length tags. |
maxReadLength | Maximum read length for reading an attribute value. |
Reimplemented from DcmItem.
virtual void DcmDataset::removeInvalidGroups | ( | const OFBool | cmdSet = OFFalse | ) | [virtual] |
remove all elements with an invalid group number, i.e.
0x0000 to 0x0003, 0x0005, 0x0007 and 0xFFFF in case of a data set. For sequence items, also group 0x0006 is disallowed. For command sets, only group 0x0000 is allowed, i.e. the elements from all other groups are removed.
cmdSet | specifies whether this object represents a command or data set |
virtual OFCondition DcmDataset::saveFile | ( | const OFFilename & | fileName, |
const E_TransferSyntax | writeXfer = EXS_Unknown , |
||
const E_EncodingType | encodingType = EET_UndefinedLength , |
||
const E_GrpLenEncoding | groupLength = EGL_recalcGL , |
||
const E_PaddingEncoding | padEncoding = EPD_noChange , |
||
const Uint32 | padLength = 0 , |
||
const Uint32 | subPadLength = 0 |
||
) | [virtual] |
save object to a DICOM file.
This method only supports DICOM objects stored as a dataset, i.e. without meta header. Use DcmFileFormat::saveFile() to save files with meta header.
fileName | name of the file to save (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. |
writeXfer | transfer syntax used to write the data (EXS_Unknown means use current) |
encodingType | flag, specifying the encoding with undefined or explicit length |
groupLength | flag, specifying how to handle the group length tags |
padEncoding | flag, specifying how to handle the padding tags |
padLength | number of bytes used for the dataset padding (has to be an even number) |
subPadLength | number of bytes used for the item padding (has to be an even number) |
virtual void DcmDataset::updateOriginalXfer | ( | ) | [virtual] |
update the original transfer syntax, e.g. in case the dataset was created in memory and pixel data was added with a particular representation.
Icon images and other nested pixel data elements are not checked. If previously unknown, the original transfer syntax is set to the default EXS_LittleEndianExplicit. Please note that the current transfer syntax might also be updated if its value was not in sync with the internal representation of the pixel data.
virtual OFCondition DcmDataset::write | ( | DcmOutputStream & | outStream, |
const E_TransferSyntax | oxfer, | ||
const E_EncodingType | enctype, | ||
DcmWriteCache * | wcache | ||
) | [virtual] |
write dataset 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 DcmDataset::write | ( | DcmOutputStream & | outStream, |
const E_TransferSyntax | oxfer, | ||
const E_EncodingType | enctype, | ||
DcmWriteCache * | wcache, | ||
const E_GrpLenEncoding | glenc, | ||
const E_PaddingEncoding | padenc = EPD_noChange , |
||
const Uint32 | padlen = 0 , |
||
const Uint32 | subPadlen = 0 , |
||
Uint32 | instanceLength = 0 |
||
) | [virtual] |
This function writes data values which are contained in this DcmDataset object to the stream which is passed as first argument.
With regard to the writing of information, the other parameters which are passed are accounted for. The function will return EC_Normal, if the information from all elements of this data set has been written to the buffer, it will return EC_StreamNotifyClient, if there is no more space in the buffer and _not_ all elements have been written to it, and it will return some other (error) value if there was an error.
outStream | The stream that the information will be written to. |
oxfer | The transfer syntax which shall be used. |
enctype | Encoding type for sequences; specifies how sequences will be handled. |
wcache | pointer to write cache object, may be NULL |
glenc | Encoding type for group length; specifies what will be done with group length tags. |
padenc | Encoding type for padding. Specifies what will be done with padding tags. |
padlen | The length up to which the dataset shall be padded, if padding is desired. |
subPadlen | For sequences (ie sub elements), the length up to which item shall be padded, if padding is desired. |
instanceLength | Number of extra bytes added to the item/dataset length used when computing the padding; this parameter is for instance used to pass the length of the file meta header from the DcmFileFormat to the DcmDataset object. |
virtual OFCondition DcmDataset::writeSignatureFormat | ( | DcmOutputStream & | outStream, |
const E_TransferSyntax | oxfer, | ||
const E_EncodingType | enctype, | ||
DcmWriteCache * | wcache | ||
) | [virtual] |
special write method for creation of digital signatures
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 DcmDataset::writeXML | ( | STD_NAMESPACE ostream & | out, |
const size_t | flags = 0 |
||
) | [virtual] |
write object in XML format.
The XML declaration (e.g. <?xml version="1.0"?>) is not written by this function.
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.