G4RTSteppingAction.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 
00032 
00033 #include "G4RTSteppingAction.hh"
00034 
00035 #include "G4SteppingManager.hh"
00036 #include "G4VisManager.hh"
00037 #include "G4VisAttributes.hh"
00038 #include "G4Colour.hh"
00039 #include "G4Track.hh"
00040 #include "G4StepStatus.hh"
00041 #include "G4TransportationManager.hh"
00042 
00043 G4RTSteppingAction::G4RTSteppingAction()
00044 {
00045   ignoreTransparency=false;
00046 }
00047 
00048 void G4RTSteppingAction::UserSteppingAction(const G4Step* aStep)
00049 {
00050   // Stop the ray particle if it reaches to the coloured volume with its alpha = 1
00051   // or coloured volume and the user request to ignore transparency
00052 
00053   G4StepPoint* fpStepPoint = aStep -> GetPostStepPoint();
00054   G4VPhysicalVolume* postVolume_phys=fpStepPoint->GetPhysicalVolume();
00055 
00056   if(!postVolume_phys) return;   // Reach to out of the world
00057 
00058   const G4LogicalVolume* postVolume_log = postVolume_phys->GetLogicalVolume();
00059   const G4VisAttributes* postVisAtt = postVolume_log -> GetVisAttributes();
00060   G4VisManager* visManager = G4VisManager::GetInstance();
00061   if(visManager) {
00062     G4VViewer* viewer = visManager->GetCurrentViewer();
00063     if (viewer) {
00064       postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
00065     }
00066   }
00067   if((!postVisAtt) || (!(postVisAtt->IsVisible()))) return; // Invisible volume, continue tracking
00068 
00069   if((postVisAtt->IsForceDrawingStyle())
00070     &&(postVisAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe)) return;
00071                                           // Wire frame volume, continue tracking
00072 
00073   G4double postAlpha=(postVisAtt->GetColour()).GetAlpha();
00074 
00075   if(postAlpha==1.0 || ignoreTransparency) // Stop stepping
00076   { 
00077     G4Track* currentTrack = aStep -> GetTrack();
00078     currentTrack -> SetTrackStatus(fStopAndKill);
00079   }
00080 }
00081 

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