30 #include "dcmtk/dcmdata/dcfilefo.h"
31 #include "dcmtk/dcmdata/dcdeftag.h"
32 #include "dcmtk/dcmdata/dcpixel.h"
33 #include "dcmtk/dcmdata/dcpxitem.h"
34 #include "dcmtk/dcmdata/dcpixseq.h"
35 #include "dcmtk/dcmrt/drtstrct.h"
36 #include "dcmtk/dcmrt/seq/drtrfors.h"
37 #include "dcmtk/dcmrt/seq/drtssrs.h"
38 #include "dcmtk/dcmrt/seq/drtrcs.h"
39 #include "dcmtk/dcmrt/seq/drtcs.h"
40 #include "dcmtk/dcmrt/seq/drtcis.h"
41 #include "dcmtk/config/osconfig.h"
52 DRTStructureSetIOD rtstruct;
53 OFCondition result = rtstruct.read(*
theDataset);
64 DRTReferencedFrameOfReferenceSequence refSeq = rtstruct.getReferencedFrameOfReferenceSequence();
65 if( refSeq.isEmpty() ) {
69 "DRTReferencedFrameOfReferenceSequence is empty");
72 G4cout <<
"@@@@@ NUMBER OF ReferenceSequences " << refSeq.getNumberOfItems() <<
G4endl;
73 refSeq.gotoFirstItem();
74 for(
size_t i1 = 0; i1 < refSeq.getNumberOfItems(); i1++ ) {
75 DRTReferencedFrameOfReferenceSequence::Item &item = refSeq.getCurrentItem();
77 item.getFrameOfReferenceUID(uid);
79 DRTRTReferencedStudySequence &reference_study_sequence_ref =
80 item.getRTReferencedStudySequence();
81 G4cout <<
"@@@@ NUMBER OF ReferenceStudySequences "
82 << reference_study_sequence_ref.getNumberOfItems() <<
G4endl;
83 reference_study_sequence_ref.gotoFirstItem();
84 for(
size_t i2 = 0; i2 < reference_study_sequence_ref.getNumberOfItems(); i2++ ) {
85 DRTRTReferencedStudySequence::Item &rss_item = reference_study_sequence_ref.getCurrentItem();
86 DRTRTReferencedSeriesSequence &series_seq_ref = rss_item.getRTReferencedSeriesSequence();
87 G4cout <<
"@@@ NUMBER OF SeriesSequences " << series_seq_ref.getNumberOfItems() <<
G4endl;
88 series_seq_ref.gotoFirstItem();
89 for(
size_t i3 = 0; i3 < series_seq_ref.getNumberOfItems(); i3++ ) {
90 DRTRTReferencedSeriesSequence::Item &ref_series_seq_item = series_seq_ref.getCurrentItem();
91 DRTContourImageSequence &image_sequence_seq_ref =
92 ref_series_seq_item.getContourImageSequence();
93 G4cout <<
"@@ NUMBER OF ContourImageSequences "
94 << image_sequence_seq_ref.getNumberOfItems() <<
G4endl;
95 image_sequence_seq_ref.gotoFirstItem();
96 for(
size_t i4 = 0; i4 < image_sequence_seq_ref.getNumberOfItems(); i4++ ) {
97 DRTContourImageSequence::Item &image_contour_item =
98 image_sequence_seq_ref.getCurrentItem();
99 OFString refSOPInstUID;
100 image_contour_item.getReferencedSOPInstanceUID(refSOPInstUID);
101 std::cout <<
"ReferencedSOPInstanceUID= " << refSOPInstUID << std::endl;
102 image_sequence_seq_ref.gotoNextItem().good();
104 series_seq_ref.gotoNextItem();
106 reference_study_sequence_ref.gotoNextItem();
108 refSeq.gotoNextItem();
112 DRTStructureSetROISequence ROISeq = rtstruct.getStructureSetROISequence();
113 G4cout <<
"@@@@@ NUMBER OF ROISequences " << ROISeq.getNumberOfItems() <<
G4endl;
114 for(
size_t i1 = 0; i1 < ROISeq.getNumberOfItems(); i1++ ) {
115 DRTStructureSetROISequence::Item &item = ROISeq.getCurrentItem();
116 OFString ROIName, ROINumber, ROIGenerationAlgorithm;
117 item.getROINumber(ROINumber);
118 item.getROIName(ROIName);
119 item.getROIGenerationAlgorithm(ROIGenerationAlgorithm);
120 if( ROINumber !=
"" ) {
124 << ROIGenerationAlgorithm <<
G4endl;
127 ROISeq.gotoNextItem().good();
132 DRTROIContourSequence ROIContourSeq = rtstruct.getROIContourSequence();
133 if( ROISeq.getNumberOfItems() != ROIContourSeq.getNumberOfItems() ) {
137 (
"Different number of ROIs and ROI Contours "
138 + std::to_string(ROISeq.getNumberOfItems()) +
" <> "
139 + std::to_string(ROIContourSeq.getNumberOfItems())).c_str());
142 ROIContourSeq.gotoFirstItem();
143 for(
size_t i1 = 0; i1 < ROIContourSeq.getNumberOfItems(); i1++ ) {
144 DRTROIContourSequence::Item &item = ROIContourSeq.getCurrentItem();
145 OFString displayColor;
146 item.getROIDisplayColor(displayColor);
149 DRTContourSequence contour_seq = item.getContourSequence();
151 contour_seq.gotoFirstItem();
152 for(
size_t i2 = 0; i2 < contour_seq.getNumberOfItems(); i2++ ) {
155 DRTContourSequence::Item &cs_item = contour_seq.getCurrentItem();
159 DRTContourImageSequence &contour_image_seq = cs_item.getContourImageSequence();
161 contour_image_seq.gotoFirstItem();
162 for(
size_t i3 = 0; i3 < contour_image_seq.getNumberOfItems(); i3++ ) {
163 DRTContourImageSequence::Item cis_item = contour_image_seq.getCurrentItem();
165 cis_item.getReferencedSOPClassUID(refSOPCUID);
167 cis_item.getReferencedSOPInstanceUID(refSOPIUID);
168 if( refSOPIUID !=
"") roiC->
AddImageIUID(refSOPIUID.c_str());
169 contour_image_seq.gotoNextItem();
174 cs_item.getContourGeometricType(geomType);
176 cs_item.getNumberOfContourPoints(nPoints);
178 OFVector<Float64> data;
179 cs_item.getContourData(data);
180 std::vector<G4ThreeVector> dataV;
181 for( Sint32 ii = 0; ii < nPoints*3; ii++ ) {
182 if( ii%3 == 2 ) dataV.push_back(
G4ThreeVector( data[ii-2], data[ii-1], data[ii] ) );
187 contour_seq.gotoNextItem();
189 ROIContourSeq.gotoNextItem();
194 for(
size_t ii = 0; ii <
theROIs.size(); ii++ ) {
CLHEP::Hep3Vector G4ThreeVector
void SetData(std::vector< G4ThreeVector > data)
G4GLOB_DLL std::ostream G4cout
static G4int ConvertToInt(const char *st)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::vector< DicomROI * > theROIs
void SetGeomType(OFString gt)
DicomFileStructure(DcmDataset *dset)
void AddImageIUID(OFString ima)