Menu

#485 StringFilter::ToString(const Tag& t) fails for private tags.

3.0.7
closed
5
2020-06-25
2019-09-04
Sethur
No

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);
}

Discussion

  • Mathieu Malaterre

    • assigned_to: Mathieu Malaterre
     
  • Mathieu Malaterre

    • status: open --> closed
    • Group: 3.1 --> 3.0.7
     
  • Mathieu Malaterre

    ce9c7aab23

     

Log in to post a comment.

MongoDB Logo MongoDB