Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes
G4TheRayTracer Class Reference

#include <G4TheRayTracer.hh>

Inheritance diagram for G4TheRayTracer:
G4TheMTRayTracer

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

G4RayShootertheRayShooter
 
G4VFigureFileMakertheFigMaker
 
G4RTMessengertheMessenger
 
G4VRTScannertheScanner
 
G4EventManagertheEventManager
 
G4UserEventActiontheUserEventAction
 
G4UserStackingActiontheUserStackingAction
 
G4UserTrackingActiontheUserTrackingAction
 
G4UserSteppingActiontheUserSteppingAction
 
G4UserEventActiontheRayTracerEventAction
 
G4UserStackingActiontheRayTracerStackingAction
 
G4RTTrackingActiontheRayTracerTrackingAction
 
G4RTSteppingActiontheRayTracerSteppingAction
 
unsigned char * colorR
 
unsigned char * colorG
 
unsigned char * colorB
 
G4int nColumn
 
G4int nRow
 
G4ThreeVector eyePosition
 
G4ThreeVector targetPosition
 
G4ThreeVector eyeDirection
 
G4ThreeVector lightDirection
 
G4ThreeVector up
 
G4double headAngle
 
G4double viewSpan
 
G4double attenuationLength
 
G4bool distortionOn
 
G4bool antialiasingOn
 
G4Colour rayColour
 
G4Colour backgroundColour
 

Detailed Description

Definition at line 72 of file G4TheRayTracer.hh.

Constructor & Destructor Documentation

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

Definition at line 58 of file G4TheRayTracer.cc.

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

60 {
61  theFigMaker = figMaker;
63  theScanner = scanner;
72 
73  nColumn = 640;
74  nRow = 640;
75 
76  eyePosition = G4ThreeVector(1.*m,1.*m,1.*m);
77  targetPosition = G4ThreeVector(0.,0.,0.);
78  lightDirection = G4ThreeVector(-0.1,-0.2,-0.3).unit();
79  up = G4ThreeVector(0,1,0);
80  viewSpan = 5.0*deg;
81  headAngle = 0.;
82  attenuationLength = 1.0*m;
83 
84  distortionOn = false;
85  antialiasingOn = false;
86 
87  backgroundColour = G4Colour(1.,1.,1.);
88 }
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector targetPosition
G4UserStackingAction * theRayTracerStackingAction
G4RTSteppingAction * theRayTracerSteppingAction
G4RayShooter * theRayShooter
static G4RTMessenger * GetInstance(G4TheRayTracer *p1)
G4VRTScanner * theScanner
G4ThreeVector lightDirection
G4ThreeVector up
G4EventManager * theEventManager
G4RTTrackingAction * theRayTracerTrackingAction
G4VFigureFileMaker * theFigMaker
Hep3Vector unit() const
G4UserEventAction * theRayTracerEventAction
static G4EventManager * GetEventManager()
G4Colour backgroundColour
G4ThreeVector eyePosition
G4double attenuationLength
G4RTMessenger * theMessenger
G4TheRayTracer::~G4TheRayTracer ( )
virtual

Definition at line 90 of file G4TheRayTracer.cc.

References theFigMaker, theMessenger, theRayShooter, theRayTracerSteppingAction, theRayTracerTrackingAction, and theScanner.

91 {
92  delete theRayShooter;
95  delete theMessenger;
96  delete theScanner;
97  delete theFigMaker;
98 }
G4RTSteppingAction * theRayTracerSteppingAction
G4RayShooter * theRayShooter
G4VRTScanner * theScanner
G4RTTrackingAction * theRayTracerTrackingAction
G4VFigureFileMaker * theFigMaker
G4RTMessenger * theMessenger

Member Function Documentation

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

Definition at line 385 of file G4TheRayTracer.cc.

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

Referenced by GenerateColour().

386 {
387  const G4VisAttributes* preAtt = point->GetPreStepAtt();
388 
389  G4bool visible = ValidColour(preAtt);
390  if(!visible) return sourceCol;
391 
392  G4Colour objCol = preAtt->GetColour();
393  G4double stepRed = objCol.GetRed();
394  G4double stepGreen = objCol.GetGreen();
395  G4double stepBlue = objCol.GetBlue();
396  G4double stepAlpha = objCol.GetAlpha();
397  G4double stepLength = point->GetStepLength();
398 
399  G4double attenuationFuctor;
400  if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
401  attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
402 
403  G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
404  G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
405  G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
406  if(KtRed>1.0){KtRed=1.0;}
407  if(KtGreen>1.0){KtGreen=1.0;}
408  if(KtBlue>1.0){KtBlue=1.0;}
409  return G4Colour(sourceCol.GetRed()*KtRed,
410  sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
411 }
G4double GetAlpha() const
Definition: G4Colour.hh:142
const G4VisAttributes * GetPreStepAtt() const
const G4Colour & GetColour() const
G4double GetBlue() const
Definition: G4Colour.hh:141
G4double GetRed() const
Definition: G4Colour.hh:139
bool G4bool
Definition: G4Types.hh:79
G4double GetGreen() const
Definition: G4Colour.hh:140
G4bool ValidColour(const G4VisAttributes *visAtt)
double G4double
Definition: G4Types.hh:76
G4double GetStepLength() const
G4double attenuationLength
G4bool G4TheRayTracer::CreateBitMap ( )
protectedvirtual

Reimplemented in G4TheMTRayTracer.

Definition at line 183 of file G4TheRayTracer.cc.

References backgroundColour, G4GeometryManager::CloseGeometry(), colorB, colorG, colorR, G4VRTScanner::Coords(), distortionOn, G4VRTScanner::Draw(), eyeDirection, eyePosition, G4State_GeomClosed, G4State_Idle, G4Geantino::GeantinoDefinition(), GenerateColour(), G4Colour::GetBlue(), G4VVisManager::GetConcreteInstance(), G4Colour::GetGreen(), G4RegionStore::GetInstance(), G4GeometryManager::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(), kInside, G4Navigator::LocateGlobalPointAndSetup(), 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().

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

Definition at line 292 of file G4TheRayTracer.cc.

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

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

293 {
294  //G4cout << nColumn << " " << nRow << G4endl;
296 }
unsigned char * colorR
virtual void CreateFigureFile(const G4String &fileName, int nColumn, int nRow, unsigned char *colorR, unsigned char *colorG, unsigned char *colorB)=0
G4VFigureFileMaker * theFigMaker
unsigned char * colorB
unsigned char * colorG
G4bool G4TheRayTracer::GenerateColour ( G4Event anEvent)
protected

Definition at line 298 of file G4TheRayTracer.cc.

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

Referenced by CreateBitMap().

299 {
300  G4TrajectoryContainer * trajectoryContainer = anEvent->GetTrajectoryContainer();
301 
302  G4RayTrajectory* trajectory = (G4RayTrajectory*)( (*trajectoryContainer)[0] );
303  if(!trajectory) return false;
304 
305  G4int nPoint = trajectory->GetPointEntries();
306  if(nPoint==0) return false;
307 
308  G4Colour initialColour(backgroundColour);
309  if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
310  { initialColour = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
311  rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialColour);
312 
313  for(int i=nPoint-2;i>=0;i--)
314  {
315  G4Colour surfaceColour = GetSurfaceColour(trajectory->GetPointC(i));
316  G4double weight = 1.0 - surfaceColour.GetAlpha();
317  G4Colour mixedColour = GetMixedColour(rayColour,surfaceColour,weight);
318  rayColour = Attenuate(trajectory->GetPointC(i),mixedColour);
319  }
320 
321  return true;
322 }
G4double GetAlpha() const
Definition: G4Colour.hh:142
G4Colour GetSurfaceColour(G4RayTrajectoryPoint *point)
G4Colour Attenuate(G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
int G4int
Definition: G4Types.hh:78
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:178
virtual int GetPointEntries() const
G4Colour GetMixedColour(const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)
const G4VisAttributes * GetPostStepAtt() const
G4RayTrajectoryPoint * GetPointC(G4int i) const
G4Colour backgroundColour
double G4double
Definition: G4Types.hh:76
G4double G4TheRayTracer::GetAttenuationLength ( ) const
inline

Definition at line 182 of file G4TheRayTracer.hh.

References attenuationLength.

Referenced by G4RTMessenger::GetCurrentValue().

182 { return attenuationLength; }
G4double attenuationLength
G4Colour G4TheRayTracer::GetBackgroundColour ( ) const
inline

Definition at line 186 of file G4TheRayTracer.hh.

References backgroundColour.

Referenced by G4RTMessenger::GetCurrentValue().

186 { return backgroundColour; }
G4Colour backgroundColour
G4bool G4TheRayTracer::GetDistortion ( ) const
inline

Definition at line 184 of file G4TheRayTracer.hh.

References distortionOn.

Referenced by G4RTMessenger::GetCurrentValue().

184 { return distortionOn; }
G4ThreeVector G4TheRayTracer::GetEyePosition ( ) const
inline

Definition at line 170 of file G4TheRayTracer.hh.

References eyePosition.

Referenced by G4RTMessenger::GetCurrentValue().

170 { return eyePosition; }
G4ThreeVector eyePosition
G4VFigureFileMaker* G4TheRayTracer::GetFigureFileMaker ( )
inline

Definition at line 117 of file G4TheRayTracer.hh.

References theFigMaker.

117 {return theFigMaker;}
G4VFigureFileMaker * theFigMaker
G4double G4TheRayTracer::GetHeadAngle ( ) const
inline

Definition at line 178 of file G4TheRayTracer.hh.

References headAngle.

Referenced by G4RTMessenger::GetCurrentValue().

178 { return headAngle; }
G4ThreeVector G4TheRayTracer::GetLightDirection ( ) const
inline

Definition at line 174 of file G4TheRayTracer.hh.

References lightDirection.

Referenced by G4RTMessenger::GetCurrentValue().

174 { return lightDirection; }
G4ThreeVector lightDirection
G4Colour G4TheRayTracer::GetMixedColour ( const G4Colour surfCol,
const G4Colour transCol,
G4double  weight = 0.5 
)
protected

Definition at line 325 of file G4TheRayTracer.cc.

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

Referenced by GenerateColour(), and GetSurfaceColour().

326 {
327  G4double red = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
328  G4double green = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
329  G4double blue = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
330  G4double alpha = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
331  return G4Colour(red,green,blue,alpha);
332 }
G4double GetAlpha() const
Definition: G4Colour.hh:142
Definition: test07.cc:36
G4double GetBlue() const
Definition: G4Colour.hh:141
Definition: test07.cc:36
G4double GetRed() const
Definition: G4Colour.hh:139
G4double GetGreen() const
Definition: G4Colour.hh:140
double G4double
Definition: G4Types.hh:76
G4int G4TheRayTracer::GetNColumn ( ) const
inline

Definition at line 166 of file G4TheRayTracer.hh.

References nColumn.

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

166 { return nColumn; }
G4int G4TheRayTracer::GetNRow ( ) const
inline

Definition at line 168 of file G4TheRayTracer.hh.

References nRow.

Referenced by G4RTMessenger::GetCurrentValue().

168 { return nRow; }
G4VRTScanner* G4TheRayTracer::GetScanner ( )
inline

Definition at line 122 of file G4TheRayTracer.hh.

References theScanner.

122 {return theScanner;}
G4VRTScanner * theScanner
G4Colour G4TheRayTracer::GetSurfaceColour ( G4RayTrajectoryPoint point)
protected

Definition at line 334 of file G4TheRayTracer.cc.

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

Referenced by GenerateColour().

335 {
336  const G4VisAttributes* preAtt = point->GetPreStepAtt();
337  const G4VisAttributes* postAtt = point->GetPostStepAtt();
338 
339  G4bool preVis = ValidColour(preAtt);
340  G4bool postVis = ValidColour(postAtt);
341 
342  G4Colour transparent(1.,1.,1.,0.);
343 
344  if(!preVis&&!postVis) return transparent;
345 
346  G4ThreeVector normal = point->GetSurfaceNormal();
347 
348  G4Colour preCol(1.,1.,1.);
349  G4Colour postCol(1.,1.,1.);
350 
351  if(preVis)
352  {
353  const G4Colour& preAttColour = preAtt->GetColour();
354  G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
355  G4double red = preAttColour.GetRed();
356  G4double green = preAttColour.GetGreen();
357  G4double blue = preAttColour.GetBlue();
358  preCol = G4Colour
359  (red*brill,green*brill,blue*brill,preAttColour.GetAlpha());
360  }
361  else
362  { preCol = transparent; }
363 
364  if(postVis)
365  {
366  const G4Colour& postAttColour = postAtt->GetColour();
367  G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
368  G4double red = postAttColour.GetRed();
369  G4double green = postAttColour.GetGreen();
370  G4double blue = postAttColour.GetBlue();
371  postCol = G4Colour
372  (red*brill,green*brill,blue*brill,postAttColour.GetAlpha());
373  }
374  else
375  { postCol = transparent; }
376 
377  if(!preVis) return postCol;
378  if(!postVis) return preCol;
379 
380  G4double weight = 0.5;
381  return GetMixedColour(preCol,postCol,weight);
382 }
G4double GetAlpha() const
Definition: G4Colour.hh:142
Definition: test07.cc:36
const G4VisAttributes * GetPreStepAtt() const
const G4Colour & GetColour() const
G4double GetBlue() const
Definition: G4Colour.hh:141
Definition: test07.cc:36
G4ThreeVector lightDirection
G4double GetRed() const
Definition: G4Colour.hh:139
bool G4bool
Definition: G4Types.hh:79
G4double GetGreen() const
Definition: G4Colour.hh:140
G4Colour GetMixedColour(const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)
G4ThreeVector GetSurfaceNormal() const
const G4VisAttributes * GetPostStepAtt() const
G4bool ValidColour(const G4VisAttributes *visAtt)
double G4double
Definition: G4Types.hh:76
G4ThreeVector G4TheRayTracer::GetTargetPosition ( ) const
inline

Definition at line 172 of file G4TheRayTracer.hh.

References targetPosition.

Referenced by G4RTMessenger::GetCurrentValue().

172 { return targetPosition; }
G4ThreeVector targetPosition
G4ThreeVector G4TheRayTracer::GetUpVector ( ) const
inline

Definition at line 176 of file G4TheRayTracer.hh.

References up.

176 { return up; }
G4ThreeVector up
G4double G4TheRayTracer::GetViewSpan ( ) const
inline

Definition at line 180 of file G4TheRayTracer.hh.

References viewSpan.

Referenced by G4RTMessenger::GetCurrentValue().

180 { return viewSpan; }
void G4TheRayTracer::RestoreUserActions ( )
protectedvirtual

Reimplemented in G4TheMTRayTracer.

Definition at line 167 of file G4TheRayTracer.cc.

References G4SDManager::Activate(), G4SDManager::GetSDMpointerIfExist(), G4EventManager::SetUserAction(), theEventManager, theUserEventAction, theUserStackingAction, theUserSteppingAction, and theUserTrackingAction.

Referenced by Trace().

168 {
173 
175  if(theSDMan)
176  { theSDMan->Activate("/",true); }
177 }
G4UserStackingAction * theUserStackingAction
G4UserTrackingAction * theUserTrackingAction
G4UserSteppingAction * theUserSteppingAction
G4UserEventAction * theUserEventAction
void Activate(G4String dName, G4bool activeFlag)
Definition: G4SDManager.cc:117
G4EventManager * theEventManager
void SetUserAction(G4UserEventAction *userAction)
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
void G4TheRayTracer::SetAttenuationLength ( G4double  val)
inline

Definition at line 181 of file G4TheRayTracer.hh.

References attenuationLength.

Referenced by G4RTMessenger::SetNewValue().

181 { attenuationLength = val; }
G4double attenuationLength
void G4TheRayTracer::SetBackgroundColour ( const G4Colour val)
inline

Definition at line 185 of file G4TheRayTracer.hh.

References backgroundColour.

Referenced by G4RayTracerViewer::SetView().

185 { backgroundColour = val; }
G4Colour backgroundColour
void G4TheRayTracer::SetDistortion ( G4bool  val)
inline

Definition at line 183 of file G4TheRayTracer.hh.

References distortionOn.

Referenced by G4RTMessenger::SetNewValue().

183 { distortionOn = val; }
void G4TheRayTracer::SetEyePosition ( const G4ThreeVector val)
inline

Definition at line 169 of file G4TheRayTracer.hh.

References eyePosition.

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

169 { eyePosition = val; }
G4ThreeVector eyePosition
void G4TheRayTracer::SetFigureFileMaker ( G4VFigureFileMaker figMaker)
inline

Definition at line 113 of file G4TheRayTracer.hh.

References theFigMaker.

116  { theFigMaker = figMaker; }
G4VFigureFileMaker * theFigMaker
void G4TheRayTracer::SetHeadAngle ( G4double  val)
inline

Definition at line 177 of file G4TheRayTracer.hh.

References headAngle.

Referenced by G4RTMessenger::SetNewValue().

177 { headAngle = val; }
void G4TheRayTracer::SetLightDirection ( const G4ThreeVector val)
inline

Definition at line 173 of file G4TheRayTracer.hh.

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

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

173 { lightDirection = val.unit(); }
G4ThreeVector lightDirection
Hep3Vector unit() const
void G4TheRayTracer::SetNColumn ( G4int  val)
inline

Definition at line 165 of file G4TheRayTracer.hh.

References nColumn.

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

165 { nColumn = val; }
void G4TheRayTracer::SetNRow ( G4int  val)
inline

Definition at line 167 of file G4TheRayTracer.hh.

References nRow.

Referenced by G4RTMessenger::SetNewValue().

167 { nRow = val; }
void G4TheRayTracer::SetScanner ( G4VRTScanner scanner)
inline

Definition at line 118 of file G4TheRayTracer.hh.

References theScanner.

121  { theScanner = scanner; }
G4VRTScanner * theScanner
void G4TheRayTracer::SetTargetPosition ( const G4ThreeVector val)
inline

Definition at line 171 of file G4TheRayTracer.hh.

References targetPosition.

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

171 { targetPosition = val; }
G4ThreeVector targetPosition
void G4TheRayTracer::SetUpVector ( const G4ThreeVector val)
inline

Definition at line 175 of file G4TheRayTracer.hh.

References up.

Referenced by G4RayTracerViewer::SetView().

175 { up = val; }
G4ThreeVector up
void G4TheRayTracer::SetViewSpan ( G4double  val)
inline

Definition at line 179 of file G4TheRayTracer.hh.

References viewSpan.

Referenced by G4RTMessenger::SetNewValue().

179 { viewSpan = val; }
void G4TheRayTracer::StoreUserActions ( )
protectedvirtual

Reimplemented in G4TheMTRayTracer.

Definition at line 143 of file G4TheRayTracer.cc.

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().

144 {
149 
152 
157 
159  if(theSDMan)
160  { theSDMan->Activate("/",false); }
161 
163  theGeomMan->OpenGeometry();
164  theGeomMan->CloseGeometry(true);
165 }
G4UserStackingAction * theRayTracerStackingAction
G4UserStackingAction * theUserStackingAction
G4RTSteppingAction * theRayTracerSteppingAction
G4UserTrackingAction * theUserTrackingAction
G4UserSteppingAction * theUserSteppingAction
G4UserEventAction * GetUserEventAction()
G4UserEventAction * theUserEventAction
void Activate(G4String dName, G4bool activeFlag)
Definition: G4SDManager.cc:117
G4UserSteppingAction * GetUserSteppingAction()
static G4GeometryManager * GetInstance()
G4EventManager * theEventManager
G4RTTrackingAction * theRayTracerTrackingAction
void SetUserAction(G4UserEventAction *userAction)
G4UserTrackingAction * GetUserTrackingAction()
G4UserEventAction * theRayTracerEventAction
void OpenGeometry(G4VPhysicalVolume *vol=0)
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=0)
G4UserStackingAction * GetUserStackingAction()
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
void G4TheRayTracer::Trace ( const G4String fileName)
virtual

Reimplemented in G4TheMTRayTracer.

Definition at line 100 of file G4TheRayTracer.cc.

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().

101 {
103  G4ApplicationState currentState = theStateMan->GetCurrentState();
104  if(currentState!=G4State_Idle)
105  {
106  G4cerr << "Illegal application state - Trace() ignored." << G4endl;
107  return;
108  }
109 
110  if(!theFigMaker)
111  {
112  G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
113  return;
114  }
115 
117  G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
118  if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 1");
119 
120 
122  eyeDirection = tmpVec.unit();
123  colorR = new unsigned char[nColumn*nRow];
124  colorG = new unsigned char[nColumn*nRow];
125  colorB = new unsigned char[nColumn*nRow];
126 
128  G4bool succeeded = CreateBitMap();
129  if(succeeded)
130  { CreateFigureFile(fileName); }
131  else
132  { G4cerr << "Could not create figure file" << G4endl;
133  G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
135 
136  if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 0");
137 
138  delete [] colorR;
139  delete [] colorG;
140  delete [] colorB;
141 }
virtual void StoreUserActions()
G4ThreeVector targetPosition
virtual void RestoreUserActions()
void CreateFigureFile(const G4String &fileName)
G4ThreeVector eyeDirection
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
unsigned char * colorR
static G4StateManager * GetStateManager()
bool G4bool
Definition: G4Types.hh:79
virtual G4bool CreateBitMap()
G4ApplicationState GetCurrentState() const
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:218
G4VFigureFileMaker * theFigMaker
Hep3Vector unit() const
unsigned char * colorB
#define G4endl
Definition: G4ios.hh:61
G4ThreeVector eyePosition
G4ApplicationState
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
G4GLOB_DLL std::ostream G4cerr
unsigned char * colorG
G4bool G4TheRayTracer::ValidColour ( const G4VisAttributes visAtt)
protected

Definition at line 413 of file G4TheRayTracer.cc.

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

Referenced by GetSurfaceColour().

414 {
415  G4bool val = true;
416  if(!visAtt)
417  { val = false; }
418  else if(!(visAtt->IsVisible()))
419  { val = false; }
420  else if(visAtt->IsForceDrawingStyle()
422  { val = false; }
423  return val;
424 }
G4bool IsVisible() const
bool G4bool
Definition: G4Types.hh:79
G4bool IsForceDrawingStyle() const
ForcedDrawingStyle GetForcedDrawingStyle() const

Field Documentation

G4bool G4TheRayTracer::antialiasingOn
protected

Definition at line 159 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer().

G4double G4TheRayTracer::attenuationLength
protected
G4Colour G4TheRayTracer::backgroundColour
protected
unsigned char* G4TheRayTracer::colorB
protected
unsigned char* G4TheRayTracer::colorG
protected
unsigned char* G4TheRayTracer::colorR
protected
G4bool G4TheRayTracer::distortionOn
protected
G4ThreeVector G4TheRayTracer::eyeDirection
protected
G4ThreeVector G4TheRayTracer::eyePosition
protected
G4double G4TheRayTracer::headAngle
protected

Definition at line 154 of file G4TheRayTracer.hh.

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

G4ThreeVector G4TheRayTracer::lightDirection
protected
G4int G4TheRayTracer::nColumn
protected
G4int G4TheRayTracer::nRow
protected
G4Colour G4TheRayTracer::rayColour
protected

Definition at line 161 of file G4TheRayTracer.hh.

Referenced by CreateBitMap(), and GenerateColour().

G4ThreeVector G4TheRayTracer::targetPosition
protected
G4EventManager* G4TheRayTracer::theEventManager
protected
G4VFigureFileMaker* G4TheRayTracer::theFigMaker
protected
G4RTMessenger* G4TheRayTracer::theMessenger
protected

Definition at line 127 of file G4TheRayTracer.hh.

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

G4RayShooter* G4TheRayTracer::theRayShooter
protected

Definition at line 125 of file G4TheRayTracer.hh.

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

G4UserEventAction* G4TheRayTracer::theRayTracerEventAction
protected

Definition at line 137 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), and StoreUserActions().

G4UserStackingAction* G4TheRayTracer::theRayTracerStackingAction
protected

Definition at line 138 of file G4TheRayTracer.hh.

Referenced by G4TheRayTracer(), and StoreUserActions().

G4RTSteppingAction* G4TheRayTracer::theRayTracerSteppingAction
protected

Definition at line 140 of file G4TheRayTracer.hh.

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

G4RTTrackingAction* G4TheRayTracer::theRayTracerTrackingAction
protected

Definition at line 139 of file G4TheRayTracer.hh.

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

G4VRTScanner* G4TheRayTracer::theScanner
protected
G4UserEventAction* G4TheRayTracer::theUserEventAction
protected

Definition at line 132 of file G4TheRayTracer.hh.

Referenced by RestoreUserActions(), and StoreUserActions().

G4UserStackingAction* G4TheRayTracer::theUserStackingAction
protected

Definition at line 133 of file G4TheRayTracer.hh.

Referenced by RestoreUserActions(), and StoreUserActions().

G4UserSteppingAction* G4TheRayTracer::theUserSteppingAction
protected

Definition at line 135 of file G4TheRayTracer.hh.

Referenced by RestoreUserActions(), and StoreUserActions().

G4UserTrackingAction* G4TheRayTracer::theUserTrackingAction
protected

Definition at line 134 of file G4TheRayTracer.hh.

Referenced by RestoreUserActions(), and StoreUserActions().

G4ThreeVector G4TheRayTracer::up
protected

Definition at line 153 of file G4TheRayTracer.hh.

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

G4double G4TheRayTracer::viewSpan
protected

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