Geant4  10.00.p01
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 73076 2013-08-16 07:45:30Z 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 
41 
43 #include "G4UnitsTable.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 //====================================================================================
47 
49 
50 {
51 
52 }
53 
54 //====================================================================================
55 
57 {
58  fSlices.clear();
59 }
60 
61 //====================================================================================
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 << "]: Real Distance = "
108  << real_distance/mm
109  << " mm, Stated Distance = " << stated_distance/mm << G4endl;
110  slice->SetMinZ(slice->GetSliceLocation()-real_min_distance);
111  slice->SetMaxZ(slice->GetSliceLocation()+real_max_distance);
112 
113  if(ite0 == fSlices.begin()) {
114  prev->SetMaxZ(slice->GetMinZ());
115  // Using below would make all slice same thickness
116  //prev->SetMinZ(prev->GetSliceLocation()-real_min_distance);
117  if(uniformSliceThickness) {
118  prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); }
119 
120  }
121  if(static_cast<unsigned int>(std::distance(fSlices.begin(), ite2)+1) ==
122  fSlices.size()) {
123  next->SetMinZ(slice->GetMaxZ());
124  // Using below would make all slice same thickness
125  //next->SetMaxZ(next->GetSliceLocation()+real_max_distance);
126  if(uniformSliceThickness) {
127  next->SetMaxZ(next->GetSliceLocation()+real_max_distance); }
128  }
129  }
130  }
131  }
132  }
133  G4cout << G4endl;
134 
135  std::map<G4double,DicomPhantomZSliceHeader*>::iterator ite = fSlices.begin();
136  for(ite = fSlices.begin(); ite != fSlices.end(); ++ite) {
137  ite->second->DumpToFile();
138  }
139 
140 
141 }
142 
143 
144 //====================================================================================
145 
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