32 #ifndef DicomPhantomZSliceHeader_h
33 #define DicomPhantomZSliceHeader_h 1
120 void AddRow() { fValues.push_back(std::vector<G4double>(0)); fMateIDs.push_back(std::vector<G4int>(0)); }
122 void AddValue(
G4double val) { (fValues.size() > 0) ? fValues.back().push_back(val) : fValues.push_back(std::vector<G4double>(1,val)); }
123 void AddValue(
const std::vector<G4double>& val) { fValues.push_back(val); }
124 void AddValue(
const std::vector<std::vector<G4double> >& val) {
125 for(
unsigned int i = 0; i < val.size(); ++i) { fValues.push_back(val.at(i)); }
128 void AddMateID(
G4int val) { (fMateIDs.size() > 0) ? fMateIDs.back().push_back(val) : fMateIDs.push_back(std::vector<G4int>(1,val)); }
129 void AddMateID(
const std::vector<G4int>& val) { fMateIDs.push_back(val); }
130 void AddMateID(
const std::vector<std::vector<G4int> >& val) {
131 for(
unsigned int i = 0; i < val.size(); ++i) { fMateIDs.push_back(val.at(i)); }
134 const std::vector<std::vector<G4double> >&
GetValues()
const {
return fValues; }
135 const std::vector<std::vector<G4int> >&
GetMateIDs()
const {
return fMateIDs; }
140 void DumpExcessMemory() {
if(fFilename.length() != 0) { fValues.clear(); fMateIDs.clear(); } }
146 template <
typename T>
inline void print(std::ostream&,
const std::vector<T>&,
const G4String&,
G4int breakLine = -1);
147 template <
typename T>
inline T g4s2n(
const G4String&);
148 template <
typename T>
inline bool CheckConsistency(
const T&,
const T&,
G4String);
158 G4int fNoVoxelX, fNoVoxelY, fNoVoxelZ;
162 std::vector<G4String> fMaterialNames;
165 std::vector<std::vector<G4double> > fValues;
166 std::vector<std::vector<G4int> > fMateIDs;
180 inline G4bool DicomPhantomZSliceHeader::IsInteger(
const G4String& str)
182 return (str.find_first_not_of(
"0123456789") == std::string::npos) ?
true :
false;
185 template <
typename T>
186 inline T DicomPhantomZSliceHeader::g4s2n(
const G4String& str)
188 std::istringstream iss(str);
194 template <
typename T>
195 inline bool DicomPhantomZSliceHeader::CheckConsistency(
const T& val1,
const T& val2,
G4String category) {
197 G4Exception(
"DicomPhantomSliceZHeader::CheckConsistency",
"Consistency Mismatch : Keeping previous value if nonzero",
204 template <
typename T>
205 inline void DicomPhantomZSliceHeader::print(std::ostream& out,
const std::vector<T>& val,
const G4String& delim,
G4int breakLine)
207 for(
unsigned int i = 0; i < val.size(); ++i) {
210 if(i+1 < val.size()) { out << delim; }
213 ((i != 0 && i%breakLine == 0) ? (out <<
G4endl) : (out << delim)); }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)