To elaborate a bit more about the change I would like to have or make:
The easiest way would be to just ignore these ambiguous VRs if
dcmPreferVRFromDataDictionary is set, e.g. something like:
Code: Select all
if (dcmPreferVRFromDataDictionary.get() && (newEVR != EVR_UNKNOWN) && (newEVR != EVR_UNKNOWN2B))
{
if (newEVR != vr.getEVR())
{
if (vr.getEVR() != EVR_ox && vr.getEVR() != EVR_ox && vr.getEVR() != EVR_px && vr.getEVR() != EVR_xs && vr.getEVR() != EVR_lt)
{
/* ignore explicit VR in dataset if tag is defined in data dictionary */
DCMDATA_DEBUG("DcmItem::readTagAndLength() ignoring explicit VR in data set ("
<< vr.getVRName() << ") for element " << newTag
<< ", using the one from data dictionary (" << newTag.getVRName() << ")");
} else {
newTag.setVR(vr);
}
}
} else {
/* set the VR which was read in the above created tag object */
newTag.setVR(vr);
}
This would just leave the VR for these values. There are more complicated possibilities, like checking if the current VR is allowed (e.g. OB or OW in the case of EVR_ox) and leave it in this case, otherwise setting EVR_ox, though I doubt that that makes much sense, if the code that defines the correct VR for ambiguous cases has already run.
Another possibility would be to adapt the check in
getUint8Array and
getUint16Array:
Code: Select all
OFCondition DcmOtherByteOtherWord::getUint16Array(Uint16 *&wordVals)
{
errorFlag = EC_Normal;
if (getTag().getEVR() == EVR_OW || getTag().getEVR() == EVR_lt || getTag().getEVR() == EVR_ox)
wordVals = OFstatic_cast(Uint16 *, getValue());
else
errorFlag = EC_IllegalCall;
return errorFlag;
}
The current code already checks for EVR_lt, so it may also check for EVR_ox, provided there is no reason why that would be wrong.
This would fix that concrete problem, but there may be similar problems elsewhere if the VR is reset to the ambiguous value.