Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 92820 2015-09-17 15:22:14Z gcosmo $
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 
42 #include "G4UnitsTable.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 {
49 
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56  fSlices.clear();
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  G4cout << "\nDicomPhantomZSliceMerged::Checking "
64  << fSlices.size() << " fSlices..." << G4endl;
65 
66  G4bool uniformSliceThickness = true;
67 
68  if(fSlices.size() > 1) {
69  if(fSlices.size() == 2) {
70  DicomPhantomZSliceHeader* one = fSlices.begin()->second;
71  DicomPhantomZSliceHeader* two = fSlices.end()->second;
72 
73  G4double real_distance = (two->GetSliceLocation()-one->GetSliceLocation())/2.;
74 
75  if(one->GetMaxZ() != two->GetMinZ()) {
76  one->SetMaxZ(one->GetSliceLocation()+real_distance);
77  two->SetMinZ(two->GetSliceLocation()-real_distance);
78  //one->SetMinZ(one->GetSliceLocation()-real_distance);
79  //two->SetMaxZ(two->GetSliceLocation()+real_distance);
80  if(uniformSliceThickness) {
81  one->SetMinZ(one->GetSliceLocation()-real_distance);
82  two->SetMaxZ(two->GetSliceLocation()+real_distance);
83  }
84  }
85  } else {
86  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite0 = fSlices.begin();
87  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite1 = fSlices.begin();
88  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite2 = fSlices.begin();
89  ++ite1;
90  ++ite2; ++ite2;
91 
92  for(; ite2 != fSlices.end(); ++ite0, ++ite1, ++ite2) {
93  DicomPhantomZSliceHeader* prev = ite0->second;
94  DicomPhantomZSliceHeader* slice = ite1->second;
95  DicomPhantomZSliceHeader* next = ite2->second;
96  G4double real_max_distance = (next->GetSliceLocation() -
97  slice->GetSliceLocation())/2.;
98  G4double real_min_distance = (slice->GetSliceLocation() -
99  prev->GetSliceLocation())/2.;
100  G4double real_distance = real_max_distance + real_min_distance;
101  G4double stated_distance = slice->GetMaxZ()-slice->GetMinZ();
102  if(real_distance != stated_distance) {
103  unsigned int sliceNum = std::distance(fSlices.begin(),ite1);
104  G4cout << "\tDicomPhantomZSliceMerged::CheckSlices - \
105  Slice Distance Error in slice [" << sliceNum
106  << "]: Real Distance = "
107  << real_distance/mm
108  << " mm, Stated Distance = " << stated_distance/mm << G4endl;
109  slice->SetMinZ(slice->GetSliceLocation()-real_min_distance);
110  slice->SetMaxZ(slice->GetSliceLocation()+real_max_distance);
111 
112  if(ite0 == fSlices.begin()) {
113  prev->SetMaxZ(slice->GetMinZ());
114  // Using below would make all slice same thickness
115  //prev->SetMinZ(prev->GetSliceLocation()-real_min_distance);
116  if(uniformSliceThickness) {
117  prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); }
118 
119  }
120  if(static_cast<unsigned int>(std::distance(fSlices.begin(),ite2)+1)==
121  fSlices.size()) {
122  next->SetMinZ(slice->GetMaxZ());
123  // Using below would make all slice same thickness
124  //next->SetMaxZ(next->GetSliceLocation()+real_max_distance);
125  if(uniformSliceThickness) {
126  next->SetMaxZ(next->GetSliceLocation()+real_max_distance); }
127  }
128  }
129  }
130  }
131  }
132  G4cout << G4endl;
133 
134  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite = fSlices.begin();
135  for(ite = fSlices.begin(); ite != fSlices.end(); ++ite) {
136  ite->second->DumpToFile();
137  }
138 
139 }
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static constexpr double mm
Definition: G4SIunits.hh:115
void SetMinZ(const G4double &val)
const G4double & GetSliceLocation() const
Definition of the DicomPhantomZSliceMerged class.
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetMaxZ(const G4double &val)