File indexing completed on 2025-01-18 09:16:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "ICRP110PhantomNestedParameterisation.hh"
0034 #include "G4VPhysicalVolume.hh"
0035 #include "G4VTouchable.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4Box.hh"
0038 #include "G4LogicalVolume.hh"
0039 #include "G4Material.hh"
0040 #include "G4VisAttributes.hh"
0041 #include "G4VVisManager.hh"
0042
0043 ICRP110PhantomNestedParameterisation::
0044 ICRP110PhantomNestedParameterisation(const G4ThreeVector& halfVoxelSize,
0045 std::vector<G4Material*>& mat,
0046 G4int fnX_, G4int fnY_, G4int fnZ_)
0047 :
0048 fdX(halfVoxelSize.x()), fdY(halfVoxelSize.y()), fdZ(halfVoxelSize.z()),
0049 fnX(fnX_), fnY(fnY_), fnZ(fnZ_),
0050 fMaterials(mat),
0051 fMaterialIndices(nullptr)
0052 {
0053 ReadColourData();
0054
0055 }
0056
0057 ICRP110PhantomNestedParameterisation::~ICRP110PhantomNestedParameterisation()
0058 {}
0059
0060 void ICRP110PhantomNestedParameterisation::ReadColourData()
0061 {
0062
0063
0064
0065 auto blankAtt = new G4VisAttributes;
0066 blankAtt->SetVisibility( FALSE );
0067 fColours["Default"] = blankAtt;
0068
0069 G4String colourFile = "ColourMap.dat";
0070 G4cout << "Phantom Material Colours set via ColourMap.dat data file " << G4endl;
0071
0072 std::ifstream fin(colourFile.c_str());
0073 G4int nMate;
0074 G4String mateName;
0075 G4double cred, cgreen, cblue, copacity;
0076 fin >> nMate;
0077 G4VisAttributes* visAtt=nullptr;
0078
0079 for( G4int ii = 0; ii < nMate; ii++ ){
0080 fin >> mateName >> cred >> cgreen >> cblue >> copacity;
0081 G4Colour colour( cred, cgreen, cblue, copacity );
0082 visAtt = new G4VisAttributes( colour );
0083 visAtt->SetForceSolid(true);
0084 fColours[mateName] = visAtt;
0085
0086 }
0087 }
0088
0089 void ICRP110PhantomNestedParameterisation::
0090 SetNoVoxel( G4int nx, G4int ny, G4int nz )
0091 {
0092 fnX = nx;
0093 fnY = ny;
0094 fnZ = nz;
0095 }
0096
0097 G4Material* ICRP110PhantomNestedParameterisation::
0098 ComputeMaterial(G4VPhysicalVolume* physVol, const G4int iz,
0099 const G4VTouchable* parentTouch)
0100 {
0101
0102
0103 if(parentTouch == nullptr)
0104 return fMaterials[0];
0105
0106
0107
0108
0109
0110 G4int ix = parentTouch -> GetReplicaNumber(0);
0111 G4int iy = parentTouch -> GetReplicaNumber(1);
0112
0113 G4int copyID = ix + fnX*iy + fnX*fnY*iz;
0114
0115
0116
0117
0118 std::size_t matIndex = GetMaterialIndex(copyID);
0119 G4Material* mate = fMaterials[matIndex];
0120
0121 if(true && physVol && G4VVisManager::GetConcreteInstance()) {
0122 G4String mateName = fMaterials.at(matIndex)->GetName();
0123 std::string::size_type iuu = mateName.find("__");
0124
0125 if( iuu != std::string::npos ) {
0126 mateName = mateName.substr( 0, iuu );
0127 }
0128
0129 if(0 < fColours.count(mateName)) {
0130 physVol -> GetLogicalVolume() ->
0131 SetVisAttributes(fColours.find(mateName)->second);
0132 }
0133 else {
0134 physVol->GetLogicalVolume() ->
0135 SetVisAttributes(fColours.begin() ->second);
0136 }
0137 }
0138 physVol -> GetLogicalVolume()->SetMaterial(mate);
0139
0140 return mate;
0141 }
0142
0143 G4int ICRP110PhantomNestedParameterisation::GetMaterialIndex( G4int copyNo ) const
0144 {
0145 return fMaterialIndices[copyNo];
0146 }
0147
0148 G4int ICRP110PhantomNestedParameterisation::GetNumberOfMaterials() const
0149 {
0150 return fMaterials.size();
0151 }
0152
0153 G4Material* ICRP110PhantomNestedParameterisation::GetMaterial(G4int i) const
0154 {
0155 return fMaterials[i];
0156 }
0157
0158 void ICRP110PhantomNestedParameterisation::
0159 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
0160 {
0161
0162
0163
0164
0165 physVol -> SetTranslation(G4ThreeVector(0.,0.,(2.*static_cast<double>(copyNo)
0166 +1.)*fdZ - fdZ*fnZ));
0167 }
0168
0169 void ICRP110PhantomNestedParameterisation::
0170 ComputeDimensions( G4Box& box, const G4int, const G4VPhysicalVolume* ) const
0171 {
0172 box.SetXHalfLength(fdX);
0173 box.SetYHalfLength(fdY);
0174 box.SetZHalfLength(fdZ);
0175 }