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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/RayTracer/src/G4RayTrajectory.cc (Version 11.3.0) and /visualization/RayTracer/src/G4RayTrajectory.cc (Version 2.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                             << 
 26 //                                                  7 //
                                                   >>   8 // $Id: G4RayTrajectory.cc,v 1.4 2000/03/09 15:36:38 asaim Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-02-00 $
 27 //                                                 10 //
 28 //                                                 11 //
 29 //                                                 12 //
 30                                                    13 
 31 ///////////////////                                14 ///////////////////
 32 //G4RayTrajectory.cc                               15 //G4RayTrajectory.cc
 33 ///////////////////                                16 ///////////////////
 34                                                    17 
                                                   >>  18 
 35 #include "G4RayTrajectory.hh"                      19 #include "G4RayTrajectory.hh"
 36 #include "G4RayTrajectoryPoint.hh"                 20 #include "G4RayTrajectoryPoint.hh"
 37 #include "G4RayTracerSceneHandler.hh"          << 
 38 #include "G4Step.hh"                               21 #include "G4Step.hh"
                                                   >>  22 #include "G4VPhysicalVolume.hh"
 39 #include "G4VisManager.hh"                         23 #include "G4VisManager.hh"
 40 #include "G4VisAttributes.hh"                      24 #include "G4VisAttributes.hh"
 41 #include "G4Colour.hh"                             25 #include "G4Colour.hh"
 42 #include "G4TransportationManager.hh"              26 #include "G4TransportationManager.hh"
 43 #include "G4ios.hh"                                27 #include "G4ios.hh"
 44 #include "G4ParallelWorldProcess.hh"           << 
 45                                                    28 
 46 G4Allocator<G4RayTrajectory>*& rayTrajectoryAl <<  29 G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
 47 {                                              <<  30 
 48     G4ThreadLocalStatic G4Allocator<G4RayTraje << 
 49     return _instance;                          << 
 50 }                                              << 
 51                                                    31 
 52 G4RayTrajectory :: G4RayTrajectory()               32 G4RayTrajectory :: G4RayTrajectory()
 53 {                                                  33 {
 54   positionRecord = new std::vector<G4RayTrajec <<  34   positionRecord = new G4RWTPtrOrderedVector<G4RayTrajectoryPoint>;
 55 }                                                  35 }
 56                                                    36 
 57 G4RayTrajectory :: G4RayTrajectory(G4RayTrajec     37 G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right)
 58 : G4VTrajectory()                              << 
 59 {                                                  38 {
 60   positionRecord = new std::vector<G4RayTrajec <<  39   positionRecord = new G4RWTPtrOrderedVector<G4RayTrajectoryPoint>;
 61   for(size_t i=0;i<right.positionRecord->size( <<  40   for(int i=0;i<right.positionRecord->entries();i++)
 62   {                                                41   {
 63     G4RayTrajectoryPoint* rightPoint = (G4RayT     42     G4RayTrajectoryPoint* rightPoint = (G4RayTrajectoryPoint*)
 64         ((*(right.positionRecord))[i]);            43         ((*(right.positionRecord))[i]);
 65     positionRecord->push_back(new G4RayTraject <<  44     positionRecord->insert(new G4RayTrajectoryPoint(*rightPoint));
 66   }                                                45   }
 67 }                                                  46 }
 68                                                    47 
 69 G4RayTrajectory :: ~G4RayTrajectory()              48 G4RayTrajectory :: ~G4RayTrajectory()
 70 {                                                  49 {
 71   //positionRecord->clearAndDestroy();         <<  50   positionRecord->clearAndDestroy();
 72   for(size_t i=0;i<positionRecord->size();i++) << 
 73   { delete (*positionRecord)[i]; }             << 
 74   positionRecord->clear();                     << 
 75   delete positionRecord;                           51   delete positionRecord;
 76 }                                                  52 }
 77                                                    53 
 78 void G4RayTrajectory::AppendStep(const G4Step* <<  54 void G4RayTrajectory::AppendStep(const G4Step* aStep)
 79 {                                                  55 {
 80   G4RayTrajectoryPoint* trajectoryPoint = new      56   G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
 81                                                    57 
 82   const G4Step* aStep = theStep;               << 
 83   G4Navigator* theNavigator                    << 
 84     = G4TransportationManager::GetTransportati << 
 85                                                << 
 86   // Take care of parallel world(s)            << 
 87   if(G4ParallelWorldProcess::GetHyperStep())   << 
 88   {                                            << 
 89     aStep = G4ParallelWorldProcess::GetHyperSt << 
 90     G4int navID = G4ParallelWorldProcess::GetH << 
 91     std::vector<G4Navigator*>::iterator iNav = << 
 92       G4TransportationManager::GetTransportati << 
 93                                          GetAc << 
 94     theNavigator = iNav[navID];                << 
 95   }                                            << 
 96                                                << 
 97   trajectoryPoint->SetStepLength(aStep->GetSte     58   trajectoryPoint->SetStepLength(aStep->GetStepLength());
 98                                                    59 
 99   // Surface normal                            <<  60   G4Navigator* theNavigator 
                                                   >>  61     = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
100   G4bool valid;                                    62   G4bool valid;
101   G4ThreeVector theLocalNormal = theNavigator-     63   G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
102   if(valid) { theLocalNormal = -theLocalNormal     64   if(valid) { theLocalNormal = -theLocalNormal; }
103   G4ThreeVector theGrobalNormal                    65   G4ThreeVector theGrobalNormal 
104     = theNavigator->GetLocalToGlobalTransform(     66     = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
105   trajectoryPoint->SetSurfaceNormal(theGrobalN     67   trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
106                                                    68 
                                                   >>  69   G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume();
                                                   >>  70   const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
107   G4VisManager* visManager = G4VisManager::Get     71   G4VisManager* visManager = G4VisManager::GetInstance();
108   G4RayTracerSceneHandler* sceneHandler =      <<  72   if(visManager) {
109   static_cast<G4RayTracerSceneHandler*>(visMan <<  73     G4VViewer* viewer = visManager->GetCurrentViewer();
110   const auto& sceneVisAttsMap = sceneHandler-> <<  74     if (viewer) {
111                                                <<  75       preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
112   // Make a path from the preStepPoint touchab <<  76     }
113   G4StepPoint* preStepPoint = aStep -> GetPreS <<  77   }
114   const G4VTouchable* preTouchable = preStepPo <<  78   trajectoryPoint->SetPreStepAtt(preVisAtt);
115   G4int preDepth = preTouchable->GetHistoryDep <<  79 
116   G4ModelingParameters::PVPointerCopyNoPath lo <<  80   const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
117   for (G4int i = preDepth; i >= 0; --i) {      <<  81   const G4VisAttributes* postVisAtt = NULL;
118     localPrePVPointerCopyNoPath.push_back      <<  82   if(postPhys) {
119     (G4ModelingParameters::PVPointerCopyNo     <<  83     postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
120      (preTouchable->GetVolume(i),preTouchable- <<  84     if(visManager) {
121   }                                            <<  85       G4VViewer* viewer = visManager->GetCurrentViewer();
122                                                <<  86       if (viewer) {
123   // Pick up the vis atts, if any, from the sc <<  87   postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
124   auto preIterator = sceneVisAttsMap.find(loca <<  88       }
125   const G4VisAttributes* preVisAtts;           <<  89     }
126   if (preIterator != sceneVisAttsMap.end()) {  << 
127     preVisAtts = &preIterator->second;         << 
128   } else {                                     << 
129     preVisAtts = 0;                            << 
130   }                                            << 
131   trajectoryPoint->SetPreStepAtt(preVisAtts);  << 
132                                                << 
133   // Make a path from the postStepPoint toucha << 
134   G4StepPoint* postStepPoint = aStep -> GetPos << 
135   const G4VTouchable* postTouchable = postStep << 
136   G4int postDepth = postTouchable->GetHistoryD << 
137   G4ModelingParameters::PVPointerCopyNoPath lo << 
138   for (G4int i = postDepth; i >= 0; --i) {     << 
139     localPostPVPointerCopyNoPath.push_back     << 
140     (G4ModelingParameters::PVPointerCopyNo     << 
141      (postTouchable->GetVolume(i),postTouchabl << 
142   }                                            << 
143                                                << 
144   // Pick up the vis atts, if any, from the sc << 
145   auto postIterator = sceneVisAttsMap.find(loc << 
146   const G4VisAttributes* postVisAtts;          << 
147   if (postIterator != sceneVisAttsMap.end()) { << 
148     postVisAtts = &postIterator->second;       << 
149   } else {                                     << 
150     postVisAtts = 0;                           << 
151   }                                                90   }
152   trajectoryPoint->SetPostStepAtt(postVisAtts) <<  91   trajectoryPoint->SetPostStepAtt(postVisAtt);
153                                                    92 
154   positionRecord->push_back(trajectoryPoint);  <<  93   positionRecord->append(trajectoryPoint);
155 }                                                  94 }
156                                                    95 
157 void G4RayTrajectory::ShowTrajectory(std::ostr <<  96 void G4RayTrajectory::ShowTrajectory() const
158 { }                                                97 { }
159                                                    98 
160 void G4RayTrajectory::MergeTrajectory(G4VTraje     99 void G4RayTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
161 {                                                 100 {
162   if(!secondTrajectory) return;                   101   if(!secondTrajectory) return;
163                                                   102 
164   G4RayTrajectory* seco = (G4RayTrajectory*)se    103   G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
165   G4int ent = seco->GetPointEntries();            104   G4int ent = seco->GetPointEntries();
166   for(G4int i=0;i<ent;i++)                        105   for(G4int i=0;i<ent;i++)
167   { positionRecord->push_back((G4RayTrajectory << 106   { positionRecord->append(seco->positionRecord->removeAt(0)); }
168   seco->positionRecord->clear();               << 
169 }                                                 107 }
170                                                   108 
171                                                   109