43 : fNoVoxelX(0),fNoVoxelY(0),fNoVoxelZ(0),
44 fMinX(0),fMinY(0),fMinZ(0),
45 fMaxX(0),fMaxY(0),fMaxZ(0),
46 fFilename(fname),fSliceLocation(0)
71 fFilename = rhs.fFilename;
72 fValues = rhs.fValues;
73 fMateIDs = rhs.fMateIDs;
74 fSliceLocation = rhs.fSliceLocation;
86 G4cout <<
" DicomPhantomZSliceHeader reading number of materials "
90 for(
G4int im = 0; im < nmate; im++ ){
91 fin >> mateindex >> matename;
97 if( ! CheckMaterialExists( matename ) ) {
98 G4Exception(
"DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
99 "A material is found in file that is not built in the C++ code",
103 fMaterialNames.push_back(matename);
107 fin >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
109 G4cout <<
" Number of voxels " << fNoVoxelX <<
" " << fNoVoxelY
110 <<
" " << fNoVoxelZ <<
G4endl;
114 fin >> fMinX >> fMaxX;
115 fin >> fMinY >> fMaxY;
116 fin >> fMinZ >> fMaxZ;
118 G4cout <<
" Extension in X " << fMinX <<
" " << fMaxX << G4endl
119 <<
" Extension in Y " << fMinY <<
" " << fMaxY << G4endl
120 <<
" Extension in Z " << fMinZ <<
" " << fMaxZ <<
G4endl;
123 fSliceLocation = 0.5*(fMinZ + fMaxZ);
127 G4bool DicomPhantomZSliceHeader::CheckMaterialExists(
const G4String& mateName )
130 std::vector<G4Material*>::const_iterator matite;
131 for( matite = matTab->begin(); matite != matTab->end(); ++matite ) {
132 if( (*matite)->GetName() == mateName ) {
return true; }
157 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
158 !!! Different number of voxels: "
159 <<
" X= " << fNoVoxelX <<
" =? " << rhs.
GetNoVoxelX()
160 <<
" Y= " << fNoVoxelY <<
" =? " << rhs.
GetNoVoxelY()
161 <<
" Z= " << fNoVoxelZ <<
" =? " << rhs.
GetNoVoxelZ()
163 G4Exception(
"DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
169 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
170 !!! Different extensions: "
171 <<
" Xmin= " << fMinX <<
" =? " << rhs.
GetMinX()
172 <<
" Xmax= " << fMaxX <<
" =? " << rhs.
GetMaxX()
173 <<
" Ymin= " << fMinY <<
" =? " << rhs.
GetMinY()
174 <<
" Ymax= " << fMaxY <<
" =? " << rhs.
GetMaxY()
176 G4Exception(
"DicomPhantomZSliceHeader::operator+",
"",
182 if( fMaterialNames.size() != fMaterialNames2.size() ) {
183 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
184 !!! Different number of materials: " << fMaterialNames.size() <<
" =? "
185 << fMaterialNames2.size() <<
G4endl;
186 G4Exception(
"DicomPhantomZSliceHeader::operator+",
"",
189 for(
unsigned int ii = 0; ii < fMaterialNames.size(); ii++ ) {
190 if( fMaterialNames[ii] != fMaterialNames2[ii] ) {
191 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
192 !!! Different material number " << ii <<
" : "
193 << fMaterialNames[ii] <<
" =? "
194 << fMaterialNames2[ii] <<
G4endl;
195 G4Exception(
"DicomPhantomZSliceHeader::operator+",
"",
201 if( std::fabs( fMinZ - rhs.
GetMaxZ() ) >
203 std::fabs( fMaxZ - rhs.
GetMinZ() ) >
205 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers: !!!\
206 Slices are not contiguous in Z "
207 <<
" Zmin= " << fMinZ <<
" & " << rhs.
GetMinZ()
208 <<
" Zmax= " << fMaxZ <<
" & " << rhs.
GetMaxZ()
210 G4Exception(
"DicomPhantomZSliceHeader::operator+",
"",
229 G4cout <<
"DicomPhantomZSliceHeader::Dumping Z Slice data to "
230 << fFilename <<
"..." <<
G4endl;
239 out.open(fFilename.c_str());
242 G4String descript =
"DicomPhantomZSliceHeader::DumpToFile: could not open "
247 out << fMaterialNames.size() << std::endl;
248 for(
unsigned int i = 0; i < fMaterialNames.size(); ++i) {
249 out << i <<
" " << fMaterialNames.at(i) << std::endl;
252 out << fNoVoxelX <<
" " << fNoVoxelY <<
" " << fNoVoxelZ << std::endl;
253 out << fMinX <<
" " << fMaxX << std::endl;
254 out << fMinY <<
" " << fMaxY << std::endl;
255 out << fMinZ <<
" " << fMaxZ << std::endl;
257 for(
unsigned int i = 0; i < fMateIDs.size(); ++i) { Print(out,fMateIDs.at(i),
" "); }
258 for(
unsigned int i = 0; i < fValues.size(); ++i) { Print(out,fValues.at(i),
" ",6); }
268 in.open(fFilename.c_str());
271 G4String descript =
"DicomPhantomZSliceHeader::DumpToFile: could not open "
279 fMaterialNames.resize(nMaterials,
"");
280 for(
G4int i = 0; i < nMaterials; ++i) {
283 if(!IsInteger(str1)) {
284 G4String descript =
"String : " + str1 +
" supposed to be integer";
285 G4Exception(
"DicomPhantomZSliceHeader::ReadDataFromFile - error in \
286 formatting: missing material index",
"",
FatalException,descript.c_str());
288 G4int index = G4s2n<G4int>(str1);
289 if(index > nMaterials || index < 0) {
290 G4String descript =
"Index : " + str1;
291 G4Exception(
"DicomPhantomZSliceHeader::ReadDataFromFile - error:\
294 fMaterialNames[index] = str2;
297 in >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
302 in >> tmpMinX >> tmpMaxX;
303 in >> tmpMinY >> tmpMaxY;
304 in >> tmpMinZ >> tmpMaxZ;
306 fMinX = (CheckConsistency(tmpMinX,fMinX,
"Min X value")) ?
307 fMinX : ((fMinX == 0) ? tmpMinX : fMinX);
308 fMaxX = (CheckConsistency(tmpMaxX,fMaxX,
"Max X value")) ?
309 fMaxX : ((fMaxX == 0) ? tmpMaxX : fMaxX);
311 fMinY = (CheckConsistency(tmpMinY,fMinY,
"Min Y value")) ?
312 fMinY : ((fMinY == 0) ? tmpMinY : fMinY);
313 fMaxY = (CheckConsistency(tmpMaxY,fMaxY,
"Max Y value")) ?
314 fMaxY : ((fMaxY == 0) ? tmpMaxY : fMaxY);
316 fMinZ = (CheckConsistency(tmpMinZ,fMinZ,
"Min Z value")) ?
317 fMinZ : ((fMinZ == 0) ? tmpMinZ : fMinZ);
318 fMaxZ = (CheckConsistency(tmpMaxZ,fMaxZ,
"Max Z value")) ?
319 fMaxZ : ((fMaxZ == 0) ? tmpMaxZ : fMaxZ);
323 fMateIDs.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4int>(fNoVoxelX,0));
324 fValues.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4double>(fNoVoxelX,0.));
325 for(
G4int k = 0; k < fNoVoxelZ; ++k) {
326 for(
G4int j = 0; j < fNoVoxelY; ++j) {
327 for(
G4int i = 0; i < fNoVoxelX; ++i) {
331 fMateIDs[row][i] = tmpMateID;
336 for(
G4int k = 0; k < fNoVoxelZ; ++k) {
337 for(
G4int j = 0; j < fNoVoxelY; ++j) {
338 for(
G4int i = 0; i < fNoVoxelX; ++i) {
342 fValues[row][i] = tmpValue;
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
static G4NistManager * Instance()
G4GLOB_DLL std::ostream G4cout
G4double GetRadialTolerance() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static G4GeometryTolerance * GetInstance()
G4GLOB_DLL std::ostream G4cerr