DCMTK  Version 3.6.1 20120515
OFFIS DICOM Toolkit
Public Member Functions | Protected Member Functions | Private Attributes
DcmDataset Class Reference

a class handling the DICOM dataset format (files without meta header) More...

+ Inheritance diagram for DcmDataset:

List of all members.

Public Member Functions

 DcmDataset ()
 default constructor
 DcmDataset (const DcmDataset &old)
 copy constructor
virtual ~DcmDataset ()
 destructor
DcmDatasetoperator= (const DcmDataset &obj)
 assignment operator
virtual DcmObjectclone () 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

Detailed Description

a class handling the DICOM dataset format (files without meta header)


Constructor & Destructor Documentation

copy constructor

Parameters:
olddataset to be copied

Member Function Documentation

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.

Parameters:
xfertransfer syntax for length calculation
enctypesequence encoding type for length calculation
Returns:
length of DICOM element

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.

Parameters:
newXfertransfer syntax in which the DICOM object is to be encoded
oldXfertransfer syntax in which the DICOM object was read or created (optional). If EXS_Unknown, the return value of getOriginalXfer() is used.
Returns:
true if object can be encoded in desired transfer syntax, false otherwise.

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

Returns:
always returns OFTrue, i.e. SpecificCharacterSet should be checked

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.

Parameters:
repTypedesired transfer syntax
repParamdesired representation parameter (e.g. quality factor for lossy compression)
Returns:
EC_Normal upon success, an error code otherwise.
virtual OFCondition DcmDataset::clear ( ) [virtual]

clear (remove) attribute value

Returns:
EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.

virtual DcmObject* DcmDataset::clone ( ) const [inline, virtual]

clone method

Returns:
deep copy of this object

Reimplemented from DcmItem.

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.

Parameters:
rhs- [in] The instance to copy from. Has to be of the same class type as "this" object
Returns:
EC_Normal if copying was successful, error otherwise

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().

Returns:
transfer syntax in which this dataset is currently stored (see above)
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.

Returns:
transfer syntax in which this dataset was originally read. Might be EXS_Unknown if the dataset was 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").

Parameters:
repTypedesired transfer syntax
repParamdesired representation parameter (e.g. quality factor for lossy compression)
Returns:
true if all pixel elements have the desired representation, false otherwise
virtual DcmEVR DcmDataset::ident ( ) const [virtual]

get type identifier

Returns:
type identifier of this class (EVR_dataset)

Reimplemented from DcmItem.

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.

Parameters:
fileNamename 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.
readXfertransfer syntax used to read the data (auto detection if EXS_Unknown)
groupLengthflag, specifying how to handle the group length tags
maxReadLengthmaximum 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.
Returns:
status, EC_Normal if successful, an error code otherwise
DcmDataset& DcmDataset::operator= ( const DcmDataset obj)

assignment operator

Parameters:
objthe 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

Parameters:
outoutput stream
flagsoptional flag used to customize the output (see DCMTypes::PF_xxx)
levelcurrent level of nested items. Used for indentation.
pixelFileNameoptional filename used to write the raw pixel data file
pixelCounteroptional 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).

Parameters:
inStreamThe stream which contains the information.
xferThe transfer syntax which was used to encode the information in inStream.
glencEncoding type for group length; specifies what will be done with group length tags.
maxReadLengthMaximum read length for reading an attribute value.
Returns:
status, EC_Normal if successful, an error code otherwise

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.

Parameters:
cmdSetspecifies 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.

Parameters:
fileNamename 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.
writeXfertransfer syntax used to write the data (EXS_Unknown means use current)
encodingTypeflag, specifying the encoding with undefined or explicit length
groupLengthflag, specifying how to handle the group length tags
padEncodingflag, specifying how to handle the padding tags
padLengthnumber of bytes used for the dataset padding (has to be an even number)
subPadLengthnumber of bytes used for the item padding (has to be an even number)
Returns:
status, EC_Normal if successful, an error code otherwise
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

Parameters:
outStreamDICOM output stream
oxferoutput transfer syntax
enctypeencoding types (undefined or explicit length)
wcachepointer to write cache object, may be NULL
Returns:
status, EC_Normal if successful, an error code otherwise

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.

Parameters:
outStreamThe stream that the information will be written to.
oxferThe transfer syntax which shall be used.
enctypeEncoding type for sequences; specifies how sequences will be handled.
wcachepointer to write cache object, may be NULL
glencEncoding type for group length; specifies what will be done with group length tags.
padencEncoding type for padding. Specifies what will be done with padding tags.
padlenThe length up to which the dataset shall be padded, if padding is desired.
subPadlenFor sequences (ie sub elements), the length up to which item shall be padded, if padding is desired.
instanceLengthNumber 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.
Returns:
status, EC_Normal if successful, an error code otherwise
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

Parameters:
outStreamDICOM output stream
oxferoutput transfer syntax
enctypeencoding types (undefined or explicit length)
wcachepointer to write cache object, may be NULL
Returns:
status, EC_Normal if successful, an error code otherwise

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.

Parameters:
outoutput stream to which the XML document is written
flagsoptional flag used to customize the output (see DCMTypes::XF_xxx)
Returns:
status, EC_Normal if successful, an error code otherwise

Reimplemented from DcmItem.


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


Generated on Tue May 15 2012 for DCMTK Version 3.6.1 20120515 by Doxygen 1.7.5.1-20111027