Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
DicomPhantomParameterisationColour Class Reference

Class inherited from G4PhantomParameterisation to provide different. More...

#include <Doxymodules_medical.h>

Inheritance diagram for DicomPhantomParameterisationColour:
G4PhantomParameterisation G4VPVParameterisation

Public Types

typedef std::map< G4String, G4VisAttributes * > ColourMap_t
 

Public Member Functions

 DicomPhantomParameterisationColour (G4String colorFile=fDefaultColorFile)
 
 ~DicomPhantomParameterisationColour ()
 
virtual G4MaterialComputeMaterial (const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
 
const ColourMap_tGetColourMap () const
 
ColourMap_tGetColourMap ()
 

Static Public Attributes

static G4String fDefaultColorFile
 

Private Member Functions

void ReadColourData (G4String colourFile)
 

Private Attributes

ColourMap_t fColours
 
std::map< G4int, G4VisAttributes * > fColours2
 

Detailed Description

Class inherited from G4PhantomParameterisation to provide different.

History:

Definition at line 26 of file Doxymodules_medical.h.

Member Typedef Documentation

◆ ColourMap_t

Definition at line 51 of file DicomPhantomParameterisationColour.hh.

Constructor & Destructor Documentation

◆ DicomPhantomParameterisationColour()

DicomPhantomParameterisationColour::DicomPhantomParameterisationColour ( G4String  colorFile = fDefaultColorFile)

Definition at line 48 of file DicomPhantomParameterisationColour.cc.

51{
52 ReadColourData(colourFile);
53 SetSkipEqualMaterials(false);
54}

◆ ~DicomPhantomParameterisationColour()

DicomPhantomParameterisationColour::~DicomPhantomParameterisationColour ( )

Definition at line 57 of file DicomPhantomParameterisationColour.cc.

58{
59}

Member Function Documentation

◆ ComputeMaterial()

G4Material * DicomPhantomParameterisationColour::ComputeMaterial ( const G4int  repNo,
G4VPhysicalVolume currentVol,
const G4VTouchable *  parentTouch = 0 
)
virtual

Definition at line 91 of file DicomPhantomParameterisationColour.cc.

94{
95 G4Material* mate = G4PhantomParameterisation::ComputeMaterial(
96 copyNo, physVol, 0 );
97
98 if(G4VVisManager::GetConcreteInstance() && physVol)
99 {
100 G4String mateName = mate->GetName();
101 std::string::size_type iuu = mateName.find("__");
102 if( iuu != std::string::npos )
103 mateName = mateName.substr( 0, iuu );
104
105 if(0 < fColours.count(mateName))
106 physVol->GetLogicalVolume()->SetVisAttributes(
107 fColours.find(mateName)->second);
108 else
109 {
110 bool found = false;
111 for(const auto& itr : fColours)
112 {
113 G4String mat_color = itr.first;
114 auto len = mat_color.length();
115 if(mateName.find(mat_color) == 0 &&
116 mateName.length() > len && mateName[len] == '_')
117 {
118 physVol->GetLogicalVolume()->SetVisAttributes(
119 fColours.find(mat_color)->second);
120 found = true;
121 }
122 if(found)
123 break;
124 }
125 if(!found)
126 {
127 G4int matIndex = G4int(GetMaterialIndex(copyNo));
128 static uintmax_t n = 0;
129 if(n++ < 100)
130 G4cout << "Unknown material name " << mateName
131 << " for index " << matIndex << G4endl;
132 if(fColours2.find(matIndex) != fColours2.end())
133 physVol->GetLogicalVolume()->SetVisAttributes(
134 fColours2.find(matIndex)->second);
135 else
136 physVol->GetLogicalVolume()->SetVisAttributes(
137 fColours.begin()->second);
138 }
139 }
140 physVol -> GetLogicalVolume()->SetMaterial(mate);
141 }
142
143 return mate;
144}
std::map< G4int, G4VisAttributes * > fColours2

◆ GetColourMap() [1/2]

const ColourMap_t & DicomPhantomParameterisationColour::GetColourMap ( ) const
inline

Definition at line 64 of file DicomPhantomParameterisationColour.hh.

64{ return fColours; }

◆ GetColourMap() [2/2]

ColourMap_t & DicomPhantomParameterisationColour::GetColourMap ( )
inline

Definition at line 65 of file DicomPhantomParameterisationColour.hh.

65{ return fColours; }

◆ ReadColourData()

void DicomPhantomParameterisationColour::ReadColourData ( G4String  colourFile)
private

Definition at line 62 of file DicomPhantomParameterisationColour.cc.

63{
64 //----- Add a G4VisAttributes for materials not defined in file;
65 G4VisAttributes* blankAtt = new G4VisAttributes;
66 blankAtt->SetVisibility( FALSE );
67 fColours["Default"] = blankAtt;
68
69 //----- Read file
70 std::ifstream fin(colourFile.c_str());
71 G4int nMate;
72 G4String mateName;
73 G4double cred, cgreen, cblue, copacity;
74 fin >> nMate;
75 for( G4int ii = 0; ii < nMate; ii++ )
76 {
77 fin >> mateName;
78 if(fin.eof())
79 break;
80 fin >> cred >> cgreen >> cblue >> copacity;
81 G4Colour colour( cred, cgreen, cblue, copacity );
82 G4VisAttributes* visAtt = new G4VisAttributes( colour );
83 visAtt->SetVisibility(true);
84 fColours[mateName] = visAtt;
85 fColours2[ii] = new G4VisAttributes(*visAtt);
86 }
87
88}

Member Data Documentation

◆ fDefaultColorFile

G4String DicomPhantomParameterisationColour::fDefaultColorFile
static
Initial value:
=
DicomHandler::GetDicomDataPath() + "/ColourMap.dat"
static G4String GetDicomDataPath()

Definition at line 53 of file DicomPhantomParameterisationColour.hh.

◆ fColours

ColourMap_t DicomPhantomParameterisationColour::fColours
private

Definition at line 71 of file DicomPhantomParameterisationColour.hh.

◆ fColours2

std::map<G4int, G4VisAttributes*> DicomPhantomParameterisationColour::fColours2
private

Definition at line 72 of file DicomPhantomParameterisationColour.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration