Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
G4TheRayTracer Class Reference

#include <G4TheRayTracer.hh>

Inheritance diagram for G4TheRayTracer:
G4TheMTRayTracer

Public Member Functions

 G4TheRayTracer (G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
 
G4double GetAttenuationLength () const
 
G4Colour GetBackgroundColour () const
 
G4bool GetDistortion () const
 
G4ThreeVector GetEyePosition () const
 
G4VFigureFileMaker * GetFigureFileMaker ()
 
G4double GetHeadAngle () const
 
G4ThreeVector GetLightDirection () const
 
G4int GetNColumn () const
 
G4int GetNRow () const
 
G4VRTScanner * GetScanner ()
 
G4ThreeVector GetTargetPosition () const
 
G4ThreeVector GetUpVector () const
 
G4double GetViewSpan () const
 
void SetAttenuationLength (G4double val)
 
void SetBackgroundColour (const G4Colour &val)
 
void SetDistortion (G4bool val)
 
void SetEyePosition (const G4ThreeVector &val)
 
void SetFigureFileMaker (G4VFigureFileMaker *figMaker)
 
void SetHeadAngle (G4double val)
 
void SetLightDirection (const G4ThreeVector &val)
 
void SetNColumn (G4int val)
 
void SetNRow (G4int val)
 
void SetScanner (G4VRTScanner *scanner)
 
void SetTargetPosition (const G4ThreeVector &val)
 
void SetUpVector (const G4ThreeVector &val)
 
void SetViewSpan (G4double val)
 
virtual void Trace (const G4String &fileName)
 
virtual ~G4TheRayTracer ()
 

Protected Member Functions

G4Colour Attenuate (G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
 
virtual G4bool CreateBitMap ()
 
void CreateFigureFile (const G4String &fileName)
 
G4bool GenerateColour (G4Event *anEvent)
 
G4Colour GetMixedColour (const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)
 
G4Colour GetSurfaceColour (G4RayTrajectoryPoint *point)
 
virtual void RestoreUserActions ()
 
virtual void StoreUserActions ()
 
G4bool ValidColour (const G4VisAttributes *visAtt)
 

Protected Attributes

G4bool antialiasingOn
 
G4double attenuationLength
 
G4Colour backgroundColour
 
unsigned char * colorB
 
unsigned char * colorG
 
unsigned char * colorR
 
G4bool distortionOn
 
G4ThreeVector eyeDirection
 
G4ThreeVector eyePosition
 
G4double headAngle
 
G4ThreeVector lightDirection
 
G4int nColumn
 
G4int nRow
 
G4Colour rayColour
 
G4ThreeVector targetPosition
 
G4EventManager * theEventManager
 
G4RTMessenger * theMessenger
 
G4RayShooter * theRayShooter
 
G4UserEventAction * theRayTracerEventAction
 
G4UserStackingAction * theRayTracerStackingAction
 
G4RTSteppingAction * theRayTracerSteppingAction
 
G4RTTrackingAction * theRayTracerTrackingAction
 
G4UserEventAction * theUserEventAction
 
G4UserStackingAction * theUserStackingAction
 
G4UserSteppingAction * theUserSteppingAction
 
G4UserTrackingAction * theUserTrackingAction
 
G4ThreeVector up
 
G4double viewSpan
 

Static Protected Attributes

static G4VFigureFileMaker * theFigMaker = 0
 
static G4VRTScanner * theScanner = 0
 

Detailed Description

Definition at line 71 of file G4TheRayTracer.hh.

Constructor & Destructor Documentation

◆ G4TheRayTracer()

G4TheRayTracer::G4TheRayTracer ( G4VFigureFileMaker *  figMaker = 0,
G4VRTScanner *  scanner = 0 
)

Definition at line 60 of file G4TheRayTracer.cc.

62{
63 theFigMaker = figMaker;
65 theScanner = scanner;
76 colorR = 0;
77 colorG = 0;
78 colorB = 0;
79
82
83 nColumn = 640;
84 nRow = 640;
85
86 eyePosition = G4ThreeVector(1.*m,1.*m,1.*m);
87 targetPosition = G4ThreeVector(0.,0.,0.);
88 lightDirection = G4ThreeVector(-0.1,-0.2,-0.3).unit();
89 up = G4ThreeVector(0,1,0);
90 viewSpan = 5.0*deg;
91 headAngle = 0.;
92 attenuationLength = 1.0*m;
93
94 distortionOn = false;
95 antialiasingOn = false;
96
97 backgroundColour = G4Colour(1.,1.,1.);
98}
static constexpr double m
Definition: G4SIunits.hh:109
static constexpr double deg
Definition: G4SIunits.hh:132
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector unit() const
static G4EventManager * GetEventManager()
static G4RTMessenger * GetInstance(G4TheRayTracer *p1)
G4RTTrackingAction * theRayTracerTrackingAction
G4UserTrackingAction * theUserTrackingAction
G4RTSteppingAction * theRayTracerSteppingAction
static G4VRTScanner * theScanner
G4ThreeVector lightDirection
G4EventManager * theEventManager
static G4VFigureFileMaker * theFigMaker
G4UserStackingAction * theRayTracerStackingAction
G4UserEventAction * theUserEventAction
unsigned char * colorG
G4UserSteppingAction * theUserSteppingAction
G4Colour backgroundColour
unsigned char * colorR
G4double attenuationLength
G4ThreeVector targetPosition
G4UserEventAction * theRayTracerEventAction
G4UserStackingAction * theUserStackingAction
G4ThreeVector eyePosition
unsigned char * colorB
G4RTMessenger * theMessenger
G4RayShooter * theRayShooter
G4ThreeVector up

References antialiasingOn, attenuationLength, backgroundColour, colorB, colorG, colorR, deg, distortionOn, eyePosition, G4EventManager::GetEventManager(), G4RTMessenger::GetInstance(), headAngle, lightDirection, m, nColumn, nRow, targetPosition, theEventManager, theFigMaker, theMessenger, theRayShooter, theRayTracerEventAction, theRayTracerStackingAction, theRayTracerSteppingAction, theRayTracerTrackingAction, theScanner, theUserEventAction, theUserStackingAction, theUserSteppingAction, theUserTrackingAction, CLHEP::Hep3Vector::unit(), up, and viewSpan.

◆ ~G4TheRayTracer()

G4TheRayTracer::~G4TheRayTracer ( )
virtual

Member Function Documentation

◆ Attenuate()

G4Colour G4TheRayTracer::Attenuate ( G4RayTrajectoryPoint *  point,
const G4Colour &  sourceCol 
)
protected

Definition at line 394 of file G4TheRayTracer.cc.

396{
397 const G4VisAttributes* preAtt = point->GetPreStepAtt();
398
399 G4bool visible = ValidColour(preAtt);
400 if(!visible) return sourceCol;
401
402 G4Colour objCol = preAtt->GetColour();
403 G4double stepRed = objCol.GetRed();
404 G4double stepGreen = objCol.GetGreen();
405 G4double stepBlue = objCol.GetBlue();
406 G4double stepAlpha = objCol.GetAlpha();
407 G4double stepLength = point->GetStepLength();
408
409 G4double attenuationFuctor;
410 if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
411 attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
412
413 G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
414 G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
415 G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
416 if(KtRed>1.0){KtRed=1.0;}
417 if(KtGreen>1.0){KtGreen=1.0;}
418 if(KtBlue>1.0){KtBlue=1.0;}
419 return G4Colour(sourceCol.GetRed()*KtRed,
420 sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
421}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetAlpha() const
Definition: G4Colour.hh:155
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153
G4double GetStepLength() const
const G4VisAttributes * GetPreStepAtt() const
G4bool ValidColour(const G4VisAttributes *visAtt)
const G4Colour & GetColour() const

References attenuationLength, G4Colour::GetAlpha(), G4Colour::GetBlue(), G4VisAttributes::GetColour(), G4Colour::GetGreen(), G4RayTrajectoryPoint::GetPreStepAtt(), G4Colour::GetRed(), G4RayTrajectoryPoint::GetStepLength(), and ValidColour().

Referenced by GenerateColour().

◆ CreateBitMap()

G4bool G4TheRayTracer::CreateBitMap ( )
protectedvirtual

Reimplemented in G4TheMTRayTracer.

Definition at line 193 of file G4TheRayTracer.cc.

194{
195 G4int iEvent = 0;
196 G4double stepAngle = viewSpan/100.;
197 G4double viewSpanX = stepAngle*nColumn;
198 G4double viewSpanY = stepAngle*nRow;
199 G4bool succeeded;
200
202 visMan->IgnoreStateChanges(true);
203
204// Confirm process(es) of Geantino is initialized
205 G4VPhysicalVolume* pWorld =
207 GetNavigatorForTracking()->GetWorldVolume();
210 G4ProcessVector* pVector
212 for (std::size_t j=0; j < pVector->size(); ++j) {
213 (*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
214 }
215
216// Close geometry and set the application state
218 geomManager->OpenGeometry();
219 geomManager->CloseGeometry(1,0);
220
221 G4ThreeVector center(0,0,0);
224 navigator->LocateGlobalPointAndSetup(center,0,false);
225
227 theStateMan->SetNewState(G4State_GeomClosed);
228
229// Event loop
231 G4int iRow, iColumn;
232 while (theScanner->Coords(iRow,iColumn)) {
233 G4int iCoord = iRow * nColumn + iColumn;
234 G4double dRow = 0, dColumn = 0; // Antialiasing increments.
235 G4Event* anEvent = new G4Event(iEvent++);
236 G4double angleX = -(viewSpanX/2. - (iColumn+dColumn)*stepAngle);
237 G4double angleY = viewSpanY/2. - (iRow+dRow)*stepAngle;
238 G4ThreeVector rayDirection;
239 if(distortionOn)
240 {
241 rayDirection = G4ThreeVector(-std::tan(angleX)/std::cos(angleY),std::tan(angleY)/std::cos(angleX),1.0);
242 }
243 else
244 {
245 rayDirection = G4ThreeVector(-std::tan(angleX),std::tan(angleY),1.0);
246 }
247 G4double cp = std::cos(eyeDirection.phi());
248 G4double sp = std::sqrt(1.-cp*cp);
249 G4double ct = std::cos(eyeDirection.theta());
250 G4double st = std::sqrt(1.-ct*ct);
251 G4double gamma = std::atan2(ct*cp*up.x()+ct*sp*up.y()-st*up.z(), -sp*up.x()+cp*up.y());
252 rayDirection.rotateZ(-gamma);
253 rayDirection.rotateZ(headAngle);
254 rayDirection.rotateUz(eyeDirection);
255 G4ThreeVector rayPosition(eyePosition);
256 G4bool interceptable = true;
257 // Check if rayPosition is in the world.
258 EInside whereisit =
259 pWorld->GetLogicalVolume()->GetSolid()->Inside(rayPosition);
260 if (whereisit != kInside) {
261 // It's outside the world, so move it inside.
262 G4double outsideDistance =
263 pWorld->GetLogicalVolume()->GetSolid()->
264 DistanceToIn(rayPosition,rayDirection);
265 if (outsideDistance != kInfinity) {
266 // Borrowing from geometry, where 1e-8 < epsilon < 1e-3, in
267 // absolute/internal length units, is used for ensuring good
268 // behaviour, choose to add 0.001 to ensure rayPosition is
269 // definitely inside the world volume (JA 16/9/2005)...
270 rayPosition = rayPosition+(outsideDistance+0.001)*rayDirection;
271 }
272 else {
273 interceptable = false;
274 }
275 }
276 if (interceptable) {
277 theRayShooter->Shoot(anEvent,rayPosition,rayDirection.unit());
279 succeeded = GenerateColour(anEvent);
280 colorR[iCoord] = (unsigned char)(G4int(255*rayColour.GetRed()));
281 colorG[iCoord] = (unsigned char)(G4int(255*rayColour.GetGreen()));
282 colorB[iCoord] = (unsigned char)(G4int(255*rayColour.GetBlue()));
283 } else { // Ray does not intercept world at all.
284 // Store background colour...
285 colorR[iCoord] = (unsigned char)(G4int(255*backgroundColour.GetRed()));
286 colorG[iCoord] = (unsigned char)(G4int(255*backgroundColour.GetGreen()));
287 colorB[iCoord] = (unsigned char)(G4int(255*backgroundColour.GetBlue()));
288 succeeded = true;
289 }
290
291 theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord]);
292
293 delete anEvent;
294 if(!succeeded) return false;
295 }
296
297 theStateMan->SetNewState(G4State_Idle);
298 visMan->IgnoreStateChanges(false);
299 return true;
300}
@ G4State_Idle
@ G4State_GeomClosed
static const G4double cp
int G4int
Definition: G4Types.hh:85
double z() const
double phi() const
double theta() const
double x() const
Hep3Vector & rotateZ(double)
Definition: ThreeVector.cc:107
double y() const
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:33
void ProcessOneEvent(G4Event *anEvent)
static G4Geantino * GeantinoDefinition()
Definition: G4Geantino.cc:81
static G4GeometryManager * GetInstance()
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
G4VSolid * GetSolid() const
G4ProcessManager * GetProcessManager() const
G4ProcessVector * GetProcessList() const
std::size_t size() const
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
static G4ProductionCutsTable * GetProductionCutsTable()
void Shoot(G4Event *evt, G4ThreeVector vtx, G4ThreeVector direc)
Definition: G4RayShooter.cc:57
static G4RegionStore * GetInstance()
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=nullptr)
static G4StateManager * GetStateManager()
G4bool SetNewState(const G4ApplicationState &requestedState)
G4ThreeVector eyeDirection
G4bool GenerateColour(G4Event *anEvent)
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
G4LogicalVolume * GetLogicalVolume() const
virtual void Initialize(G4int nRow, G4int nColumn)=0
virtual void Draw(unsigned char red, unsigned char green, unsigned char blue)
Definition: G4VRTScanner.hh:70
virtual G4bool Coords(G4int &iRow, G4int &iColumn)=0
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void IgnoreStateChanges(G4bool)
static G4VVisManager * GetConcreteInstance()
EInside
Definition: geomdefs.hh:67
@ kInside
Definition: geomdefs.hh:70
static const G4double kInfinity
Definition: geomdefs.hh:41

References backgroundColour, G4GeometryManager::CloseGeometry(), colorB, colorG, colorR, G4VRTScanner::Coords(), cp, distortionOn, G4VRTScanner::Draw(), eyeDirection, eyePosition, G4State_GeomClosed, G4State_Idle, G4Geantino::GeantinoDefinition(), GenerateColour(), G4Colour::GetBlue(), G4VVisManager::GetConcreteInstance(), G4Colour::GetGreen(), G4GeometryManager::GetInstance(), G4RegionStore::GetInstance(), G4VPhysicalVolume::GetLogicalVolume(), G4TransportationManager::GetNavigatorForTracking(), G4ProcessManager::GetProcessList(), G4ParticleDefinition::GetProcessManager(), G4ProductionCutsTable::GetProductionCutsTable(), G4Colour::GetRed(), G4LogicalVolume::GetSolid(), G4StateManager::GetStateManager(), G4TransportationManager::GetTransportationManager(), headAngle, G4VVisManager::IgnoreStateChanges(), G4VRTScanner::Initialize(), G4VSolid::Inside(), kInfinity, kInside, write_gdml::navigator, nColumn, nRow, G4GeometryManager::OpenGeometry(), CLHEP::Hep3Vector::phi(), G4EventManager::ProcessOneEvent(), rayColour, CLHEP::Hep3Vector::rotateUz(), CLHEP::Hep3Vector::rotateZ(), G4StateManager::SetNewState(), G4RayShooter::Shoot(), G4ProcessVector::size(), G4InuclParticleNames::sp, theEventManager, theRayShooter, theScanner, CLHEP::Hep3Vector::theta(), CLHEP::Hep3Vector::unit(), up, G4ProductionCutsTable::UpdateCoupleTable(), G4RegionStore::UpdateMaterialList(), viewSpan, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by Trace().

◆ CreateFigureFile()

void G4TheRayTracer::CreateFigureFile ( const G4String &  fileName)
protected

Definition at line 302 of file G4TheRayTracer.cc.

303{
304 //G4cout << nColumn << " " << nRow << G4endl;
306}
virtual void CreateFigureFile(const G4String &fileName, int nColumn, int nRow, unsigned char *colorR, unsigned char *colorG, unsigned char *colorB)=0

References colorB, colorG, colorR, G4VFigureFileMaker::CreateFigureFile(), nColumn, nRow, and theFigMaker.

Referenced by G4TheMTRayTracer::Trace(), and Trace().

◆ GenerateColour()

G4bool G4TheRayTracer::GenerateColour ( G4Event *  anEvent)
protected

Definition at line 308 of file G4TheRayTracer.cc.

309{
310 G4TrajectoryContainer * trajectoryContainer = anEvent->GetTrajectoryContainer();
311
312 G4RayTrajectory* trajectory = (G4RayTrajectory*)( (*trajectoryContainer)[0] );
313 if(!trajectory) return false;
314
315 G4int nPoint = trajectory->GetPointEntries();
316 if(nPoint==0) return false;
317
318 G4Colour initialColour(backgroundColour);
319 if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
320 { initialColour = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
321 rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialColour);
322
323 for(G4int i=nPoint-2;i>=0;--i)
324 {
325 G4Colour surfaceColour = GetSurfaceColour(trajectory->GetPointC(i));
326 G4double weight = 1.0 - surfaceColour.GetAlpha();
327 G4Colour mixedColour = GetMixedColour(rayColour,surfaceColour,weight);
328 rayColour = Attenuate(trajectory->GetPointC(i),mixedColour);
329 }
330
331 return true;
332}
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:160
const G4VisAttributes * GetPostStepAtt() const
virtual int GetPointEntries() const
G4RayTrajectoryPoint * GetPointC(G4int i) const
G4Colour Attenuate(G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
G4Colour GetSurfaceColour(G4RayTrajectoryPoint *point)
G4Colour GetMixedColour(const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)

References Attenuate(), backgroundColour, G4Colour::GetAlpha(), GetMixedColour(), G4RayTrajectory::GetPointC(), G4RayTrajectory::GetPointEntries(), G4RayTrajectoryPoint::GetPostStepAtt(), GetSurfaceColour(), G4Event::GetTrajectoryContainer(), and rayColour.

Referenced by CreateBitMap().

◆ GetAttenuationLength()

G4double G4TheRayTracer::GetAttenuationLength ( ) const
inline

Definition at line 181 of file G4TheRayTracer.hh.

181{ return attenuationLength; }

References attenuationLength.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetBackgroundColour()

G4Colour G4TheRayTracer::GetBackgroundColour ( ) const
inline

Definition at line 185 of file G4TheRayTracer.hh.

185{ return backgroundColour; }

References backgroundColour.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetDistortion()

G4bool G4TheRayTracer::GetDistortion ( ) const
inline

Definition at line 183 of file G4TheRayTracer.hh.

183{ return distortionOn; }

References distortionOn.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetEyePosition()

G4ThreeVector G4TheRayTracer::GetEyePosition ( ) const
inline

Definition at line 169 of file G4TheRayTracer.hh.

169{ return eyePosition; }

References eyePosition.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetFigureFileMaker()

G4VFigureFileMaker * G4TheRayTracer::GetFigureFileMaker ( )
inline

Definition at line 116 of file G4TheRayTracer.hh.

116{return theFigMaker;}

References theFigMaker.

◆ GetHeadAngle()

G4double G4TheRayTracer::GetHeadAngle ( ) const
inline

Definition at line 177 of file G4TheRayTracer.hh.

177{ return headAngle; }

References headAngle.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetLightDirection()

G4ThreeVector G4TheRayTracer::GetLightDirection ( ) const
inline

Definition at line 173 of file G4TheRayTracer.hh.

173{ return lightDirection; }

References lightDirection.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetMixedColour()

G4Colour G4TheRayTracer::GetMixedColour ( const G4Colour &  surfCol,
const G4Colour &  transCol,
G4double  weight = 0.5 
)
protected

Definition at line 334 of file G4TheRayTracer.cc.

336{
337 G4double red = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
338 G4double green = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
339 G4double blue = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
340 G4double alpha = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
341 return G4Colour(red,green,blue,alpha);
342}
static const G4double alpha

References alpha, G4Colour::GetAlpha(), G4Colour::GetBlue(), G4Colour::GetGreen(), and G4Colour::GetRed().

Referenced by GenerateColour(), and GetSurfaceColour().

◆ GetNColumn()

G4int G4TheRayTracer::GetNColumn ( ) const
inline

Definition at line 165 of file G4TheRayTracer.hh.

165{ return nColumn; }

References nColumn.

Referenced by G4RTMessenger::GetCurrentValue(), and G4RayTracerViewer::SetView().

◆ GetNRow()

G4int G4TheRayTracer::GetNRow ( ) const
inline

Definition at line 167 of file G4TheRayTracer.hh.

167{ return nRow; }

References nRow.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetScanner()

G4VRTScanner * G4TheRayTracer::GetScanner ( )
inline

Definition at line 121 of file G4TheRayTracer.hh.

121{return theScanner;}

References theScanner.

Referenced by G4RayTracerXViewer::Initialise().

◆ GetSurfaceColour()

G4Colour G4TheRayTracer::GetSurfaceColour ( G4RayTrajectoryPoint *  point)
protected

Definition at line 344 of file G4TheRayTracer.cc.

345{
346 const G4VisAttributes* preAtt = point->GetPreStepAtt();
347 const G4VisAttributes* postAtt = point->GetPostStepAtt();
348
349 G4bool preVis = ValidColour(preAtt);
350 G4bool postVis = ValidColour(postAtt);
351
352 G4Colour transparent(1.,1.,1.,0.);
353
354 if(!preVis&&!postVis) return transparent;
355
357
358 G4Colour preCol(1.,1.,1.);
359 G4Colour postCol(1.,1.,1.);
360
361 if(preVis)
362 {
363 const G4Colour& preAttColour = preAtt->GetColour();
364 G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
365 G4double red = preAttColour.GetRed();
366 G4double green = preAttColour.GetGreen();
367 G4double blue = preAttColour.GetBlue();
368 preCol = G4Colour
369 (red*brill,green*brill,blue*brill,preAttColour.GetAlpha());
370 }
371 else
372 { preCol = transparent; }
373
374 if(postVis)
375 {
376 const G4Colour& postAttColour = postAtt->GetColour();
377 G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
378 G4double red = postAttColour.GetRed();
379 G4double green = postAttColour.GetGreen();
380 G4double blue = postAttColour.GetBlue();
381 postCol = G4Colour
382 (red*brill,green*brill,blue*brill,postAttColour.GetAlpha());
383 }
384 else
385 { postCol = transparent; }
386
387 if(!preVis) return postCol;
388 if(!postVis) return preCol;
389
390 G4double weight = 0.5;
391 return GetMixedColour(preCol,postCol,weight);
392}
G4ThreeVector GetSurfaceNormal() const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:79

References G4Colour::GetAlpha(), G4Colour::GetBlue(), G4VisAttributes::GetColour(), G4Colour::GetGreen(), GetMixedColour(), G4RayTrajectoryPoint::GetPostStepAtt(), G4RayTrajectoryPoint::GetPreStepAtt(), G4Colour::GetRed(), G4RayTrajectoryPoint::GetSurfaceNormal(), lightDirection, CLHEP::normal(), and ValidColour().

Referenced by GenerateColour().

◆ GetTargetPosition()

G4ThreeVector G4TheRayTracer::GetTargetPosition ( ) const
inline

Definition at line 171 of file G4TheRayTracer.hh.

171{ return targetPosition; }

References targetPosition.

Referenced by G4RTMessenger::GetCurrentValue().

◆ GetUpVector()

G4ThreeVector G4TheRayTracer::GetUpVector ( ) const
inline

Definition at line 175 of file G4TheRayTracer.hh.

175{ return up; }

References up.

◆ GetViewSpan()

G4double G4TheRayTracer::GetViewSpan ( ) const
inline

Definition at line 179 of file G4TheRayTracer.hh.

179{ return viewSpan; }

References viewSpan.

Referenced by G4RTMessenger::GetCurrentValue().

◆ RestoreUserActions()

void G4TheRayTracer::RestoreUserActions ( )
protectedvirtual

◆ SetAttenuationLength()

void G4TheRayTracer::SetAttenuationLength ( G4double  val)
inline

Definition at line 180 of file G4TheRayTracer.hh.

180{ attenuationLength = val; }

References attenuationLength.

Referenced by G4RTMessenger::SetNewValue().

◆ SetBackgroundColour()

void G4TheRayTracer::SetBackgroundColour ( const G4Colour &  val)
inline

Definition at line 184 of file G4TheRayTracer.hh.

184{ backgroundColour = val; }

References backgroundColour.

Referenced by G4RayTracerViewer::SetView().

◆ SetDistortion()

void G4TheRayTracer::SetDistortion ( G4bool  val)
inline

Definition at line 182 of file G4TheRayTracer.hh.

182{ distortionOn = val; }

References distortionOn.

Referenced by G4RTMessenger::SetNewValue().

◆ SetEyePosition()

void G4TheRayTracer::SetEyePosition ( const G4ThreeVector &  val)
inline

Definition at line 168 of file G4TheRayTracer.hh.

168{ eyePosition = val; }

References eyePosition.

Referenced by G4RTMessenger::SetNewValue(), and G4RayTracerViewer::SetView().

◆ SetFigureFileMaker()

void G4TheRayTracer::SetFigureFileMaker ( G4VFigureFileMaker *  figMaker)
inline

Definition at line 112 of file G4TheRayTracer.hh.

115 { theFigMaker = figMaker; }

References theFigMaker.

◆ SetHeadAngle()

void G4TheRayTracer::SetHeadAngle ( G4double  val)
inline

Definition at line 176 of file G4TheRayTracer.hh.

176{ headAngle = val; }

References headAngle.

Referenced by G4RTMessenger::SetNewValue().

◆ SetLightDirection()

void G4TheRayTracer::SetLightDirection ( const G4ThreeVector &  val)
inline

Definition at line 172 of file G4TheRayTracer.hh.

172{ lightDirection = val.unit(); }

References lightDirection, and CLHEP::Hep3Vector::unit().

Referenced by G4RTMessenger::SetNewValue(), and G4RayTracerViewer::SetView().

◆ SetNColumn()

void G4TheRayTracer::SetNColumn ( G4int  val)
inline

Definition at line 164 of file G4TheRayTracer.hh.

164{ nColumn = val; }

References nColumn.

Referenced by G4RayTracerViewer::Initialise(), and G4RTMessenger::SetNewValue().

◆ SetNRow()

void G4TheRayTracer::SetNRow ( G4int  val)
inline

Definition at line 166 of file G4TheRayTracer.hh.

166{ nRow = val; }

References nRow.

Referenced by G4RayTracerViewer::Initialise(), and G4RTMessenger::SetNewValue().

◆ SetScanner()

void G4TheRayTracer::SetScanner ( G4VRTScanner *  scanner)
inline

Definition at line 117 of file G4TheRayTracer.hh.

120 { theScanner = scanner; }

References theScanner.

◆ SetTargetPosition()

void G4TheRayTracer::SetTargetPosition ( const G4ThreeVector &  val)
inline

Definition at line 170 of file G4TheRayTracer.hh.

170{ targetPosition = val; }

References targetPosition.

Referenced by G4RTMessenger::SetNewValue(), and G4RayTracerViewer::SetView().

◆ SetUpVector()

void G4TheRayTracer::SetUpVector ( const G4ThreeVector &  val)
inline

Definition at line 174 of file G4TheRayTracer.hh.

174{ up = val; }

References up.

Referenced by G4RayTracerViewer::SetView().

◆ SetViewSpan()

void G4TheRayTracer::SetViewSpan ( G4double  val)
inline

Definition at line 178 of file G4TheRayTracer.hh.

178{ viewSpan = val; }

References viewSpan.

Referenced by G4RTMessenger::SetNewValue().

◆ StoreUserActions()

void G4TheRayTracer::StoreUserActions ( )
protectedvirtual

Reimplemented in G4TheMTRayTracer.

Definition at line 153 of file G4TheRayTracer.cc.

154{
159
162
167
169 if(theSDMan)
170 { theSDMan->Activate("/",false); }
171
173 theGeomMan->OpenGeometry();
174 theGeomMan->CloseGeometry(true);
175}
G4UserTrackingAction * GetUserTrackingAction()
G4UserSteppingAction * GetUserSteppingAction()
G4UserStackingAction * GetUserStackingAction()
G4UserEventAction * GetUserEventAction()

References G4SDManager::Activate(), G4GeometryManager::CloseGeometry(), G4GeometryManager::GetInstance(), G4SDManager::GetSDMpointerIfExist(), G4EventManager::GetUserEventAction(), G4EventManager::GetUserStackingAction(), G4EventManager::GetUserSteppingAction(), G4EventManager::GetUserTrackingAction(), G4GeometryManager::OpenGeometry(), G4EventManager::SetUserAction(), theEventManager, theRayTracerEventAction, theRayTracerStackingAction, theRayTracerSteppingAction, theRayTracerTrackingAction, theUserEventAction, theUserStackingAction, theUserSteppingAction, and theUserTrackingAction.

Referenced by Trace().

◆ Trace()

void G4TheRayTracer::Trace ( const G4String &  fileName)
virtual

Reimplemented in G4TheMTRayTracer.

Definition at line 110 of file G4TheRayTracer.cc.

111{
113 G4ApplicationState currentState = theStateMan->GetCurrentState();
114 if(currentState!=G4State_Idle)
115 {
116 G4cerr << "Illegal application state - Trace() ignored." << G4endl;
117 return;
118 }
119
120 if(!theFigMaker)
121 {
122 G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
123 return;
124 }
125
127 G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
128 if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 1");
129
130
132 eyeDirection = tmpVec.unit();
133 colorR = new unsigned char[nColumn*nRow];
134 colorG = new unsigned char[nColumn*nRow];
135 colorB = new unsigned char[nColumn*nRow];
136
138 G4bool succeeded = CreateBitMap();
139 if(succeeded)
140 { CreateFigureFile(fileName); }
141 else
142 { G4cerr << "Could not create figure file" << G4endl;
143 G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
145
146 if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 0");
147
148 delete [] colorR;
149 delete [] colorG;
150 delete [] colorB;
151}
G4ApplicationState
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4ApplicationState & GetCurrentState() const
virtual void StoreUserActions()
virtual G4bool CreateBitMap()
void CreateFigureFile(const G4String &fileName)
virtual void RestoreUserActions()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:231
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77

References G4UImanager::ApplyCommand(), colorB, colorG, colorR, CreateBitMap(), CreateFigureFile(), eyeDirection, eyePosition, G4cerr, G4endl, G4State_Idle, G4UImanager::GetCurrentIntValue(), G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), nColumn, nRow, RestoreUserActions(), StoreUserActions(), targetPosition, theFigMaker, and CLHEP::Hep3Vector::unit().

Referenced by G4RayTracerViewer::DrawView(), and G4RTMessenger::SetNewValue().

◆ ValidColour()

G4bool G4TheRayTracer::ValidColour ( const G4VisAttributes *  visAtt)
protected

Definition at line 423 of file G4TheRayTracer.cc.

424{
425 G4bool val = true;
426 if(!visAtt)
427 { val = false; }
428 else if(!(visAtt->IsVisible()))
429 { val = false; }
430 else if(visAtt->IsForceDrawingStyle()
432 { val = false; }
433 return val;
434}
G4bool IsVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
G4bool IsForceDrawingStyle() const

References G4VisAttributes::GetForcedDrawingStyle(), G4VisAttributes::IsForceDrawingStyle(), G4VisAttributes::IsVisible(), and G4VisAttributes::wireframe.

Referenced by Attenuate(), and GetSurfaceColour().

Field Documentation

◆ antialiasingOn

G4bool G4TheRayTracer::antialiasingOn
protected

Definition at line 158 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer().

◆ attenuationLength

G4double G4TheRayTracer::attenuationLength
protected

◆ backgroundColour

G4Colour G4TheRayTracer::backgroundColour
protected

◆ colorB

unsigned char* G4TheRayTracer::colorB
protected

◆ colorG

unsigned char* G4TheRayTracer::colorG
protected

◆ colorR

unsigned char* G4TheRayTracer::colorR
protected

◆ distortionOn

G4bool G4TheRayTracer::distortionOn
protected

◆ eyeDirection

G4ThreeVector G4TheRayTracer::eyeDirection
protected

◆ eyePosition

G4ThreeVector G4TheRayTracer::eyePosition
protected

◆ headAngle

G4double G4TheRayTracer::headAngle
protected

Definition at line 153 of file G4TheRayTracer.hh.

Referenced by CreateBitMap(), G4TheRayTracer(), GetHeadAngle(), and SetHeadAngle().

◆ lightDirection

G4ThreeVector G4TheRayTracer::lightDirection
protected

◆ nColumn

G4int G4TheRayTracer::nColumn
protected

◆ nRow

G4int G4TheRayTracer::nRow
protected

◆ rayColour

G4Colour G4TheRayTracer::rayColour
protected

Definition at line 160 of file G4TheRayTracer.hh.

Referenced by CreateBitMap(), and GenerateColour().

◆ targetPosition

G4ThreeVector G4TheRayTracer::targetPosition
protected

◆ theEventManager

G4EventManager* G4TheRayTracer::theEventManager
protected

◆ theFigMaker

G4VFigureFileMaker * G4TheRayTracer::theFigMaker = 0
staticprotected

◆ theMessenger

G4RTMessenger* G4TheRayTracer::theMessenger
protected

Definition at line 126 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), and ~G4TheRayTracer().

◆ theRayShooter

G4RayShooter* G4TheRayTracer::theRayShooter
protected

Definition at line 124 of file G4TheRayTracer.hh.

Referenced by CreateBitMap(), G4TheRayTracer(), and ~G4TheRayTracer().

◆ theRayTracerEventAction

G4UserEventAction* G4TheRayTracer::theRayTracerEventAction
protected

Definition at line 136 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), and StoreUserActions().

◆ theRayTracerStackingAction

G4UserStackingAction* G4TheRayTracer::theRayTracerStackingAction
protected

Definition at line 137 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), and StoreUserActions().

◆ theRayTracerSteppingAction

G4RTSteppingAction* G4TheRayTracer::theRayTracerSteppingAction
protected

Definition at line 139 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), StoreUserActions(), and ~G4TheRayTracer().

◆ theRayTracerTrackingAction

G4RTTrackingAction* G4TheRayTracer::theRayTracerTrackingAction
protected

Definition at line 138 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), StoreUserActions(), and ~G4TheRayTracer().

◆ theScanner

G4VRTScanner * G4TheRayTracer::theScanner = 0
staticprotected

◆ theUserEventAction

G4UserEventAction* G4TheRayTracer::theUserEventAction
protected

Definition at line 131 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), RestoreUserActions(), and StoreUserActions().

◆ theUserStackingAction

G4UserStackingAction* G4TheRayTracer::theUserStackingAction
protected

Definition at line 132 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), RestoreUserActions(), and StoreUserActions().

◆ theUserSteppingAction

G4UserSteppingAction* G4TheRayTracer::theUserSteppingAction
protected

Definition at line 134 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), RestoreUserActions(), and StoreUserActions().

◆ theUserTrackingAction

G4UserTrackingAction* G4TheRayTracer::theUserTrackingAction
protected

Definition at line 133 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), RestoreUserActions(), and StoreUserActions().

◆ up

G4ThreeVector G4TheRayTracer::up
protected

Definition at line 152 of file G4TheRayTracer.hh.

Referenced by CreateBitMap(), G4TheRayTracer(), GetUpVector(), and SetUpVector().

◆ viewSpan

G4double G4TheRayTracer::viewSpan
protected

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