Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4RayTrajectory.cc
이 파일의 문서화 페이지로 가기
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 110261 2018-05-17 14:24:23Z gcosmo $
28 //
29 //
30 //
31 
33 //G4RayTrajectory.cc
35 
36 #include "G4RayTrajectory.hh"
37 #include "G4RayTrajectoryPoint.hh"
39 #include "G4Step.hh"
40 #include "G4VPhysicalVolume.hh"
41 #include "G4VisManager.hh"
42 #include "G4VisAttributes.hh"
43 #include "G4Colour.hh"
45 #include "G4ios.hh"
47 
49 {
51  return _instance;
52 }
53 
55 {
56  positionRecord = new std::vector<G4RayTrajectoryPoint*>;
57 }
58 
60 : G4VTrajectory()
61 {
62  positionRecord = new std::vector<G4RayTrajectoryPoint*>;
63  for(size_t i=0;i<right.positionRecord->size();i++)
64  {
66  ((*(right.positionRecord))[i]);
67  positionRecord->push_back(new G4RayTrajectoryPoint(*rightPoint));
68  }
69 }
70 
72 {
73  //positionRecord->clearAndDestroy();
74  for(size_t i=0;i<positionRecord->size();i++)
75  { delete (*positionRecord)[i]; }
76  positionRecord->clear();
77  delete positionRecord;
78 }
79 
80 void G4RayTrajectory::AppendStep(const G4Step* theStep)
81 {
82  G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
83 
84  const G4Step* aStep = theStep;
85  G4Navigator* theNavigator
87 
88  // Take care of parallel world(s)
90  {
93  std::vector<G4Navigator*>::iterator iNav =
95  GetActiveNavigatorsIterator();
96  theNavigator = iNav[navID];
97  }
98 
99  trajectoryPoint->SetStepLength(aStep->GetStepLength());
100 
101  // Surface normal
102  G4bool valid;
103  G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
104  if(valid) { theLocalNormal = -theLocalNormal; }
105  G4ThreeVector theGrobalNormal
106  = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
107  trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
108 
109  G4VisManager* visManager = G4VisManager::GetInstance();
110  G4RayTracerSceneHandler* sceneHandler =
111  static_cast<G4RayTracerSceneHandler*>(visManager->GetCurrentSceneHandler());
112  const auto& sceneVisAttsMap = sceneHandler->GetSceneVisAttsMap();
113 
114  // Make a path from the preStepPoint touchable
115  G4StepPoint* preStepPoint = aStep -> GetPreStepPoint();
116  const G4VTouchable* preTouchable = preStepPoint->GetTouchable();
117  G4int preDepth = preTouchable->GetHistoryDepth();
118  G4ModelingParameters::PVPointerCopyNoPath localPrePVPointerCopyNoPath;
119  for (G4int i = preDepth; i >= 0; --i) {
120  localPrePVPointerCopyNoPath.push_back
122  (preTouchable->GetVolume(i),preTouchable->GetCopyNumber(i)));
123  }
124 
125  // Pick up the vis atts, if any, from the scene handler
126  auto preIterator = sceneVisAttsMap.find(localPrePVPointerCopyNoPath);
127  const G4VisAttributes* preVisAtts;
128  if (preIterator != sceneVisAttsMap.end()) {
129  preVisAtts = &preIterator->second;
130  } else {
131  preVisAtts = 0;
132  }
133  trajectoryPoint->SetPreStepAtt(preVisAtts);
134 
135  // Make a path from the postStepPoint touchable
136  G4StepPoint* postStepPoint = aStep -> GetPostStepPoint();
137  const G4VTouchable* postTouchable = postStepPoint->GetTouchable();
138  G4int postDepth = postTouchable->GetHistoryDepth();
139  G4ModelingParameters::PVPointerCopyNoPath localPostPVPointerCopyNoPath;
140  for (G4int i = postDepth; i >= 0; --i) {
141  localPostPVPointerCopyNoPath.push_back
143  (postTouchable->GetVolume(i),postTouchable->GetCopyNumber(i)));
144  }
145 
146  // Pick up the vis atts, if any, from the scene handler
147  auto postIterator = sceneVisAttsMap.find(localPostPVPointerCopyNoPath);
148  const G4VisAttributes* postVisAtts;
149  if (postIterator != sceneVisAttsMap.end()) {
150  postVisAtts = &postIterator->second;
151  } else {
152  postVisAtts = 0;
153  }
154  trajectoryPoint->SetPostStepAtt(postVisAtts);
155 
156  positionRecord->push_back(trajectoryPoint);
157 }
158 
159 void G4RayTrajectory::ShowTrajectory(std::ostream&) const
160 { }
161 
163 {
164  if(!secondTrajectory) return;
165 
166  G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
167  G4int ent = seco->GetPointEntries();
168  for(G4int i=0;i<ent;i++)
169  { positionRecord->push_back((G4RayTrajectoryPoint*)seco->GetPoint(i)); }
170  seco->positionRecord->clear();
171 }
172 
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
const G4VTouchable * GetTouchable() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
void SetSurfaceNormal(const G4ThreeVector &val)
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
static G4VisManager * GetInstance()
void SetStepLength(G4double val)
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
G4Navigator * GetNavigatorForTracking() const
#define G4ThreadLocalStatic
Definition: tls.hh:68
static const G4Step * GetHyperStep()
virtual int GetPointEntries() const
const G4AffineTransform GetLocalToGlobalTransform() const
bool G4bool
Definition: G4Types.hh:79
G4double GetStepLength() const
virtual void ShowTrajectory(std::ostream &) const
void SetPostStepAtt(const G4VisAttributes *val)
Definition: G4Step.hh:76
G4int GetCopyNumber(G4int depth=0) const
static G4TransportationManager * GetTransportationManager()
std::vector< PVPointerCopyNo > PVPointerCopyNoPath
const std::map< G4ModelingParameters::PVPointerCopyNoPath, G4VisAttributes, PathLessThan > & GetSceneVisAttsMap() const
int G4int
Definition: G4Types.hh:78
virtual ~G4RayTrajectory()
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
virtual G4int GetHistoryDepth() const
Definition: G4VTouchable.cc:79
void SetPreStepAtt(const G4VisAttributes *val)
G4DLLIMPORT G4Allocator< G4RayTrajectory > *& rayTrajectoryAllocator()
virtual void AppendStep(const G4Step *)
G4VSceneHandler * GetCurrentSceneHandler() const
std::vector< G4RayTrajectoryPoint * > * positionRecord