DRTStructureSetIOD structureSet;
structureSet.setStudyInstanceUID("1.2.3.4");
structureSet.setSeriesInstanceUID("1.2.3.4.5");
structureSet.setSOPInstanceUID("1.2.3.4.5.6");
structureSet.setModality("RTSTRUCT");
structureSet.setStructureSetLabel("TEST");
// TODO: add further mandatory data elements
DRTROIContourSequence& roiContourSequence = structureSet.getROIContourSequence();
DRTROIContourSequence::Item* roiContourSequenceItem = NULL;
// add new item
if (roiContourSequence.addItem(roiContourSequenceItem).good())
{
DRTContourSequence& contourSequence = roiContourSequenceItem->getContourSequence();
DRTContourSequence::Item* contourSequenceItem = NULL;
// add mandatory data elements
roiContourSequenceItem->setReferencedROINumber("1");
// also add a new item to the nested sub-sequence
if (contourSequence.addItem(contourSequenceItem).good())
{
contourSequenceItem->setContourGeometricType("POINT");
contourSequenceItem->setNumberOfContourPoints("2");
// set contour data (dummy values)
DCMRT_INFO("set contour data: " << contourSequenceItem->setContourData("100\\200\\146\\101\\201\\147").text());
}
}
DcmFileFormat rtFileformat;
if (structureSet.write(*rtFileformat.getDataset()).good())
{
// save file
DCMRT_INFO("save dataset to file: " << rtFileformat.saveFile("test_RTStruct.dcm", EXS_LittleEndianExplicit).text());
}
Thank you for the clarification. I wasn't aware that DRTStructureSetIOD checks the data before writing it.
I did try to set all necessary fields, but I wanted to post a minimal example here. Apparently I missed some vital field. And you are right, I should have checked the log for details.
Anyway, in the meantime I have already re-written my code to generate the RT-Structure Set files using "pure" DCMTK, i.e. without DCMRT, so the problem is solved.