Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
@@ -46,8 +46,6 @@ G4ArrowModel::~G4ArrowModel ()
{
delete fpHeadPolyhedron;
delete fpShaftPolyhedron;
delete fpHeadPolyhedronOrig;
delete fpShaftPolyhedronOrig;
}
G4ArrowModel::G4ArrowModel
@@ -55,11 +53,11 @@ G4ArrowModel::G4ArrowModel
G4double x2, G4double y2, G4double z2,
G4double width, const G4Colour& colour,
const G4String& description,
G4int lineSegmentsPerCircle)
G4int lineSegmentsPerCircle,
const G4Transform3D& transform)
: fpShaftPolyhedron(nullptr)
, fpHeadPolyhedron(nullptr)
, fpShaftPolyhedronOrig(nullptr)
, fpHeadPolyhedronOrig(nullptr)
, fTransform(transform)
{
fType = "G4ArrowModel";
fGlobalTag = fType;
@@ -127,33 +125,10 @@ G4ArrowModel::G4ArrowModel
G4Polyhedron::SetNumberOfRotationSteps(tempN);
}
void G4ArrowModel::SetTransformation (const G4Transform3D& transform)
{
fTransform = transform; // A new transform
if (fpShaftPolyhedron) {
if (fpShaftPolyhedronOrig == nullptr) { // Must be first time
fpShaftPolyhedronOrig = new G4Polyhedron(*fpShaftPolyhedron);
}
delete fpShaftPolyhedron; // Has transformation of old transfrom
fpShaftPolyhedron = new G4Polyhedron(*fpShaftPolyhedronOrig);
fpShaftPolyhedron->Transform(fTransform);
}
if (fpHeadPolyhedron) {
if (fpHeadPolyhedronOrig == nullptr) { // Must be first time
fpHeadPolyhedronOrig = new G4Polyhedron(*fpHeadPolyhedron);
}
delete fpHeadPolyhedron; // Has transformation of old transfrom
fpHeadPolyhedron = new G4Polyhedron(*fpHeadPolyhedronOrig);
fpHeadPolyhedron->Transform(fTransform);
}
}
void G4ArrowModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
if (fpShaftPolyhedron && fpHeadPolyhedron) {
sceneHandler.BeginPrimitives();
sceneHandler.BeginPrimitives(fTransform);
sceneHandler.AddPrimitive(*fpShaftPolyhedron);
sceneHandler.AddPrimitive(*fpHeadPolyhedron);
sceneHandler.EndPrimitives();
@@ -58,18 +58,52 @@ G4AxesModel::G4AxesModel
G4double arrowWidth, const G4String& colourString,
const G4String& description,
G4bool withAnnotation,
G4double textSize):
fXAxisModel(0),
fXLabelModel(0),
fXAnnotationModel(0),
fYAxisModel(0),
fYLabelModel(0),
fYAnnotationModel(0),
fZAxisModel(0),
fZLabelModel(0),
fZAnnotationModel(0)
G4double textSize,
const G4Transform3D& transform)
{
fType = "G4AxesModel";
Construct
(x0,y0,z0,length,arrowWidth,
colourString,description,withAnnotation,textSize,
transform);
}
// Alternative short constructor
G4AxesModel::G4AxesModel
(G4double x0, G4double y0, G4double z0, G4double length,
const G4Transform3D& transform)
{
G4double arrowWidth = 1.;
const G4String& colourString = "auto";
const G4String& description = "";
G4bool withAnnotation = true;
G4double textSize = 10.;
Construct
(x0,y0,z0,length,arrowWidth,
colourString,description,withAnnotation,textSize,
transform);
}
void G4AxesModel::Construct
(G4double x0, G4double y0, G4double z0, G4double length,
G4double arrowWidth, const G4String& colourString,
const G4String& description,
G4bool withAnnotation,
G4double textSize,
const G4Transform3D& transform)
{
fXAxisModel = nullptr;
fXLabelModel = nullptr;
fXAnnotationModel = nullptr;
fYAxisModel = nullptr;
fYLabelModel = nullptr;
fYAnnotationModel = nullptr;
fZAxisModel = nullptr;
fZLabelModel = nullptr;
fZAnnotationModel = nullptr;
fTransform = transform;
fType = "Axes";
fGlobalTag = fType;
fGlobalDescription = fType + ": " + description;
fExtent = G4VisExtent
@@ -93,12 +127,14 @@ G4AxesModel::G4AxesModel
G4Text* text = 0;
G4VisAttributes* va = 0;
G4int lineSegmentsPerCircle = 6;
G4Colour xColour(colour);
if (autoColour) xColour = G4Colour::Red();
fXAxisModel = new G4ArrowModel
(x0, y0, z0, x0+length, y0, z0, arrowWidth,
xColour, "x-axis: " + description);
xColour, "x-axis: " + description,
lineSegmentsPerCircle, fTransform);
if (withAnnotation) {
text = new G4Text("x",G4Point3D(x0+1.05*length, y0, z0));
text->SetScreenSize(textSize);
@@ -106,7 +142,7 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(xColour);
text->SetVisAttributes(va);
fXLabelModel = new G4TextModel(*text);
fXLabelModel = new G4TextModel(*text,fTransform);
delete text;
text = new G4Text(annotation,G4Point3D(x0+0.8*length, y0, z0));
text->SetScreenSize(textSize);
@@ -114,7 +150,7 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(xColour);
text->SetVisAttributes(va);
fXAnnotationModel = new G4TextModel(*text);
fXAnnotationModel = new G4TextModel(*text,fTransform);
delete text;
}
@@ -122,7 +158,8 @@ G4AxesModel::G4AxesModel
if (autoColour) yColour = G4Colour::Green();
fYAxisModel = new G4ArrowModel
(x0, y0, z0, x0, y0+length, z0, arrowWidth,
yColour, "y-axis: " + description);
yColour, "y-axis: " + description,
lineSegmentsPerCircle, fTransform);
if (withAnnotation) {
text = new G4Text("y",G4Point3D(x0, y0+1.05*length, z0));
text->SetScreenSize(textSize);
@@ -130,7 +167,7 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(yColour);
text->SetVisAttributes(va);
fYLabelModel = new G4TextModel(*text);
fYLabelModel = new G4TextModel(*text,fTransform);
delete text;
text = new G4Text(annotation,G4Point3D(x0, y0+0.8*length, z0));
text->SetScreenSize(textSize);
@@ -138,7 +175,7 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(yColour);
text->SetVisAttributes(va);
fYAnnotationModel = new G4TextModel(*text);
fYAnnotationModel = new G4TextModel(*text,fTransform);
delete text;
}
@@ -146,7 +183,8 @@ G4AxesModel::G4AxesModel
if (autoColour) zColour = G4Colour::Blue();
fZAxisModel = new G4ArrowModel
(x0, y0, z0, x0, y0, z0+length, arrowWidth,
zColour, "z-axis: " + description);
zColour, "z-axis: " + description,
lineSegmentsPerCircle, fTransform);
if (withAnnotation) {
text = new G4Text("z",G4Point3D(x0, y0, z0+1.05*length));
text->SetScreenSize(textSize);
@@ -154,7 +192,7 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(zColour);
text->SetVisAttributes(va);
fZLabelModel = new G4TextModel(*text);
fZLabelModel = new G4TextModel(*text,fTransform);
delete text;
text = new G4Text(annotation,G4Point3D(x0, y0, z0+0.8*length));
text->SetScreenSize(textSize);
@@ -162,28 +200,11 @@ G4AxesModel::G4AxesModel
text->SetLayout(G4Text::centre);
va = new G4VisAttributes(zColour);
text->SetVisAttributes(va);
fZAnnotationModel = new G4TextModel(*text);
fZAnnotationModel = new G4TextModel(*text,fTransform);
delete text;
}
}
void G4AxesModel::SetTransformation (const G4Transform3D& transform)
{
fTransform = transform;
if (fXAxisModel) fXAxisModel-> SetTransformation(fTransform);
if (fXLabelModel) fXLabelModel-> SetTransformation(fTransform);
if (fXAnnotationModel) fXAnnotationModel->SetTransformation(fTransform);
if (fYAxisModel) fYAxisModel-> SetTransformation(fTransform);
if (fYLabelModel) fYLabelModel-> SetTransformation(fTransform);
if (fYAnnotationModel) fYAnnotationModel->SetTransformation(fTransform);
if (fZAxisModel) fZAxisModel-> SetTransformation(fTransform);
if (fZLabelModel) fZLabelModel-> SetTransformation(fTransform);
if (fZAnnotationModel) fZAnnotationModel->SetTransformation(fTransform);
}
void G4AxesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
if (fXAxisModel) fXAxisModel-> DescribeYourselfTo(sceneHandler);
@@ -33,7 +33,7 @@
#include "G4NullModel.hh"
G4NullModel::G4NullModel (const G4ModelingParameters* pMP):
G4VModel (G4Transform3D(), pMP) {}
G4VModel (pMP) {}
G4NullModel::~G4NullModel () {}
@@ -63,21 +63,22 @@ namespace {
G4PhysicalVolumeModel::G4PhysicalVolumeModel
(G4VPhysicalVolume* pVPV
, G4int requestedDepth
, const G4Transform3D& modelTransformation
, const G4Transform3D& modelTransform
, const G4ModelingParameters* pMP
, G4bool useFullExtent
, const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
: G4VModel (modelTransformation,pMP)
: G4VModel (pMP)
, fpTopPV (pVPV)
, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
, fRequestedDepth (requestedDepth)
, fUseFullExtent (useFullExtent)
, fTransform (modelTransform)
, fCurrentDepth (0)
, fpCurrentPV (fpTopPV)
, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
, fpCurrentTransform (const_cast<G4Transform3D*>(&modelTransformation))
, fCurrentTransform (modelTransform)
, fBaseFullPVPath (baseFullPVPath)
, fAbort (false)
, fCurtailDescent (false)
@@ -172,6 +173,7 @@ void G4PhysicalVolumeModel::CalculateExtent ()
if (radius < 0.) { // Nothing in the scene - revert to top extent
fExtent = fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ();
}
fExtent.Transform(fTransform);
}
void G4PhysicalVolumeModel::DescribeYourselfTo
@@ -394,7 +396,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
// Create a nodeID for use below - note the "drawn" flag is true
G4int copyNo = fpCurrentPV->GetCopyNo();
auto nodeID = G4PhysicalVolumeNodeID
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform);
(fpCurrentPV,copyNo,fCurrentDepth,fCurrentTransform);
// Update full path of physical volumes...
fFullPVPath.push_back(nodeID);
@@ -412,7 +414,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
// not be accumulated.
G4Transform3D theNewAT (theAT);
if (fCurrentDepth != 0) theNewAT = theAT * theLT;
fpCurrentTransform = &theNewAT;
fCurrentTransform = theNewAT;
const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
// If the volume does not have any vis attributes, create it.
@@ -584,6 +586,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
sceneHandler.AddCompound(mesh);
fFullPVPath.pop_back();
fDrawnPVPath.pop_back();
delete tempVisAtts; // Needs cleaning up (Coverity warning!!)
return;
} // else continue processing
}
@@ -713,6 +716,7 @@ continue_processing:
}
}
// Clean up
delete tempVisAtts;
// Reset for normal descending of next volume at this level...
@@ -840,10 +844,9 @@ G4bool G4PhysicalVolumeModel::Validate (G4bool warn)
auto iterator = find(pvStore->begin(),pvStore->end(),fpTopPV);
if (iterator == pvStore->end()) {
if (warn) {
G4cerr <<
"G4PhysicalVolumeModel::Validate(): No volume of name \""
<< fpTopPV->GetName() << "\" exists."
<< G4endl;
G4ExceptionDescription ed;
ed << "Attempt to validate a volume that is no longer in the physical volume store.";
G4Exception("G4PhysicalVolumeModel::Validate", "modeling0015", JustWarning, ed);
}
return false;
} else {
@@ -1005,7 +1008,7 @@ std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
const G4ThreeVector& localTranslation = fpCurrentPV->GetTranslation();
oss.str(""); oss << '\n' << G4Transform3D(localRotation,localTranslation);
values->push_back(G4AttValue("LocalTrans", oss.str(),""));
oss.str(""); oss << '\n' << *fpCurrentTransform;
oss.str(""); oss << '\n' << fCurrentTransform;
values->push_back(G4AttValue("GlobalTrans", oss.str(),""));
G4String matName = fpCurrentMaterial? fpCurrentMaterial->GetName(): G4String("No material");
values->push_back(G4AttValue("Material", matName,""));
@@ -101,7 +101,7 @@ G4PhysicalVolumesSearchScene::Matcher::Matcher(const G4String& requiredMatch)
fRequiredMatch = requiredMatch;
}
}
if (fRequiredMatch.isNull()) {
if (fRequiredMatch.empty()) {
G4Exception
("G4PhysicalVolumesSearchScene::Matcher::Matcher",
"modeling0013", JustWarning, "Required match is null");
@@ -22,39 +22,32 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 21st July 2001.
// Model which knows how to draw scale.
// Guy Barrand 25th September 2021
#include "G4ScaleModel.hh"
#include "G4PlotterModel.hh"
#include "G4ModelingParameters.hh"
#include "G4VGraphicsScene.hh"
G4ScaleModel::~G4ScaleModel () {}
G4ScaleModel::G4ScaleModel (const G4Scale& scale): fScale(scale) {
fType = "G4ScaleModel";
fGlobalTag = "G4ScaleModel: " + fScale.GetAnnotation();
switch (fScale.GetDirection()) {
case G4Scale::x:
fGlobalTag += " x";
break;
case G4Scale::y:
fGlobalTag += " y";
break;
case G4Scale::z:
fGlobalTag += " z";
break;
}
fGlobalDescription = fGlobalTag;
G4PlotterModel::G4PlotterModel(G4Plotter& a_plotter,const G4String& description,const G4Transform3D& a_transform)
:fPlotter(a_plotter),fTransform(a_transform)
{
fType = "G4PlotterModel";
fGlobalTag = fType;
fGlobalDescription = fType + ": " + description;
// Have the extent so that the viewer will have an ortho camera
// with a height of 1 in order to map the tools::sg::plots height of 1:
// radius = sqrt(half_x*half_x+half_y*half_y+half_z*half_z);
// radius = sqrt(3*half*half)
// half = sqrt(radius*radius/3)
double radius = 0.5;
double half = ::sqrt(radius*radius/3.0);
fExtent = G4VisExtent(-half,half,-half,half,-half,half); //x,y,z min/max.
}
void G4ScaleModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler) {
sceneHandler.BeginPrimitives ();
sceneHandler.AddPrimitive (fScale);
sceneHandler.EndPrimitives ();
void G4PlotterModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
sceneHandler.BeginPrimitives(fTransform);
sceneHandler.AddPrimitive(fPlotter);
sceneHandler.EndPrimitives();
}
@@ -39,9 +39,8 @@
G4TextModel::~G4TextModel () {}
G4TextModel::G4TextModel (const G4Text& g4Text)
G4TextModel::G4TextModel (const G4Text& g4Text, const G4Transform3D& transform)
: fG4Text(g4Text)
, fG4TextOrig(g4Text)
{
fType = "G4TextModel";
std::ostringstream oss;
@@ -51,12 +50,7 @@ G4TextModel::G4TextModel (const G4Text& g4Text)
<< " with offsets " << g4Text.GetXOffset() << ',' << g4Text.GetYOffset();
fGlobalTag = oss.str();
fGlobalDescription = fGlobalTag;
}
void G4TextModel::SetTransformation (const G4Transform3D& transform)
{
fTransform = transform;
fG4Text = fG4TextOrig;
fG4Text.SetPosition(fG4Text.GetPosition()+transform.getTranslation());
}
@@ -67,7 +67,7 @@ void G4TouchablePropertiesScene::ProcessVolume (const G4VSolid& /*solid*/) {
fFoundTouchableProperties.fTouchablePath = fRequiredTouchable;
fFoundTouchableProperties.fpTouchablePV = fpSearchPVModel->GetCurrentPV();
fFoundTouchableProperties.fCopyNo = fpSearchPVModel->GetCurrentPVCopyNo();
fFoundTouchableProperties.fTouchableGlobalTransform = *fpSearchPVModel->GetCurrentTransform();
fFoundTouchableProperties.fTouchableGlobalTransform = fpSearchPVModel->GetCurrentTransform();
fFoundTouchableProperties.fTouchableBaseFullPVPath = fpSearchPVModel->GetFullPVPath();
// Base path is one down from found PV
fFoundTouchableProperties.fTouchableBaseFullPVPath.pop_back();
@@ -62,7 +62,7 @@ G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object,
const G4bool& /*visible*/) const
{
// Return if attribute name has not been set. Just print one warning
if (fAttName.isNull()) {
if (fAttName.empty()) {
if (!fWarnedMissingAttribute) {
G4ExceptionDescription ed;
@@ -62,7 +62,7 @@ G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj, const G4boo
std::vector<G4AttValue>::const_iterator iAtt;
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
if (iAtt->GetName() == "PostVPath" &&
iAtt->GetValue().contains(soughtPVName)) break;
G4StrUtil::contains(iAtt->GetValue(), soughtPVName)) break;
}
if (iAtt != attValues->end()) { // Required value found
fMap.GetColour(soughtPVName, colour);
@@ -56,7 +56,7 @@ G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
std::vector<G4AttValue>::const_iterator iAtt;
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
if (iAtt->GetName() == "PostVPath" &&
iAtt->GetValue().contains(pvname)) break;
G4StrUtil::contains(iAtt->GetValue(),pvname)) break;
}
if (iAtt != attValues->end()) { // Required value found
return true; // First found pvname determines selection.
+1 -24
View File
@@ -34,12 +34,10 @@
#include "G4RotationMatrix.hh"
#include "G4ModelingParameters.hh"
G4VModel::G4VModel (const G4Transform3D& modelTransformation,
const G4ModelingParameters* pMP):
G4VModel::G4VModel (const G4ModelingParameters* pMP):
fType ("Other"),
fGlobalTag ("Empty"),
fGlobalDescription ("Empty"),
fTransform (modelTransformation),
fpMP (pMP)
{}
@@ -55,17 +53,6 @@ G4String G4VModel::GetCurrentDescription () const {
return fGlobalDescription;
}
const G4VisExtent& G4VModel::GetTransformedExtent () const {
static G4VisExtent transformedExtent;
transformedExtent = fExtent;
transformedExtent.Transform(fTransform);
return transformedExtent;
}
void G4VModel::SetTransformation (const G4Transform3D& transform) {
fTransform = transform;
}
G4bool G4VModel::Validate (G4bool) {
return true;
}
@@ -77,15 +64,5 @@ std::ostream& operator << (std::ostream& os, const G4VModel& model) {
if (mp) os << "\n " << *mp;
else os << " none.";
os << "\n Extent: " << model.fExtent;
os << "\n Transformation: ";
os << "\n Rotation: ";
G4RotationMatrix rotation = model.fTransform.getRotation ();
os << rotation.thetaX() << ", "
<< rotation.phiX() << ", "
<< rotation.thetaY() << ", "
<< rotation.phiY() << ", "
<< rotation.thetaZ() << ", "
<< rotation.phiZ();
os << "\n Translation: " << model.fTransform.getTranslation ();
return os;
}