3

给定一个 gdcm 标记,例如gdcm::Tag(0x0010,0x0010)如何将其转换为相应的标记名称字符串,在这种情况下"PatientsName"是 C++?

4

1 回答 1

3

这是我在使用 GDCM 的基于 Qt 的应用程序中所做的:

QString duDicomDictionary::getTagName( const gdcm::Tag & tag )
{
    QString retVal;

    const gdcm::Global& g = gdcm::Global::GetInstance();
    const gdcm::Dicts &dicts = g.GetDicts();
    const gdcm::Dict &pubdict = dicts.GetPublicDict();

    gdcm::DictEntry ent = pubdict.GetDictEntry(tag);

    if (ent.GetVR() != gdcm::VR::INVALID ) {
        retVal = QString::fromStdString(ent.GetName());
    }

    return retVal;
}

此代码仅适用于公共团体。

要获取我使用的私人组(在我填充私人字典之后):

QString duDicomDictionary::getTagName( const gdcm::PrivateTag & tag )
{
    QString retVal;

    const gdcm::Global& g = gdcm::Global::GetInstance();
    const gdcm::Dicts &dicts = g.GetDicts();
    const gdcm::PrivateDict &privdict = dicts.GetPrivateDict();

    gdcm::DictEntry ent = privdict.GetDictEntry(tag);

    if (ent.GetVR() != gdcm::VR::INVALID ) {
        retVal = QString::fromStdString(ent.GetName());
    }
    else
    {
        ent = g_privateDict.GetDictEntry(tag);

        if (ent.GetVR() != gdcm::VR::INVALID ) {
            retVal = QString::fromStdString(ent.GetName());
        }

    }

    return retVal;
}
于 2014-07-24T21:19:30.973 回答