Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Module : G4modeling
|
||||
# Package: Geant4.src.G4visualization.G4modeling
|
||||
#------------------------------------------------------------------------------
|
||||
# - G4modeling category build
|
||||
|
||||
geant4_global_library_target(COMPONENTS sources.cmake)
|
||||
|
||||
@@ -19,12 +19,83 @@ committal in the CVS repository !
|
||||
History file for visualization/modeling
|
||||
---------------------------------------
|
||||
|
||||
15 June 2021 John Allison (modeling-V10-07-10)
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
o Move fFullPVPath.push_back earlier - fixes vis touchables bug.
|
||||
|
||||
07 June 2021 John Allison (modeling-V10-07-09)
|
||||
- Requires greps-V10-07-07 (new method AddCompound (const G4Mesh&...)).
|
||||
- Introduce G4Mesh, a light class that encapsulates and validates a
|
||||
nested parameterisation, which we call a "mesh". If a valid mesh
|
||||
cannot be created out of this G4VPhysicalVolume* it will
|
||||
have a type "invalid". Then, usually, it may simply be destroyed.
|
||||
The overhead of an invalid attempt is expected to be small - all the
|
||||
same it should only be invoked if the user specifies mesh rendering.
|
||||
- G4PseudoScene....
|
||||
o Implement new method AddCompound (const G4Mesh&
|
||||
- G4ModelingParameters: Add data members and access functions:
|
||||
G4bool fSpecialMeshRendering; // Request special rendering
|
||||
std::vector<PVNameCopyNo> fSpecialMeshVolumes; // If empty, all meshes.
|
||||
- G4PhysicalVolumeModel.hh:
|
||||
o Change the default for the "drawn" flag to "true" (the more usual
|
||||
case and therefore more efficient) in the nested class
|
||||
G4PhysicalVolumeNodeID.
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
o Add code for special mesh rendering, under control of user flag. If
|
||||
flag is set by the above commands, and if a volume is a "mesh" (a
|
||||
container for a nested parameterisation), invoke new method
|
||||
AddCompound (const G4Mesh&).
|
||||
|
||||
28 May 2021 Ben Morgan (modeling-V10-07-08)
|
||||
- Migrate to modular CMake build
|
||||
|
||||
27 May 2021 John Allison (modeling-V10-07-07)
|
||||
- Minor fix to "current tag" ('.' changed to ':').
|
||||
|
||||
24 May 2021 John Allison (modeling-V10-07-06)
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
o For the resultant of clipping, set the vis attributes of the original.
|
||||
|
||||
11 May 2021 John Allison (modeling-V10-07-05)
|
||||
- G4VModel:
|
||||
o Make SetTransform virtual.
|
||||
- G4ArrowModel, G4AxesModel and G4TextModel:
|
||||
o Implement SetTransform.
|
||||
o Take care to apply to original model. For example, if SetTransform is
|
||||
called more than once it must apply to the original.
|
||||
|
||||
20 April 2021 John Allison (modeling-V10-07-04)
|
||||
- G4PseudoScene::ProcessVolume: Add G4Exception.
|
||||
|
||||
26 March 2021 John Allison (modeling-V10-07-03)
|
||||
- G4PhysicalVolumesSearchScene:
|
||||
o Allow user to limit the depth of descent during a geometry tree search.
|
||||
|
||||
12 March 2021 John Allison (modeling-V10-07-02)
|
||||
- G4PhysicalVolumeModel:
|
||||
o If opacity (alpha) == 0 (completely transparent), treat same
|
||||
as pVisAttribs->IsVisible(). Thus:
|
||||
G4bool markedVisible
|
||||
= pVisAttribs->IsVisible() && pVisAttribs->GetColour().GetAlpha() > 0;
|
||||
|
||||
02 January 2021 John Allison (modeling-V10-07-01)
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
o Simplify validation. The old way sometimes consumes much CPU.
|
||||
|
||||
29 December 2020 John Allison (modeling-V10-07-00)
|
||||
- G4VFieldModel: Change concept of choice of data points:
|
||||
o fNDataPointsPerMaxHalfScene becomes fNDataPointsPerMaxHalfExtent.
|
||||
o Hitherto, this model simply checked that a data point was within the
|
||||
extent. Now it uses the extent to determine the datapoint spacing.
|
||||
o Note: If fExtentForField is null, the used extent is that of the
|
||||
current scene. Otherwise it uses that supplied by the user.
|
||||
|
||||
20 October 2020 Jonathan Madsen (modeling-V10-06-05)
|
||||
- Implemented G4RunManagerFactory::GetMasterRunManager()
|
||||
|
||||
18 September 2020 John Allison (modeling-V10-06-04)
|
||||
- Part of vis-V10-06-07.
|
||||
- G4PhysicalVlumeModel.cc:
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
o Pick up default vis attributes.
|
||||
o Improve operator<< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID
|
||||
|
||||
|
||||
@@ -53,9 +53,12 @@ public: // With description
|
||||
G4double width, const G4Colour& colour,
|
||||
const G4String& description = "",
|
||||
G4int lineSegmentsPerCircle = 6);
|
||||
|
||||
virtual ~G4ArrowModel ();
|
||||
|
||||
virtual void DescribeYourselfTo (G4VGraphicsScene&);
|
||||
void SetTransformation (const G4Transform3D& transform) override;
|
||||
|
||||
void DescribeYourselfTo (G4VGraphicsScene&) override;
|
||||
// The main task of a model is to describe itself to the graphics scene.
|
||||
|
||||
private:
|
||||
@@ -66,6 +69,9 @@ private:
|
||||
|
||||
G4Polyhedron* fpShaftPolyhedron;
|
||||
G4Polyhedron* fpHeadPolyhedron;
|
||||
|
||||
G4Polyhedron* fpShaftPolyhedronOrig;
|
||||
G4Polyhedron* fpHeadPolyhedronOrig;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,7 +56,9 @@ public: // With description
|
||||
|
||||
virtual ~G4AxesModel ();
|
||||
|
||||
virtual void DescribeYourselfTo (G4VGraphicsScene&);
|
||||
void SetTransformation (const G4Transform3D& transform) override;
|
||||
|
||||
void DescribeYourselfTo (G4VGraphicsScene&) override;
|
||||
// The main task of a model is to describe itself to the graphics scene.
|
||||
|
||||
private:
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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
|
||||
//
|
||||
// Class Description:
|
||||
// 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.
|
||||
// Class Description - End:
|
||||
|
||||
#ifndef G4MESH_HH
|
||||
#define G4MESH_HH
|
||||
|
||||
#include "G4Transform3D.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
|
||||
class G4Mesh
|
||||
{
|
||||
public: // With description
|
||||
enum MeshType
|
||||
{
|
||||
invalid,
|
||||
rectangle,
|
||||
cylinder,
|
||||
sphere
|
||||
};
|
||||
|
||||
G4Mesh(G4VPhysicalVolume* containerVolume, const G4Transform3D&);
|
||||
virtual ~G4Mesh();
|
||||
|
||||
const std::map<G4int,G4String>& GetEnumMap() const { return fEnumMap; }
|
||||
G4VPhysicalVolume* GetContainerVolume() const { return fpContainerVolume; }
|
||||
MeshType GetMeshType() const { return fMeshType; }
|
||||
G4int GetMeshDepth() const { return fMeshDepth; }
|
||||
const G4Transform3D& GetTransform() const { return fTransform; }
|
||||
|
||||
private:
|
||||
static std::map<G4int,G4String> fEnumMap;
|
||||
G4VPhysicalVolume* fpContainerVolume;
|
||||
MeshType fMeshType;
|
||||
G4int fMeshDepth;
|
||||
G4Transform3D fTransform;
|
||||
};
|
||||
|
||||
std::ostream& operator << (std::ostream& os, const G4Mesh& mesh);
|
||||
|
||||
#endif
|
||||
@@ -177,6 +177,8 @@ public: // With description
|
||||
G4DisplacedSolid* GetCutawaySolid () const;
|
||||
const G4Event* GetEvent () const;
|
||||
const std::vector<VisAttributesModifier>& GetVisAttributesModifiers() const;
|
||||
G4bool IsSpecialMeshRendering () const;
|
||||
const std::vector<PVNameCopyNo>& GetSpecialMeshVolumes() const;
|
||||
|
||||
// Set functions...
|
||||
void SetWarning (G4bool);
|
||||
@@ -197,6 +199,8 @@ public: // With description
|
||||
void SetCutawaySolid (G4DisplacedSolid* pCutawaySolid);
|
||||
void SetEvent (const G4Event* pEvent);
|
||||
void SetVisAttributesModifiers(const std::vector<VisAttributesModifier>&);
|
||||
void SetSpecialMeshRendering (G4bool);
|
||||
void SetSpecialMeshVolumes (const std::vector<PVNameCopyNo>&);
|
||||
|
||||
friend std::ostream& operator <<
|
||||
(std::ostream& os, const G4ModelingParameters&);
|
||||
@@ -233,6 +237,8 @@ private:
|
||||
G4DisplacedSolid* fpCutawaySolid; // For generic cutaways.
|
||||
const G4Event* fpEvent; // Event being processed.
|
||||
std::vector<VisAttributesModifier> fVisAttributesModifiers;
|
||||
G4bool fSpecialMeshRendering; // Request special rendering of parameterised volumes
|
||||
std::vector<PVNameCopyNo> fSpecialMeshVolumes; // If empty, all meshes.
|
||||
};
|
||||
|
||||
std::ostream& operator <<
|
||||
|
||||
@@ -105,6 +105,13 @@ G4ModelingParameters::GetVisAttributesModifiers() const {
|
||||
return fVisAttributesModifiers;
|
||||
}
|
||||
|
||||
inline G4bool G4ModelingParameters::IsSpecialMeshRendering () const
|
||||
{return fSpecialMeshRendering;}
|
||||
|
||||
inline const std::vector<G4ModelingParameters::PVNameCopyNo>&
|
||||
G4ModelingParameters::GetSpecialMeshVolumes() const
|
||||
{return fSpecialMeshVolumes;}
|
||||
|
||||
inline void G4ModelingParameters::SetWarning (G4bool value) {
|
||||
fWarning = value;
|
||||
}
|
||||
@@ -165,3 +172,10 @@ inline void G4ModelingParameters::SetVisAttributesModifiers
|
||||
(const std::vector<G4ModelingParameters::VisAttributesModifier>& vams) {
|
||||
fVisAttributesModifiers = vams;
|
||||
}
|
||||
|
||||
inline void G4ModelingParameters::SetSpecialMeshRendering (G4bool smr)
|
||||
{fSpecialMeshRendering = smr;}
|
||||
|
||||
inline void G4ModelingParameters::SetSpecialMeshVolumes
|
||||
(const std::vector<G4ModelingParameters::PVNameCopyNo>& smvs)
|
||||
{fSpecialMeshVolumes = smvs;}
|
||||
|
||||
@@ -95,7 +95,7 @@ public: // With description
|
||||
G4int iCopyNo = 0,
|
||||
G4int depth = 0,
|
||||
const G4Transform3D& transform = G4Transform3D(),
|
||||
G4bool drawn = false):
|
||||
G4bool drawn = true):
|
||||
fpPV(pPV),
|
||||
fCopyNo(iCopyNo),
|
||||
fNonCulledDepth(depth),
|
||||
|
||||
@@ -49,7 +49,9 @@ public:
|
||||
G4PhysicalVolumesSearchScene
|
||||
(G4PhysicalVolumeModel* pSearchVolumeModel, // usually a world
|
||||
const G4String& requiredPhysicalVolumeName,
|
||||
G4int requiredCopyNo = -1); // -1 means any copy no
|
||||
G4int requiredCopyNo = -1, // -1 means any copy no
|
||||
// Don't continue beyond requiredContinuation once found
|
||||
G4int requiredContinuation = G4PhysicalVolumeModel::UNLIMITED);
|
||||
|
||||
virtual ~G4PhysicalVolumesSearchScene () {}
|
||||
|
||||
@@ -108,6 +110,7 @@ private:
|
||||
const G4PhysicalVolumeModel* fpSearchVolumesModel;
|
||||
Matcher fMatcher;
|
||||
G4int fRequiredCopyNo;
|
||||
G4int fRequiredContinuation;
|
||||
std::vector<Findings> fFindings;
|
||||
};
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ public:
|
||||
void AddCompound (const G4VDigi&) {}
|
||||
void AddCompound (const G4THitsMap<G4double>&) {}
|
||||
void AddCompound (const G4THitsMap<G4StatDouble>&) {}
|
||||
void AddCompound (const G4Mesh&) {}
|
||||
// Primitives
|
||||
void BeginPrimitives (const G4Transform3D&) {}
|
||||
void EndPrimitives () {}
|
||||
@@ -95,7 +96,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ProcessVolume (const G4VSolid&) = 0;
|
||||
virtual void ProcessVolume (const G4VSolid&);
|
||||
const G4Transform3D* fpCurrentObjectTransformation;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ public: // With description
|
||||
|
||||
virtual ~G4TextModel ();
|
||||
|
||||
virtual void DescribeYourselfTo (G4VGraphicsScene&);
|
||||
void SetTransformation (const G4Transform3D& transform) override;
|
||||
|
||||
void DescribeYourselfTo (G4VGraphicsScene&) override;
|
||||
// The main task of a model is to describe itself to the graphics scene.
|
||||
|
||||
private:
|
||||
@@ -60,6 +62,7 @@ private:
|
||||
G4TextModel& operator = (const G4TextModel&);
|
||||
|
||||
G4Text fG4Text;
|
||||
G4Text fG4TextOrig;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ private:
|
||||
// If non-empty, use fExtentForField alone for sampling, but only
|
||||
// draw if sampling point is in the specified physical volume(s).
|
||||
|
||||
G4int fNDataPointsPerMaxHalfScene;
|
||||
// No. of data points sampled per maximum half scene.
|
||||
G4int fNDataPointsPerMaxHalfExtent;
|
||||
// No. of data points sampled per maximum half extent.
|
||||
// Note that total number of sampling points can be as high as
|
||||
// (2*n+1)^3, which can get very big. However, fields are usually
|
||||
// confined to only parts of the scene, so this may not be a problem.
|
||||
|
||||
@@ -36,6 +36,15 @@
|
||||
// to a scene handler. A scene is a collection of models.
|
||||
// A special case is made for G4PhysicalVolumeModel - a non-null pointer
|
||||
// is to be returned by G4PhysicalVolumeModel::GetG4PhysicalVolumeModel().
|
||||
//
|
||||
// The model must take care of the required transformation itself - thus the
|
||||
// models components should be transformed before delivering to the scene
|
||||
// handler. The model could receive the transformation in its constructor,
|
||||
// e.g., G4PhysicalVolumeModel, or handle it in the model's SetTransformation,
|
||||
// e.g., in G4AxesModel (relatively simple) or in G4ArrowModel (quite
|
||||
// complicated). This avoids having to transform the components perhaps
|
||||
// multiple times. The reasons for this are mainly to do with how we implement
|
||||
// G4PhysicalVolumeModel
|
||||
|
||||
#ifndef G4VMODEL_HH
|
||||
#define G4VMODEL_HH
|
||||
@@ -100,7 +109,7 @@ public: // With description
|
||||
void SetType (const G4String&);
|
||||
void SetGlobalDescription (const G4String&);
|
||||
void SetGlobalTag (const G4String&);
|
||||
void SetTransformation (const G4Transform3D&);
|
||||
virtual void SetTransformation (const G4Transform3D&);
|
||||
|
||||
virtual G4bool Validate (G4bool warn = true);
|
||||
// Validate, but allow internal changes (hence non-const function).
|
||||
|
||||
@@ -72,7 +72,3 @@ inline void G4VModel::SetType (const G4String& type) {
|
||||
inline void G4VModel::SetGlobalTag (const G4String& tag) {
|
||||
fGlobalTag = tag;
|
||||
}
|
||||
|
||||
inline void G4VModel::SetTransformation (const G4Transform3D& transform) {
|
||||
fTransform = transform;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Module : G4modeling
|
||||
# Package: Geant4.src.G4visualization.G4modeling
|
||||
#------------------------------------------------------------------------------
|
||||
# - G4modeling module build definition
|
||||
|
||||
#
|
||||
# Define the Geant4 Module.
|
||||
#
|
||||
geant4_define_module(NAME G4modeling
|
||||
HEADERS
|
||||
geant4_add_module(G4modeling
|
||||
PUBLIC_HEADERS
|
||||
G4ArrowModel.hh
|
||||
G4AttFilterUtils.hh
|
||||
G4AttValueFilterT.hh
|
||||
@@ -24,6 +19,7 @@ geant4_define_module(NAME G4modeling
|
||||
G4HitsModel.hh
|
||||
G4LogicalVolumeModel.hh
|
||||
G4MagneticFieldModel.hh
|
||||
G4Mesh.hh
|
||||
G4ModelApplyCommandsT.hh
|
||||
G4ModelColourMap.hh
|
||||
G4ModelCommandUtils.hh
|
||||
@@ -79,6 +75,7 @@ geant4_define_module(NAME G4modeling
|
||||
G4HitsModel.cc
|
||||
G4LogicalVolumeModel.cc
|
||||
G4MagneticFieldModel.cc
|
||||
G4Mesh.cc
|
||||
G4ModelingParameters.cc
|
||||
G4NullModel.cc
|
||||
G4PSHitsModel.cc
|
||||
@@ -86,6 +83,7 @@ geant4_define_module(NAME G4modeling
|
||||
G4PhysicalVolumeModel.cc
|
||||
G4PhysicalVolumeSearchScene.cc
|
||||
G4PhysicalVolumesSearchScene.cc
|
||||
G4PseudoScene.cc
|
||||
G4ScaleModel.cc
|
||||
G4TextModel.cc
|
||||
G4TouchablePropertiesScene.cc
|
||||
@@ -107,44 +105,29 @@ geant4_define_module(NAME G4modeling
|
||||
G4VFieldModel.cc
|
||||
G4VModel.cc
|
||||
G4VTrajectoryModel.cc
|
||||
G4VisTrajContext.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4csg
|
||||
G4detector
|
||||
G4detutils
|
||||
G4digits
|
||||
G4run
|
||||
G4tasking
|
||||
G4event
|
||||
G4geomBoolean
|
||||
G4geometrymng
|
||||
G4globman
|
||||
G4graphics_reps
|
||||
G4hepnumerics
|
||||
G4hits
|
||||
G4intercoms
|
||||
G4materials
|
||||
G4navigation
|
||||
G4partman
|
||||
G4procman
|
||||
G4specsolids
|
||||
G4track
|
||||
G4tracking
|
||||
G4volumes
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4digits_hits
|
||||
G4run
|
||||
G4tasking
|
||||
G4event
|
||||
G4geometry
|
||||
G4global
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4materials
|
||||
G4particles
|
||||
G4processes
|
||||
G4track
|
||||
G4tracking
|
||||
)
|
||||
G4VisTrajContext.cc)
|
||||
|
||||
# List any source specific properties here
|
||||
geant4_module_link_libraries(G4modeling
|
||||
PUBLIC
|
||||
G4graphics_reps
|
||||
G4csg
|
||||
G4geometrymng
|
||||
G4hepgeometry
|
||||
G4specsolids
|
||||
G4hepnumerics
|
||||
G4intercoms
|
||||
G4globman
|
||||
G4digits
|
||||
G4hits
|
||||
G4tracking
|
||||
PRIVATE
|
||||
G4geomBoolean
|
||||
G4navigation
|
||||
G4event
|
||||
G4magneticfield
|
||||
G4materials
|
||||
G4volumes
|
||||
G4run
|
||||
G4tasking
|
||||
G4detutils
|
||||
G4detector)
|
||||
|
||||
@@ -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