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 DicomVFileImage__HH
0027 #define DicomVFileImage__HH
0028 
0029 #include "DicomFileMgr.hh"
0030 #include "DicomVFile.hh"
0031 
0032 #include "G4ThreeVector.hh"
0033 
0034 class DicomVFileImage : public DicomVFile
0035 {
0036   public:
0037     DicomVFileImage();
0038     DicomVFileImage(DcmDataset* dset);
0039     ~DicomVFileImage() {};
0040 
0041   public:
0042     virtual void ReadData();
0043 
0044     void operator+=(const DicomVFileImage& rhs);
0045     DicomVFileImage operator+(const DicomVFileImage& rhs);
0046     // add two slices that have the same dimensions, merging them in Z
0047 
0048     void DumpHeaderToTextFile(std::ofstream& fout);
0049 
0050     // Get and set methods
0051     G4int GetNoVoxelsX() const { return fNoVoxelsX; };
0052     G4int GetNoVoxelsY() const { return fNoVoxelsY; };
0053     G4int GetNoVoxelsZ() const { return fNoVoxelsZ; };
0054     G4int GetNoVoxels() const { return fNoVoxelsX * fNoVoxelsY * fNoVoxelsZ; };
0055 
0056     G4double GetMinX() const { return fMinX; };
0057     G4double GetMinY() const { return fMinY; };
0058     G4double GetMinZ() const { return fMinZ; };
0059     G4double GetMaxX() const { return fMaxX; };
0060     G4double GetMaxY() const { return fMaxY; };
0061     G4double GetMaxZ() const { return fMaxZ; };
0062 
0063     void SetNoVoxelsX(const G4int& val) { fNoVoxelsX = val; }
0064     void SetNoVoxelsY(const G4int& val) { fNoVoxelsY = val; }
0065     void SetNoVoxelsZ(const G4int& val) { fNoVoxelsZ = val; }
0066 
0067     void SetMinX(const G4double& val) { fMinX = val; };
0068     void SetMaxX(const G4double& val) { fMaxX = val; };
0069     void SetMinY(const G4double& val) { fMinY = val; };
0070     void SetMaxY(const G4double& val) { fMaxY = val; };
0071     void SetMinZ(const G4double& val) { fMinZ = val; };
0072     void SetMaxZ(const G4double& val) { fMaxZ = val; };
0073 
0074     const G4double& GetLocation() const { return fLocation; }
0075 
0076     void SetLocation(const G4double& val) { fLocation = val; }
0077 
0078     G4ThreeVector GetOrientationRows() const { return fOrientationRows; }
0079     G4ThreeVector GetOrientationColumns() const { return fOrientationColumns; }
0080 
0081   private:
0082     template<typename T>
0083     inline bool CheckConsistency(const T&, const T&, G4String);
0084 
0085     void ReadPixelData();
0086     void Print(std::ostream& out);
0087 
0088   protected:
0089     G4double fLocation;
0090     G4double fBitAllocated;
0091     G4double fRescaleSlope;
0092     G4double fRescaleIntercept;
0093 
0094     G4int fNoVoxelsX, fNoVoxelsY, fNoVoxelsZ;  // number of voxels in each dimensions
0095     G4double fMinX, fMinY, fMinZ;  // minimum extension of voxels (position of wall)
0096     G4double fMaxX, fMaxY, fMaxZ;  // maximum extension of voxels (position of wall)
0097     G4double fVoxelDimX, fVoxelDimY, fVoxelDimZ;  // maximum extension of voxels (position of wall)
0098 
0099     G4ThreeVector fOrientationRows;
0100     G4ThreeVector fOrientationColumns;
0101 
0102     std::vector<int> fHounsfieldV;
0103 
0104     DicomFileMgr* theFileMgr;
0105 };
0106 
0107 //============================================================================
0108 template<typename T>
0109 inline bool DicomVFileImage::CheckConsistency(const T& val1, const T& val2, G4String category)
0110 {
0111   if (val1 != val2) {
0112     G4Exception("DicomVFileImager::CheckConsistency",
0113                 "Consistency Mismatch : Keeping previous value if nonzero", JustWarning,
0114                 category.c_str());
0115     return false;
0116   }
0117   return true;
0118 }
0119 
0120 #endif