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3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/DICOM/dicomReader/src/DicomFileStructure.cc (Version 11.3.0) and /examples/extended/medical/DICOM/dicomReader/src/DicomFileStructure.cc (Version 10.3.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 #include "DicomFileStructure.hh"                   26 #include "DicomFileStructure.hh"
 27                                                    27 
 28 #include "dcmtk/config/osconfig.h"  // make su <<  28 #include "G4ThreeVector.hh"
 29 #include "dcmtk/dcmdata/dcdeftag.h"            <<  29 
 30 #include "dcmtk/dcmdata/dcfilefo.h"                30 #include "dcmtk/dcmdata/dcfilefo.h"
                                                   >>  31 #include "dcmtk/dcmdata/dcdeftag.h"
 31 #include "dcmtk/dcmdata/dcpixel.h"                 32 #include "dcmtk/dcmdata/dcpixel.h"
 32 #include "dcmtk/dcmdata/dcpixseq.h"            << 
 33 #include "dcmtk/dcmdata/dcpxitem.h"                33 #include "dcmtk/dcmdata/dcpxitem.h"
                                                   >>  34 #include "dcmtk/dcmdata/dcpixseq.h"
 34 #include "dcmtk/dcmrt/drtstrct.h"                  35 #include "dcmtk/dcmrt/drtstrct.h"
 35 #include "dcmtk/dcmrt/seq/drtcis.h"  // for Co << 
 36 #include "dcmtk/dcmrt/seq/drtcs.h"  // for Con << 
 37 #include "dcmtk/dcmrt/seq/drtrcs.h"  // for RO << 
 38 #include "dcmtk/dcmrt/seq/drtrfors.h"  // for      36 #include "dcmtk/dcmrt/seq/drtrfors.h"  // for ReferencedFrameOfReferenceSequence
 39 #include "dcmtk/dcmrt/seq/drtssrs.h"  // for S <<  37 #include "dcmtk/dcmrt/seq/drtssrs.h"   // for StructureSetROISequence
 40                                                <<  38 #include "dcmtk/dcmrt/seq/drtrcs.h"      // for ROIContourSequence
 41 #include "G4ThreeVector.hh"                    <<  39 #include "dcmtk/dcmrt/seq/drtcs.h"      // for ContourSequence
                                                   >>  40 #include "dcmtk/dcmrt/seq/drtcis.h"      // for ContourImageSequence
                                                   >>  41 #include "dcmtk/config/osconfig.h"   // make sure OS specific configuration is included 
 42 #include "G4UIcommand.hh"                          42 #include "G4UIcommand.hh"
 43                                                    43 
 44 //....oooOO0OOooo........oooOO0OOooo........oo     44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 45 DicomFileStructure::DicomFileStructure(DcmData <<  45 DicomFileStructure::DicomFileStructure(DcmDataset* dset) : DicomVFile(dset)
                                                   >>  46 {
                                                   >>  47 }
 46                                                    48 
 47 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 48 void DicomFileStructure::ReadData()                50 void DicomFileStructure::ReadData()
 49 {                                                  51 {
 50   DRTStructureSetIOD rtstruct;                     52   DRTStructureSetIOD rtstruct;
 51   OFCondition result = rtstruct.read(*theDatas     53   OFCondition result = rtstruct.read(*theDataset);
 52   //  DCMRT_INFO("Read RT Structure Set: " <<      54   //  DCMRT_INFO("Read RT Structure Set: " << status.text());
 53   if (!result.good()) {                            55   if (!result.good()) {
 54     G4Exception("DicomFileStructure::ReadData" <<  56     G4Exception("DicomFileStructure::ReadData",
                                                   >>  57                 "DFS001",
                                                   >>  58                 FatalException,
                                                   >>  59                 result.text());
 55   }                                                60   }
 56                                                    61 
                                                   >>  62 
 57   //@@@@@@@@@@@@ DRTReferencedFrameOfReference     63   //@@@@@@@@@@@@ DRTReferencedFrameOfReferenceSequence
 58   DRTReferencedFrameOfReferenceSequence refSeq     64   DRTReferencedFrameOfReferenceSequence refSeq = rtstruct.getReferencedFrameOfReferenceSequence();
 59   if (refSeq.isEmpty()) {                      <<  65   if( refSeq.isEmpty() ) {
 60     G4Exception("DicomFileStructure::ReadData" <<  66     G4Exception("DicomFileStructure::ReadData",
                                                   >>  67                 "DFS002",
                                                   >>  68                 JustWarning,
 61                 "DRTReferencedFrameOfReference     69                 "DRTReferencedFrameOfReferenceSequence is empty");
 62   }                                                70   }
 63                                                    71 
 64   G4cout << "@@@@@ NUMBER OF ReferenceSequence     72   G4cout << "@@@@@ NUMBER OF ReferenceSequences " << refSeq.getNumberOfItems() << G4endl;
 65   refSeq.gotoFirstItem();                          73   refSeq.gotoFirstItem();
 66   for (size_t i1 = 0; i1 < refSeq.getNumberOfI <<  74   for( size_t i1 = 0; i1 < refSeq.getNumberOfItems(); i1++ ) {
 67     DRTReferencedFrameOfReferenceSequence::Ite <<  75     DRTReferencedFrameOfReferenceSequence::Item &item = refSeq.getCurrentItem();
 68     OFString uid;                                  76     OFString uid;
 69     item.getFrameOfReferenceUID(uid);              77     item.getFrameOfReferenceUID(uid);
 70     G4cout << " FrameOfReferenceUID " << uid <     78     G4cout << " FrameOfReferenceUID " << uid << G4endl;
 71     DRTRTReferencedStudySequence& reference_st <<  79     DRTRTReferencedStudySequence &reference_study_sequence_ref = 
 72       item.getRTReferencedStudySequence();     <<  80      item.getRTReferencedStudySequence();   
 73     G4cout << "@@@@ NUMBER OF ReferenceStudySe <<  81     G4cout << "@@@@ NUMBER OF ReferenceStudySequences " 
 74            << reference_study_sequence_ref.get     82            << reference_study_sequence_ref.getNumberOfItems() << G4endl;
 75     reference_study_sequence_ref.gotoFirstItem     83     reference_study_sequence_ref.gotoFirstItem();
 76     for (size_t i2 = 0; i2 < reference_study_s <<  84     for( size_t i2 = 0; i2 < reference_study_sequence_ref.getNumberOfItems(); i2++ ) {
 77       DRTRTReferencedStudySequence::Item& rss_ <<  85       DRTRTReferencedStudySequence::Item &rss_item = reference_study_sequence_ref.getCurrentItem();
 78       DRTRTReferencedSeriesSequence& series_se <<  86       DRTRTReferencedSeriesSequence &series_seq_ref = rss_item.getRTReferencedSeriesSequence();
 79       G4cout << "@@@ NUMBER OF SeriesSequences     87       G4cout << "@@@ NUMBER OF SeriesSequences " << series_seq_ref.getNumberOfItems() << G4endl;
 80       series_seq_ref.gotoFirstItem();              88       series_seq_ref.gotoFirstItem();
 81       for (size_t i3 = 0; i3 < series_seq_ref. <<  89       for( size_t i3 = 0; i3 < series_seq_ref.getNumberOfItems(); i3++ ) {
 82         DRTRTReferencedSeriesSequence::Item& r <<  90         DRTRTReferencedSeriesSequence::Item &ref_series_seq_item = series_seq_ref.getCurrentItem();
 83         DRTContourImageSequence& image_sequenc <<  91         DRTContourImageSequence &image_sequence_seq_ref = 
 84           ref_series_seq_item.getContourImageS <<  92          ref_series_seq_item.getContourImageSequence();
 85         G4cout << "@@ NUMBER OF ContourImageSe <<  93         G4cout << "@@ NUMBER OF ContourImageSequences "
 86                << G4endl;                      <<  94                << image_sequence_seq_ref.getNumberOfItems() << G4endl;
 87         image_sequence_seq_ref.gotoFirstItem()     95         image_sequence_seq_ref.gotoFirstItem();
 88         for (size_t i4 = 0; i4 < image_sequenc <<  96         for( size_t i4 = 0; i4 < image_sequence_seq_ref.getNumberOfItems(); i4++ ) {
 89           DRTContourImageSequence::Item& image <<  97           DRTContourImageSequence::Item &image_contour_item = 
 90             image_sequence_seq_ref.getCurrentI <<  98            image_sequence_seq_ref.getCurrentItem();
 91           OFString refSOPInstUID;                  99           OFString refSOPInstUID;
 92           image_contour_item.getReferencedSOPI    100           image_contour_item.getReferencedSOPInstanceUID(refSOPInstUID);
 93           std::cout << "ReferencedSOPInstanceU << 101           std::cout <<"ReferencedSOPInstanceUID= " << refSOPInstUID << std::endl;
 94           image_sequence_seq_ref.gotoNextItem(    102           image_sequence_seq_ref.gotoNextItem().good();
 95         }  // end if image_sequence_seq_ref    << 103         } // end if image_sequence_seq_ref
 96         series_seq_ref.gotoNextItem();            104         series_seq_ref.gotoNextItem();
 97       }  // end if series_seq_ref good         << 105       } // end if series_seq_ref good
 98       reference_study_sequence_ref.gotoNextIte    106       reference_study_sequence_ref.gotoNextItem();
 99     }  // end if reference_study_sequence_ref  << 107     } // end if reference_study_sequence_ref good
100     refSeq.gotoNextItem();                        108     refSeq.gotoNextItem();
101   }  // end if refSeq.first item               << 109   } // end if refSeq.first item
102                                                << 110   
103   //@@@@@@@@@@@@   DRTROISequence              << 111   //@@@@@@@@@@@@   DRTROISequence 
104   DRTStructureSetROISequence ROISeq = rtstruct    112   DRTStructureSetROISequence ROISeq = rtstruct.getStructureSetROISequence();
105   G4cout << "@@@@@ NUMBER OF ROISequences " <<    113   G4cout << "@@@@@ NUMBER OF ROISequences " << ROISeq.getNumberOfItems() << G4endl;
106   for (size_t i1 = 0; i1 < ROISeq.getNumberOfI << 114   for( size_t i1 = 0; i1 < ROISeq.getNumberOfItems(); i1++ ) {
107     DRTStructureSetROISequence::Item& item = R << 115     DRTStructureSetROISequence::Item &item = ROISeq.getCurrentItem();
108     OFString ROIName, ROINumber, ROIGeneration    116     OFString ROIName, ROINumber, ROIGenerationAlgorithm;
109     item.getROINumber(ROINumber);                 117     item.getROINumber(ROINumber);
110     item.getROIName(ROIName);                     118     item.getROIName(ROIName);
111     item.getROIGenerationAlgorithm(ROIGenerati    119     item.getROIGenerationAlgorithm(ROIGenerationAlgorithm);
112     if (ROINumber != "") {                     << 120     if( ROINumber != "" ) {
113       DicomROI* roi = new DicomROI(G4UIcommand    121       DicomROI* roi = new DicomROI(G4UIcommand::ConvertToInt(ROINumber.c_str()), ROIName.c_str());
114       theROIs.push_back(roi);                  << 122       theROIs.push_back( roi );
115       G4cout << " ROI: " << roi->GetNumber() <    123       G4cout << " ROI: " << roi->GetNumber() << " " << roi->GetName() << " "
116              << ROIGenerationAlgorithm << G4en    124              << ROIGenerationAlgorithm << G4endl;
117     }                                             125     }
118                                                   126 
119     ROISeq.gotoNextItem().good();                 127     ROISeq.gotoNextItem().good();
120   }  // end if ROISeq.first item               << 128   } // end if ROISeq.first item
                                                   >> 129 
121                                                   130 
122   //@@@@@@@@@@@@   DRTROIContourSequence          131   //@@@@@@@@@@@@   DRTROIContourSequence
123   DRTROIContourSequence ROIContourSeq = rtstru    132   DRTROIContourSequence ROIContourSeq = rtstruct.getROIContourSequence();
124   if (ROISeq.getNumberOfItems() != ROIContourS << 133   if( ROISeq.getNumberOfItems() != ROIContourSeq.getNumberOfItems() ) {
125     G4Exception("DicomFileStructure", "DCS0001 << 134     G4Exception("DicomFileStructure",
126                 ("Different number of ROIs and << 135                 "DCS0001",
127                  + std::to_string(ROISeq.getNu << 136                 FatalException,
128                  + std::to_string(ROIContourSe << 137                 ("Different number of ROIs and ROI Contours " 
129                   .c_str());                   << 138                  + std::to_string(ROISeq.getNumberOfItems()) + " <> " 
130   }                                            << 139                  + std::to_string(ROIContourSeq.getNumberOfItems())).c_str());
                                                   >> 140   } 
131                                                   141 
132   ROIContourSeq.gotoFirstItem();                  142   ROIContourSeq.gotoFirstItem();
133   for (size_t i1 = 0; i1 < ROIContourSeq.getNu << 143   for( size_t i1 = 0; i1 < ROIContourSeq.getNumberOfItems(); i1++ ) {
134     DRTROIContourSequence::Item& item = ROICon << 144     DRTROIContourSequence::Item &item = ROIContourSeq.getCurrentItem();
135     OFString displayColor;                        145     OFString displayColor;
136     item.getROIDisplayColor(displayColor);        146     item.getROIDisplayColor(displayColor);
137     //    G4cout << " ROIDisplayColor " << dis    147     //    G4cout << " ROIDisplayColor " << displayColor << G4endl;
138                                                << 148     
139     DRTContourSequence contour_seq = item.getC    149     DRTContourSequence contour_seq = item.getContourSequence();
140     //    G4cout << "@@@@ NUMBER OF ContourSeq    150     //    G4cout << "@@@@ NUMBER OF ContourSequences " << contour_seq.getNumberOfItems() << G4endl;
141     contour_seq.gotoFirstItem();                  151     contour_seq.gotoFirstItem();
142     for (size_t i2 = 0; i2 < contour_seq.getNu << 152     for( size_t i2 = 0; i2 < contour_seq.getNumberOfItems(); i2++ ) {
143       //      if (contour_seq.gotoFirstItem().    153       //      if (contour_seq.gotoFirstItem().good()) {
144       //        do {                              154       //        do {
145       DRTContourSequence::Item& cs_item = cont << 155       DRTContourSequence::Item &cs_item = contour_seq.getCurrentItem();
146                                                << 156       
147       DicomROIContour* roiC = new DicomROICont    157       DicomROIContour* roiC = new DicomROIContour();
148                                                << 158       
149       DRTContourImageSequence& contour_image_s << 159       DRTContourImageSequence &contour_image_seq = cs_item.getContourImageSequence();
150                                                << 160       
151       contour_image_seq.gotoFirstItem();          161       contour_image_seq.gotoFirstItem();
152       for (size_t i3 = 0; i3 < contour_image_s << 162       for( size_t i3 = 0; i3 < contour_image_seq.getNumberOfItems(); i3++ ) {
153         DRTContourImageSequence::Item cis_item    163         DRTContourImageSequence::Item cis_item = contour_image_seq.getCurrentItem();
154         OFString refSOPCUID;                      164         OFString refSOPCUID;
155         cis_item.getReferencedSOPClassUID(refS    165         cis_item.getReferencedSOPClassUID(refSOPCUID);
156         OFString refSOPIUID;                      166         OFString refSOPIUID;
157         cis_item.getReferencedSOPInstanceUID(r    167         cis_item.getReferencedSOPInstanceUID(refSOPIUID);
158         if (refSOPIUID != "") roiC->AddImageIU << 168         if( refSOPIUID != "") roiC->AddImageIUID(refSOPIUID.c_str());
159         contour_image_seq.gotoNextItem();         169         contour_image_seq.gotoNextItem();
160       }  // end if contour_image_seq           << 170       } // end if contour_image_seq
161                                                << 171       
162       //@@@                                    << 172         //@@@
163       OFString geomType;                          173       OFString geomType;
164       cs_item.getContourGeometricType(geomType    174       cs_item.getContourGeometricType(geomType);
165       Sint32 nPoints;                             175       Sint32 nPoints;
166       cs_item.getNumberOfContourPoints(nPoints    176       cs_item.getNumberOfContourPoints(nPoints);
167       roiC->SetGeomType(geomType);                177       roiC->SetGeomType(geomType);
168       OFVector<Float64> data;                     178       OFVector<Float64> data;
169       cs_item.getContourData(data);               179       cs_item.getContourData(data);
170       std::vector<G4ThreeVector> dataV;           180       std::vector<G4ThreeVector> dataV;
171       for (Sint32 ii = 0; ii < nPoints * 3; ii << 181       for( Sint32 ii = 0; ii < nPoints*3; ii++ ) {
172         if (ii % 3 == 2) dataV.push_back(G4Thr << 182         if( ii%3 == 2 ) dataV.push_back( G4ThreeVector( data[ii-2], data[ii-1], data[ii] ) );
173       }                                           183       }
174       roiC->SetData(dataV);                       184       roiC->SetData(dataV);
175       theROIs[i1]->AddContour(roiC);              185       theROIs[i1]->AddContour(roiC);
176                                                   186 
177       contour_seq.gotoNextItem();                 187       contour_seq.gotoNextItem();
178     }                                             188     }
179     ROIContourSeq.gotoNextItem();                 189     ROIContourSeq.gotoNextItem();
180   }  // end if ROIContourSeq.first item        << 190   } // end if ROIContourSeq.first item
181                                                   191 
182   //@@@@ Print ROIs                               192   //@@@@ Print ROIs
183   G4cout << " @@@@@@@@@@@ ROIs " << G4endl;       193   G4cout << " @@@@@@@@@@@ ROIs " << G4endl;
184   for (size_t ii = 0; ii < theROIs.size(); ii+ << 194   for( size_t ii = 0; ii < theROIs.size(); ii++ ) {
185     theROIs[ii]->Print(G4cout);                   195     theROIs[ii]->Print(G4cout);
186   }                                               196   }
187 }                                                 197 }
                                                   >> 198 
188                                                   199