Geant4 Cross Reference |
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 // $Id$ 26 // 27 // 27 /// \file medical/DICOM/src/DicomPhantomZSlice 28 /// \file medical/DICOM/src/DicomPhantomZSliceMerged.cc 28 /// \brief Implementation of the DicomPhantomZ 29 /// \brief Implementation of the DicomPhantomZSliceMerged class 29 // 30 // 30 // 31 // 31 // The code was written by : 32 // The code was written by : 32 // * Jonathan Madsen : jonathan.madsen@ce 33 // * Jonathan Madsen : jonathan.madsen@cern.ch (12/18/2012) 33 // 34 // 34 // Texas A&M University 35 // Texas A&M University 35 // 3133 TAMU, Zachry Building 36 // 3133 TAMU, Zachry Building 36 // College Station, TX 77843, USA 37 // College Station, TX 77843, USA 37 // 38 // 38 //******************************************** 39 //******************************************************* 39 40 40 #include "DicomPhantomZSliceMerged.hh" 41 #include "DicomPhantomZSliceMerged.hh" 41 << 42 #include "G4SystemOfUnits.hh" << 43 #include "G4UnitsTable.hh" 42 #include "G4UnitsTable.hh" >> 43 #include "G4SystemOfUnits.hh" 44 44 45 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 46 47 DicomPhantomZSliceMerged::DicomPhantomZSliceMe << 47 DicomPhantomZSliceMerged::DicomPhantomZSliceMerged() >> 48 { >> 49 >> 50 } 48 51 49 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 53 51 DicomPhantomZSliceMerged::~DicomPhantomZSliceM 54 DicomPhantomZSliceMerged::~DicomPhantomZSliceMerged() 52 { 55 { 53 fSlices.clear(); << 56 fSlices.clear(); 54 } 57 } 55 58 56 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 60 58 void DicomPhantomZSliceMerged::CheckSlices() 61 void DicomPhantomZSliceMerged::CheckSlices() 59 { 62 { 60 G4cout << "\nDicomPhantomZSliceMerged::Check << 63 G4cout << "\nDicomPhantomZSliceMerged::Checking " 61 << 64 << fSlices.size() << " fSlices..." << G4endl; >> 65 62 G4bool uniformSliceThickness = true; 66 G4bool uniformSliceThickness = true; 63 << 67 64 if (fSlices.size() > 1) { << 68 if(fSlices.size() > 1) { 65 if (fSlices.size() == 2) { << 69 if(fSlices.size() == 2) { 66 DicomPhantomZSliceHeader* one = fSlices. 70 DicomPhantomZSliceHeader* one = fSlices.begin()->second; 67 DicomPhantomZSliceHeader* two = fSlices. 71 DicomPhantomZSliceHeader* two = fSlices.end()->second; 68 << 72 69 G4double real_distance = (two->GetSliceL << 73 G4double real_distance = (two->GetSliceLocation()-one->GetSliceLocation())/2.; 70 << 74 71 if (one->GetMaxZ() != two->GetMinZ()) { << 75 if(one->GetMaxZ() != two->GetMinZ()) { 72 one->SetMaxZ(one->GetSliceLocation() + << 76 one->SetMaxZ(one->GetSliceLocation()+real_distance); 73 two->SetMinZ(two->GetSliceLocation() - << 77 two->SetMinZ(two->GetSliceLocation()-real_distance); 74 // one->SetMinZ(one->GetSliceLocation( << 78 //one->SetMinZ(one->GetSliceLocation()-real_distance); 75 // two->SetMaxZ(two->GetSliceLocation( << 79 //two->SetMaxZ(two->GetSliceLocation()+real_distance); 76 if (uniformSliceThickness) { << 80 if(uniformSliceThickness) { 77 one->SetMinZ(one->GetSliceLocation() << 81 one->SetMinZ(one->GetSliceLocation()-real_distance); 78 two->SetMaxZ(two->GetSliceLocation() << 82 two->SetMaxZ(two->GetSliceLocation()+real_distance); 79 } 83 } 80 } 84 } 81 } << 85 } else { 82 else { << 86 std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite0 = fSlices.begin(); 83 auto ite0 = fSlices.begin(); << 87 std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite1 = fSlices.begin(); 84 auto ite1 = fSlices.begin(); << 88 std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite2 = fSlices.begin(); 85 auto ite2 = fSlices.begin(); << 86 ++ite1; 89 ++ite1; 87 ++ite2; << 90 ++ite2; ++ite2; 88 ++ite2; << 91 89 << 92 for(; ite2 != fSlices.end(); ++ite0, ++ite1, ++ite2) { 90 for (; ite2 != fSlices.end(); ++ite0, ++ << 91 DicomPhantomZSliceHeader* prev = ite0- 93 DicomPhantomZSliceHeader* prev = ite0->second; 92 DicomPhantomZSliceHeader* slice = ite1 94 DicomPhantomZSliceHeader* slice = ite1->second; 93 DicomPhantomZSliceHeader* next = ite2- 95 DicomPhantomZSliceHeader* next = ite2->second; 94 G4double real_max_distance = (next->Ge << 96 G4double real_max_distance = (next->GetSliceLocation() - 95 G4double real_min_distance = (slice->G << 97 slice->GetSliceLocation())/2.; >> 98 G4double real_min_distance = (slice->GetSliceLocation() - >> 99 prev->GetSliceLocation())/2.; 96 G4double real_distance = real_max_dist 100 G4double real_distance = real_max_distance + real_min_distance; 97 G4double stated_distance = slice->GetM << 101 G4double stated_distance = slice->GetMaxZ()-slice->GetMinZ(); 98 if (real_distance != stated_distance) << 102 if(real_distance != stated_distance) { 99 uintmax_t sliceNum = std::distance(f << 103 unsigned int sliceNum = std::distance(fSlices.begin(),ite1); 100 G4cout << "\tDicomPhantomZSliceMerge 104 G4cout << "\tDicomPhantomZSliceMerged::CheckSlices - \ 101 Slice Distance Error in sl << 105 Slice Distance Error in slice [" << sliceNum 102 << sliceNum << "]: Real Dista << 106 << "]: Real Distance = " 103 << " mm, Stated Distance = " << 107 << real_distance/mm 104 slice->SetMinZ(slice->GetSliceLocati << 108 << " mm, Stated Distance = " << stated_distance/mm << G4endl; 105 slice->SetMaxZ(slice->GetSliceLocati << 109 slice->SetMinZ(slice->GetSliceLocation()-real_min_distance); 106 << 110 slice->SetMaxZ(slice->GetSliceLocation()+real_max_distance); 107 if (ite0 == fSlices.begin()) { << 111 >> 112 if(ite0 == fSlices.begin()) { 108 prev->SetMaxZ(slice->GetMinZ()); 113 prev->SetMaxZ(slice->GetMinZ()); 109 // Using below would make all slic 114 // Using below would make all slice same thickness 110 // prev->SetMinZ(prev->GetSliceLoc << 115 //prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); 111 if (uniformSliceThickness) { << 116 if(uniformSliceThickness) { 112 prev->SetMinZ(prev->GetSliceLoca << 117 prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); } 113 } << 118 114 } 119 } 115 if (static_cast<unsigned int>(std::d << 120 if(static_cast<unsigned int>(std::distance(fSlices.begin(),ite2)+1)== 116 { << 121 fSlices.size()) { 117 next->SetMinZ(slice->GetMaxZ()); 122 next->SetMinZ(slice->GetMaxZ()); 118 // Using below would make all slic 123 // Using below would make all slice same thickness 119 // next->SetMaxZ(next->GetSliceLoc << 124 //next->SetMaxZ(next->GetSliceLocation()+real_max_distance); 120 if (uniformSliceThickness) { << 125 if(uniformSliceThickness) { 121 next->SetMaxZ(next->GetSliceLoca << 126 next->SetMaxZ(next->GetSliceLocation()+real_max_distance); } 122 } << 123 } 127 } 124 } 128 } 125 } 129 } 126 } 130 } 127 } 131 } 128 G4cout << G4endl; 132 G4cout << G4endl; 129 << 133 130 for (auto ite = fSlices.cbegin(); ite != fSl << 134 std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite = fSlices.begin(); >> 135 for(ite = fSlices.begin(); ite != fSlices.end(); ++ite) { 131 ite->second->DumpToFile(); 136 ite->second->DumpToFile(); 132 } 137 } >> 138 133 } 139 } 134 //....oooOO0OOooo........oooOO0OOooo........oo 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 135 141