Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:19

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 #ifndef DicomFileCT_NOdcmrt__HH
0027 #define DicomFileCT_NOdcmrt__HH
0028 
0029 #include "DicomFileMgr.hh"
0030 #include "DicomVFile.hh"
0031 
0032 #include "G4ThreeVector.hh"
0033 
0034 class DicomFileCT_NOdcmrt : public DicomVFile
0035 {
0036   public:
0037     DicomFileCT_NOdcmrt();
0038     DicomFileCT_NOdcmrt(DcmDataset* dset);
0039     ~DicomFileCT_NOdcmrt() {};
0040 
0041   public:
0042     virtual void ReadData();
0043 
0044     void operator+=(const DicomFileCT_NOdcmrt& rhs);
0045     DicomFileCT_NOdcmrt operator+(const DicomFileCT_NOdcmrt& rhs);
0046     // add two slices that have the same dimensions, merging them in Z
0047 
0048     void BuildMaterials();
0049     void DumpHeaderToTextFile(std::ofstream& fout);
0050     void DumpMateIDsToTextFile(std::ofstream& fout);
0051     void DumpDensitiesToTextFile(std::ofstream& fout);
0052     void BuildStructureIDs();
0053     void DumpStructureIDsToTextFile(std::ofstream& fout);
0054 
0055     // Get and set methods
0056     G4int GetNoVoxelsX() const { return fNoVoxelsX; };
0057     G4int GetNoVoxelsY() const { return fNoVoxelsY; };
0058     G4int GetNoVoxelsZ() const { return fNoVoxelsZ; };
0059     G4int GetNoVoxels() const { return fNoVoxelsX * fNoVoxelsY * fNoVoxelsZ; };
0060 
0061     G4double GetMinX() const { return fMinX; };
0062     G4double GetMinY() const { return fMinY; };
0063     G4double GetMinZ() const { return fMinZ; };
0064     G4double GetMaxX() const { return fMaxX; };
0065     G4double GetMaxY() const { return fMaxY; };
0066     G4double GetMaxZ() const { return fMaxZ; };
0067 
0068     void SetNoVoxelsX(const G4int& val) { fNoVoxelsX = val; }
0069     void SetNoVoxelsY(const G4int& val) { fNoVoxelsY = val; }
0070     void SetNoVoxelsZ(const G4int& val) { fNoVoxelsZ = val; }
0071 
0072     void SetMinX(const G4double& val) { fMinX = val; };
0073     void SetMaxX(const G4double& val) { fMaxX = val; };
0074     void SetMinY(const G4double& val) { fMinY = val; };
0075     void SetMaxY(const G4double& val) { fMaxY = val; };
0076     void SetMinZ(const G4double& val) { fMinZ = val; };
0077     void SetMaxZ(const G4double& val) { fMaxZ = val; };
0078 
0079     const G4double& GetLocation() const { return fLocation; }
0080 
0081     void SetLocation(const G4double& val) { fLocation = val; }
0082 
0083     G4ThreeVector GetOrientationRows() const { return fOrientationRows; }
0084     G4ThreeVector GetOrientationColumns() const { return fOrientationColumns; }
0085 
0086     void DumpToTextFile();
0087     void DumpToBinaryFile();
0088 
0089     void ReadDataFromFile();
0090 
0091   private:
0092     template<typename T>
0093     inline bool CheckConsistency(const T&, const T&, G4String);
0094 
0095     void ReadPixelData();
0096     void Print(std::ostream& out);
0097 
0098   private:
0099     G4double fLocation;
0100     G4double fBitAllocated;
0101     G4double fRescaleSlope;
0102     G4double fRescaleIntercept;
0103 
0104     G4int fNoVoxelsX, fNoVoxelsY, fNoVoxelsZ;  // number of voxels in each dimensions
0105     G4double fMinX, fMinY, fMinZ;  // minimum extension of voxels (position of wall)
0106     G4double fMaxX, fMaxY, fMaxZ;  // maximum extension of voxels (position of wall)
0107     G4double fVoxelDimX, fVoxelDimY, fVoxelDimZ;  // maximum extension of voxels (position of wall)
0108 
0109     G4ThreeVector fOrientationRows;
0110     G4ThreeVector fOrientationColumns;
0111 
0112     std::vector<int> fHounsfieldV;
0113     std::vector<size_t> fMateIDs;
0114     std::vector<G4double> fDensities;
0115     std::vector<G4int> fStructure;
0116     //  G4int* fStructure;
0117 
0118     DicomFileMgr* theFileMgr;
0119 };
0120 
0121 //============================================================================
0122 template<typename T>
0123 inline bool DicomFileCT_NOdcmrt::CheckConsistency(const T& val1, const T& val2, G4String category)
0124 {
0125   if (val1 != val2) {
0126     G4Exception("DicomFileCT_NOdcmrtr::CheckConsistency",
0127                 "Consistency Mismatch : Keeping previous value if nonzero", JustWarning,
0128                 category.c_str());
0129     return false;
0130   }
0131   return true;
0132 }
0133 
0134 #endif