Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -46,6 +46,8 @@ G4ArrowModel::~G4ArrowModel ()
|
||||
{
|
||||
delete fpHeadPolyhedron;
|
||||
delete fpShaftPolyhedron;
|
||||
delete fpHeadPolyhedronOrig;
|
||||
delete fpShaftPolyhedronOrig;
|
||||
}
|
||||
|
||||
G4ArrowModel::G4ArrowModel
|
||||
@@ -56,6 +58,8 @@ G4ArrowModel::G4ArrowModel
|
||||
G4int lineSegmentsPerCircle)
|
||||
: fpShaftPolyhedron(nullptr)
|
||||
, fpHeadPolyhedron(nullptr)
|
||||
, fpShaftPolyhedronOrig(nullptr)
|
||||
, fpHeadPolyhedronOrig(nullptr)
|
||||
{
|
||||
fType = "G4ArrowModel";
|
||||
fGlobalTag = fType;
|
||||
@@ -123,10 +127,35 @@ 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)
|
||||
{
|
||||
sceneHandler.BeginPrimitives();
|
||||
if (fpShaftPolyhedron) sceneHandler.AddPrimitive(*fpShaftPolyhedron);
|
||||
if (fpHeadPolyhedron) sceneHandler.AddPrimitive(*fpHeadPolyhedron);
|
||||
sceneHandler.EndPrimitives();
|
||||
if (fpShaftPolyhedron && fpHeadPolyhedron) {
|
||||
sceneHandler.BeginPrimitives();
|
||||
sceneHandler.AddPrimitive(*fpShaftPolyhedron);
|
||||
sceneHandler.AddPrimitive(*fpHeadPolyhedron);
|
||||
sceneHandler.EndPrimitives();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,15 +167,34 @@ G4AxesModel::G4AxesModel
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (fXLabelModel) fXLabelModel->DescribeYourselfTo(sceneHandler);
|
||||
if (fXAxisModel) fXAxisModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fXLabelModel) fXLabelModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fXAnnotationModel) fXAnnotationModel->DescribeYourselfTo(sceneHandler);
|
||||
if (fYAxisModel) fYAxisModel->DescribeYourselfTo(sceneHandler);
|
||||
if (fYLabelModel) fYLabelModel->DescribeYourselfTo(sceneHandler);
|
||||
|
||||
if (fYAxisModel) fYAxisModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fYLabelModel) fYLabelModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fYAnnotationModel) fYAnnotationModel->DescribeYourselfTo(sceneHandler);
|
||||
if (fZAxisModel) fZAxisModel->DescribeYourselfTo(sceneHandler);
|
||||
if (fZLabelModel) fZLabelModel->DescribeYourselfTo(sceneHandler);
|
||||
|
||||
if (fZAxisModel) fZAxisModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fZLabelModel) fZLabelModel-> DescribeYourselfTo(sceneHandler);
|
||||
if (fZAnnotationModel) fZAnnotationModel->DescribeYourselfTo(sceneHandler);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// John Allison May 2021
|
||||
//
|
||||
// G4Mesh encapsulates and validates a nested parameterisation, which we
|
||||
// call a "mesh". If a valid mesh cannot be created out of this
|
||||
// G4VPhysicalVolume* (which will probably be most common), it will
|
||||
// have a type "invalid". Then, usually, it may simply be destroyed.
|
||||
// The overhead of an invalid attempt is expected to be small.
|
||||
|
||||
#include "G4Mesh.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4VNestedParameterisation.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Sphere.hh"
|
||||
|
||||
std::map<G4int,G4String> G4Mesh::fEnumMap;
|
||||
|
||||
G4Mesh::G4Mesh (G4VPhysicalVolume* containerVolume,const G4Transform3D& transform)
|
||||
: fpContainerVolume(containerVolume)
|
||||
, fMeshType(invalid)
|
||||
, fMeshDepth(0)
|
||||
, fTransform(transform)
|
||||
{
|
||||
if (fpContainerVolume == nullptr) return;
|
||||
|
||||
static G4bool first = true;
|
||||
if (first) {
|
||||
first = false;
|
||||
fEnumMap[invalid] = "invalid";
|
||||
fEnumMap[rectangle] = "rectangle";
|
||||
fEnumMap[cylinder] = "cylinder";
|
||||
fEnumMap[sphere] = "sphere";
|
||||
}
|
||||
|
||||
const G4LogicalVolume* pLV = fpContainerVolume->GetLogicalVolume();
|
||||
|
||||
// check if this is a container for a nested parameterisation
|
||||
G4bool isContainer = false;
|
||||
if (pLV->GetNoDaughters()) {
|
||||
fMeshDepth++;
|
||||
const auto d0 = pLV->GetDaughter(0);
|
||||
const auto d0LV = d0->GetLogicalVolume();
|
||||
if (d0LV->GetNoDaughters()) {
|
||||
fMeshDepth++;
|
||||
const auto d00 = d0LV->GetDaughter(0);
|
||||
const auto pvParam00 = dynamic_cast<G4PVParameterised*>(d00);
|
||||
if (pvParam00) {
|
||||
const auto param00 = pvParam00->GetParameterisation();
|
||||
const auto nestedParam00 = dynamic_cast<G4VNestedParameterisation*>(param00);
|
||||
if (nestedParam00) { // 2-deep mesh
|
||||
isContainer = true;
|
||||
}
|
||||
} else {
|
||||
const auto d00LV = d00->GetLogicalVolume();
|
||||
if (d00LV->GetNoDaughters()) {
|
||||
fMeshDepth++;
|
||||
const auto d000 = d00LV->GetDaughter(0);
|
||||
const auto pvParam000 = dynamic_cast<G4PVParameterised*>(d000);
|
||||
if (pvParam000) {
|
||||
const auto param000 = pvParam000->GetParameterisation();
|
||||
const auto nestedParam000 = dynamic_cast<G4VNestedParameterisation*>(param000);
|
||||
if (nestedParam000) { // 3-deep mesh
|
||||
isContainer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isContainer) {
|
||||
// Get type
|
||||
G4VSolid* pSol = pLV -> GetSolid ();
|
||||
if (dynamic_cast<G4Box*>(pSol)) {
|
||||
fMeshType = rectangle;
|
||||
} else if (dynamic_cast<G4Tubs*>(pSol)) {
|
||||
fMeshType = cylinder;
|
||||
} else if (dynamic_cast<G4Sphere*>(pSol)) {
|
||||
fMeshType = sphere;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4Mesh::~G4Mesh () {}
|
||||
|
||||
std::ostream& operator << (std::ostream& os, const G4Mesh& mesh) {
|
||||
os << "G4Mesh: ";
|
||||
os << "\nContainer: " << mesh.GetContainerVolume()->GetName();
|
||||
os << "\nType: " << mesh.GetEnumMap().find(mesh.GetMeshType())->second;
|
||||
os << "\nDepth: " << mesh.GetMeshDepth();
|
||||
os << "\nTranslation: " << mesh.GetTransform().getTranslation();
|
||||
os << "\nRotation: " << mesh.GetTransform().getRotation();
|
||||
return os;
|
||||
}
|
||||
@@ -56,7 +56,8 @@ G4ModelingParameters::G4ModelingParameters ():
|
||||
fNoOfSides (24),
|
||||
fpSectionSolid (0),
|
||||
fpCutawaySolid (0),
|
||||
fpEvent (0)
|
||||
fpEvent (0),
|
||||
fSpecialMeshRendering (false)
|
||||
{}
|
||||
|
||||
G4ModelingParameters::G4ModelingParameters
|
||||
@@ -83,7 +84,8 @@ G4ModelingParameters::G4ModelingParameters
|
||||
fNoOfSides (noOfSides),
|
||||
fpSectionSolid (0),
|
||||
fpCutawaySolid (0),
|
||||
fpEvent (0)
|
||||
fpEvent (0),
|
||||
fSpecialMeshRendering (false)
|
||||
{}
|
||||
|
||||
G4ModelingParameters::~G4ModelingParameters ()
|
||||
@@ -237,6 +239,19 @@ std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp)
|
||||
os << vams;
|
||||
}
|
||||
|
||||
os << "\n Special Mesh Rendering: ";
|
||||
if (mp.fSpecialMeshRendering) {
|
||||
os << "on: ";
|
||||
if (mp.fSpecialMeshVolumes.empty()) {
|
||||
os << "all meshes";
|
||||
} else {
|
||||
os << "selected meshes";
|
||||
for (const auto& vol: mp.fSpecialMeshVolumes) {
|
||||
os << "\n " << vol.GetName() << ':' << vol.GetCopyNo();
|
||||
}
|
||||
}
|
||||
} else os << "off";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -258,7 +273,8 @@ G4bool G4ModelingParameters::operator !=
|
||||
(fNoOfSides != mp.fNoOfSides) ||
|
||||
(fpSectionSolid != mp.fpSectionSolid) ||
|
||||
(fpCutawaySolid != mp.fpCutawaySolid) ||
|
||||
(fpEvent != mp.fpEvent)
|
||||
(fpEvent != mp.fpEvent) ||
|
||||
(fSpecialMeshRendering != mp.fSpecialMeshRendering)
|
||||
)
|
||||
return true;
|
||||
|
||||
@@ -273,6 +289,11 @@ G4bool G4ModelingParameters::operator !=
|
||||
if (fVisAttributesModifiers != mp.fVisAttributesModifiers)
|
||||
return true;
|
||||
|
||||
if (fSpecialMeshRendering) {
|
||||
if (fSpecialMeshVolumes != mp.fSpecialMeshVolumes)
|
||||
return true;;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
@@ -50,6 +51,7 @@
|
||||
#include "G4AttValue.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Vector3D.hh"
|
||||
#include "G4Mesh.hh"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -215,7 +217,7 @@ G4String G4PhysicalVolumeModel::GetCurrentTag () const
|
||||
if (fpCurrentPV) {
|
||||
std::ostringstream o;
|
||||
o << fpCurrentPV -> GetCopyNo ();
|
||||
return fpCurrentPV -> GetName () + "." + o.str();
|
||||
return fpCurrentPV -> GetName () + ":" + o.str();
|
||||
}
|
||||
else {
|
||||
return "WARNING: NO CURRENT VOLUME - global tag is " + fGlobalTag;
|
||||
@@ -242,7 +244,6 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
|
||||
// Find corresponding logical volume and (later) solid, storing in
|
||||
// local variables to preserve re-entrancy.
|
||||
G4LogicalVolume* pLV = pVPV -> GetLogicalVolume ();
|
||||
|
||||
G4VSolid* pSol = nullptr;
|
||||
G4Material* pMaterial = nullptr;
|
||||
|
||||
@@ -390,6 +391,14 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
fpCurrentLV = pLV;
|
||||
fpCurrentMaterial = pMaterial;
|
||||
|
||||
// Create a nodeID for use below - note the "drawn" flag is true
|
||||
G4int copyNo = fpCurrentPV->GetCopyNo();
|
||||
auto nodeID = G4PhysicalVolumeNodeID
|
||||
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform);
|
||||
|
||||
// Update full path of physical volumes...
|
||||
fFullPVPath.push_back(nodeID);
|
||||
|
||||
const G4RotationMatrix objectRotation = pVPV -> GetObjectRotationValue ();
|
||||
const G4ThreeVector& translation = pVPV -> GetTranslation ();
|
||||
G4Transform3D theLT (G4Transform3D (objectRotation, translation));
|
||||
@@ -450,15 +459,6 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// From here, can assume pVisAttribs is a valid pointer. This is necessary
|
||||
// because PreAddSolid needs a vis attributes object.
|
||||
|
||||
// Make decision to draw...
|
||||
G4bool thisToBeDrawn = true;
|
||||
|
||||
// Update full path of physical volumes...
|
||||
G4int copyNo = fpCurrentPV->GetCopyNo();
|
||||
fFullPVPath.push_back
|
||||
(G4PhysicalVolumeNodeID
|
||||
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
|
||||
|
||||
// Check if vis attributes are to be modified by a /vis/touchable/set/ command.
|
||||
const auto& vams = fpMP->GetVisAttributesModifiers();
|
||||
if (vams.size()) {
|
||||
@@ -551,11 +551,53 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
}
|
||||
}
|
||||
|
||||
// Check for special mesh rendering
|
||||
if (fpMP->IsSpecialMeshRendering()) {
|
||||
if (fpMP->GetSpecialMeshVolumes().empty()) {
|
||||
// No volumes specified - all are potentially possible
|
||||
goto create_mesh;
|
||||
} else {
|
||||
for (const auto& pvNameCopyNo: fpMP->GetSpecialMeshVolumes()) {
|
||||
if (pVPV->GetName() == pvNameCopyNo.GetName()) {
|
||||
// We have a name match
|
||||
if (pvNameCopyNo.GetCopyNo() < 0) {
|
||||
// Any copy number is OK
|
||||
goto create_mesh;
|
||||
} else {
|
||||
if (pVPV->GetCopyNo() == pvNameCopyNo.GetCopyNo()) {
|
||||
// We have a name and copy number match
|
||||
goto create_mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// We have fallen out of this loop without finding a match
|
||||
goto continue_processing;
|
||||
}
|
||||
create_mesh:
|
||||
// Create - or at least attempt to create - a mesh. If it cannot be created
|
||||
// out of this pVPV the type will be "invalid".
|
||||
G4Mesh mesh(pVPV,theNewAT);
|
||||
if (mesh.GetMeshType() != G4Mesh::invalid) {
|
||||
fFullPVPath.push_back(nodeID);
|
||||
fDrawnPVPath.push_back(nodeID);
|
||||
sceneHandler.AddCompound(mesh);
|
||||
fFullPVPath.pop_back();
|
||||
fDrawnPVPath.pop_back();
|
||||
return;
|
||||
} // else continue processing
|
||||
}
|
||||
continue_processing:
|
||||
|
||||
// Make decision to draw...
|
||||
G4bool thisToBeDrawn = true;
|
||||
|
||||
// There are various reasons why this volume
|
||||
// might not be drawn...
|
||||
G4bool culling = fpMP->IsCulling();
|
||||
G4bool cullingInvisible = fpMP->IsCullingInvisible();
|
||||
G4bool markedVisible = pVisAttribs->IsVisible();
|
||||
G4bool markedVisible
|
||||
= pVisAttribs->IsVisible() && pVisAttribs->GetColour().GetAlpha() > 0;
|
||||
G4bool cullingLowDensity = fpMP->IsDensityCulling();
|
||||
G4double density = pMaterial? pMaterial->GetDensity(): 0;
|
||||
G4double densityCut = fpMP -> GetVisibleDensity ();
|
||||
@@ -576,15 +618,13 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// 6) The user has asked for all further traversing to be aborted...
|
||||
if (fAbort) thisToBeDrawn = false;
|
||||
|
||||
// Record thisToBeDrawn in path...
|
||||
fFullPVPath.back().SetDrawn(thisToBeDrawn);
|
||||
// Set "drawn" flag (it was true by default) - thisToBeDrawn may be false
|
||||
nodeID.SetDrawn(thisToBeDrawn);
|
||||
|
||||
if (thisToBeDrawn) {
|
||||
|
||||
// Update path of drawn physical volumes...
|
||||
fDrawnPVPath.push_back
|
||||
(G4PhysicalVolumeNodeID
|
||||
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform,thisToBeDrawn));
|
||||
fDrawnPVPath.push_back(nodeID);
|
||||
|
||||
if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
|
||||
// For top-level drawn volumes, explode along radius...
|
||||
@@ -752,7 +792,7 @@ void G4PhysicalVolumeModel::DescribeSolid
|
||||
("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
|
||||
}
|
||||
|
||||
const G4Polyhedron* pResultantPolyhedron = pResultantSolid->GetPolyhedron();
|
||||
G4Polyhedron* pResultantPolyhedron = pResultantSolid->GetPolyhedron();
|
||||
if (!pResultantPolyhedron) {
|
||||
if (fpMP->IsWarning())
|
||||
G4cout <<
|
||||
@@ -778,6 +818,7 @@ void G4PhysicalVolumeModel::DescribeSolid
|
||||
if (pResultantPolyhedron) {
|
||||
// Finally, draw polyhedron...
|
||||
sceneHandler.BeginPrimitives(theAT);
|
||||
pResultantPolyhedron->SetVisAttributes(pVisAttribs);
|
||||
sceneHandler.AddPrimitive(*pResultantPolyhedron);
|
||||
sceneHandler.EndPrimitives();
|
||||
}
|
||||
@@ -789,57 +830,75 @@ void G4PhysicalVolumeModel::DescribeSolid
|
||||
|
||||
G4bool G4PhysicalVolumeModel::Validate (G4bool warn)
|
||||
{
|
||||
G4TransportationManager* transportationManager =
|
||||
G4TransportationManager::GetTransportationManager ();
|
||||
// Not easy to see how to validate this sort of model. Previously there was
|
||||
// a check that a volume of the same name (fTopPVName) existed somewhere in
|
||||
// the geometry tree but under some circumstances this consumed lots of CPU
|
||||
// time. Instead, let us simply check that the volume (fpTopPV) exists in the
|
||||
// physical volume store.
|
||||
|
||||
size_t nWorlds = transportationManager->GetNoWorlds();
|
||||
|
||||
G4bool found = false;
|
||||
|
||||
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
|
||||
transportationManager->GetWorldsIterator();
|
||||
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
|
||||
G4VPhysicalVolume* world = (*iterWorld);
|
||||
if (!world) break; // This can happen if geometry has been cleared/destroyed.
|
||||
// The idea now is to seek a PV with the same name and copy no
|
||||
// in the hope it's the same one!!
|
||||
G4PhysicalVolumeModel searchModel (world);
|
||||
G4int verbosity = 0; // Suppress messages from G4PhysicalVolumeSearchScene.
|
||||
G4PhysicalVolumeSearchScene searchScene
|
||||
(&searchModel, fTopPVName, fTopPVCopyNo, verbosity);
|
||||
G4ModelingParameters mp; // Default modeling parameters for this search.
|
||||
mp.SetDefaultVisAttributes(fpMP? fpMP->GetDefaultVisAttributes(): 0);
|
||||
searchModel.SetModelingParameters (&mp);
|
||||
searchModel.DescribeYourselfTo (searchScene);
|
||||
G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
|
||||
if (foundVolume) {
|
||||
if (foundVolume != fpTopPV && warn) {
|
||||
G4cout <<
|
||||
"G4PhysicalVolumeModel::Validate(): A volume of the same name and"
|
||||
"\n copy number (\""
|
||||
<< fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
<< ") still exists and is being used."
|
||||
"\n But it is not the same volume you originally specified"
|
||||
"\n in /vis/scene/add/."
|
||||
<< G4endl;
|
||||
}
|
||||
fpTopPV = foundVolume;
|
||||
CalculateExtent ();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (found) return true;
|
||||
else {
|
||||
const auto& pvStore = G4PhysicalVolumeStore::GetInstance();
|
||||
auto iterator = find(pvStore->begin(),pvStore->end(),fpTopPV);
|
||||
if (iterator == pvStore->end()) {
|
||||
if (warn) {
|
||||
G4cout <<
|
||||
"G4PhysicalVolumeModel::Validate(): No volume of name and"
|
||||
"\n copy number (\""
|
||||
<< fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
<< ") exists."
|
||||
<< G4endl;
|
||||
G4cerr <<
|
||||
"G4PhysicalVolumeModel::Validate(): No volume of name \""
|
||||
<< fpTopPV->GetName() << "\" exists."
|
||||
<< G4endl;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Previous algorithm
|
||||
// G4TransportationManager* transportationManager =
|
||||
// G4TransportationManager::GetTransportationManager ();
|
||||
// size_t nWorlds = transportationManager->GetNoWorlds();
|
||||
// G4bool found = false;
|
||||
// std::vector<G4VPhysicalVolume*>::iterator iterWorld =
|
||||
// transportationManager->GetWorldsIterator();
|
||||
// for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
|
||||
// G4VPhysicalVolume* world = (*iterWorld);
|
||||
// if (!world) break; // This can happen if geometry has been cleared/destroyed.
|
||||
// // The idea now is to seek a PV with the same name and copy no
|
||||
// // in the hope it's the same one!!
|
||||
// G4PhysicalVolumeModel searchModel (world);
|
||||
// G4int verbosity = 0; // Suppress messages from G4PhysicalVolumeSearchScene.
|
||||
// G4PhysicalVolumeSearchScene searchScene
|
||||
// (&searchModel, fTopPVName, fTopPVCopyNo, verbosity);
|
||||
// G4ModelingParameters mp; // Default modeling parameters for this search.
|
||||
// mp.SetDefaultVisAttributes(fpMP? fpMP->GetDefaultVisAttributes(): 0);
|
||||
// searchModel.SetModelingParameters (&mp);
|
||||
// searchModel.DescribeYourselfTo (searchScene);
|
||||
// G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
|
||||
// if (foundVolume) {
|
||||
// if (foundVolume != fpTopPV && warn) {
|
||||
// G4cout <<
|
||||
// "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
|
||||
// "\n copy number (\""
|
||||
// << fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
// << ") still exists and is being used."
|
||||
// "\n But it is not the same volume you originally specified"
|
||||
// "\n in /vis/scene/add/."
|
||||
// << G4endl;
|
||||
// }
|
||||
// fpTopPV = foundVolume;
|
||||
// CalculateExtent ();
|
||||
// found = true;
|
||||
// }
|
||||
// }
|
||||
// if (found) return true;
|
||||
// else {
|
||||
// if (warn) {
|
||||
// G4cout <<
|
||||
// "G4PhysicalVolumeModel::Validate(): No volume of name and"
|
||||
// "\n copy number (\""
|
||||
// << fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
// << ") exists."
|
||||
// << G4endl;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
const std::map<G4String,G4AttDef>* G4PhysicalVolumeModel::GetAttDefs() const
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
G4PhysicalVolumesSearchScene::G4PhysicalVolumesSearchScene
|
||||
(G4PhysicalVolumeModel* pSearchVolumesModel, // usually a world
|
||||
const G4String& requiredPhysicalVolumeName,
|
||||
G4int requiredCopyNo)
|
||||
G4int requiredCopyNo,
|
||||
G4int requiredContinuation)
|
||||
: fpSearchVolumesModel (pSearchVolumesModel)
|
||||
, fMatcher (requiredPhysicalVolumeName)
|
||||
, fRequiredCopyNo (requiredCopyNo)
|
||||
, fRequiredContinuation (requiredContinuation)
|
||||
{}
|
||||
|
||||
void G4PhysicalVolumesSearchScene::ProcessVolume (const G4VSolid&)
|
||||
@@ -68,6 +70,14 @@ void G4PhysicalVolumesSearchScene::ProcessVolume (const G4VSolid&)
|
||||
fpSearchVolumesModel->GetCurrentDepth(),
|
||||
basePath,
|
||||
*fpCurrentObjectTransformation));
|
||||
// If user has asked for limited descent
|
||||
if (fRequiredContinuation >= 0) {
|
||||
static G4int firstFoundDepth = fpSearchVolumesModel->GetCurrentDepth();
|
||||
G4int foundDepth = fpSearchVolumesModel->GetCurrentDepth();
|
||||
if (foundDepth >= firstFoundDepth + fRequiredContinuation) {
|
||||
fpSearchVolumesModel->CurtailDescent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// John Allison 15th May 2014
|
||||
// A base class for "pseudo" scenes/graphics systems.
|
||||
|
||||
#include "G4PseudoScene.hh"
|
||||
|
||||
void G4PseudoScene::ProcessVolume (const G4VSolid& solid)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "G4PseudoScene::ProcessVolume called for solid \"" << solid.GetName()
|
||||
<< "\".\n This is a base class - it shouldn't happen."
|
||||
<< "\n The concrete implementation has not processed this solid.";
|
||||
G4Exception("G4PseudoScene::ProcessVolume", "modeling0014",
|
||||
FatalException, ed);
|
||||
}
|
||||
@@ -39,7 +39,10 @@
|
||||
|
||||
G4TextModel::~G4TextModel () {}
|
||||
|
||||
G4TextModel::G4TextModel (const G4Text& g4Text): fG4Text(g4Text) {
|
||||
G4TextModel::G4TextModel (const G4Text& g4Text)
|
||||
: fG4Text(g4Text)
|
||||
, fG4TextOrig(g4Text)
|
||||
{
|
||||
fType = "G4TextModel";
|
||||
std::ostringstream oss;
|
||||
oss << "G4TextModel: \"" << fG4Text.GetText()
|
||||
@@ -50,6 +53,13 @@ G4TextModel::G4TextModel (const G4Text& g4Text): fG4Text(g4Text) {
|
||||
fGlobalDescription = fGlobalTag;
|
||||
}
|
||||
|
||||
void G4TextModel::SetTransformation (const G4Transform3D& transform)
|
||||
{
|
||||
fTransform = transform;
|
||||
fG4Text = fG4TextOrig;
|
||||
fG4Text.SetPosition(fG4Text.GetPosition()+transform.getTranslation());
|
||||
}
|
||||
|
||||
void G4TextModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler) {
|
||||
sceneHandler.BeginPrimitives ();
|
||||
sceneHandler.AddPrimitive (fG4Text);
|
||||
|
||||
@@ -61,12 +61,12 @@ G4VFieldModel::G4VFieldModel
|
||||
(const G4String& typeOfField, const G4String& symbol,
|
||||
const G4VisExtent& extentForField,
|
||||
const std::vector<G4PhysicalVolumesSearchScene::Findings>& pvFindings,
|
||||
G4int nDataPointsPerMaxHalfScene,
|
||||
G4int nDataPointsPerMaxHalfExtent,
|
||||
Representation representation,
|
||||
G4int arrow3DLineSegmentsPerCircle)
|
||||
: fExtentForField(extentForField)
|
||||
, fPVFindings(pvFindings)
|
||||
, fNDataPointsPerMaxHalfScene(nDataPointsPerMaxHalfScene)
|
||||
, fNDataPointsPerMaxHalfExtent(nDataPointsPerMaxHalfExtent)
|
||||
, fRepresentation(representation)
|
||||
, fArrow3DLineSegmentsPerCircle(arrow3DLineSegmentsPerCircle)
|
||||
, fTypeOfField(typeOfField)
|
||||
@@ -76,7 +76,7 @@ G4VFieldModel::G4VFieldModel
|
||||
fGlobalTag = fType;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << ':' << fNDataPointsPerMaxHalfScene
|
||||
oss << ':' << fNDataPointsPerMaxHalfExtent
|
||||
<< ':' << fArrow3DLineSegmentsPerCircle;
|
||||
if (fExtentForField == G4VisExtent::GetNullExtent()) {
|
||||
oss << " whole scene";
|
||||
@@ -137,13 +137,18 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
|
||||
}
|
||||
}
|
||||
|
||||
G4VisExtent sceneExtent = sceneHandler.GetExtent();
|
||||
const G4double& xMin = sceneExtent.GetXmin();
|
||||
const G4double& yMin = sceneExtent.GetYmin();
|
||||
const G4double& zMin = sceneExtent.GetZmin();
|
||||
const G4double& xMax = sceneExtent.GetXmax();
|
||||
const G4double& yMax = sceneExtent.GetYmax();
|
||||
const G4double& zMax = sceneExtent.GetZmax();
|
||||
G4VisExtent extent = sceneHandler.GetExtent();
|
||||
if (fExtentForField == G4VisExtent::GetNullExtent()) {
|
||||
extent = sceneHandler.GetExtent();
|
||||
} else {
|
||||
extent = fExtentForField;
|
||||
}
|
||||
const G4double& xMin = extent.GetXmin();
|
||||
const G4double& yMin = extent.GetYmin();
|
||||
const G4double& zMin = extent.GetZmin();
|
||||
const G4double& xMax = extent.GetXmax();
|
||||
const G4double& yMax = extent.GetYmax();
|
||||
const G4double& zMax = extent.GetZmax();
|
||||
const G4double xHalfScene = 0.5 * (xMax - xMin);
|
||||
const G4double yHalfScene = 0.5 * (yMax - yMin);
|
||||
const G4double zHalfScene = 0.5 * (zMax - zMin);
|
||||
@@ -158,7 +163,7 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
|
||||
}
|
||||
|
||||
// Constants
|
||||
const G4double interval = maxHalfScene / fNDataPointsPerMaxHalfScene;
|
||||
const G4double interval = maxHalfScene / fNDataPointsPerMaxHalfExtent;
|
||||
const G4int nDataPointsPerXHalfScene = G4int(xHalfScene / interval);
|
||||
const G4int nDataPointsPerYHalfScene = G4int(yHalfScene / interval);
|
||||
const G4int nDataPointsPerZHalfScene = G4int(zHalfScene / interval);
|
||||
@@ -189,15 +194,6 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
|
||||
|
||||
G4ThreeVector pos(x,y,z);
|
||||
|
||||
// Check if point is in extent for field
|
||||
if (fExtentForField != G4VisExtent::GetNullExtent()) {
|
||||
const auto& ext = fExtentForField; // Alias
|
||||
if (x < ext.GetXmin() || x > ext.GetXmax() ||
|
||||
y < ext.GetYmin() || y > ext.GetYmax() ||
|
||||
z < ext.GetZmin() || z > ext.GetZmax())
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if point is in findings
|
||||
if (!fPVFindings.empty()) {
|
||||
G4bool isInPV = false;
|
||||
|
||||
@@ -62,6 +62,10 @@ const G4VisExtent& G4VModel::GetTransformedExtent () const {
|
||||
return transformedExtent;
|
||||
}
|
||||
|
||||
void G4VModel::SetTransformation (const G4Transform3D& transform) {
|
||||
fTransform = transform;
|
||||
}
|
||||
|
||||
G4bool G4VModel::Validate (G4bool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user