Geant4  10.01
DicomPhantomZSliceMerged.cc
Go to the documentation of this file.
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 // $Id: DicomPhantomZSliceMerged.cc 87449 2014-12-04 14:13:06Z gunter $
27 //
30 //
31 //
32 // The code was written by :
33 // * Jonathan Madsen : jonathan.madsen@cern.ch (12/18/2012)
34 //
35 // Texas A&M University
36 // 3133 TAMU, Zachry Building
37 // College Station, TX 77843, USA
38 //
39 //*******************************************************
40 
41 
43 #include "G4UnitsTable.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 
50 {
51 
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 {
58  fSlices.clear();
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  G4cout << "\nDicomPhantomZSliceMerged::Checking "
66  << fSlices.size() << " fSlices..." << G4endl;
67 
68  G4bool uniformSliceThickness = true;
69 
70  if(fSlices.size() > 1) {
71  if(fSlices.size() == 2) {
72  DicomPhantomZSliceHeader* one = fSlices.begin()->second;
73  DicomPhantomZSliceHeader* two = fSlices.end()->second;
74 
75  G4double real_distance = (two->GetSliceLocation()-one->GetSliceLocation())/2.;
76 
77  if(one->GetMaxZ() != two->GetMinZ()) {
78  one->SetMaxZ(one->GetSliceLocation()+real_distance);
79  two->SetMinZ(two->GetSliceLocation()-real_distance);
80  //one->SetMinZ(one->GetSliceLocation()-real_distance);
81  //two->SetMaxZ(two->GetSliceLocation()+real_distance);
82  if(uniformSliceThickness) {
83  one->SetMinZ(one->GetSliceLocation()-real_distance);
84  two->SetMaxZ(two->GetSliceLocation()+real_distance);
85  }
86  }
87  } else {
88  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite0 = fSlices.begin();
89  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite1 = fSlices.begin();
90  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite2 = fSlices.begin();
91  ++ite1;
92  ++ite2; ++ite2;
93 
94  for(; ite2 != fSlices.end(); ++ite0, ++ite1, ++ite2) {
95  DicomPhantomZSliceHeader* prev = ite0->second;
96  DicomPhantomZSliceHeader* slice = ite1->second;
97  DicomPhantomZSliceHeader* next = ite2->second;
98  G4double real_max_distance = (next->GetSliceLocation() -
99  slice->GetSliceLocation())/2.;
100  G4double real_min_distance = (slice->GetSliceLocation() -
101  prev->GetSliceLocation())/2.;
102  G4double real_distance = real_max_distance + real_min_distance;
103  G4double stated_distance = slice->GetMaxZ()-slice->GetMinZ();
104  if(real_distance != stated_distance) {
105  unsigned int sliceNum = std::distance(fSlices.begin(),ite1);
106  G4cout << "\tDicomPhantomZSliceMerged::CheckSlices - \
107  Slice Distance Error in slice [" << sliceNum
108  << "]: Real Distance = "
109  << real_distance/mm
110  << " mm, Stated Distance = " << stated_distance/mm << G4endl;
111  slice->SetMinZ(slice->GetSliceLocation()-real_min_distance);
112  slice->SetMaxZ(slice->GetSliceLocation()+real_max_distance);
113 
114  if(ite0 == fSlices.begin()) {
115  prev->SetMaxZ(slice->GetMinZ());
116  // Using below would make all slice same thickness
117  //prev->SetMinZ(prev->GetSliceLocation()-real_min_distance);
118  if(uniformSliceThickness) {
119  prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); }
120 
121  }
122  if(static_cast<unsigned int>(std::distance(fSlices.begin(),ite2)+1)==
123  fSlices.size()) {
124  next->SetMinZ(slice->GetMaxZ());
125  // Using below would make all slice same thickness
126  //next->SetMaxZ(next->GetSliceLocation()+real_max_distance);
127  if(uniformSliceThickness) {
128  next->SetMaxZ(next->GetSliceLocation()+real_max_distance); }
129  }
130  }
131  }
132  }
133  }
134  G4cout << G4endl;
135 
136  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite = fSlices.begin();
137  for(ite = fSlices.begin(); ite != fSlices.end(); ++ite) {
138  ite->second->DumpToFile();
139  }
140 
141 
142 }
143 
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
void SetMinZ(const G4double &val)
const G4double & GetSliceLocation() const
std::map< G4double, DicomPhantomZSliceHeader * > fSlices
Definition of the DicomPhantomZSliceMerged class.
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
DicomPhantomZSliceHeader class.
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetMaxZ(const G4double &val)
static const double mm
Definition: G4SIunits.hh:102