Geant4_10
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: G4RayTrajectory.cc 71495 2013-06-17 09:13:30Z gcosmo $
28 //
29 //
30 //
31 
33 //G4RayTrajectory.cc
35 
36 #include "G4RayTrajectory.hh"
37 #include "G4RayTrajectoryPoint.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 
49 {
50  positionRecord = new std::vector<G4RayTrajectoryPoint*>;
51 }
52 
54 : G4VTrajectory()
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 
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 
116 void 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 
G4DLLIMPORT G4ThreadLocal G4Allocator< G4RayTrajectory > * rayTrajectoryAllocator
G4double GetStepLength() const
void SetPostStepAtt(const G4VisAttributes *val)
G4Navigator * GetNavigatorForTracking() const
void SetStepLength(G4double val)
void SetSurfaceNormal(const G4ThreeVector &val)
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
Definition: G4VViewer.cc:78
const G4AffineTransform GetLocalToGlobalTransform() const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
virtual int GetPointEntries() const
virtual ~G4RayTrajectory()
G4StepPoint * GetPreStepPoint() const
G4VPhysicalVolume * GetPhysicalVolume() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
bool G4bool
Definition: G4Types.hh:79
void SetPreStepAtt(const G4VisAttributes *val)
const G4VisAttributes * GetVisAttributes() const
Definition: G4Step.hh:76
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
static G4TransportationManager * GetTransportationManager()
G4LogicalVolume * GetLogicalVolume() const
G4StepPoint * GetPostStepPoint() const
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
virtual void AppendStep(const G4Step *)
G4VViewer * GetCurrentViewer() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
virtual void ShowTrajectory(std::ostream &) const