StringFilter::ToString(const Tag& t) fails for private tags.
Cross-platform DICOM implementation
Brought to you by:
malat
Hi,
I found an unintended behavior/bug in the current master branch (coming from the GitHub mirror). When using StringFilter::ToString (and ToStringPair) to access private tags, only the interface that takes a DataElement works as indended. When using StringFilter::ToString(Tag), the proper private tag will not get extracted, since ToString, at some point, calls GetDataElement(Tag) and not GetDataElement(PrivateTag).
One way to fix this would be to use proper polymorphism in GetDataElement to achieve the indended behavior instead of having a version for Tag and a version for PrivateTag.
Here is a minimalistic example:
#include <iostream>
#include <string>
#include "gdcmPrivateTag.h"
#include "gdcmReader.h"
#include "gdcmStringFilter.h"
int main(int argc, char** argv)
{
const char* filename = argv[1];
gdcm::Reader reader;
reader.SetFileName(filename);
reader.Read();
gdcm::File& file = reader.GetFile();
gdcm::DataSet& ds = file.GetDataSet();
gdcm::StringFilter filter;
filter.SetFile(file);
gdcm::PrivateTag privTag(0x0051, 0x10, "SIEMENS MED SP DXMG WH AWS 1");
// Works as intended
std::string privTagValue1 = filter.ToString(ds.GetDataElement(privTag));
// Does not work, returns string value of the private creator instead of the actual tag
std::string privTagValue2 = filter.ToString(privTag);
}
ce9c7aab23