Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RayTrajectory.cc
Go to the documentation of this file.
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//
27// $Id$
28//
29//
30//
31
32///////////////////
33//G4RayTrajectory.cc
34///////////////////
35
36#include "G4RayTrajectory.hh"
38#include "G4Step.hh"
39#include "G4VPhysicalVolume.hh"
40#include "G4VisManager.hh"
41#include "G4VisAttributes.hh"
42#include "G4Colour.hh"
44#include "G4ios.hh"
45
47
48G4RayTrajectory :: G4RayTrajectory()
49{
50 positionRecord = new std::vector<G4RayTrajectoryPoint*>;
51}
52
53G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right)
55{
56 positionRecord = new std::vector<G4RayTrajectoryPoint*>;
57 for(size_t i=0;i<right.positionRecord->size();i++)
58 {
60 ((*(right.positionRecord))[i]);
61 positionRecord->push_back(new G4RayTrajectoryPoint(*rightPoint));
62 }
63}
64
65G4RayTrajectory :: ~G4RayTrajectory()
66{
67 //positionRecord->clearAndDestroy();
68 for(size_t i=0;i<positionRecord->size();i++)
69 { delete (*positionRecord)[i]; }
70 positionRecord->clear();
71 delete positionRecord;
72}
73
75{
76 G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
77
78 trajectoryPoint->SetStepLength(aStep->GetStepLength());
79
80 G4Navigator* theNavigator
82 G4bool valid;
83 G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
84 if(valid) { theLocalNormal = -theLocalNormal; }
85 G4ThreeVector theGrobalNormal
86 = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
87 trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
88
90 const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
91 G4VisManager* visManager = G4VisManager::GetInstance();
92 if(visManager) {
93 G4VViewer* viewer = visManager->GetCurrentViewer();
94 if (viewer) {
95 preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
96 }
97 }
98 trajectoryPoint->SetPreStepAtt(preVisAtt);
99
100 const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
101 const G4VisAttributes* postVisAtt = NULL;
102 if(postPhys) {
103 postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
104 if(visManager) {
105 G4VViewer* viewer = visManager->GetCurrentViewer();
106 if (viewer) {
107 postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
108 }
109 }
110 }
111 trajectoryPoint->SetPostStepAtt(postVisAtt);
112
113 positionRecord->push_back(trajectoryPoint);
114}
115
116void G4RayTrajectory::ShowTrajectory(std::ostream&) const
117{ }
118
120{
121 if(!secondTrajectory) return;
122
123 G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
124 G4int ent = seco->GetPointEntries();
125 for(G4int i=0;i<ent;i++)
126 { positionRecord->push_back((G4RayTrajectoryPoint*)seco->GetPoint(i)); }
127 seco->positionRecord->clear();
128}
129
G4Allocator< G4RayTrajectory > G4RayTrajectoryAllocator
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
const G4VisAttributes * GetVisAttributes() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
const G4AffineTransform GetLocalToGlobalTransform() const
void SetSurfaceNormal(G4ThreeVector val)
void SetStepLength(G4double val)
void SetPreStepAtt(const G4VisAttributes *val)
void SetPostStepAtt(const G4VisAttributes *val)
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
virtual int GetPointEntries() const
virtual void ShowTrajectory(std::ostream &) const
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
virtual void AppendStep(const G4Step *)
G4VPhysicalVolume * GetPhysicalVolume() const
Definition: G4Step.hh:78
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4StepPoint * GetPostStepPoint() const
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
G4LogicalVolume * GetLogicalVolume() const
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
Definition: G4VViewer.cc:78
G4VViewer * GetCurrentViewer() const