Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/medical/DICOM/src/DicomPhantomZSliceHeader.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/DICOM/src/DicomPhantomZSliceHeader.cc (Version 11.3.0) and /examples/extended/medical/DICOM/src/DicomPhantomZSliceHeader.cc (Version 10.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: DicomPhantomZSliceHeader.cc 101109 2016-11-07 08:14:53Z gcosmo $
 26 //                                                 27 //
 27 /// \file DicomPhantomZSliceHeader.cc              28 /// \file DicomPhantomZSliceHeader.cc
 28 /// \brief Implementation of the DicomPhantomZ     29 /// \brief Implementation of the DicomPhantomZSliceHeader class
 29 //                                                 30 //
 30                                                    31 
 31 #include "DicomPhantomZSliceHeader.hh"         <<  32 #include "globals.hh"
 32                                                << 
 33 #include "G4GeometryTolerance.hh"              << 
 34 #include "G4LogicalVolume.hh"                      33 #include "G4LogicalVolume.hh"
 35 #include "G4Material.hh"                       << 
 36 #include "G4MaterialTable.hh"                      34 #include "G4MaterialTable.hh"
                                                   >>  35 #include "G4Material.hh"
                                                   >>  36 #include "G4GeometryTolerance.hh"
 37 #include "G4NistManager.hh"                        37 #include "G4NistManager.hh"
 38 #include "globals.hh"                          << 
 39                                                    38 
 40 //....oooOO0OOooo........oooOO0OOooo........oo <<  39 #include "DicomPhantomZSliceHeader.hh"
                                                   >>  40 
                                                   >>  41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 41 DicomPhantomZSliceHeader::DicomPhantomZSliceHe     42 DicomPhantomZSliceHeader::DicomPhantomZSliceHeader(const G4String& fname)
 42   : fNoVoxelsX(0),                             <<  43 :   fNoVoxelX(0),fNoVoxelY(0),fNoVoxelZ(0),
 43     fNoVoxelsY(0),                             <<  44     fMinX(0),fMinY(0),fMinZ(0),
 44     fNoVoxelsZ(0),                             <<  45     fMaxX(0),fMaxY(0),fMaxZ(0),
 45     fMinX(0),                                  <<  46     fFilename(fname),fSliceLocation(0)
 46     fMinY(0),                                  <<  47 {
 47     fMinZ(0),                                  << 
 48     fMaxX(0),                                  << 
 49     fMaxY(0),                                  << 
 50     fMaxZ(0),                                  << 
 51     fFilename(fname),                          << 
 52     fSliceLocation(0)                          << 
 53 {}                                             << 
 54                                                    48 
 55 //....oooOO0OOooo........oooOO0OOooo........oo <<  49 }
 56 DicomPhantomZSliceHeader::~DicomPhantomZSliceH << 
 57                                                    50 
 58 //....oooOO0OOooo........oooOO0OOooo........oo <<  51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 59 DicomPhantomZSliceHeader::DicomPhantomZSliceHe <<  52 DicomPhantomZSliceHeader::~DicomPhantomZSliceHeader()
 60 {                                                  53 {
 61   //----- Read material indices and names      <<  54 
 62   G4int nmate;                                 <<  55 }
 63   G4String mateindex;                          <<  56 
 64   G4String matename;                           <<  57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65   fin >> nmate;                                <<  58 DicomPhantomZSliceHeader::DicomPhantomZSliceHeader( 
                                                   >>  59                               const DicomPhantomZSliceHeader& rhs )
                                                   >>  60 {
                                                   >>  61     fNoVoxelX = rhs.GetNoVoxelX();
                                                   >>  62     fNoVoxelY = rhs.GetNoVoxelY();
                                                   >>  63     fNoVoxelZ = rhs.GetNoVoxelZ();
                                                   >>  64     fMinX = rhs.GetMinX();
                                                   >>  65     fMaxX = rhs.GetMaxX();
                                                   >>  66     fMinY = rhs.GetMinY();
                                                   >>  67     fMaxY = rhs.GetMaxY();
                                                   >>  68     fMinZ = rhs.GetMinZ();
                                                   >>  69     fMaxZ = rhs.GetMaxZ();
                                                   >>  70     fMaterialNames = rhs.GetMaterialNames();
                                                   >>  71     fFilename = rhs.fFilename;
                                                   >>  72     fValues = rhs.fValues;
                                                   >>  73     fMateIDs = rhs.fMateIDs;
                                                   >>  74     fSliceLocation = rhs.fSliceLocation;
                                                   >>  75 }
                                                   >>  76 
                                                   >>  77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >>  78 DicomPhantomZSliceHeader::DicomPhantomZSliceHeader( std::ifstream& fin )
                                                   >>  79 {
                                                   >>  80     //----- Read material indices and names
                                                   >>  81     G4int nmate;
                                                   >>  82     G4String mateindex;
                                                   >>  83     G4String matename;
                                                   >>  84     fin >> nmate;
 66 #ifdef G4VERBOSE                                   85 #ifdef G4VERBOSE
 67   G4cout << " DicomPhantomZSliceHeader reading <<  86     G4cout << " DicomPhantomZSliceHeader reading number of materials " 
                                                   >>  87            << nmate << G4endl;
 68 #endif                                             88 #endif
 69                                                    89 
 70   for (G4int im = 0; im < nmate; im++) {       <<  90     for( G4int im = 0; im < nmate; im++ ){
 71     fin >> mateindex >> matename;              <<  91         fin >> mateindex >> matename;
 72 #ifdef G4VERBOSE                                   92 #ifdef G4VERBOSE
 73     // G4cout << " DicomPhantomZSliceHeader re <<  93         //G4cout << " DicomPhantomZSliceHeader reading material " << im << " : "
 74     //  << im << " : "<< mateindex << "  " <<  <<  94         //        << mateindex << "  " << matename << G4endl;
 75 #endif                                             95 #endif
 76                                                    96 
 77     if (!CheckMaterialExists(matename)) {      <<  97         if( ! CheckMaterialExists( matename ) ) {
 78       G4Exception("DicomPhantomZSliceHeader::D <<  98             G4Exception("DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
 79                   "A material is found in file <<  99             "A material is found in file that is not built in the C++ code",
 80                   FatalErrorInArgument, matena << 100             FatalErrorInArgument, matename.c_str());
 81     }                                          << 101         }
 82                                                   102 
 83     fMaterialNames.push_back(matename);        << 103         fMaterialNames.push_back(matename);
 84   }                                            << 104     }
 85                                                   105 
 86   //----- Read number of voxels                << 106     //----- Read number of voxels
 87   fin >> fNoVoxelsX >> fNoVoxelsY >> fNoVoxels << 107     fin >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
 88 #ifdef G4VERBOSE                                  108 #ifdef G4VERBOSE
 89   G4cout << " Number of voxels " << fNoVoxelsX << 109     G4cout << " Number of voxels " << fNoVoxelX << " " << fNoVoxelY 
                                                   >> 110            << " " << fNoVoxelZ << G4endl;
 90 #endif                                            111 #endif
 91                                                   112 
 92   //----- Read minimal and maximal extensions  << 113     //----- Read minimal and maximal extensions (= walls of phantom)
 93   fin >> fMinX >> fMaxX;                       << 114     fin >> fMinX >> fMaxX;
 94   fin >> fMinY >> fMaxY;                       << 115     fin >> fMinY >> fMaxY;
 95   fin >> fMinZ >> fMaxZ;                       << 116     fin >> fMinZ >> fMaxZ;
 96 #ifdef G4VERBOSE                                  117 #ifdef G4VERBOSE
 97   G4cout << " Extension in X " << fMinX << " " << 118     G4cout << " Extension in X " << fMinX << " " << fMaxX << G4endl
 98          << " " << fMaxY << G4endl << " Extens << 119     << " Extension in Y " << fMinY << " " << fMaxY << G4endl
                                                   >> 120     << " Extension in Z " << fMinZ << " " << fMaxZ << G4endl;
 99 #endif                                            121 #endif
100                                                   122 
101   fSliceLocation = 0.5 * (fMinZ + fMaxZ);      << 123     fSliceLocation = 0.5*(fMinZ + fMaxZ);
102 }                                                 124 }
103                                                   125 
104 //....oooOO0OOooo........oooOO0OOooo........oo << 126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 G4bool DicomPhantomZSliceHeader::CheckMaterial << 127 G4bool DicomPhantomZSliceHeader::CheckMaterialExists( const G4String& mateName )
106 {                                                 128 {
107   const G4MaterialTable* matTab = G4Material:: << 129     const G4MaterialTable* matTab = G4Material::GetMaterialTable();
108   std::vector<G4Material*>::const_iterator mat << 130     std::vector<G4Material*>::const_iterator matite;
109   for (matite = matTab->begin(); matite != mat << 131     for( matite = matTab->begin(); matite != matTab->end(); ++matite ) {
110     if ((*matite)->GetName() == mateName) {    << 132         if( (*matite)->GetName() == mateName ) { return true; }
                                                   >> 133     }
                                                   >> 134 
                                                   >> 135     G4Material* g4mate = G4NistManager::Instance()->FindOrBuildMaterial(mateName);
                                                   >> 136     if( g4mate ) {
                                                   >> 137       return false;
                                                   >> 138     } else {
111       return true;                                139       return true;
112     }                                             140     }
113   }                                            << 
114                                                   141 
115   G4Material* g4mate = G4NistManager::Instance << 
116   if (g4mate) {                                << 
117     return false;                              << 
118   }                                            << 
119   else {                                       << 
120     return true;                               << 
121   }                                            << 
122 }                                                 142 }
123                                                   143 
124 //....oooOO0OOooo........oooOO0OOooo........oo << 144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 void DicomPhantomZSliceHeader::operator+=(cons << 145 void DicomPhantomZSliceHeader::operator+=( const DicomPhantomZSliceHeader& rhs )
126 {                                                 146 {
127   *this = *this + rhs;                         << 147     *this = *this + rhs;
128 }                                                 148 }
129                                                   149 
130 //....oooOO0OOooo........oooOO0OOooo........oo << 150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 DicomPhantomZSliceHeader DicomPhantomZSliceHea << 151 DicomPhantomZSliceHeader DicomPhantomZSliceHeader::operator+( 
                                                   >> 152                        const DicomPhantomZSliceHeader& rhs )
132 {                                                 153 {
133   //----- Check that both slices has the same  << 154     //----- Check that both slices has the same dimensions
134   if (fNoVoxelsX != rhs.GetNoVoxelsX() || fNoV << 155     if( fNoVoxelX != rhs.GetNoVoxelX()
135     G4cerr << "DicomPhantomZSliceHeader error  << 156        || fNoVoxelY != rhs.GetNoVoxelY() ) {
                                                   >> 157         G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
136         !!! Different number of voxels: "         158         !!! Different number of voxels: "
137            << "  X= " << fNoVoxelsX << " =? "  << 159         << "  X= " << fNoVoxelX << " =? " << rhs.GetNoVoxelX()
138            << " =? " << rhs.GetNoVoxelsY() <<  << 160         << "  Y=  " << fNoVoxelY << " =? " << rhs.GetNoVoxelY()
139            << G4endl;                          << 161         << "  Z=  " << fNoVoxelZ << " =? " << rhs.GetNoVoxelZ()
140     G4Exception("DicomPhantomZSliceHeader::Dic << 162         << G4endl;
141   }                                            << 163         G4Exception("DicomPhantomZSliceHeader::DicomPhantomZSliceHeader",
142   //----- Check that both slices has the same  << 164         "",FatalErrorInArgument,"");
143   if (fMinX != rhs.GetMinX() || fMaxX != rhs.G << 165     }
144       || fMaxY != rhs.GetMaxY())               << 166     //----- Check that both slices has the same extensions
145   {                                            << 167     if( fMinX != rhs.GetMinX() || fMaxX != rhs.GetMaxX()
146     G4cerr << "DicomPhantomZSliceHeader error  << 168        || fMinY != rhs.GetMinY() || fMaxY != rhs.GetMaxY() ) {
                                                   >> 169         G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
147         !!! Different extensions: "               170         !!! Different extensions: "
148            << "  Xmin= " << fMinX << " =? " << << 171         << "  Xmin= " << fMinX << " =? " << rhs.GetMinX()
149            << rhs.GetMaxX() << "  Ymin= " << f << 172         << "  Xmax= " << fMaxX << " =? " << rhs.GetMaxX()
150            << " =? " << rhs.GetMaxY() << G4end << 173         << "  Ymin= " << fMinY << " =? " << rhs.GetMinY()
151     G4Exception("DicomPhantomZSliceHeader::ope << 174         << "  Ymax= " << fMaxY << " =? " << rhs.GetMaxY()
152   }                                            << 175         << G4endl;
                                                   >> 176         G4Exception("DicomPhantomZSliceHeader::operator+","",
                                                   >> 177                     FatalErrorInArgument,"");
                                                   >> 178     }
153                                                   179 
154   //----- Check that both slices have the same << 180     //----- Check that both slices have the same materials
155   std::vector<G4String> fMaterialNames2 = rhs. << 181     std::vector<G4String> fMaterialNames2 = rhs.GetMaterialNames();
156   if (fMaterialNames.size() != fMaterialNames2 << 182     if( fMaterialNames.size() != fMaterialNames2.size() ) {
157     G4cerr << "DicomPhantomZSliceHeader error  << 183         G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
158         !!! Different number of materials: "   << 184         !!! Different number of materials: " << fMaterialNames.size() << " =? "
159            << fMaterialNames.size() << " =? "  << 185         << fMaterialNames2.size() << G4endl;
160     G4Exception("DicomPhantomZSliceHeader::ope << 186         G4Exception("DicomPhantomZSliceHeader::operator+","",
161   }                                            << 187                     FatalErrorInArgument,"");
162   for (unsigned int ii = 0; ii < fMaterialName << 188     }
163     if (fMaterialNames[ii] != fMaterialNames2[ << 189     for( unsigned int ii = 0; ii < fMaterialNames.size(); ii++ ) {
164       G4cerr << "DicomPhantomZSliceHeader erro << 190         if( fMaterialNames[ii] != fMaterialNames2[ii] ) {
165             !!! Different material number "    << 191             G4cerr << "DicomPhantomZSliceHeader error adding two slice headers:\
166              << ii << " : " << fMaterialNames[ << 192             !!! Different material number " << ii << " : " 
167       G4Exception("DicomPhantomZSliceHeader::o << 193                    << fMaterialNames[ii] << " =? "
                                                   >> 194             << fMaterialNames2[ii] << G4endl;
                                                   >> 195             G4Exception("DicomPhantomZSliceHeader::operator+","",
                                                   >> 196                         FatalErrorInArgument,"");
                                                   >> 197         }
168     }                                             198     }
169   }                                            << 
170                                                   199 
171   //----- Check that the slices are contiguous << 200     //----- Check that the slices are contiguous in Z
172   if (std::fabs(fMinZ - rhs.GetMaxZ()) > G4Geo << 201     if( std::fabs( fMinZ - rhs.GetMaxZ() ) >
173       && std::fabs(fMaxZ - rhs.GetMinZ())      << 202     G4GeometryTolerance::GetInstance()->GetRadialTolerance() &&
174            > G4GeometryTolerance::GetInstance( << 203        std::fabs( fMaxZ - rhs.GetMinZ() ) >
175   {                                            << 204        G4GeometryTolerance::GetInstance()->GetRadialTolerance() ){
176     G4cerr << "DicomPhantomZSliceHeader error  << 205         G4cerr << "DicomPhantomZSliceHeader error adding two slice headers: !!!\
177         Slices are not contiguous in Z "          206         Slices are not contiguous in Z "
178            << "  Zmin= " << fMinZ << " & " <<  << 207         << "  Zmin= " << fMinZ << " & " << rhs.GetMinZ()
179            << rhs.GetMaxZ() << G4endl;         << 208         << "  Zmax= " << fMaxZ << " & " << rhs.GetMaxZ()
180     G4Exception("DicomPhantomZSliceHeader::ope << 209         << G4endl;
181   }                                            << 210         G4Exception("DicomPhantomZSliceHeader::operator+","",
                                                   >> 211                     FatalErrorInArgument,"");
                                                   >> 212     }
182                                                   213 
183   //----- Build slice header copying first one << 214     //----- Build slice header copying first one
184   DicomPhantomZSliceHeader temp(*this);        << 215     DicomPhantomZSliceHeader temp( *this );
185                                                   216 
186   //----- Add data from second slice header    << 217     //----- Add data from second slice header
187   temp.SetMinZ(std::min(fMinZ, rhs.GetMinZ())) << 218     temp.SetMinZ( std::min( fMinZ, rhs.GetMinZ() ) );
188   temp.SetMaxZ(std::max(fMaxZ, rhs.GetMaxZ())) << 219     temp.SetMaxZ( std::max( fMaxZ, rhs.GetMaxZ() ) );
189   temp.SetNoVoxelsZ(fNoVoxelsZ + rhs.GetNoVoxe << 220     temp.SetNoVoxelZ( fNoVoxelZ + rhs.GetNoVoxelZ() );
190                                                   221 
191   return temp;                                 << 222     return temp;
192 }                                                 223 }
193                                                   224 
194 //....oooOO0OOooo........oooOO0OOooo........oo << 225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195 void DicomPhantomZSliceHeader::DumpToFile()       226 void DicomPhantomZSliceHeader::DumpToFile()
196 {                                                 227 {
197   G4cout << "DicomPhantomZSliceHeader::Dumping << 228   
198   // sleep(5);                                 << 229   G4cout << "DicomPhantomZSliceHeader::Dumping Z Slice data to " 
199                                                << 230          << fFilename << "..." << G4endl;
                                                   >> 231   //sleep(5);
                                                   >> 232   
200   //  May seen counter-intuitive (dumping to f    233   //  May seen counter-intuitive (dumping to file you are reading from), but
201   //  the reason for this is modification slic    234   //  the reason for this is modification slice spacing
202   if (fMateIDs.size() == 0 || fValues.size() = << 235   if(fMateIDs.size() == 0 || fValues.size() == 0) { ReadDataFromFile(); }
203     ReadDataFromFile();                        << 236   
204   }                                            << 237   
205                                                << 
206   std::ofstream out;                              238   std::ofstream out;
207   out.open(fFilename.c_str());                    239   out.open(fFilename.c_str());
208                                                << 240   
209   if (!out) {                                  << 241   if(!out) {
210     G4String descript = "DicomPhantomZSliceHea << 242     G4String descript = "DicomPhantomZSliceHeader::DumpToFile: could not open "
211     G4Exception(descript.c_str(), "", FatalExc << 243       +fFilename;
                                                   >> 244     G4Exception(descript.c_str(),"", FatalException, "");
212   }                                               245   }
213                                                << 246   
214   out << fMaterialNames.size() << std::endl;      247   out << fMaterialNames.size() << std::endl;
215   for (unsigned int i = 0; i < fMaterialNames. << 248   for(unsigned int i = 0; i < fMaterialNames.size(); ++i) {
216     out << i << " " << fMaterialNames.at(i) <<    249     out << i << " " << fMaterialNames.at(i) << std::endl;
217   }                                               250   }
218                                                << 251   
219   out << fNoVoxelsX << " " << fNoVoxelsY << "  << 252   out << fNoVoxelX << " " << fNoVoxelY << " " << fNoVoxelZ << std::endl;
220   out << fMinX << " " << fMaxX << std::endl;      253   out << fMinX << " " << fMaxX << std::endl;
221   out << fMinY << " " << fMaxY << std::endl;      254   out << fMinY << " " << fMaxY << std::endl;
222   out << fMinZ << " " << fMaxZ << std::endl;      255   out << fMinZ << " " << fMaxZ << std::endl;
223                                                << 256   
224   for (unsigned int i = 0; i < fMateIDs.size() << 257   for(unsigned int i = 0; i < fMateIDs.size(); ++i) { Print(out,fMateIDs.at(i)," "); }
225     Print(out, fMateIDs.at(i), " ");           << 258   for(unsigned int i = 0; i < fValues.size(); ++i) { Print(out,fValues.at(i)," ",6); }
226   }                                            << 259   
227                                                << 
228   for (unsigned int i = 0; i < fValues.size(); << 
229     Print(out, fValues.at(i), " ", 6);         << 
230   }                                            << 
231                                                << 
232   out.close();                                    260   out.close();
                                                   >> 261   
233 }                                                 262 }
234                                                   263 
235 //....oooOO0OOooo........oooOO0OOooo........oo << 264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
236 void DicomPhantomZSliceHeader::ReadDataFromFil    265 void DicomPhantomZSliceHeader::ReadDataFromFile()
237 {                                                 266 {
238   std::ifstream in;                               267   std::ifstream in;
239   in.open(fFilename.c_str());                     268   in.open(fFilename.c_str());
240                                                << 269   
241   if (!in) {                                   << 270   if(!in) {
242     G4String descript = "DicomPhantomZSliceHea << 271     G4String descript = "DicomPhantomZSliceHeader::DumpToFile: could not open "
243     G4Exception(descript.c_str(), "", FatalExc << 272       +fFilename;
                                                   >> 273     G4Exception(descript.c_str(),"", FatalException, "");
244   }                                               274   }
245                                                << 275   
246   G4int nMaterials;                               276   G4int nMaterials;
247   in >> nMaterials;                               277   in >> nMaterials;
248                                                << 278   
249   fMaterialNames.resize(nMaterials, "");       << 279   fMaterialNames.resize(nMaterials,"");
250   for (G4int i = 0; i < nMaterials; ++i) {     << 280   for(G4int i = 0; i < nMaterials; ++i) {
251     G4String str1, str2;                          281     G4String str1, str2;
252     in >> str1 >> str2;                           282     in >> str1 >> str2;
253     if (!IsInteger(str1)) {                    << 283     if(!IsInteger(str1)) {
254       G4String descript = "String : " + str1 +    284       G4String descript = "String : " + str1 + " supposed to be integer";
255       G4Exception(                             << 285       G4Exception("DicomPhantomZSliceHeader::ReadDataFromFile - error in \
256         "DicomPhantomZSliceHeader::ReadDataFro << 286        formatting: missing material index","", FatalException,descript.c_str());
257        formatting: missing material index",    << 
258         "", FatalException, descript.c_str()); << 
259     }                                             287     }
260     G4int index = G4s2n<G4int>(str1);             288     G4int index = G4s2n<G4int>(str1);
261     if (index > nMaterials || index < 0) {     << 289     if(index > nMaterials || index < 0) {
262       G4String descript = "Index : " + str1;      290       G4String descript = "Index : " + str1;
263       G4Exception(                             << 291       G4Exception("DicomPhantomZSliceHeader::ReadDataFromFile - error:\
264         "DicomPhantomZSliceHeader::ReadDataFro << 292             bad material index","", FatalException,descript.c_str());
265             bad material index",               << 
266         "", FatalException, descript.c_str()); << 
267     }                                             293     }
268     fMaterialNames[index] = str2;                 294     fMaterialNames[index] = str2;
269   }                                               295   }
270                                                << 296   
271   in >> fNoVoxelsX >> fNoVoxelsY >> fNoVoxelsZ << 297   in >> fNoVoxelX >> fNoVoxelY >> fNoVoxelZ;
272                                                << 298   
273   G4double tmpMinX, tmpMinY, tmpMinZ;             299   G4double tmpMinX, tmpMinY, tmpMinZ;
274   G4double tmpMaxX, tmpMaxY, tmpMaxZ;             300   G4double tmpMaxX, tmpMaxY, tmpMaxZ;
275                                                << 301   
276   in >> tmpMinX >> tmpMaxX;                       302   in >> tmpMinX >> tmpMaxX;
277   in >> tmpMinY >> tmpMaxY;                       303   in >> tmpMinY >> tmpMaxY;
278   in >> tmpMinZ >> tmpMaxZ;                       304   in >> tmpMinZ >> tmpMaxZ;
279                                                << 305   
280   fMinX =                                      << 306   fMinX = (CheckConsistency(tmpMinX,fMinX,"Min X value")) ?
281     (CheckConsistency(tmpMinX, fMinX, "Min X v << 307     fMinX : ((fMinX == 0) ? tmpMinX : fMinX);
282   fMaxX =                                      << 308   fMaxX = (CheckConsistency(tmpMaxX,fMaxX,"Max X value")) ?
283     (CheckConsistency(tmpMaxX, fMaxX, "Max X v << 309     fMaxX : ((fMaxX == 0) ? tmpMaxX : fMaxX);
284                                                << 310   
285   fMinY =                                      << 311   fMinY = (CheckConsistency(tmpMinY,fMinY,"Min Y value")) ?
286     (CheckConsistency(tmpMinY, fMinY, "Min Y v << 312     fMinY : ((fMinY == 0) ? tmpMinY : fMinY);
287   fMaxY =                                      << 313   fMaxY = (CheckConsistency(tmpMaxY,fMaxY,"Max Y value")) ?
288     (CheckConsistency(tmpMaxY, fMaxY, "Max Y v << 314     fMaxY : ((fMaxY == 0) ? tmpMaxY : fMaxY);
289                                                << 315   
290   fMinZ =                                      << 316   fMinZ = (CheckConsistency(tmpMinZ,fMinZ,"Min Z value")) ?
291     (CheckConsistency(tmpMinZ, fMinZ, "Min Z v << 317     fMinZ : ((fMinZ == 0) ? tmpMinZ : fMinZ);
292   fMaxZ =                                      << 318   fMaxZ = (CheckConsistency(tmpMaxZ,fMaxZ,"Max Z value")) ?
293     (CheckConsistency(tmpMaxZ, fMaxZ, "Max Z v << 319     fMaxZ : ((fMaxZ == 0) ? tmpMaxZ : fMaxZ);
294                                                << 320   
295   fMateIDs.clear();                               321   fMateIDs.clear();
296   fValues.clear();                                322   fValues.clear();
297   fMateIDs.resize(fNoVoxelsY * fNoVoxelsZ, std << 323   fMateIDs.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4int>(fNoVoxelX,0));
298   fValues.resize(fNoVoxelsY * fNoVoxelsZ, std: << 324   fValues.resize(fNoVoxelY*fNoVoxelZ,std::vector<G4double>(fNoVoxelX,0.));
299   for (G4int k = 0; k < fNoVoxelsZ; ++k) {     << 325   for(G4int k = 0; k < fNoVoxelZ; ++k) {
300     for (G4int j = 0; j < fNoVoxelsY; ++j) {   << 326     for(G4int j = 0; j < fNoVoxelY; ++j) {
301       for (G4int i = 0; i < fNoVoxelsX; ++i) { << 327       for(G4int i = 0; i < fNoVoxelX; ++i) {
302         G4int tmpMateID;                          328         G4int tmpMateID;
303         in >> tmpMateID;                          329         in >> tmpMateID;
304         G4int row = j * (k + 1);               << 330         G4int row = j*(k+1);
305         fMateIDs[row][i] = tmpMateID;             331         fMateIDs[row][i] = tmpMateID;
306       }                                           332       }
307     }                                             333     }
308   }                                               334   }
309                                                << 335   
310   for (G4int k = 0; k < fNoVoxelsZ; ++k) {     << 336   for(G4int k = 0; k < fNoVoxelZ; ++k) {
311     for (G4int j = 0; j < fNoVoxelsY; ++j) {   << 337     for(G4int j = 0; j < fNoVoxelY; ++j) {
312       for (G4int i = 0; i < fNoVoxelsX; ++i) { << 338       for(G4int i = 0; i < fNoVoxelX; ++i) {
313         G4double tmpValue;                        339         G4double tmpValue;
314         in >> tmpValue;                           340         in >> tmpValue;
315         G4int row = j * (k + 1);               << 341         G4int row = j*(k+1);
316         fValues[row][i] = tmpValue;               342         fValues[row][i] = tmpValue;
317       }                                           343       }
318     }                                             344     }
319   }                                               345   }
320                                                << 346   
321   in.close();                                     347   in.close();
322 }                                                 348 }
323 //....oooOO0OOooo........oooOO0OOooo........oo << 349 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
324                                                   350