G4RayTrajectory.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 //
00031 
00033 //G4RayTrajectory.cc
00035 
00036 #include "G4RayTrajectory.hh"
00037 #include "G4RayTrajectoryPoint.hh"
00038 #include "G4Step.hh"
00039 #include "G4VPhysicalVolume.hh"
00040 #include "G4VisManager.hh"
00041 #include "G4VisAttributes.hh"
00042 #include "G4Colour.hh"
00043 #include "G4TransportationManager.hh"
00044 #include "G4ios.hh"
00045 
00046 G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
00047 
00048 G4RayTrajectory :: G4RayTrajectory()
00049 {
00050   positionRecord = new std::vector<G4RayTrajectoryPoint*>;
00051 }
00052 
00053 G4RayTrajectory :: G4RayTrajectory(G4RayTrajectory & right)
00054 : G4VTrajectory()
00055 {
00056   positionRecord = new std::vector<G4RayTrajectoryPoint*>;
00057   for(size_t i=0;i<right.positionRecord->size();i++)
00058   {
00059     G4RayTrajectoryPoint* rightPoint = (G4RayTrajectoryPoint*)
00060                                 ((*(right.positionRecord))[i]);
00061     positionRecord->push_back(new G4RayTrajectoryPoint(*rightPoint));
00062   }
00063 }
00064 
00065 G4RayTrajectory :: ~G4RayTrajectory()
00066 {
00067   //positionRecord->clearAndDestroy();
00068   for(size_t i=0;i<positionRecord->size();i++)
00069   { delete (*positionRecord)[i]; }
00070   positionRecord->clear();
00071   delete positionRecord;
00072 }
00073 
00074 void G4RayTrajectory::AppendStep(const G4Step* aStep)
00075 {
00076   G4RayTrajectoryPoint* trajectoryPoint = new G4RayTrajectoryPoint();
00077 
00078   trajectoryPoint->SetStepLength(aStep->GetStepLength());
00079 
00080   G4Navigator* theNavigator 
00081     = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
00082   G4bool valid;
00083   G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
00084   if(valid) { theLocalNormal = -theLocalNormal; }
00085   G4ThreeVector theGrobalNormal 
00086     = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
00087   trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
00088 
00089   G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume();
00090   const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
00091   G4VisManager* visManager = G4VisManager::GetInstance();
00092   if(visManager) {
00093     G4VViewer* viewer = visManager->GetCurrentViewer();
00094     if (viewer) {
00095       preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
00096     }
00097   }
00098   trajectoryPoint->SetPreStepAtt(preVisAtt);
00099 
00100   const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
00101   const G4VisAttributes* postVisAtt = NULL;
00102   if(postPhys) {
00103     postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
00104     if(visManager) {
00105       G4VViewer* viewer = visManager->GetCurrentViewer();
00106       if (viewer) {
00107         postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
00108       }
00109     }
00110   }
00111   trajectoryPoint->SetPostStepAtt(postVisAtt);
00112 
00113   positionRecord->push_back(trajectoryPoint);
00114 }
00115 
00116 void G4RayTrajectory::ShowTrajectory(std::ostream&) const
00117 { }
00118 
00119 void G4RayTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
00120 {
00121   if(!secondTrajectory) return;
00122 
00123   G4RayTrajectory* seco = (G4RayTrajectory*)secondTrajectory;
00124   G4int ent = seco->GetPointEntries();
00125   for(G4int i=0;i<ent;i++)
00126   { positionRecord->push_back((G4RayTrajectoryPoint*)seco->GetPoint(i)); }
00127   seco->positionRecord->clear();
00128 }
00129 

Generated on Mon May 27 17:49:42 2013 for Geant4 by  doxygen 1.4.7