Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
@@ -33,7 +33,6 @@
//G4RTRun.cc
///////////////////////
#include "G4RTRun.hh"
#include "G4RTRun.hh"
#include "G4TheMTRayTracer.hh"
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RTSteppingAction.cc 74050 2013-09-20 09:38:19Z gcosmo $
// $Id: G4RTSteppingAction.cc 104015 2017-05-08 07:28:08Z gcosmo $
//
//
//
@@ -32,6 +32,7 @@
#include "G4RTSteppingAction.hh"
#include "G4RayTracerSceneHandler.hh"
#include "G4SteppingManager.hh"
#include "G4VisManager.hh"
#include "G4VisAttributes.hh"
@@ -50,27 +51,42 @@ void G4RTSteppingAction::UserSteppingAction(const G4Step* aStep)
// Stop the ray particle if it reaches to the coloured volume with its alpha = 1
// or coloured volume and the user request to ignore transparency
G4StepPoint* fpStepPoint = aStep -> GetPostStepPoint();
G4VPhysicalVolume* postVolume_phys=fpStepPoint->GetPhysicalVolume();
G4StepPoint* postStepPoint = aStep -> GetPostStepPoint();
G4VPhysicalVolume* postVolume_phys=postStepPoint->GetPhysicalVolume();
if(!postVolume_phys) return; // Reach to out of the world
const G4LogicalVolume* postVolume_log = postVolume_phys->GetLogicalVolume();
const G4VisAttributes* postVisAtt = postVolume_log -> GetVisAttributes();
G4VisManager* visManager = G4VisManager::GetInstance();
if(visManager) {
G4VViewer* viewer = visManager->GetCurrentViewer();
if (viewer) {
postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
}
}
if((!postVisAtt) || (!(postVisAtt->IsVisible()))) return; // Invisible volume, continue tracking
G4RayTracerSceneHandler* sceneHandler =
static_cast<G4RayTracerSceneHandler*>(visManager->GetCurrentSceneHandler());
if((postVisAtt->IsForceDrawingStyle())
&&(postVisAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe)) return;
// Make a path from the touchable
const G4VTouchable* postTouchable = postStepPoint->GetTouchable();
G4int postDepth = postTouchable->GetHistoryDepth();
G4ModelingParameters::PVPointerCopyNoPath localPostPVPointerCopyNoPath;
for (G4int i = postDepth; i >= 0; --i) {
localPostPVPointerCopyNoPath.push_back
(G4ModelingParameters::PVPointerCopyNo
(postTouchable->GetVolume(i),postTouchable->GetCopyNumber(i)));
}
// Pick up the vis atts, if any, from the scene handler
const auto& sceneVisAttsMap = sceneHandler->GetSceneVisAttsMap();
auto postIterator = sceneVisAttsMap.find(localPostPVPointerCopyNoPath);
const G4VisAttributes* postVisAtts;
if (postIterator != sceneVisAttsMap.end()) {
postVisAtts = &postIterator->second;
} else {
postVisAtts = 0;
}
if((!postVisAtts) || (!(postVisAtts->IsVisible()))) return; // Invisible volume, continue tracking
if((postVisAtts->IsForceDrawingStyle())
&&(postVisAtts->GetForcedDrawingStyle()==G4VisAttributes::wireframe)) return;
// Wire frame volume, continue tracking
G4double postAlpha=(postVisAtt->GetColour()).GetAlpha();
G4double postAlpha=(postVisAtts->GetColour()).GetAlpha();
if(postAlpha==1.0 || ignoreTransparency) // Stop stepping
{
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RTXScanner.cc 102778 2017-02-22 10:50:10Z gcosmo $
// $Id: G4RTXScanner.cc 103626 2017-04-19 13:29:18Z gcosmo $
//
//
@@ -177,16 +177,16 @@ G4bool G4RTXScanner::GetXWindow(const G4String& name, G4ViewParameters& vp)
int nMaps;
Status status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_DEFAULT_MAP);
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
system("xstdcmap -best"); // ...and try again...
status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_DEFAULT_MAP);
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
G4cerr <<
"G4RTXScanner::Initialize(): cannot get color map."
"\n Perhaps your system does not support XA_RGB_DEFAULT_MAP."
"\n Perhaps your system does not support XA_RGB_BEST_MAP."
<< G4endl;
return false;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RayTracer.cc 74050 2013-09-20 09:38:19Z gcosmo $
// $Id: G4RayTracer.cc 103626 2017-04-19 13:29:18Z gcosmo $
#include "G4RayTracer.hh"
#include "G4RayTracerFeatures.hh"
@@ -61,7 +61,8 @@ G4VSceneHandler* G4RayTracer::CreateSceneHandler (const G4String& name) {
G4VViewer* G4RayTracer::CreateViewer (G4VSceneHandler& sceneHandler,
const G4String& name) {
G4VViewer* pViewer = new G4RayTracerViewer (sceneHandler, name);
G4VViewer* pViewer = new G4RayTracerViewer
(sceneHandler, name, theRayTracer);
if (pViewer) {
if (pViewer->GetViewId() < 0) {
G4cout <<
@@ -24,17 +24,20 @@
// ********************************************************************
//
//
// $Id: G4RayTracerSceneHandler.cc 66870 2013-01-14 23:38:59Z adotti $
// $Id: G4RayTracerSceneHandler.cc 104015 2017-05-08 07:28:08Z gcosmo $
#include "G4RayTracerSceneHandler.hh"
#include "G4VisManager.hh"
#include "G4LogicalVolume.hh"
G4int G4RayTracerSceneHandler::fSceneIdCount = 0;
G4RayTracerSceneHandler::G4RayTracerSceneHandler(G4VGraphicsSystem& system,
const G4String& name):
G4VSceneHandler(system, fSceneIdCount++, name)
const G4String& name)
: G4VSceneHandler(system, fSceneIdCount++, name)
{
// Ray Tracer does not use the vis concept of scene (G4Scene) - keep
// vis manager happy when someone opens a ray tracer with "/vis/open
// Keep vis manager happy when someone opens a ray tracer with "/vis/open
// RayTracer" but uses the ray tracer with "/vis/rayTracer" commands
// before creating any scenes, for example, instead of using
// "/vis/drawVolume"...
@@ -58,4 +61,55 @@ G4RayTracerSceneHandler::G4RayTracerSceneHandler(G4VGraphicsSystem& system,
G4RayTracerSceneHandler::~G4RayTracerSceneHandler()
{}
G4int G4RayTracerSceneHandler::fSceneIdCount = 0;
void G4RayTracerSceneHandler::ClearStore()
{
fSceneVisAttsMap.clear();
}
G4bool G4RayTracerSceneHandler::PathLessThan::operator()
(const G4ModelingParameters::PVPointerCopyNoPath& a,
const G4ModelingParameters::PVPointerCopyNoPath& b) const
{
if (a.size() != b.size()) return a.size() < b.size();
auto ia = a.begin();
auto ib = b.begin();
for (; ia != a.end(); ++ia, ++ib) {
if (ia->GetPVPointer() < ib->GetPVPointer()) return true;
if (ia->GetPVPointer() > ib->GetPVPointer()) return false;
// Pointers equal
if (ia->GetCopyNo() < ib->GetCopyNo()) return true;
if (ia->GetCopyNo() > ib->GetCopyNo()) return false;
// Both pointers and copy no are equal - continue
}
// Equality
return false;
}
void G4RayTracerSceneHandler::BuildVisAttsMap (const G4VSolid&)
{
// Build map of vis attributes
G4PhysicalVolumeModel* fpPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
if (fpPVModel) {
G4ModelingParameters::PVPointerCopyNoPath temp;
for (const auto& nodeID: fpPVModel->GetFullPVPath()) {
// Build an element from the nodeid.
temp.push_back(G4ModelingParameters::PVPointerCopyNo(nodeID));
}
const G4VisAttributes* pVisAtts = fpVisAttribs;
if (!pVisAtts) {
// Shouldn't happen.
if (G4VisManager::GetInstance()->GetVerbosity() >= G4VisManager::warnings) {
G4cout <<
"WARNING: G4RayTracerSceneHandler::BuildVisAttsMap: null vis atts pointer."
"\n Using a default vis atts."
<< G4endl;
}
static const G4VisAttributes defaultVisAtts;
pVisAtts = &defaultVisAtts;
}
// Copy vis atts into the vis atts map
fSceneVisAttsMap[temp] = *pVisAtts;
}
}
@@ -24,12 +24,14 @@
// ********************************************************************
//
//
// $Id: G4RayTracerViewer.cc 74050 2013-09-20 09:38:19Z gcosmo $
// $Id: G4RayTracerViewer.cc 104015 2017-05-08 07:28:08Z gcosmo $
#include "G4RayTracerViewer.hh"
#include "G4ios.hh"
#include <sstream>
#include <iomanip>
#include "G4SystemOfUnits.hh"
#include "G4VSceneHandler.hh"
@@ -37,30 +39,29 @@
#include "G4TheRayTracer.hh"
#include "G4UImanager.hh"
#ifdef G4MULTITHREADED
#include "G4TheMTRayTracer.hh"
#endif
G4RayTracerViewer::G4RayTracerViewer
(G4VSceneHandler& sceneHandler,
const G4String& name,
G4TheRayTracer* aTracer):
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name),
fFileCount(0)
G4TheRayTracer* aTracer)
: G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
, fFileCount(0)
, theTracer(aTracer)
{
theTracer = aTracer;
#ifdef G4MULTITHREADED
if (!aTracer) theTracer = G4TheMTRayTracer::theInstance;
if (!theTracer) theTracer = new G4TheMTRayTracer;
#else
if (!aTracer) theTracer = new G4TheRayTracer;
#endif
theTracer->SetNColumn(fVP.GetWindowSizeHintX());
theTracer->SetNRow(fVP.GetWindowSizeHintY());
if (!theTracer) {
G4cerr << "G4RayTracerViewer::Initialise: No tracer" << G4endl;
fViewId = -1; // This flags an error.
return;
}
}
G4RayTracerViewer::~G4RayTracerViewer() {}
void G4RayTracerViewer::Initialise()
{
theTracer->SetNColumn(fVP.GetWindowSizeHintX());
theTracer->SetNRow(fVP.GetWindowSizeHintY());
}
void G4RayTracerViewer::SetView()
{
// Get radius of scene, etc. (See G4OpenGLViewer::SetView().)
@@ -110,14 +111,16 @@ void G4RayTracerViewer::DrawView()
<< fieldHalfAngle <<
" radians."
<< G4endl;
SetView(); // Special graphics system - bypass ProcessView().
SetView(); // With this fieldHalfAngle
ProcessView();
fVP.SetFieldHalfAngle(0.);
}
else {
SetView(); // Special graphics system - bypass ProcessView().
ProcessView();
}
std::ostringstream filename;
filename << "g4RayTracer." << fShortName << '_' << fFileCount++ << ".jpeg";
filename << "g4RayTracer." << fShortName << '_'
<< std::setw(4) << std::setfill('0') << fFileCount++ << ".jpeg";
theTracer->Trace(filename.str());
// Reset call flag
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RayTracerXViewer.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4RayTracerXViewer.cc 104015 2017-05-08 07:28:08Z gcosmo $
#ifdef G4VIS_BUILD_RAYTRACERX_DRIVER
@@ -50,14 +50,7 @@ G4RayTracerXViewer::~G4RayTracerXViewer() {}
void G4RayTracerXViewer::Initialise() {
if (!theTracer) {
G4cerr << "G4RayTracerXViewer::Initialise: No tracer" << G4endl;
fViewId = -1; // This flags an error.
return;
}
theTracer->SetNColumn(fVP.GetWindowSizeHintX());
theTracer->SetNRow(fVP.GetWindowSizeHintY());
G4RayTracerViewer::Initialise();
// Set up X Window...
G4RTXScanner* theXScanner = (G4RTXScanner*)theTracer->GetScanner();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RayTrajectory.cc 71495 2013-06-17 09:13:30Z gcosmo $
// $Id: G4RayTrajectory.cc 104015 2017-05-08 07:28:08Z gcosmo $
//
//
//
@@ -35,6 +35,7 @@
#include "G4RayTrajectory.hh"
#include "G4RayTrajectoryPoint.hh"
#include "G4RayTracerSceneHandler.hh"
#include "G4Step.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VisManager.hh"
@@ -86,29 +87,52 @@ void G4RayTrajectory::AppendStep(const G4Step* aStep)
= theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
trajectoryPoint->SetSurfaceNormal(theGrobalNormal);
G4VPhysicalVolume* prePhys = aStep->GetPreStepPoint()->GetPhysicalVolume();
const G4VisAttributes* preVisAtt = prePhys->GetLogicalVolume()->GetVisAttributes();
G4VisManager* visManager = G4VisManager::GetInstance();
if(visManager) {
G4VViewer* viewer = visManager->GetCurrentViewer();
if (viewer) {
preVisAtt = viewer->GetApplicableVisAttributes(preVisAtt);
}
}
trajectoryPoint->SetPreStepAtt(preVisAtt);
G4RayTracerSceneHandler* sceneHandler =
static_cast<G4RayTracerSceneHandler*>(visManager->GetCurrentSceneHandler());
const auto& sceneVisAttsMap = sceneHandler->GetSceneVisAttsMap();
const G4VPhysicalVolume* postPhys = aStep->GetPostStepPoint()->GetPhysicalVolume();
const G4VisAttributes* postVisAtt = NULL;
if(postPhys) {
postVisAtt = postPhys->GetLogicalVolume()->GetVisAttributes();
if(visManager) {
G4VViewer* viewer = visManager->GetCurrentViewer();
if (viewer) {
postVisAtt = viewer->GetApplicableVisAttributes(postVisAtt);
}
}
// Make a path from the preStepPoint touchable
G4StepPoint* preStepPoint = aStep -> GetPreStepPoint();
const G4VTouchable* preTouchable = preStepPoint->GetTouchable();
G4int preDepth = preTouchable->GetHistoryDepth();
G4ModelingParameters::PVPointerCopyNoPath localPrePVPointerCopyNoPath;
for (G4int i = preDepth; i >= 0; --i) {
localPrePVPointerCopyNoPath.push_back
(G4ModelingParameters::PVPointerCopyNo
(preTouchable->GetVolume(i),preTouchable->GetCopyNumber(i)));
}
trajectoryPoint->SetPostStepAtt(postVisAtt);
// Pick up the vis atts, if any, from the scene handler
auto preIterator = sceneVisAttsMap.find(localPrePVPointerCopyNoPath);
const G4VisAttributes* preVisAtts;
if (preIterator != sceneVisAttsMap.end()) {
preVisAtts = &preIterator->second;
} else {
preVisAtts = 0;
}
trajectoryPoint->SetPreStepAtt(preVisAtts);
// Make a path from the postStepPoint touchable
G4StepPoint* postStepPoint = aStep -> GetPostStepPoint();
const G4VTouchable* postTouchable = postStepPoint->GetTouchable();
G4int postDepth = postTouchable->GetHistoryDepth();
G4ModelingParameters::PVPointerCopyNoPath localPostPVPointerCopyNoPath;
for (G4int i = postDepth; i >= 0; --i) {
localPostPVPointerCopyNoPath.push_back
(G4ModelingParameters::PVPointerCopyNo
(postTouchable->GetVolume(i),postTouchable->GetCopyNumber(i)));
}
// Pick up the vis atts, if any, from the scene handler
auto postIterator = sceneVisAttsMap.find(localPostPVPointerCopyNoPath);
const G4VisAttributes* postVisAtts;
if (postIterator != sceneVisAttsMap.end()) {
postVisAtts = &postIterator->second;
} else {
postVisAtts = 0;
}
trajectoryPoint->SetPostStepAtt(postVisAtts);
positionRecord->push_back(trajectoryPoint);
}