Geant4  10.02.p03
DicomPhantomZSliceHeader Class Reference

#include <DicomPhantomZSliceHeader.hh>

Collaboration diagram for DicomPhantomZSliceHeader:

Public Member Functions

 DicomPhantomZSliceHeader (const G4String &)
 
 DicomPhantomZSliceHeader (const DicomPhantomZSliceHeader &rhs)
 
 DicomPhantomZSliceHeader (std::ifstream &fin)
 
 ~DicomPhantomZSliceHeader ()
 
G4int GetNoVoxelX () const
 
G4int GetNoVoxelY () const
 
G4int GetNoVoxelZ () const
 
G4int GetNoVoxels () const
 
G4double GetMinX () const
 
G4double GetMinY () const
 
G4double GetMinZ () const
 
G4double GetMaxX () const
 
G4double GetMaxY () const
 
G4double GetMaxZ () const
 
G4double GetVoxelHalfX () const
 
G4double GetVoxelHalfY () const
 
G4double GetVoxelHalfZ () const
 
const std::vector< G4String > & GetMaterialNames () const
 
void SetNoVoxelX (const G4int &val)
 
void SetNoVoxelY (const G4int &val)
 
void SetNoVoxelZ (const G4int &val)
 
void SetMinX (const G4double &val)
 
void SetMaxX (const G4double &val)
 
void SetMinY (const G4double &val)
 
void SetMaxY (const G4double &val)
 
void SetMinZ (const G4double &val)
 
void SetMaxZ (const G4double &val)
 
void SetMaterialNames (std::vector< G4String > &mn)
 
void operator+= (const DicomPhantomZSliceHeader &rhs)
 
DicomPhantomZSliceHeader operator+ (const DicomPhantomZSliceHeader &rhs)
 
void SetFilename (const G4String &val)
 
void SetSliceLocation (const G4double &val)
 
void AddMaterial (const G4String &val)
 
const G4doubleGetSliceLocation () const
 
void AddRow ()
 
void AddValue (G4double val)
 
void AddValue (const std::vector< G4double > &val)
 
void AddValue (const std::vector< std::vector< G4double > > &val)
 
void AddMateID (G4int val)
 
void AddMateID (const std::vector< G4int > &val)
 
void AddMateID (const std::vector< std::vector< G4int > > &val)
 
const std::vector< std::vector< G4double > > & GetValues () const
 
const std::vector< std::vector< G4int > > & GetMateIDs () const
 
void DumpToFile ()
 
void ReadDataFromFile ()
 
void DumpExcessMemory ()
 
void FlipData ()
 

Private Member Functions

G4bool IsInteger (const G4String &)
 
template<typename T >
void Print (std::ostream &, const std::vector< T > &, const G4String &, G4int breakLine=-1)
 
template<typename T >
G4s2n (const G4String &)
 
template<typename T >
bool CheckConsistency (const T &, const T &, G4String)
 
G4bool CheckMaterialExists (const G4String &mateName)
 

Private Attributes

G4int fNoVoxelX
 
G4int fNoVoxelY
 
G4int fNoVoxelZ
 
G4double fMinX
 
G4double fMinY
 
G4double fMinZ
 
G4double fMaxX
 
G4double fMaxY
 
G4double fMaxZ
 
std::vector< G4StringfMaterialNames
 
G4String fFilename
 
std::vector< std::vector< G4double > > fValues
 
std::vector< std::vector< G4int > > fMateIDs
 
G4double fSliceLocation
 

Detailed Description

DicomPhantomZSliceHeader class

Contains the meta data information corresponding to one or several Z slices (number of voxels, dimension)

History: 30.11.07 First version

Author
P. Arce

Definition at line 50 of file DicomPhantomZSliceHeader.hh.

Constructor & Destructor Documentation

◆ DicomPhantomZSliceHeader() [1/3]

◆ DicomPhantomZSliceHeader() [2/3]

DicomPhantomZSliceHeader::DicomPhantomZSliceHeader ( const DicomPhantomZSliceHeader rhs)

Definition at line 57 of file DicomPhantomZSliceHeader.cc.

59 {
60  fNoVoxelX = rhs.GetNoVoxelX();
61  fNoVoxelY = rhs.GetNoVoxelY();
62  fNoVoxelZ = rhs.GetNoVoxelZ();
63  fMinX = rhs.GetMinX();
64  fMaxX = rhs.GetMaxX();
65  fMinY = rhs.GetMinY();
66  fMaxY = rhs.GetMaxY();
67  fMinZ = rhs.GetMinZ();
68  fMaxZ = rhs.GetMaxZ();
70  fFilename = rhs.fFilename;
71  fValues = rhs.fValues;
72  fMateIDs = rhs.fMateIDs;
74 }
std::vector< std::vector< G4int > > fMateIDs
const std::vector< G4String > & GetMaterialNames() const
std::vector< G4String > fMaterialNames
std::vector< std::vector< G4double > > fValues
Here is the call graph for this function:

◆ DicomPhantomZSliceHeader() [3/3]

DicomPhantomZSliceHeader::DicomPhantomZSliceHeader ( std::ifstream &  fin)

Definition at line 77 of file DicomPhantomZSliceHeader.cc.

78 {
79  //----- Read material indices and names
80  G4int nmate;
81  G4String mateindex;
82  G4String matename;
83  fin >> nmate;
84 #ifdef G4VERBOSE
85  G4cout << " DicomPhantomZSliceHeader reading number of materials "
86  << nmate << G4endl;
87 #endif
88 
89  for( G4int im = 0; im < nmate; im++ ){
90  fin >> mateindex >> matename;
91 #ifdef G4VERBOSE
92  G4cout << " DicomPhantomZSliceHeader reading material " << im << " : "
93  << mateindex << " " << matename << G4endl;
94 #endif
95 
96  if( ! CheckMaterialExists( matename ) ) {
97  G4Exception("DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
98  "A material is found in file that is not built in the C++ code",
99  FatalErrorInArgument, matename.c_str());
100  }
101 
102  fMaterialNames.push_back(matename);
103  }
104 
105  //----- Read number of voxels
106  fin >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
107 #ifdef G4VERBOSE
108  G4cout << " Number of voxels " << fNoVoxelX << " " << fNoVoxelY
109  << " " << fNoVoxelZ << G4endl;
110 #endif
111 
112  //----- Read minimal and maximal extensions (= walls of phantom)
113  fin >> fMinX >> fMaxX;
114  fin >> fMinY >> fMaxY;
115  fin >> fMinZ >> fMaxZ;
116 #ifdef G4VERBOSE
117  G4cout << " Extension in X " << fMinX << " " << fMaxX << G4endl
118  << " Extension in Y " << fMinY << " " << fMaxY << G4endl
119  << " Extension in Z " << fMinZ << " " << fMaxZ << G4endl;
120 #endif
121 
122  fSliceLocation = 0.5*(fMinZ + fMaxZ);
123 }
TString fin
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
std::vector< G4String > fMaterialNames
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4bool CheckMaterialExists(const G4String &mateName)
Here is the call graph for this function:

◆ ~DicomPhantomZSliceHeader()

DicomPhantomZSliceHeader::~DicomPhantomZSliceHeader ( )

Definition at line 51 of file DicomPhantomZSliceHeader.cc.

52 {
53 
54 }

Member Function Documentation

◆ AddMateID() [1/3]

void DicomPhantomZSliceHeader::AddMateID ( G4int  val)
inline

Definition at line 130 of file DicomPhantomZSliceHeader.hh.

130  { (fMateIDs.size() > 0) ?
131  fMateIDs.back().push_back(val) :
132  fMateIDs.push_back(std::vector<G4int>(1,val)); }
std::vector< std::vector< G4int > > fMateIDs
Here is the caller graph for this function:

◆ AddMateID() [2/3]

void DicomPhantomZSliceHeader::AddMateID ( const std::vector< G4int > &  val)
inline

Definition at line 133 of file DicomPhantomZSliceHeader.hh.

133 { fMateIDs.push_back(val); }
std::vector< std::vector< G4int > > fMateIDs

◆ AddMateID() [3/3]

void DicomPhantomZSliceHeader::AddMateID ( const std::vector< std::vector< G4int > > &  val)
inline

Definition at line 134 of file DicomPhantomZSliceHeader.hh.

134  {
135  for(unsigned int i = 0; i < val.size(); ++i) { fMateIDs.push_back(val.at(i)); }
136  }
std::vector< std::vector< G4int > > fMateIDs

◆ AddMaterial()

void DicomPhantomZSliceHeader::AddMaterial ( const G4String val)
inline

Definition at line 115 of file DicomPhantomZSliceHeader.hh.

115 { fMaterialNames.push_back(val); }
std::vector< G4String > fMaterialNames
Here is the caller graph for this function:

◆ AddRow()

void DicomPhantomZSliceHeader::AddRow ( )
inline

Definition at line 119 of file DicomPhantomZSliceHeader.hh.

119  { fValues.push_back(std::vector<G4double>(0));
120  fMateIDs.push_back(std::vector<G4int>(0)); }
std::vector< std::vector< G4int > > fMateIDs
std::vector< std::vector< G4double > > fValues
Here is the caller graph for this function:

◆ AddValue() [1/3]

void DicomPhantomZSliceHeader::AddValue ( G4double  val)
inline

Definition at line 122 of file DicomPhantomZSliceHeader.hh.

122  { (fValues.size() > 0) ?
123  fValues.back().push_back(val) :
124  fValues.push_back(std::vector<G4double>(1,val)); }
std::vector< std::vector< G4double > > fValues
Here is the caller graph for this function:

◆ AddValue() [2/3]

void DicomPhantomZSliceHeader::AddValue ( const std::vector< G4double > &  val)
inline

Definition at line 125 of file DicomPhantomZSliceHeader.hh.

125 { fValues.push_back(val); }
std::vector< std::vector< G4double > > fValues

◆ AddValue() [3/3]

void DicomPhantomZSliceHeader::AddValue ( const std::vector< std::vector< G4double > > &  val)
inline

Definition at line 126 of file DicomPhantomZSliceHeader.hh.

126  {
127  for(unsigned int i = 0; i < val.size(); ++i) { fValues.push_back(val.at(i)); }
128  }
std::vector< std::vector< G4double > > fValues

◆ CheckConsistency()

template<typename T >
bool DicomPhantomZSliceHeader::CheckConsistency ( const T &  val1,
const T &  val2,
G4String  category 
)
inlineprivate

Definition at line 203 of file DicomPhantomZSliceHeader.hh.

204  {
205  if(val1 != val2) {
206  G4Exception("DicomPhantomSliceZHeader::CheckConsistency",
207  "Consistency Mismatch : Keeping previous value if nonzero",
208  JustWarning, category.c_str());
209  return false;
210  }
211  return true;
212 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckMaterialExists()

G4bool DicomPhantomZSliceHeader::CheckMaterialExists ( const G4String mateName)
private

Definition at line 126 of file DicomPhantomZSliceHeader.cc.

127 {
129  std::vector<G4Material*>::const_iterator matite;
130  for( matite = matTab->begin(); matite != matTab->end(); ++matite ) {
131  if( (*matite)->GetName() == mateName ) { return true; }
132  }
133 
134  return false;
135 
136 }
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
std::vector< G4Material * > G4MaterialTable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpExcessMemory()

void DicomPhantomZSliceHeader::DumpExcessMemory ( )
inline

Definition at line 144 of file DicomPhantomZSliceHeader.hh.

144  {
145  if(fFilename.length() != 0) { fValues.clear(); fMateIDs.clear(); } }
std::vector< std::vector< G4int > > fMateIDs
std::vector< std::vector< G4double > > fValues
Here is the call graph for this function:

◆ DumpToFile()

void DicomPhantomZSliceHeader::DumpToFile ( )

Definition at line 220 of file DicomPhantomZSliceHeader.cc.

221 {
222 
223  G4cout << "DicomPhantomZSliceHeader::Dumping Z Slice data to "
224  << fFilename << "..." << G4endl;
225  //sleep(5);
226 
227  // May seen counter-intuitive (dumping to file you are reading from), but
228  // the reason for this is modification slice spacing
229  if(fMateIDs.size() == 0 || fValues.size() == 0) { ReadDataFromFile(); }
230 
231 
232  std::ofstream out;
233  out.open(fFilename.c_str());
234 
235  if(!out) {
236  G4String descript = "DicomPhantomZSliceHeader::DumpToFile: could not open "
237  +fFilename;
238  G4Exception(descript.c_str(),"", FatalException, "");
239  }
240 
241  out << fMaterialNames.size() << std::endl;
242  for(unsigned int i = 0; i < fMaterialNames.size(); ++i) {
243  out << i << " " << fMaterialNames.at(i) << std::endl;
244  }
245 
246  out << fNoVoxelX << " " << fNoVoxelY << " " << fNoVoxelZ << std::endl;
247  out << fMinX << " " << fMaxX << std::endl;
248  out << fMinY << " " << fMaxY << std::endl;
249  out << fMinZ << " " << fMaxZ << std::endl;
250 
251  for(unsigned int i = 0; i < fMateIDs.size(); ++i) { Print(out,fMateIDs.at(i)," "); }
252  for(unsigned int i = 0; i < fValues.size(); ++i) { Print(out,fValues.at(i)," ",6); }
253 
254  out.close();
255 
256 }
std::vector< std::vector< G4int > > fMateIDs
G4GLOB_DLL std::ostream G4cout
std::vector< G4String > fMaterialNames
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::vector< std::vector< G4double > > fValues
#define G4endl
Definition: G4ios.hh:61
void Print(std::ostream &, const std::vector< T > &, const G4String &, G4int breakLine=-1)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlipData()

void DicomPhantomZSliceHeader::FlipData ( )
inline

Definition at line 181 of file DicomPhantomZSliceHeader.hh.

182 {
183  std::reverse(fValues.begin(), fValues.end());
184  std::reverse(fMateIDs.begin(), fMateIDs.end());
185 }
std::vector< std::vector< G4int > > fMateIDs
std::vector< std::vector< G4double > > fValues
Here is the caller graph for this function:

◆ G4s2n()

template<typename T >
T DicomPhantomZSliceHeader::G4s2n ( const G4String str)
inlineprivate

Definition at line 193 of file DicomPhantomZSliceHeader.hh.

194 {
195  std::istringstream iss(str);
196  T val;
197  iss >> val;
198  return val;
199 }
Here is the caller graph for this function:

◆ GetMateIDs()

const std::vector<std::vector<G4int> >& DicomPhantomZSliceHeader::GetMateIDs ( ) const
inline

Definition at line 139 of file DicomPhantomZSliceHeader.hh.

139 { return fMateIDs; }
std::vector< std::vector< G4int > > fMateIDs
Here is the call graph for this function:

◆ GetMaterialNames()

const std::vector<G4String>& DicomPhantomZSliceHeader::GetMaterialNames ( ) const
inline

Definition at line 80 of file DicomPhantomZSliceHeader.hh.

80 { return fMaterialNames; };
std::vector< G4String > fMaterialNames
Here is the caller graph for this function:

◆ GetMaxX()

G4double DicomPhantomZSliceHeader::GetMaxX ( ) const
inline

Definition at line 72 of file DicomPhantomZSliceHeader.hh.

72 { return fMaxX; };
Here is the caller graph for this function:

◆ GetMaxY()

G4double DicomPhantomZSliceHeader::GetMaxY ( ) const
inline

Definition at line 73 of file DicomPhantomZSliceHeader.hh.

73 { return fMaxY; };
Here is the caller graph for this function:

◆ GetMaxZ()

G4double DicomPhantomZSliceHeader::GetMaxZ ( ) const
inline

Definition at line 74 of file DicomPhantomZSliceHeader.hh.

74 { return fMaxZ; };
Here is the caller graph for this function:

◆ GetMinX()

G4double DicomPhantomZSliceHeader::GetMinX ( ) const
inline

Definition at line 69 of file DicomPhantomZSliceHeader.hh.

69 { return fMinX; };
Here is the caller graph for this function:

◆ GetMinY()

G4double DicomPhantomZSliceHeader::GetMinY ( ) const
inline

Definition at line 70 of file DicomPhantomZSliceHeader.hh.

70 { return fMinY; };
Here is the caller graph for this function:

◆ GetMinZ()

G4double DicomPhantomZSliceHeader::GetMinZ ( ) const
inline

Definition at line 71 of file DicomPhantomZSliceHeader.hh.

71 { return fMinZ; };
Here is the caller graph for this function:

◆ GetNoVoxels()

G4int DicomPhantomZSliceHeader::GetNoVoxels ( ) const
inline

Definition at line 67 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetNoVoxelX()

G4int DicomPhantomZSliceHeader::GetNoVoxelX ( ) const
inline

Definition at line 64 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetNoVoxelY()

G4int DicomPhantomZSliceHeader::GetNoVoxelY ( ) const
inline

Definition at line 65 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetNoVoxelZ()

G4int DicomPhantomZSliceHeader::GetNoVoxelZ ( ) const
inline

Definition at line 66 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetSliceLocation()

const G4double& DicomPhantomZSliceHeader::GetSliceLocation ( ) const
inline

Definition at line 117 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetValues()

const std::vector<std::vector<G4double> >& DicomPhantomZSliceHeader::GetValues ( ) const
inline

Definition at line 138 of file DicomPhantomZSliceHeader.hh.

138 { return fValues; }
std::vector< std::vector< G4double > > fValues

◆ GetVoxelHalfX()

G4double DicomPhantomZSliceHeader::GetVoxelHalfX ( ) const
inline

Definition at line 76 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetVoxelHalfY()

G4double DicomPhantomZSliceHeader::GetVoxelHalfY ( ) const
inline

Definition at line 77 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ GetVoxelHalfZ()

G4double DicomPhantomZSliceHeader::GetVoxelHalfZ ( ) const
inline

Definition at line 78 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ IsInteger()

G4bool DicomPhantomZSliceHeader::IsInteger ( const G4String str)
inlineprivate

Definition at line 187 of file DicomPhantomZSliceHeader.hh.

188 {
189  return (str.find_first_not_of("0123456789") == std::string::npos) ? true : false;
190 }
Here is the caller graph for this function:

◆ operator+()

DicomPhantomZSliceHeader DicomPhantomZSliceHeader::operator+ ( const DicomPhantomZSliceHeader rhs)

Definition at line 145 of file DicomPhantomZSliceHeader.cc.

147 {
148  //----- Check that both slices has the same dimensions
149  if( fNoVoxelX != rhs.GetNoVoxelX()
150  || fNoVoxelY != rhs.GetNoVoxelY() ) {
151  G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
152  !!! Different number of voxels: "
153  << " X= " << fNoVoxelX << " =? " << rhs.GetNoVoxelX()
154  << " Y= " << fNoVoxelY << " =? " << rhs.GetNoVoxelY()
155  << " Z= " << fNoVoxelZ << " =? " << rhs.GetNoVoxelZ()
156  << G4endl;
157  G4Exception("DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
158  "",FatalErrorInArgument,"");
159  }
160  //----- Check that both slices has the same extensions
161  if( fMinX != rhs.GetMinX() || fMaxX != rhs.GetMaxX()
162  || fMinY != rhs.GetMinY() || fMaxY != rhs.GetMaxY() ) {
163  G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
164  !!! Different extensions: "
165  << " Xmin= " << fMinX << " =? " << rhs.GetMinX()
166  << " Xmax= " << fMaxX << " =? " << rhs.GetMaxX()
167  << " Ymin= " << fMinY << " =? " << rhs.GetMinY()
168  << " Ymax= " << fMaxY << " =? " << rhs.GetMaxY()
169  << G4endl;
170  G4Exception("DicomPhantomZSliceHeader::operator+","",
172  }
173 
174  //----- Check that both slices has the same materials
175  std::vector<G4String> fMaterialNames2 = rhs.GetMaterialNames();
176  if( fMaterialNames.size() != fMaterialNames2.size() ) {
177  G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
178  !!! Different number of materials: " << fMaterialNames.size() << " =? "
179  << fMaterialNames2.size() << G4endl;
180  G4Exception("DicomPhantomZSliceHeader::operator+","",
182  }
183  for( unsigned int ii = 0; ii < fMaterialNames.size(); ii++ ) {
184  if( fMaterialNames[ii] != fMaterialNames2[ii] ) {
185  G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
186  !!! Different material number " << ii << " : "
187  << fMaterialNames[ii] << " =? "
188  << fMaterialNames2[ii] << G4endl;
189  G4Exception("DicomPhantomZSliceHeader::operator+","",
191  }
192  }
193 
194  //----- Check that the slices are contiguous in Z
195  if( std::fabs( fMinZ - rhs.GetMaxZ() ) >
197  std::fabs( fMaxZ - rhs.GetMinZ() ) >
199  G4cerr << "DicomPhantomZSliceHeader error adding two slice headers: !!!\
200  Slices are not contiguous in Z "
201  << " Zmin= " << fMinZ << " & " << rhs.GetMinZ()
202  << " Zmax= " << fMaxZ << " & " << rhs.GetMaxZ()
203  << G4endl;
204  G4Exception("DicomPhantomZSliceHeader::operator+","",
206  }
207 
208  //----- Build slice header copying first one
209  DicomPhantomZSliceHeader temp( *this );
210 
211  //----- Add data from second slice header
212  temp.SetMinZ( std::min( fMinZ, rhs.GetMinZ() ) );
213  temp.SetMaxZ( std::max( fMaxZ, rhs.GetMaxZ() ) );
214  temp.SetNoVoxelZ( fNoVoxelZ + rhs.GetNoVoxelZ() );
215 
216  return temp;
217 }
G4double GetRadialTolerance() const
const std::vector< G4String > & GetMaterialNames() const
std::vector< G4String > fMaterialNames
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
static G4GeometryTolerance * GetInstance()
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+=()

void DicomPhantomZSliceHeader::operator+= ( const DicomPhantomZSliceHeader rhs)

Definition at line 139 of file DicomPhantomZSliceHeader.cc.

140 {
141  *this = *this + rhs;
142 }
Here is the caller graph for this function:

◆ Print()

template<typename T >
void DicomPhantomZSliceHeader::Print ( std::ostream &  out,
const std::vector< T > &  val,
const G4String delim,
G4int  breakLine = -1 
)
inlineprivate

Definition at line 215 of file DicomPhantomZSliceHeader.hh.

217 {
218  for(unsigned int i = 0; i < val.size(); ++i) {
219  out << val.at(i);
220  if(breakLine < 0) {
221  if(i+1 < val.size()) { out << delim; }
222  else { out << G4endl; }
223  } else {
224  ((i != 0 && i%breakLine == 0) ? (out << G4endl) : (out << delim)); }
225  }
226 }
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ ReadDataFromFile()

void DicomPhantomZSliceHeader::ReadDataFromFile ( )

Definition at line 259 of file DicomPhantomZSliceHeader.cc.

260 {
261  std::ifstream in;
262  in.open(fFilename.c_str());
263 
264  if(!in) {
265  G4String descript = "DicomPhantomZSliceHeader::DumpToFile: could not open "
266  +fFilename;
267  G4Exception(descript.c_str(),"", FatalException, "");
268  }
269 
270  G4int nMaterials;
271  in >> nMaterials;
272 
273  fMaterialNames.resize(nMaterials,"");
274  for(G4int i = 0; i < nMaterials; ++i) {
275  G4String str1, str2;
276  in >> str1 >> str2;
277  if(!IsInteger(str1)) {
278  G4String descript = "String : " + str1 + " supposed to be integer";
279  G4Exception("DicomPhantomZSliceHeader::ReadDataFromFile - error in \
280  formatting: missing material index","", FatalException,descript.c_str());
281  }
282  G4int index = G4s2n<G4int>(str1);
283  if(index > nMaterials || index < 0) {
284  G4String descript = "Index : " + str1;
285  G4Exception("DicomPhantomZSliceHeader::ReadDataFromFile - error:\
286  bad material index","", FatalException,descript.c_str());
287  }
288  fMaterialNames[index] = str2;
289  }
290 
291  in >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
292 
293  G4double tmpMinX, tmpMinY, tmpMinZ;
294  G4double tmpMaxX, tmpMaxY, tmpMaxZ;
295 
296  in >> tmpMinX >> tmpMaxX;
297  in >> tmpMinY >> tmpMaxY;
298  in >> tmpMinZ >> tmpMaxZ;
299 
300  fMinX = (CheckConsistency(tmpMinX,fMinX,"Min X value")) ?
301  fMinX : ((fMinX == 0) ? tmpMinX : fMinX);
302  fMaxX = (CheckConsistency(tmpMaxX,fMaxX,"Max X value")) ?
303  fMaxX : ((fMaxX == 0) ? tmpMaxX : fMaxX);
304 
305  fMinY = (CheckConsistency(tmpMinY,fMinY,"Min Y value")) ?
306  fMinY : ((fMinY == 0) ? tmpMinY : fMinY);
307  fMaxY = (CheckConsistency(tmpMaxY,fMaxY,"Max Y value")) ?
308  fMaxY : ((fMaxY == 0) ? tmpMaxY : fMaxY);
309 
310  fMinZ = (CheckConsistency(tmpMinZ,fMinZ,"Min Z value")) ?
311  fMinZ : ((fMinZ == 0) ? tmpMinZ : fMinZ);
312  fMaxZ = (CheckConsistency(tmpMaxZ,fMaxZ,"Max Z value")) ?
313  fMaxZ : ((fMaxZ == 0) ? tmpMaxZ : fMaxZ);
314 
315  fMateIDs.clear();
316  fValues.clear();
317  fMateIDs.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4int>(fNoVoxelX,0));
318  fValues.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4double>(fNoVoxelX,0.));
319  for(G4int k = 0; k < fNoVoxelZ; ++k) {
320  for(G4int j = 0; j < fNoVoxelY; ++j) {
321  for(G4int i = 0; i < fNoVoxelX; ++i) {
322  G4int tmpMateID;
323  in >> tmpMateID;
324  G4int row = j*(k+1);
325  fMateIDs[row][i] = tmpMateID;
326  }
327  }
328  }
329 
330  for(G4int k = 0; k < fNoVoxelZ; ++k) {
331  for(G4int j = 0; j < fNoVoxelY; ++j) {
332  for(G4int i = 0; i < fNoVoxelX; ++i) {
333  G4double tmpValue;
334  in >> tmpValue;
335  G4int row = j*(k+1);
336  fValues[row][i] = tmpValue;
337  }
338  }
339  }
340 
341  in.close();
342 }
Int_t index
ifstream in
Definition: comparison.C:7
std::vector< std::vector< G4int > > fMateIDs
int G4int
Definition: G4Types.hh:78
std::vector< G4String > fMaterialNames
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
bool CheckConsistency(const T &, const T &, G4String)
std::vector< std::vector< G4double > > fValues
double G4double
Definition: G4Types.hh:76
G4bool IsInteger(const G4String &)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFilename()

void DicomPhantomZSliceHeader::SetFilename ( const G4String val)
inline

Definition at line 113 of file DicomPhantomZSliceHeader.hh.

◆ SetMaterialNames()

void DicomPhantomZSliceHeader::SetMaterialNames ( std::vector< G4String > &  mn)
inline

Definition at line 93 of file DicomPhantomZSliceHeader.hh.

93 { fMaterialNames = mn; }
std::vector< G4String > fMaterialNames
Here is the call graph for this function:

◆ SetMaxX()

void DicomPhantomZSliceHeader::SetMaxX ( const G4double val)
inline

Definition at line 87 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetMaxY()

void DicomPhantomZSliceHeader::SetMaxY ( const G4double val)
inline

Definition at line 89 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetMaxZ()

void DicomPhantomZSliceHeader::SetMaxZ ( const G4double val)
inline

Definition at line 91 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetMinX()

void DicomPhantomZSliceHeader::SetMinX ( const G4double val)
inline

Definition at line 86 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetMinY()

void DicomPhantomZSliceHeader::SetMinY ( const G4double val)
inline

Definition at line 88 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetMinZ()

void DicomPhantomZSliceHeader::SetMinZ ( const G4double val)
inline

Definition at line 90 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetNoVoxelX()

void DicomPhantomZSliceHeader::SetNoVoxelX ( const G4int val)
inline

Definition at line 82 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetNoVoxelY()

void DicomPhantomZSliceHeader::SetNoVoxelY ( const G4int val)
inline

Definition at line 83 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetNoVoxelZ()

void DicomPhantomZSliceHeader::SetNoVoxelZ ( const G4int val)
inline

Definition at line 84 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

◆ SetSliceLocation()

void DicomPhantomZSliceHeader::SetSliceLocation ( const G4double val)
inline

Definition at line 114 of file DicomPhantomZSliceHeader.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ fFilename

G4String DicomPhantomZSliceHeader::fFilename
private

Definition at line 171 of file DicomPhantomZSliceHeader.hh.

◆ fMateIDs

std::vector<std::vector<G4int> > DicomPhantomZSliceHeader::fMateIDs
private

Definition at line 173 of file DicomPhantomZSliceHeader.hh.

◆ fMaterialNames

std::vector<G4String> DicomPhantomZSliceHeader::fMaterialNames
private

Definition at line 169 of file DicomPhantomZSliceHeader.hh.

◆ fMaxX

G4double DicomPhantomZSliceHeader::fMaxX
private

Definition at line 167 of file DicomPhantomZSliceHeader.hh.

◆ fMaxY

G4double DicomPhantomZSliceHeader::fMaxY
private

Definition at line 167 of file DicomPhantomZSliceHeader.hh.

◆ fMaxZ

G4double DicomPhantomZSliceHeader::fMaxZ
private

Definition at line 167 of file DicomPhantomZSliceHeader.hh.

◆ fMinX

G4double DicomPhantomZSliceHeader::fMinX
private

Definition at line 166 of file DicomPhantomZSliceHeader.hh.

◆ fMinY

G4double DicomPhantomZSliceHeader::fMinY
private

Definition at line 166 of file DicomPhantomZSliceHeader.hh.

◆ fMinZ

G4double DicomPhantomZSliceHeader::fMinZ
private

Definition at line 166 of file DicomPhantomZSliceHeader.hh.

◆ fNoVoxelX

G4int DicomPhantomZSliceHeader::fNoVoxelX
private

Definition at line 165 of file DicomPhantomZSliceHeader.hh.

◆ fNoVoxelY

G4int DicomPhantomZSliceHeader::fNoVoxelY
private

Definition at line 165 of file DicomPhantomZSliceHeader.hh.

◆ fNoVoxelZ

G4int DicomPhantomZSliceHeader::fNoVoxelZ
private

Definition at line 165 of file DicomPhantomZSliceHeader.hh.

◆ fSliceLocation

G4double DicomPhantomZSliceHeader::fSliceLocation
private

Definition at line 174 of file DicomPhantomZSliceHeader.hh.

◆ fValues

std::vector<std::vector<G4double> > DicomPhantomZSliceHeader::fValues
private

Definition at line 172 of file DicomPhantomZSliceHeader.hh.


The documentation for this class was generated from the following files: