I followed the steps the forum suggested to access dicomdir, but root->nextSub(PatientRecord)) turns to be NULL, then skip the loop, could you tell me what's possible reason of it? Thank you very much.
Code: Select all
DcmDicomDir dicomdir(DIR_FilePath);
DcmDirectoryRecord *root = &(dicomdir.getRootRecord());
DcmDirectoryRecord *PatientRecord =NULL;
DcmDirectoryRecord *StudyRecord = NULL;
DcmDirectoryRecord *SeriesRecord = NULL;
DcmDirectoryRecord *FileRecord = NULL;
OFString tmpString;
if(root != NULL)
{
while (((PatientRecord = root->nextSub(PatientRecord)) != NULL))
{
if (PatientRecord->findAndGetOFString(DCM_PatientName, tmpString).good())
{
cout << "Patient Name : " << tmpString << "\n";
}
else
{
cerr << "Can't retrieve patient name from DICOMDIR file!\n";
}
while (((StudyRecord = PatientRecord->nextSub(StudyRecord)) != NULL))
{
if (StudyRecord->findAndGetOFString(DCM_StudyDescription, tmpString).good())
{
cout << "Study Description : " << tmpString << "\n";
}
else
{
cerr << "Can't retrieve study description from DICOMDIR file!\n";
}
while (((SeriesRecord = StudyRecord->nextSub(SeriesRecord)) != NULL))
{
if (SeriesRecord->findAndGetOFString(DCM_SeriesDescription, tmpString).good())
{
cout << "Series Description : " << tmpString << "\n";
}
else
{
cerr << "Can't retrieve series description from DICOMDIR file!\n";
}
}
}
}
}