source: trunk/source/visualization/RayTracer/src/G4RayTrajectory.cc @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 4.7 KB
Line 
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,v 1.15 2006/06/29 21:24:21 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31//
32
33///////////////////
34//G4RayTrajectory.cc
35///////////////////
36
37#include "G4RayTrajectory.hh"
38#include "G4RayTrajectoryPoint.hh"
39#include "G4Step.hh"
40#include "G4VPhysicalVolume.hh"
41#include "G4VisManager.hh"
42#include "G4VisAttributes.hh"
43#include "G4Colour.hh"
44#include "G4TransportationManager.hh"
45#include "G4ios.hh"
46
47G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
48
49G4RayTrajectory :: G4RayTrajectory()
50{
51  positionRecord = new std::vector<G4RayTrajectoryPoint*>;
52}
53
54G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right)
55: G4VTrajectory()
56{
57  positionRecord = new std::vector<G4RayTrajectoryPoint*>;
58  for(size_t i=0;i<right.positionRecord->size();i++)
59  {
60    G4RayTrajectoryPoint* rightPoint = (G4RayTrajectoryPoint*)
61                                ((*(right.positionRecord))[i]);
62    positionRecord->push_back(new G4RayTrajectoryPoint(*rightPoint));
63  }
64}
65
66G4RayTrajectory :: ~G4RayTrajectory()
67{
68  //positionRecord->clearAndDestroy();
69  for(size_t i=0;i<positionRecord->size();i++)
70  { delete (*positionRecord)[i]; }
71  positionRecord->clear();
72  delete positionRecord;
73}
74
75void G4RayTrajectory::AppendStep(const G4Step* aStep)
76{
77  G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
78
79  trajectoryPoint->SetStepLength(aStep->GetStepLength());
80
81  G4Navigator* theNavigator
82    = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
83  G4bool valid;
84  G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
85  if(valid) { theLocalNormal = -theLocalNormal; }
86  G4ThreeVector theGrobalNormal
87    = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
88  trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
89
90  G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume();
91  const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
92  G4VisManager* visManager = G4VisManager::GetInstance();
93  if(visManager) {
94    G4VViewer* viewer = visManager->GetCurrentViewer();
95    if (viewer) {
96      preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
97    }
98  }
99  trajectoryPoint->SetPreStepAtt(preVisAtt);
100
101  const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
102  const G4VisAttributes* postVisAtt = NULL;
103  if(postPhys) {
104    postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
105    if(visManager) {
106      G4VViewer* viewer = visManager->GetCurrentViewer();
107      if (viewer) {
108        postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
109      }
110    }
111  }
112  trajectoryPoint->SetPostStepAtt(postVisAtt);
113
114  positionRecord->push_back(trajectoryPoint);
115}
116
117void G4RayTrajectory::ShowTrajectory(std::ostream&) const
118{ }
119
120void G4RayTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
121{
122  if(!secondTrajectory) return;
123
124  G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
125  G4int ent = seco->GetPointEntries();
126  for(G4int i=0;i<ent;i++)
127  { positionRecord->push_back((G4RayTrajectoryPoint*)seco->GetPoint(i)); }
128  seco->positionRecord->clear();
129}
130
Note: See TracBrowser for help on using the repository browser.