Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: G4RayTrajectory.cc,v 1.7.2.1 2001/06/28 19:15:54 gunter Exp $ >> 25 // GEANT4 tag $Name: $ 27 // 26 // 28 // 27 // 29 // 28 // 30 29 31 /////////////////// 30 /////////////////// 32 //G4RayTrajectory.cc 31 //G4RayTrajectory.cc 33 /////////////////// 32 /////////////////// 34 33 >> 34 35 #include "G4RayTrajectory.hh" 35 #include "G4RayTrajectory.hh" 36 #include "G4RayTrajectoryPoint.hh" 36 #include "G4RayTrajectoryPoint.hh" 37 #include "G4RayTracerSceneHandler.hh" << 38 #include "G4Step.hh" 37 #include "G4Step.hh" >> 38 #include "G4VPhysicalVolume.hh" 39 #include "G4VisManager.hh" 39 #include "G4VisManager.hh" 40 #include "G4VisAttributes.hh" 40 #include "G4VisAttributes.hh" 41 #include "G4Colour.hh" 41 #include "G4Colour.hh" 42 #include "G4TransportationManager.hh" 42 #include "G4TransportationManager.hh" 43 #include "G4ios.hh" 43 #include "G4ios.hh" 44 #include "G4ParallelWorldProcess.hh" << 45 44 46 G4Allocator<G4RayTrajectory>*& rayTrajectoryAl << 45 G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator; 47 { << 46 48 G4ThreadLocalStatic G4Allocator<G4RayTraje << 49 return _instance; << 50 } << 51 47 52 G4RayTrajectory :: G4RayTrajectory() 48 G4RayTrajectory :: G4RayTrajectory() 53 { 49 { 54 positionRecord = new std::vector<G4RayTrajec << 50 positionRecord = new G4std::vector<G4RayTrajectoryPoint*>; 55 } 51 } 56 52 57 G4RayTrajectory :: G4RayTrajectory(G4RayTrajec 53 G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right) 58 : G4VTrajectory() << 59 { 54 { 60 positionRecord = new std::vector<G4RayTrajec << 55 positionRecord = new G4std::vector<G4RayTrajectoryPoint*>; 61 for(size_t i=0;i<right.positionRecord->size( 56 for(size_t i=0;i<right.positionRecord->size();i++) 62 { 57 { 63 G4RayTrajectoryPoint* rightPoint = (G4RayT 58 G4RayTrajectoryPoint* rightPoint = (G4RayTrajectoryPoint*) 64 ((*(right.positionRecord))[i]); 59 ((*(right.positionRecord))[i]); 65 positionRecord->push_back(new G4RayTraject 60 positionRecord->push_back(new G4RayTrajectoryPoint(*rightPoint)); 66 } 61 } 67 } 62 } 68 63 69 G4RayTrajectory :: ~G4RayTrajectory() 64 G4RayTrajectory :: ~G4RayTrajectory() 70 { 65 { 71 //positionRecord->clearAndDestroy(); 66 //positionRecord->clearAndDestroy(); 72 for(size_t i=0;i<positionRecord->size();i++) 67 for(size_t i=0;i<positionRecord->size();i++) 73 { delete (*positionRecord)[i]; } 68 { delete (*positionRecord)[i]; } 74 positionRecord->clear(); 69 positionRecord->clear(); 75 delete positionRecord; 70 delete positionRecord; 76 } 71 } 77 72 78 void G4RayTrajectory::AppendStep(const G4Step* << 73 void G4RayTrajectory::AppendStep(const G4Step* aStep) 79 { 74 { 80 G4RayTrajectoryPoint* trajectoryPoint = new 75 G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint(); 81 76 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 77 trajectoryPoint->SetStepLength(aStep->GetStepLength()); 98 78 99 // Surface normal << 79 G4Navigator* theNavigator >> 80 = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); 100 G4bool valid; 81 G4bool valid; 101 G4ThreeVector theLocalNormal = theNavigator- 82 G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid); 102 if(valid) { theLocalNormal = -theLocalNormal 83 if(valid) { theLocalNormal = -theLocalNormal; } 103 G4ThreeVector theGrobalNormal 84 G4ThreeVector theGrobalNormal 104 = theNavigator->GetLocalToGlobalTransform( 85 = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal); 105 trajectoryPoint->SetSurfaceNormal(theGrobalN 86 trajectoryPoint->SetSurfaceNormal(theGrobalNormal); 106 87 >> 88 G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume(); >> 89 const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes(); 107 G4VisManager* visManager = G4VisManager::Get 90 G4VisManager* visManager = G4VisManager::GetInstance(); 108 G4RayTracerSceneHandler* sceneHandler = << 91 if(visManager) { 109 static_cast<G4RayTracerSceneHandler*>(visMan << 92 G4VViewer* viewer = visManager->GetCurrentViewer(); 110 const auto& sceneVisAttsMap = sceneHandler-> << 93 if (viewer) { 111 << 94 preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt); 112 // Make a path from the preStepPoint touchab << 95 } 113 G4StepPoint* preStepPoint = aStep -> GetPreS << 96 } 114 const G4VTouchable* preTouchable = preStepPo << 97 trajectoryPoint->SetPreStepAtt(preVisAtt); 115 G4int preDepth = preTouchable->GetHistoryDep << 98 116 G4ModelingParameters::PVPointerCopyNoPath lo << 99 const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume(); 117 for (G4int i = preDepth; i >= 0; --i) { << 100 const G4VisAttributes* postVisAtt = NULL; 118 localPrePVPointerCopyNoPath.push_back << 101 if(postPhys) { 119 (G4ModelingParameters::PVPointerCopyNo << 102 postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes(); 120 (preTouchable->GetVolume(i),preTouchable- << 103 if(visManager) { 121 } << 104 G4VViewer* viewer = visManager->GetCurrentViewer(); 122 << 105 if (viewer) { 123 // Pick up the vis atts, if any, from the sc << 106 postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt); 124 auto preIterator = sceneVisAttsMap.find(loca << 107 } 125 const G4VisAttributes* preVisAtts; << 108 } 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 } 109 } 152 trajectoryPoint->SetPostStepAtt(postVisAtts) << 110 trajectoryPoint->SetPostStepAtt(postVisAtt); 153 111 154 positionRecord->push_back(trajectoryPoint); 112 positionRecord->push_back(trajectoryPoint); 155 } 113 } 156 114 157 void G4RayTrajectory::ShowTrajectory(std::ostr << 115 void G4RayTrajectory::ShowTrajectory() const 158 { } 116 { } 159 117 160 void G4RayTrajectory::MergeTrajectory(G4VTraje 118 void G4RayTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory) 161 { 119 { 162 if(!secondTrajectory) return; 120 if(!secondTrajectory) return; 163 121 164 G4RayTrajectory* seco = (G4RayTrajectory*)se 122 G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory; 165 G4int ent = seco->GetPointEntries(); 123 G4int ent = seco->GetPointEntries(); 166 for(G4int i=0;i<ent;i++) 124 for(G4int i=0;i<ent;i++) 167 { positionRecord->push_back((G4RayTrajectory 125 { positionRecord->push_back((G4RayTrajectoryPoint*)seco->GetPoint(i)); } 168 seco->positionRecord->clear(); 126 seco->positionRecord->clear(); 169 } 127 } 170 128 171 129