Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
DicomPhantomParameterisationColour.cc
이 파일의 문서화 페이지로 가기
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:DicomPhantomParameterisationColour.cc 74592 2013-10-15 21:20:11Z jmadsen $
27 //
30 
32 
33 #include "globals.hh"
34 #include "G4VisAttributes.hh"
35 #include "G4Material.hh"
36 #include "G4VPhysicalVolume.hh"
37 #include "G4LogicalVolume.hh"
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 {
44  SetSkipEqualMaterials(false);
45 }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 {
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 {
55  //----- Add a G4VisAttributes for materials not defined in file;
56  G4VisAttributes* blankAtt = new G4VisAttributes;
57  blankAtt->SetVisibility( FALSE );
58  fColours["Default"] = blankAtt;
59 
60  //----- Read file
61 #ifdef DICOM_USE_HEAD
62  G4String path = getenv("DICOM_PATH");
63  G4String colourFile = path+"/ColourMap.dat";
64  G4cout<< colourFile << G4endl;
65 #else
66  G4String colourFile = "ColourMap.dat";
67 #endif
68 
69  std::ifstream fin(colourFile.c_str());
70  G4int nMate;
71  G4String mateName;
72  G4double cred, cgreen, cblue, copacity;
73  fin >> nMate;
74  for( G4int ii = 0; ii < nMate; ii++ ){
75  fin >> mateName >> cred >> cgreen >> cblue >> copacity;
76  G4Colour colour( cred, cgreen, cblue, copacity );
77  G4VisAttributes* visAtt = new G4VisAttributes( colour );
78  //visAtt->SetForceSolid(true);
79  fColours[mateName] = visAtt;
80  }
81 
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 ComputeMaterial(const G4int copyNo, G4VPhysicalVolume * physVol, const G4VTouchable *)
87 {
88  G4Material* mate = G4PhantomParameterisation::ComputeMaterial( copyNo, physVol, 0 );
89  if( physVol ) {
90  G4String mateName = mate->GetName();
91  std::string::size_type iuu = mateName.find("__");
92  if( iuu != std::string::npos ) {
93  mateName = mateName.substr( 0, iuu );
94  }
95  std::map<G4String,G4VisAttributes*>::const_iterator ite =
96  fColours.find(mateName);
97  if( ite != fColours.end() ){
98  physVol->GetLogicalVolume()->SetVisAttributes( (*ite).second );
99  } else {
100  physVol->GetLogicalVolume()->SetVisAttributes(
101  (*(fColours.begin()) ).second );
102  // set it as unseen
103  }
104  }
105 
106  return mate;
107 }
G4LogicalVolume * GetLogicalVolume() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
#define G4endl
Definition: G4ios.hh:61
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
fin
Definition: AddMC.C:2
const G4String & GetName() const
Definition: G4Material.hh:179
double G4double
Definition: G4Types.hh:76
void SetSkipEqualMaterials(G4bool skip)
Definition of the DicomPhantomParameterisationColour class.
#define FALSE
Definition: globals.hh:52
void SetVisAttributes(const G4VisAttributes *pVA)
void SetVisibility(G4bool=true)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
std::map< G4String, G4VisAttributes * > fColours