Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:44

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 //
0027 /// \file medical/DICOM/include/DicomNestedPhantomParameterisation.hh
0028 /// \brief Definition of the DicomNestedPhantomParameterisation class
0029 //
0030 
0031 #ifndef DICOMNESTEDPARAMETERISATION_HH
0032 #define DICOMNESTEDPARAMETERISATION_HH
0033 
0034 #include "G4ThreeVector.hh"
0035 #include "G4Types.hh"
0036 #include "G4VNestedParameterisation.hh"
0037 #include "G4VTouchable.hh"
0038 
0039 #include <map>
0040 #include <vector>
0041 
0042 class G4VPhysicalVolume;
0043 class G4VSolid;
0044 class G4Material;
0045 class G4VisAttributes;
0046 
0047 // CSG Entities which may be parameterised/replicated
0048 //
0049 class G4Box;
0050 class G4Tubs;
0051 class G4Trd;
0052 class G4Trap;
0053 class G4Cons;
0054 class G4Sphere;
0055 class G4Ellipsoid;
0056 class G4Orb;
0057 class G4Torus;
0058 class G4Para;
0059 class G4Polycone;
0060 class G4Polyhedra;
0061 class G4Hype;
0062 
0063 /// Implements a G4VNestedParameterisation
0064 
0065 class DicomNestedPhantomParameterisation : public G4VNestedParameterisation
0066 {
0067   public:
0068     typedef std::map<G4String, G4VisAttributes*> ColourMap_t;
0069 
0070     static G4String fDefaultColorFile;
0071 
0072   public:
0073     DicomNestedPhantomParameterisation(const G4ThreeVector& voxelSize,
0074                                        std::vector<G4Material*>& mat, G4int fnZ_ = 0,
0075                                        G4int fnY_ = 0, G4int fnX_ = 0,
0076                                        G4String colorFile = fDefaultColorFile);
0077     ~DicomNestedPhantomParameterisation();
0078 
0079     G4Material* ComputeMaterial(G4VPhysicalVolume* currentVol, const G4int repNo,
0080                                 const G4VTouchable* parentTouch);
0081     // Must cope with parentTouch for navigator's SetupHierarchy
0082 
0083     G4int GetNumberOfMaterials() const;
0084     G4Material* GetMaterial(G4int idx) const;
0085     // Needed to define materials for instances of Nested Parameterisation
0086     // Current convention: each call should return the materials
0087     // of all instances with the same mother/ancestor volume
0088 
0089     // unsigned int GetMaterialIndex( unsigned int nx, unsigned int ny,
0090     //                                unsigned int nz) const;
0091     unsigned int GetMaterialIndex(unsigned int copyNo) const;
0092     void SetMaterialIndices(size_t* matInd) { fMaterialIndices = matInd; }
0093     void SetNoVoxels(unsigned int nx, unsigned int ny, unsigned int nz);
0094 
0095     void ComputeTransformation(const G4int no, G4VPhysicalVolume* currentPV) const;
0096 
0097     // Additional standard Parameterisation methods,
0098     // which can be optionally defined, in case solid is used.
0099     void ComputeDimensions(G4Box&, const G4int, const G4VPhysicalVolume*) const;
0100 
0101     const ColourMap_t& GetColourMap() const { return fColours; }
0102     ColourMap_t& GetColourMap() { return fColours; }
0103 
0104   private:  // Dummy declarations to get rid of warnings ...
0105     void ComputeDimensions(G4Trd&, const G4int, const G4VPhysicalVolume*) const {}
0106     void ComputeDimensions(G4Trap&, const G4int, const G4VPhysicalVolume*) const {}
0107     void ComputeDimensions(G4Cons&, const G4int, const G4VPhysicalVolume*) const {}
0108     void ComputeDimensions(G4Sphere&, const G4int, const G4VPhysicalVolume*) const {}
0109     void ComputeDimensions(G4Ellipsoid&, const G4int, const G4VPhysicalVolume*) const {}
0110     void ComputeDimensions(G4Orb&, const G4int, const G4VPhysicalVolume*) const {}
0111     void ComputeDimensions(G4Torus&, const G4int, const G4VPhysicalVolume*) const {}
0112     void ComputeDimensions(G4Para&, const G4int, const G4VPhysicalVolume*) const {}
0113     void ComputeDimensions(G4Hype&, const G4int, const G4VPhysicalVolume*) const {}
0114     void ComputeDimensions(G4Tubs&, const G4int, const G4VPhysicalVolume*) const {}
0115     void ComputeDimensions(G4Polycone&, const G4int, const G4VPhysicalVolume*) const {}
0116     void ComputeDimensions(G4Polyhedra&, const G4int, const G4VPhysicalVolume*) const {}
0117 
0118     void ReadColourData(G4String);
0119 
0120     using G4VNestedParameterisation::ComputeMaterial;
0121 
0122   private:
0123     G4double fdX, fdY, fdZ;
0124     G4int fnX, fnY, fnZ;
0125     std::vector<G4Material*> fMaterials;
0126     size_t* fMaterialIndices;  // Index in materials corresponding to each voxel
0127     ColourMap_t fColours;
0128     std::map<G4int, G4VisAttributes*> fColours2;
0129     std::vector<G4double> fpZ;
0130 };
0131 
0132 #endif