Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 #include "DicomBeamControlPoint.hh" 27 28 #include "DicomBeamDevicePos.hh" 29 #include "dcmtk/dcmrt/seq/drtcps.h" // for ControlPointSequence 30 31 #include "globals.hh" 32 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 34 DicomBeamControlPoint::DicomBeamControlPoint(DRTControlPointSequence::Item cpItem, 35 DicomBeamControlPoint* point0) 36 { 37 OFString fstr; 38 Sint32 fint; 39 Float64 ffloat; 40 Float32 ffloat32; 41 OFVector<Float64> fvfloat; 42 43 cpItem.getControlPointIndex(fint); 44 G4cout << " @ DicomBeamControlPoint: " << fint << G4endl; 45 G4cout << " " 46 << " ControlPointIndex " << fint << G4endl; 47 SetIndex(fint); 48 if (cpItem.getNominalBeamEnergy(ffloat) != EC_Normal) { 49 if (point0) ffloat = point0->GetNominalBeamEnergy(); 50 } 51 G4cout << " " 52 << " NominalBeamEnergy " << ffloat << G4endl; 53 SetNominalBeamEnergy(ffloat); 54 cpItem.getDoseRateSet(ffloat); // != EC_Normal ) { 55 G4cout << " " 56 << " DoseRateSet " << ffloat << G4endl; 57 58 DRTBeamLimitingDevicePositionSequence beamLDPS = cpItem.getBeamLimitingDevicePositionSequence(); 59 G4cout << " @ NUMBER OF BeamLimitingDevicePositionSequence " << beamLDPS.getNumberOfItems() 60 << G4endl; 61 beamLDPS.gotoFirstItem(); 62 for (size_t i3 = 0; i3 < beamLDPS.getNumberOfItems(); i3++) { 63 DRTBeamLimitingDevicePositionSequence::Item bldpsItem = beamLDPS.getCurrentItem(); 64 DicomBeamDevicePos* dbd = new DicomBeamDevicePos(bldpsItem); 65 AddDevice(dbd); 66 67 beamLDPS.gotoNextItem(); 68 } 69 70 cpItem.getGantryAngle(ffloat); 71 G4cout << " " 72 << " GantryAngle " << ffloat << G4endl; 73 74 cpItem.getGantryRotationDirection(fstr); //** 75 G4cout << " " 76 << " GantryRotationDirection " << fstr << G4endl; 77 if (fstr == "CC") { // counter-clockwise 78 SetGantryAngle(-ffloat); 79 } 80 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 81 SetGantryAngle(ffloat); 82 } 83 if (cpItem.getBeamLimitingDeviceAngle(ffloat) != EC_Normal) { 84 if (point0) ffloat = point0->GetBeamLimitingDeviceAngle(); 85 } 86 G4cout << " " 87 << " BeamLimitingDeviceAngle " << ffloat << G4endl; 88 89 if (cpItem.getBeamLimitingDeviceRotationDirection(fstr) != EC_Normal) { 90 if (point0) fstr = point0->GetBeamLimitingDeviceRotationDirection(); 91 } 92 if (fstr == "CC") { // counter-clockwise 93 SetBeamLimitingDeviceAngle(-ffloat); 94 } 95 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 96 SetBeamLimitingDeviceAngle(ffloat); 97 } 98 G4cout << " " 99 << " BeamLimitingDeviceRotationDirection " << fstr << G4endl; 100 SetBeamLimitingDeviceRotationDirection(fstr); 101 102 if (cpItem.getPatientSupportAngle(ffloat) != EC_Normal) { 103 if (point0) fstr = point0->GetPatientSupportAngle(); 104 } 105 G4cout << " " 106 << " PatientSupportAngle " << ffloat << G4endl; 107 108 if (cpItem.getPatientSupportRotationDirection(fstr) != EC_Normal) { 109 if (point0) fstr = point0->GetPatientSupportRotationDirection(); 110 } 111 G4cout << " " 112 << " PatientSupportRotationDirection " << fstr << G4endl; 113 SetPatientSupportRotationDirection(fstr); 114 if (fstr == "CC") { // counter-clockwise 115 SetPatientSupportAngle(-ffloat); 116 } 117 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 118 SetPatientSupportAngle(ffloat); 119 } 120 121 if (cpItem.getTableTopEccentricAngle(ffloat) != EC_Normal) { 122 if (point0) ffloat = point0->GetTableTopEccentricAngle(); 123 } 124 G4cout << " " 125 << " TableTopEccentricAngle " << ffloat << G4endl; 126 127 if (cpItem.getTableTopEccentricRotationDirection(fstr) != EC_Normal) { 128 if (point0) fstr = point0->GetTableTopEccentricRotationDirection(); 129 } 130 if (fstr == "CC") { // counter-clockwise 131 SetTableTopEccentricAngle(-ffloat); 132 } 133 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 134 SetTableTopEccentricAngle(ffloat); 135 } 136 G4cout << " " 137 << " TableTopEccentricRotationDirection " << fstr << G4endl; 138 SetTableTopEccentricRotationDirection(fstr); 139 140 G4ThreeVector isoCenter; 141 if (cpItem.getIsocenterPosition(fvfloat) != EC_Normal) { 142 if (point0) isoCenter = point0->GetIsocenterPosition(); 143 } 144 else { 145 isoCenter = G4ThreeVector(fvfloat[0], fvfloat[1], fvfloat[2]); 146 } 147 G4cout << " " 148 << " IsocenterPosition " << isoCenter << G4endl; 149 SetIsocenterPosition(isoCenter); 150 151 if (cpItem.getSourceToSurfaceDistance(ffloat) != EC_Normal) { 152 if (point0) ffloat = point0->GetSourceToSurfaceDistance(); 153 } 154 G4cout << " " 155 << " SourceToSurfaceDistance " << ffloat << G4endl; 156 SetSourceToSurfaceDistance(ffloat); 157 158 cpItem.getCumulativeMetersetWeight(ffloat); 159 G4cout << " " 160 << " CumulativeMetersetWeight " << ffloat << G4endl; 161 SetCumulativeMetersetWeight(ffloat); 162 163 if (cpItem.getGantryPitchAngle(ffloat32) != EC_Normal) { 164 if (point0) ffloat32 = point0->GetGantryPitchAngle(); 165 } 166 G4cout << " " 167 << " GantryPitchAngle " << ffloat32 << G4endl; 168 SetGantryPitchAngle(ffloat32); 169 170 if (cpItem.getSurfaceEntryPoint(ffloat) != EC_Normal) { 171 if (point0) ffloat = point0->GetSurfaceEntryPoint(); 172 } 173 G4cout << " " 174 << " SurfaceEntryPoint " << ffloat << G4endl; 175 SetSurfaceEntryPoint(ffloat); 176 177 if (cpItem.getTableTopEccentricAxisDistance(ffloat) != EC_Normal) { 178 if (point0) ffloat = point0->GetTableTopEccentricAxisDistance(); 179 } 180 G4cout << " " 181 << " TableTopEccentricAxisDistance " << ffloat << G4endl; 182 SetTableTopEccentricAxisDistance(ffloat); 183 184 if (cpItem.getTableTopLateralPosition(ffloat) != EC_Normal) { 185 if (point0) ffloat = point0->GetTableTopLateralPosition(); 186 } 187 G4cout << " " 188 << " TableTopLateralPosition " << ffloat << G4endl; 189 SetTableTopLateralPosition(ffloat); 190 191 if (cpItem.getTableTopLongitudinalPosition(ffloat) != EC_Normal) { 192 if (point0) ffloat = point0->GetTableTopLongitudinalPosition(); 193 } 194 G4cout << " " 195 << " TableTopLongitudinalPosition " << ffloat << G4endl; 196 SetTableTopLongitudinalPosition(ffloat); 197 198 if (cpItem.getTableTopPitchAngle(ffloat32) != EC_Normal) { 199 if (point0) ffloat32 = point0->GetTableTopPitchAngle(); 200 } 201 G4cout << " " 202 << " TableTopPitchAngle " << ffloat32 << G4endl; 203 204 if (cpItem.getTableTopPitchRotationDirection(fstr) != EC_Normal) { 205 if (point0) fstr = point0->GetTableTopPitchRotationDirection(); 206 } 207 if (fstr == "CC") { // counter-clockwise 208 SetTableTopPitchAngle(-ffloat32); 209 } 210 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 211 SetTableTopPitchAngle(ffloat32); 212 } 213 G4cout << " " 214 << " TableTopPitchRotationDirection " << fstr << G4endl; 215 SetTableTopPitchRotationDirection(fstr); 216 217 if (cpItem.getTableTopRollAngle(ffloat32) != EC_Normal) { 218 if (point0) ffloat32 = point0->GetTableTopRollAngle(); 219 } 220 G4cout << " " 221 << " TableTopRollAngle " << ffloat32 << G4endl; 222 223 if (cpItem.getTableTopRollRotationDirection(fstr) != EC_Normal) { 224 if (point0) fstr = point0->GetTableTopRollRotationDirection(); 225 } 226 if (fstr == "CC") { // counter-clockwise 227 SetTableTopRollAngle(-ffloat32); 228 } 229 else if (fstr == "CW" || fstr == "NONE" || fstr == "") { // clockwise 230 SetTableTopRollAngle(ffloat32); 231 } 232 G4cout << " " 233 << " TableTopRollRotationDirection " << fstr << G4endl; 234 SetTableTopRollRotationDirection(fstr); 235 236 if (cpItem.getTableTopVerticalPosition(ffloat) != EC_Normal) { 237 if (point0) ffloat = point0->GetTableTopVerticalPosition(); 238 } 239 G4cout << " " 240 << " TableTopVerticalPosition " << ffloat << G4endl; 241 SetTableTopVerticalPosition(ffloat); 242 243 // --- get DICOM sequence attributes --- 244 // t DRTWedgePositionSequence &getWedgePositionSequence() 245 // t const DRTWedgePositionSequence &getWedgePositionSequence() const 246 } 247 248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 249 void DicomBeamControlPoint::Print(std::ostream&) {} 250 251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 252 void DicomBeamControlPoint::DumpToFile(std::ofstream& fout) 253 { 254 fout << ":P ControlPointIndex " << theIndex << G4endl; 255 fout << ":P NominalBeamEnergy " << theNominalBeamEnergy << G4endl; 256 fout << ":P IsocenterPositionX " << theIsocenterPosition.x() << G4endl; 257 fout << ":P IsocenterPositionY " << theIsocenterPosition.y() << G4endl; 258 fout << ":P IsocenterPositionZ " << theIsocenterPosition.z() << G4endl; 259 260 // std::string iistr = std::to_string(theControlPointIndex); 261 fout << ":P SourceToSurfaceDistance " << theSourceToSurfaceDistance << G4endl; 262 fout << ":P GantryAngle " << theGantryAngle << G4endl; 263 fout << ":P BeamLimitingDeviceAngle " << theBeamLimitingDeviceAngle << G4endl; 264 fout << ":P PatientSupportAngle " << thePatientSupportAngle << G4endl; 265 fout << ":P TableTopEccentricAngle " << theTableTopEccentricAngle << G4endl; 266 fout << ":P SourceToSurfaceDistance " << theSourceToSurfaceDistance << G4endl; 267 fout << ":P MetersetWeight " << theMetersetWeight << G4endl; 268 fout << ":P GantryPitchAngle " << theGantryPitchAngle << G4endl; 269 fout << ":P SurfaceEntryPoint " << theSurfaceEntryPoint << G4endl; 270 fout << ":P TableTopEccentricAxisDistance " << theTableTopEccentricAxisDistance << G4endl; 271 fout << ":P TableTopLateralPosition " << theTableTopLateralPosition << G4endl; 272 fout << ":P TableTopLongitudinalPosition " << theTableTopLongitudinalPosition << G4endl; 273 fout << ":P TableTopPitchAngle " << theTableTopPitchAngle << G4endl; 274 fout << ":P TableTopRollAngle " << theTableTopRollAngle << G4endl; 275 fout << ":P TableTopVerticalPosition " << theTableTopVerticalPosition << G4endl; 276 277 for (size_t ii = 0; ii < theDevices.size(); ii++) { 278 theDevices[ii]->DumpToFile(fout); 279 } 280 } 281