Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file medical/DICOM/include/DicomDetectorConstruction.hh 28 /// \brief Definition of the DicomDetectorConstruction class 29 // 30 31 #ifndef DicomDetectorConstruction_h 32 #define DicomDetectorConstruction_h 1 33 34 #include "DicomPhantomZSliceHeader.hh" 35 36 #include "G4ThreeVector.hh" 37 #include "G4VUserDetectorConstruction.hh" 38 #include "globals.hh" 39 40 #include <map> 41 #include <set> 42 43 class G4Material; 44 class G4Box; 45 class G4LogicalVolume; 46 class DicomPhantomZSliceMerged; 47 48 //******************************************************* 49 /// Dicom detector construction 50 /// 51 /// - Start the building of the geometry 52 /// - Initialisation of materials 53 /// - Creation of the world 54 /// - Reading of the DICOM data 55 /// 56 /// History: 30.11.07 First version 57 /// \author P. Arce 58 //******************************************************* 59 60 struct matInfo 61 { 62 G4double fSumdens; 63 G4int fNvoxels; 64 G4int fId; 65 }; 66 67 class DicomDetectorConstruction : public G4VUserDetectorConstruction 68 { 69 public: 70 DicomDetectorConstruction(); 71 ~DicomDetectorConstruction(); 72 73 virtual G4VPhysicalVolume* Construct(); 74 // trigger the construction of the geometry 75 76 G4int GetTotalVoxels() const; 77 78 protected: 79 void InitialisationOfMaterials(); 80 // create the original materials 81 82 void ReadPhantomData(); 83 void ReadPhantomDataNew(); 84 // read the DICOM files describing the phantom 85 void ReadVoxelDensities(std::ifstream& fin); 86 87 void ReadPhantomDataFile(const G4String& fname); 88 // read one of the DICOM files describing the phantom 89 // (usually one per Z slice). 90 // Build a DicomPhantomZSliceHeader for each file 91 92 void MergeZSliceHeaders(); 93 // merge the slice headers of all the files 94 95 G4Material* BuildMaterialWithChangingDensity(const G4Material* origMate, G4float density, 96 G4String newMateName); 97 // build a new material if the density of the voxel is different 98 // to the other voxels 99 100 void ConstructPhantomContainer(); 101 void ConstructPhantomContainerNew(); 102 virtual void ConstructPhantom() = 0; 103 // construct the phantom volumes. 104 // This method should be implemented for each of the derived classes 105 106 void SetScorer(G4LogicalVolume* voxel_logic); 107 108 virtual void ConstructSDandField(); 109 110 protected: 111 G4Material* fAir; 112 113 // World ... 114 G4Box* fWorld_solid; 115 G4LogicalVolume* fWorld_logic; 116 G4VPhysicalVolume* fWorld_phys; 117 118 G4Box* fContainer_solid; 119 G4LogicalVolume* fContainer_logic; 120 G4VPhysicalVolume* fContainer_phys; 121 122 G4int fNoFiles; // number of DICOM files 123 std::vector<G4Material*> fOriginalMaterials; // list of original materials 124 std::vector<G4Material*> fMaterials; 125 // list of new materials created to distinguish different density 126 // voxels that have the same original materials 127 size_t* fMateIDs; // index of material of each voxel 128 // unsigned int* fMateIDs; // index of material of each voxel 129 130 std::map<G4int, G4double> fDensityDiffs; 131 // Density difference to distinguish material for each original 132 // material (by index) 133 134 std::vector<DicomPhantomZSliceHeader*> fZSliceHeaders; 135 // list of z slice header (one per DICOM files) 136 DicomPhantomZSliceHeader* fZSliceHeaderMerged; 137 // z slice header resulted from merging all z slice headers 138 139 G4int fNoVoxelsX, fNoVoxelsY, fNoVoxelsZ; 140 G4double fVoxelHalfDimX, fVoxelHalfDimY, fVoxelHalfDimZ; 141 G4double fMinX, fMinY, fMinZ; // minimum extension of voxels (position wall) 142 G4double fMaxX, fMaxY, fMaxZ; // maximum extension of voxels (position wall) 143 144 std::map<G4int, G4Material*> fPhantomMaterialsOriginal; 145 // map numberOfMaterial to G4Material. They are the list of materials as 146 // built from .geom file 147 148 DicomPhantomZSliceMerged* fMergedSlices; 149 150 std::set<G4LogicalVolume*> fScorers; 151 152 G4bool fConstructed; 153 }; 154 155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 156 157 inline G4int DicomDetectorConstruction::GetTotalVoxels() const 158 { 159 return fNoVoxelsX * fNoVoxelsY * fNoVoxelsZ; 160 } 161 162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 163 164 #endif 165