Geant4_10
DicomHandler.hh
Go to the documentation of this file.
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 // $Id: DicomHandler.hh 73076 2013-08-16 07:45:30Z gcosmo $
27 //
30 //
31 // The code was written by :
32 // *Louis Archambault louis.archambault@phy.ulaval.ca,
33 // *Luc Beaulieu beaulieu@phy.ulaval.ca
34 // +Vincent Hubert-Tremblay at tigre.2@sympatico.ca
35 //
36 //
37 // *Centre Hospitalier Universitaire de Quebec (CHUQ),
38 // Hotel-Dieu de Quebec, departement de Radio-oncologie
39 // 11 cote du palais. Quebec, QC, Canada, G1R 2J6
40 // tel (418) 525-4444 #6720
41 // fax (418) 691 5268
42 //
43 // + Université Laval, Québec (QC) Canada
44 //*******************************************************//
45 
46 #ifndef DicomHandler_h
47 #define DicomHandler_h 1
48 
49 #include <cstdio>
50 #include <map>
51 #include <fstream>
52 
53 #include "globals.hh"
54 
55 //*******************************************************
66 //*******************************************************
67 
70 
72 {
73 public:
74 
75  DicomHandler();
76 
77  ~DicomHandler();
78 
79  // static accessor
80  static DicomHandler* Instance();
81 
82  G4int ReadFile(FILE *,char *);
83  G4int ReadData(FILE *,char *); // note: always use readHeader
84  // before readData
85 
86  // use ImageMagick to display the image
87  //G4int displayImage(char[500]);
88 
89  void CheckFileFormat();
90 
91 private:
92  template <class Type> void GetValue(char *, Type &);
93 
94 private:
95  static DicomHandler* fgInstance;
96 
97  const int DATABUFFSIZE;
98  const int LINEBUFFSIZE;
99  const int FILENAMESIZE;
100 
101  void ReadCalibration();
102  void GetInformation(G4int &, char *);
103  G4float Pixel2density(G4int pixel);
104  void ReadMaterialIndices( std::ifstream& finData);
105  unsigned int GetMaterialIndex( G4float density );
106  void StoreData(std::ofstream& foutG4DCM);
107  void StoreData(DicomPhantomZSliceHeader* dcmPZSH);
108  G4int read_defined_nested(FILE *, G4int);
109  void read_undefined_nested(FILE *);
110  void read_undefined_item(FILE *);
111 
112  short fCompression;
113  G4int fNFiles;
114  short fRows;
115  short fColumns;
116  short fBitAllocated;
117  G4int fMaxPixelValue, fMinPixelValue;
118 
119  G4double fPixelSpacingX, fPixelSpacingY;
120  G4double fSliceThickness;
121  G4double fSliceLocation;
122 
123  G4int fRescaleIntercept, fRescaleSlope;
124 
125  G4bool fLittleEndian, fImplicitEndian;
126  short fPixelRepresentation;
127 
128  G4int** fTab;
129  std::map<G4float,G4String> fMaterialIndices;
130 
131  G4int nbrequali;
132  G4double* valuedensity;
133  G4double* valueCT;
134  bool readCalibration;
135  DicomPhantomZSliceMerged* mergedSlices;
136 
137  G4String driverFile;
138  G4String ct2densityFile;
139 
140 };
141 #endif
142 
float G4float
Definition: G4Types.hh:77
int G4int
Definition: G4Types.hh:78
G4double density
Definition: TRTMaterials.hh:39
static DicomHandler * Instance()
Definition: DicomHandler.cc:72
bool G4bool
Definition: G4Types.hh:79
G4int ReadFile(FILE *, char *)
G4int ReadData(FILE *, char *)
void CheckFileFormat()
double G4double
Definition: G4Types.hh:76