MeVisLab Toolbox Reference
ml::GenericPrivateDICOMTagDecoder Class Reference

The GenericPrivateDICOMTagDecoder class is a default decoder usable for all private DICOM tags as well as some tool functions for derived classes. More...

#include <mlGenericPrivateDICOMTagDecoder.h>

Inheritance diagram for ml::GenericPrivateDICOMTagDecoder:
ml::PMTFToshibaPrivateDICOMTagDecoders ml::PrivateSequenceDICOMTagDecoders

Public Member Functions

 GenericPrivateDICOMTagDecoder ()=default
 Constructor doing nothing.
 
 GenericPrivateDICOMTagDecoder (const GenericPrivateDICOMTagDecoder &)=default
 Default copy constructor.
 
GenericPrivateDICOMTagDecoderoperator= (const GenericPrivateDICOMTagDecoder &)=default
 Default assignment operator.
 
 ~GenericPrivateDICOMTagDecoder () override
 Destructor.
 
PrivateDICOMTagDecoderPluginBase::DecodeStates decodePrivateTag (const std::string &privateCreator, DCMTree::Const_TagPtr tagPtr, PrivateDICOMTagValueFields &resultFields) override
 If a private Toshiba PMTF header tag is passed then this routine converts its data element(s) to fields in resultFields container.
 
PrivateDICOMTagDecoderPluginBase::DecodeStates extractTag (const std::string &prefix, const unsigned char *&tagData, MLuint32 &tagDataSize, bool decodeImplicitSeqVR, PrivateDICOMTagValueFields &resultFields, bool translateStdIdToName) const
 Assume a DICOM tag as binary data and add human readable information to resultFields of the tag id, names, and content(s) as far as it can be decoded.
 

Static Public Member Functions

static void dumpHexArea (const std::string &prefix, const unsigned char *tagData, size_t tagDataSize, PrivateDICOMTagValueFields &resultFields, size_t rowSize=16, size_t maxBytesToDump=ML_SIZE_T_MAX)
 Add a range of bytes as a hex dump to the PrivateDICOMTagValueFields resultFields as "otherInfo" tag information with disabled "isValidTag" flag.
 
static bool isValidVRString (const std::string &vrStr)
 Returns true if the passed VR string is a valid known one, otherwise false.
 

Protected Member Functions

bool _getTagNameAndVrFromId (unsigned int groupId, unsigned int elementId, std::string &retName, std::string &retVr) const
 Determines the tag name and value representation corresponding to a tag id given by groupId and elementId and returns true, or - if it cannot be determined - it returns false.
 
const unsigned char * _findStr (const unsigned char *buffer, const std::string &str, size_t bufferSize) const
 Returns the pointer to the first occurrence of str in the buffer given by buffer and bufferSize.
 
PrivateDICOMTagDecoderPluginBase::DecodeStates _decodeSequenceTagData (const std::string &prefix, const unsigned char *&tagData, MLuint32 &tagDataSize, bool implicit, PrivateDICOMTagValueFields &resultFields, bool translateStdIdToName) const
 Extract a sequence of DICOM tag values whose value representations are given in VRs.
 

Static Protected Member Functions

static std::string _dumpRange (const unsigned char *start, size_t num=16, bool showStartAddress=true, bool showHexDump=true, bool showASCII=true, size_t maxRowSize=16, char defaultNonReadableChar='.')
 Creates a string containing one row with a hexadecimal start address of the buffer, hexadecimal byte data values, and ASCII dump corresponding to the data bytes.
 

Detailed Description

The GenericPrivateDICOMTagDecoder class is a default decoder usable for all private DICOM tags as well as some tool functions for derived classes.

Definition at line 25 of file mlGenericPrivateDICOMTagDecoder.h.

Constructor & Destructor Documentation

◆ GenericPrivateDICOMTagDecoder() [1/2]

ml::GenericPrivateDICOMTagDecoder::GenericPrivateDICOMTagDecoder ( )
default

Constructor doing nothing.

◆ GenericPrivateDICOMTagDecoder() [2/2]

ml::GenericPrivateDICOMTagDecoder::GenericPrivateDICOMTagDecoder ( const GenericPrivateDICOMTagDecoder )
default

Default copy constructor.

◆ ~GenericPrivateDICOMTagDecoder()

ml::GenericPrivateDICOMTagDecoder::~GenericPrivateDICOMTagDecoder ( )
override

Destructor.

Member Function Documentation

◆ _decodeSequenceTagData()

PrivateDICOMTagDecoderPluginBase::DecodeStates ml::GenericPrivateDICOMTagDecoder::_decodeSequenceTagData ( const std::string &  prefix,
const unsigned char *&  tagData,
MLuint32 tagDataSize,
bool  implicit,
PrivateDICOMTagValueFields resultFields,
bool  translateStdIdToName 
) const
protected

Extract a sequence of DICOM tag values whose value representations are given in VRs.

Parameters
prefixString added before each entry added to resultFields.
tagDataThe pointer to the tag data to be dumped, may be nullptr.
tagDataSizeThe number of bytes in tagData to be dumped.
implicitIf false then an explicitly coded tag is assumed, otherwise the VR is determined from the tag id.
resultFieldsThe container to be extended with extracted header, section, and tag information.
translateStdIdToNameIf true and if a tag id can be determined which seems to be a standard one (even group id) then try to look up the standard tag name.
Returns
PrivateDICOMTagDecoderPluginBase::FULLY_DECODED if entire tag value could be decoded and PrivateDICOMTagDecoderPluginBase::PARTIALLY_DECODED otherwise.

◆ _dumpRange()

static std::string ml::GenericPrivateDICOMTagDecoder::_dumpRange ( const unsigned char *  start,
size_t  num = 16,
bool  showStartAddress = true,
bool  showHexDump = true,
bool  showASCII = true,
size_t  maxRowSize = 16,
char  defaultNonReadableChar = '.' 
)
staticprotected

Creates a string containing one row with a hexadecimal start address of the buffer, hexadecimal byte data values, and ASCII dump corresponding to the data bytes.

Parameters
startPoints to the first byte to be dumped.
numThe number of bytes to be dumped.
showStartAddressIf enabled (the default) then the buffer start address is added at the begin of the returned string.
showHexDumpIf enabled (the default) then the data bytes are added as hex numbers after the startAddrees.
showASCIIIf enabled (the default) then the data bytes are added as ASCII bytes after the hex byte dump. Non readable values are shown as a defaultNonReadableChar.
maxRowSizeIf showASCII is enabled then maxRowSize determines to how many bytes the hex dump section shall be filled with spaces to have a formatted ASCII output in different rows. This normally is the same as rowSize of _dumpHexArea.
defaultNonReadableCharThe character to be used instead of non readable byte values in the ASCII dump.

◆ _findStr()

const unsigned char * ml::GenericPrivateDICOMTagDecoder::_findStr ( const unsigned char *  buffer,
const std::string &  str,
size_t  bufferSize 
) const
protected

Returns the pointer to the first occurrence of str in the buffer given by buffer and bufferSize.

If not found the nullptr is returned. In contrast to a normal string search buffer may contain nullptr characters.

Parameters
bufferThe pointer to the first byte of the buffer to be scanned, may be nullptr.
strThe string to be searched in the buffer.
bufferSizeThe number of bytes in the buffer.

◆ _getTagNameAndVrFromId()

bool ml::GenericPrivateDICOMTagDecoder::_getTagNameAndVrFromId ( unsigned int  groupId,
unsigned int  elementId,
std::string &  retName,
std::string &  retVr 
) const
protected

Determines the tag name and value representation corresponding to a tag id given by groupId and elementId and returns true, or - if it cannot be determined - it returns false.

If the tag id is not a standard one and privateCreator is non-empty the it is tried to find it in private dictionaries. retName and retVr are set empty if false is returned, otherwise they contained the determined values.

◆ decodePrivateTag()

PrivateDICOMTagDecoderPluginBase::DecodeStates ml::GenericPrivateDICOMTagDecoder::decodePrivateTag ( const std::string &  privateCreator,
DCMTree::Const_TagPtr  tagPtr,
PrivateDICOMTagValueFields resultFields 
)
override

If a private Toshiba PMTF header tag is passed then this routine converts its data element(s) to fields in resultFields container.

The privateCreator must be a "PMTF INFORMATION DATA" one.

Parameters
privateCreatorA string with the name of the private creator this tags belongs to.
tagPtrThe tag whose value shall be decoded.
resultFieldsThe field container to be filled with extracted information from tagPtr or returned empty if no data could be decoded.
Returns
PrivateDICOMTagDecoderPluginBase::NOT_DECODED if the tag could not be decoded, PrivateDICOMTagDecoderPluginBase::PARTIALLY_DECODED if some of the tag value components were decoded or PrivateDICOMTagDecoderPluginBase::FULLY_DECODED if entire tag value could be decoded.

◆ dumpHexArea()

static void ml::GenericPrivateDICOMTagDecoder::dumpHexArea ( const std::string &  prefix,
const unsigned char *  tagData,
size_t  tagDataSize,
PrivateDICOMTagValueFields resultFields,
size_t  rowSize = 16,
size_t  maxBytesToDump = ML_SIZE_T_MAX 
)
static

Add a range of bytes as a hex dump to the PrivateDICOMTagValueFields resultFields as "otherInfo" tag information with disabled "isValidTag" flag.

Parameters
prefixString added before each entry added to resultFields.
tagDataThe pointer to the data to be dumped, may be nullptr.
tagDataSizeThe number of bytes in tagData to be dumped.
resultFieldsThe container to be extended with string rows of dumped data.
rowSizeThe number of bytes to be dumped in one row.
maxBytesToDumpIf tagDataSize exceeds maxBytesToDump then dumping is stopped there and the string is preceeded with "First <maxBytesToDump> bytes = " to indicate that not all bytes are shown.

◆ extractTag()

PrivateDICOMTagDecoderPluginBase::DecodeStates ml::GenericPrivateDICOMTagDecoder::extractTag ( const std::string &  prefix,
const unsigned char *&  tagData,
MLuint32 tagDataSize,
bool  decodeImplicitSeqVR,
PrivateDICOMTagValueFields resultFields,
bool  translateStdIdToName 
) const

Assume a DICOM tag as binary data and add human readable information to resultFields of the tag id, names, and content(s) as far as it can be decoded.

Parameters
prefixString added before each entry added to resultFields.
tagDataThe pointer to the tag data to be dumped, may be nullptr.
tagDataSizeThe number of bytes in tagData to be dumped.
decodeImplicitSeqVRIf false then an explicitly coded tag is assumed, otherwise the VR is determined from the tag id.
resultFieldsThe container to be extended with extracted header, section, and tag information.
translateStdIdToNameIf true and if a tag id can be determined which seems to be a standard one (even group id) then try to look up the standard tag name.
Returns
The PrivateDICOMTagDecoderPluginBase::DecodeStates indicates whether the tag could be decoded fully, partially or not at all. The tagData pointer is incremented to the position directly after the parsed byte range and tagDataSize is decremented accordingly by the same amount of bytes in the case of success. In all decoding state returns tagData and tagDataSize are set to the end of the expected end of the tag. Important: May throw DCMTree::Exception in case of corrupted data!

◆ isValidVRString()

static bool ml::GenericPrivateDICOMTagDecoder::isValidVRString ( const std::string &  vrStr)
static

Returns true if the passed VR string is a valid known one, otherwise false.

◆ operator=()

GenericPrivateDICOMTagDecoder & ml::GenericPrivateDICOMTagDecoder::operator= ( const GenericPrivateDICOMTagDecoder )
default

Default assignment operator.


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