32 #include "dcmtk/config/osconfig.h"
33 #include "dcmtk/dcmdata/dcdatset.h"
34 #include "dcmtk/dcmdata/dcelem.h"
35 #include "dcmtk/oflog/oflog.h"
38 OFLogger DCM_dcmdataLibi2dGetLogger();
40 #define DCMDATA_LIBI2D_TRACE(msg) OFLOG_TRACE(DCM_dcmdataLibi2dGetLogger(), msg)
41 #define DCMDATA_LIBI2D_DEBUG(msg) OFLOG_DEBUG(DCM_dcmdataLibi2dGetLogger(), msg)
42 #define DCMDATA_LIBI2D_INFO(msg) OFLOG_INFO(DCM_dcmdataLibi2dGetLogger(), msg)
43 #define DCMDATA_LIBI2D_WARN(msg) OFLOG_WARN(DCM_dcmdataLibi2dGetLogger(), msg)
44 #define DCMDATA_LIBI2D_ERROR(msg) OFLOG_ERROR(DCM_dcmdataLibi2dGetLogger(), msg)
45 #define DCMDATA_LIBI2D_FATAL(msg) OFLOG_FATAL(DCM_dcmdataLibi2dGetLogger(), msg)
100 OFBool insertMissingType2 = OFTrue,
101 OFBool inventMissingType1 = OFTrue)
120 const OFString& defaultValue =
"")
const
122 OFBool exists = targetDset->
tagExists(key);
135 err +=
"I2DOutputPlug: Empty value for type 1 attribute: ";
142 DcmTag tag(key); OFBool wasError = OFFalse;
144 if ( newDicomElement(elem, tag).good())
148 if (elem->
putString(defaultValue.c_str()).good())
150 DCMDATA_LIBI2D_DEBUG(
"I2DOutputPlug: Inserting missing type 1 attribute: " << tag.
getTagName() <<
" with value " << defaultValue);
151 }
else wasError = OFTrue;
152 }
else wasError = OFTrue;
153 }
else wasError = OFTrue;
156 OFString err =
"Unable to insert type 1 attribute ";
157 err += tag.
getTagName(); err +=
" with value "; err += defaultValue; err +=
"\n";
173 const OFString& defaultValue =
"")
const
176 OFBool exists = targetDset->
tagExists(key);
183 DcmTag tag(key); OFBool wasError = OFFalse;
185 if ( newDicomElement(elem, tag).good())
190 if (!defaultValue.empty())
192 result = elem->
putString(defaultValue.c_str());
196 DCMDATA_LIBI2D_DEBUG(
"I2DOutputPlug: Inserting missing type 2 attribute: " << tag.
getTagName() <<
" with value " << (defaultValue.empty() ?
"<empty>" : defaultValue));
197 }
else wasError = OFTrue;
198 }
else wasError = OFTrue;
199 }
else wasError = OFTrue;
202 err +=
"Unable to insert type 2 attribute "; err += tag.
getTagName(); err +=
" with value "; err += defaultValue; err +=
"\n";
207 err =
"Image2Dcm: Missing type 2 attribute: "; err +=
DcmTag(key).
getTagName(); err +=
"\n";
228 #endif // #ifndef I2DOUTPL_H
virtual OFString checkAndInventType2Attrib(const DcmTagKey &key, DcmDataset *targetDset, const OFString &defaultValue="") const
Checks whether a given tag exists in a dataset (can be empty) If not, the tag is inserted (if enabled...
class maintaining a attribute tag (group and element number)
virtual OFCondition convert(DcmDataset &dataset) const =0
Outputs SOP class specific information into dataset.
const char * getTagName()
returns name of attribute tag.
abstract base class for all DICOM elements
virtual OFString ident()=0
Virtual function that returns a short name of the plugin.
I2DOutputPlug()
Constructor, initializes member variables.
virtual Uint32 getLength(const E_TransferSyntax=EXS_LittleEndianImplicit, const E_EncodingType=EET_UndefinedLength)
calculate the value length (without attribute tag, VR and length field) of this DICOM element when en...
this class encapsulates an attribute tag (group, element) and a VR.
virtual ~I2DOutputPlug()
Destructor.
OFBool m_inventMissingType2Attribs
if enabled, missing type 2 attributes in the dataset are added automatically.
virtual OFString checkAndInventType1Attrib(const DcmTagKey &key, DcmDataset *targetDset, const OFString &defaultValue="") const
Checks whether a given tag exists in a dataset and provides a non-empty value.
OFBool tagExists(const DcmTagKey &key, OFBool searchIntoSub=OFFalse)
check if an element with the given attribute tag exists in the dataset
OFBool good() const
returns true if status is OK
virtual void supportedSOPClassUIDs(OFList< OFString > suppSOPs)=0
Virtual function that returns the Storage SOP class UID, the plugin writes.
virtual void setValidityChecking(OFBool doChecks, OFBool insertMissingType2=OFTrue, OFBool inventMissingType1=OFTrue)
Enable/Disable basic validity checks for output dataset.
OFBool m_doAttribChecking
if enabled, some simple attribute checking is performed default: enabled (OFTrue) ...
OFCondition findAndGetElement(const DcmTagKey &tagKey, DcmElement *&element, const OFBool searchIntoSub=OFFalse, const OFBool createCopy=OFFalse)
find element and get a pointer to it (or copy it).
virtual OFCondition putString(const char *val)
replace the element value by a copy of the given string (which is possibly multi-valued).
OFBool m_inventMissingType1Attribs
if enbled, missing type 1 attributes are inserted and filled with a predefined value.
virtual OFCondition insert(DcmElement *elem, OFBool replaceOld=OFFalse, OFBool checkInsertOrder=OFFalse)
insert a new element into the list of elements maintained by this item.
a class handling the DICOM dataset format (files without meta header)
simple wrapper around the "low-level" Logger object to make it easier to switch to a different system...
a simple string class that implements a subset of std::string.
OFBool bad() const
returns true if status is not OK, i. e. error or failure
virtual OFString isValid(DcmDataset &dataset) const =0
Do some completeness / validity checks.
General purpose class for condition codes.