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)
70 fFilename = rhs.fFilename;
71 fValues = rhs.fValues;
72 fMateIDs = rhs.fMateIDs;
73 fSliceLocation = rhs.fSliceLocation;
85 G4cout <<
" DicomPhantomZSliceHeader reading number of materials " << nmate <<
G4endl;
88 for(
G4int im = 0; im < nmate; im++ ){
89 fin >> mateindex >> matename;
91 G4cout <<
" DicomPhantomZSliceHeader reading material " << im <<
" : "
92 << mateindex <<
" " << matename <<
G4endl;
95 if( ! CheckMaterialExists( matename ) ) {
96 G4Exception(
"DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
97 "A material is found in file that is not built in the C++ code",
101 fMaterialNames.push_back(matename);
105 fin >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
107 G4cout <<
" Number of voxels " << fNoVoxelX <<
" " << fNoVoxelY <<
" " << fNoVoxelZ <<
G4endl;
111 fin >> fMinX >> fMaxX;
112 fin >> fMinY >> fMaxY;
113 fin >> fMinZ >> fMaxZ;
115 G4cout <<
" Extension in X " << fMinX <<
" " << fMaxX << G4endl
116 <<
" Extension in Y " << fMinY <<
" " << fMaxY << G4endl
117 <<
" Extension in Z " << fMinZ <<
" " << fMaxZ <<
G4endl;
120 fSliceLocation = 0.5*(fMinZ + fMaxZ);
124 G4bool DicomPhantomZSliceHeader::CheckMaterialExists(
const G4String& mateName )
127 std::vector<G4Material*>::const_iterator matite;
128 for( matite = matTab->begin(); matite != matTab->end(); ++matite ) {
129 if( (*matite)->GetName() == mateName ) {
return true; }
148 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
149 !!! Different number of voxels: "
150 <<
" X= " << fNoVoxelX <<
" =? " << rhs.
GetNoVoxelX()
151 <<
" Y= " << fNoVoxelY <<
" =? " << rhs.
GetNoVoxelY()
152 <<
" Z= " << fNoVoxelZ <<
" =? " << rhs.
GetNoVoxelZ()
154 G4Exception(
"DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
160 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
161 !!! Different extensions: "
162 <<
" Xmin= " << fMinX <<
" =? " << rhs.
GetMinX()
163 <<
" Xmax= " << fMaxX <<
" =? " << rhs.
GetMaxX()
164 <<
" Ymin= " << fMinY <<
" =? " << rhs.
GetMinY()
165 <<
" Ymax= " << fMaxY <<
" =? " << rhs.
GetMaxY()
172 if( fMaterialNames.size() != fMaterialNames2.size() ) {
173 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
174 !!! Different number of materials: " << fMaterialNames.size() <<
" =? "
175 << fMaterialNames2.size() <<
G4endl;
178 for(
unsigned int ii = 0; ii < fMaterialNames.size(); ii++ ) {
179 if( fMaterialNames[ii] != fMaterialNames2[ii] ) {
180 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers:\
181 !!! Different material number " << ii <<
" : " << fMaterialNames[ii] <<
" =? "
182 << fMaterialNames2[ii] <<
G4endl;
188 if( std::fabs( fMinZ - rhs.
GetMaxZ() ) >
190 std::fabs( fMaxZ - rhs.
GetMinZ() ) >
192 G4cerr <<
"DicomPhantomZSliceHeader error adding two slice headers: !!!\
193 Slices are not contiguous in Z "
194 <<
" Zmin= " << fMinZ <<
" & " << rhs.
GetMinZ()
195 <<
" Zmax= " << fMaxZ <<
" & " << rhs.
GetMaxZ()
215 G4cout <<
"DicomPhantomZSliceHeader::Dumping Z Slice data to " << fFilename <<
"..." <<
G4endl;
224 out.open(fFilename.c_str());
227 G4String descript =
"DicomPhantomZSliceHeader::DumpToFile: could not open "+fFilename;
232 out << fMaterialNames.size() << std::endl;
233 for(
unsigned int i = 0; i < fMaterialNames.size(); ++i) {
234 out << i <<
" " << fMaterialNames.at(i) << std::endl;
237 out << fNoVoxelX <<
" " << fNoVoxelY <<
" " << fNoVoxelZ << std::endl;
238 out << fMinX <<
" " << fMaxX << std::endl;
239 out << fMinY <<
" " << fMaxY << std::endl;
240 out << fMinZ <<
" " << fMaxZ << std::endl;
242 for(
unsigned int i = 0; i < fMateIDs.size(); ++i) { print(out,fMateIDs.at(i),
" "); }
243 for(
unsigned int i = 0; i < fValues.size(); ++i) { print(out,fValues.at(i),
" ",6); }
253 in.open(fFilename.c_str());
256 G4String descript =
"DicomPhantomZSliceHeader::DumpToFile: could not open "+fFilename;
263 fMaterialNames.resize(nMaterials,
"");
264 for(
G4int i = 0; i < nMaterials; ++i) {
267 if(!IsInteger(str1)) {
268 G4String descript =
"String : " + str1 +
" supposed to be integer";
269 G4Exception(
"DicomPhantomZSliceHeader::ReadDataFromFile - error in \
270 formatting: missing material index",
"",
FatalException,descript.c_str());
273 if(index > nMaterials || index < 0) {
274 G4String descript =
"Index : " + str1;
275 G4Exception(
"DicomPhantomZSliceHeader::ReadDataFromFile - error:\
278 fMaterialNames[
index] = str2;
281 in >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
286 in >> tmpMinX >> tmpMaxX;
287 in >> tmpMinY >> tmpMaxY;
288 in >> tmpMinZ >> tmpMaxZ;
290 fMinX = (CheckConsistency(tmpMinX,fMinX,
"Min X value")) ?
291 fMinX : ((fMinX == 0) ? tmpMinX : fMinX);
292 fMaxX = (CheckConsistency(tmpMaxX,fMaxX,
"Max X value")) ?
293 fMaxX : ((fMaxX == 0) ? tmpMaxX : fMaxX);
295 fMinY = (CheckConsistency(tmpMinY,fMinY,
"Min Y value")) ?
296 fMinY : ((fMinY == 0) ? tmpMinY : fMinY);
297 fMaxY = (CheckConsistency(tmpMaxY,fMaxY,
"Max Y value")) ?
298 fMaxY : ((fMaxY == 0) ? tmpMaxY : fMaxY);
300 fMinZ = (CheckConsistency(tmpMinZ,fMinZ,
"Min Z value")) ?
301 fMinZ : ((fMinZ == 0) ? tmpMinZ : fMinZ);
302 fMaxZ = (CheckConsistency(tmpMaxZ,fMaxZ,
"Max Z value")) ?
303 fMaxZ : ((fMaxZ == 0) ? tmpMaxZ : fMaxZ);
307 fMateIDs.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4int>(fNoVoxelX,0));
308 fValues.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4double>(fNoVoxelX,0.));
309 for(
G4int k = 0; k < fNoVoxelZ; ++k) {
310 for(
G4int j = 0; j < fNoVoxelY; ++j) {
311 for(
G4int i = 0; i < fNoVoxelX; ++i) {
315 fMateIDs[row][i] = tmpMateID;
320 for(
G4int k = 0; k < fNoVoxelZ; ++k) {
321 for(
G4int j = 0; j < fNoVoxelY; ++j) {
322 for(
G4int i = 0; i < fNoVoxelX; ++i) {
326 fValues[row][i] = tmpValue;
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
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