Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
-45
View File
@@ -1,45 +0,0 @@
# --------------------------------------------------------------
# GNUmakefile for modeling library. John Allison, 31/12/1997.
# --------------------------------------------------------------
name := G4modeling
ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/global/HEPNumerics/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/geometry/navigation/include
CPPFLAGS += -I$(G4BASE)/geometry/magneticfield/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/specific/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/Boolean/include
CPPFLAGS += -I$(G4BASE)/materials/include
CPPFLAGS += -I$(G4BASE)/global/HEPRandom/include
CPPFLAGS += -I$(G4BASE)/processes/management/include
CPPFLAGS += -I$(G4BASE)/particles/management/include
CPPFLAGS += -I$(G4BASE)/run/include
CPPFLAGS += -I$(G4BASE)/tasking/include
CPPFLAGS += -I$(G4BASE)/event/include
CPPFLAGS += -I$(G4BASE)/digits_hits/utils/include
CPPFLAGS += -I$(G4BASE)/digits_hits/hits/include
CPPFLAGS += -I$(G4BASE)/digits_hits/digits/include
CPPFLAGS += -I$(G4BASE)/digits_hits/detector/include
CPPFLAGS += -I$(G4BASE)/tracking/include
CPPFLAGS += -I$(G4BASE)/track/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
include $(G4INSTALL)/config/common.gmk
+30 -1
View File
@@ -6,7 +6,36 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2022-12-13 John Allison (modeling-V11-00-15)
## 2023-05-30 John Allison (modeling-V11-01-05)
- G4PhysicalVolumeModel.cc: Fix Coverity warnings.
## 2023-04-24 John Allison (modeling-V11-01-04)
- Coworks: visman-V11-01-09.
- These two tags implement "generic cutaways"...finally...after 20 years!!!
- See extensive description in visualization/management/History.
- G4PhysicalVolumeModel.cc:
- DescribeSolid: Improve tests for invalid Boolean solid in code for
section and cutaway.
- Algorithms based on G4SubtractionSolid::BoundingLimits and
G4IntersectionSolid::BoundingLimits by Evgueni Tcherniaev.
## 2023-04-03 John Allison (modeling-V11-01-03)
- Bug fix: Initialise fFullPVPath.
## 2023-03-28 John Allison (modeling-V11-01-02)
- Add static utility G4PhysicalVolumeModel::GetPVNamePathString.
## 2023-02-12 John Allison (modeling-V11-01-01)
- G4VModel.hh
- Remove unnecessary reference to G4PhysicalVolumeModel.
- G4CallbackModel:
- Correct the description in the comments.
- G4PseudoScene:
- Add G4VisAttributes.
- This was always available, but never previously made onward
available to sub-classes.
## 2022-12-13 John Allison (modeling-V11-01-00)
- G4TextModel: Fix transform.
- The rotation part of the transform was being ignored. This impacted
the implementation of /vis/scene/add/localAxes.
@@ -38,14 +38,14 @@
// screen or remake a graphical database whenever required. The
// function class must contain:
//
// void operator()(G4VGraphicsScene&, const G4Transform3D&)
// void operator()(G4VGraphicsScene&,const G4ModelingParameters*)
//
// A base class G4VUserVisAction is provided in the visualisation
// category. A G4CallbackModel is made by instantiating this template
// with a pointer to the function object. The G4VisManager does this
// for the user if he/she registers it (SetUserAction) and issues the
// for the user if he/she registers it (Register*UserVisAction) and issues the
// command /vis/scene/add/userAction. See the User Guide for
// Application Developers, Section 8.8.7 and 8.8.8.
// Application Developers.
#ifndef G4CALLBACKMODEL_HH
#define G4CALLBACKMODEL_HH
@@ -62,6 +62,11 @@ public: // With description
cloud // Draw as a cloud of points
};
enum CutawayMode {
cutawayUnion, // Union (addition) of result of each cutaway plane.
cutawayIntersection // Intersection (multiplication).
};
// enums and nested class for communicating a modification to the vis
// attributes for a specfic touchable defined by PVNameCopyNoPath.
enum VisAttributesSignifier {
@@ -174,6 +179,7 @@ public: // With description
const G4Point3D& GetExplodeCentre () const;
G4int GetNoOfSides () const;
G4DisplacedSolid* GetSectionSolid () const;
CutawayMode GetCutawayMode () const;
G4DisplacedSolid* GetCutawaySolid () const;
const G4Event* GetEvent () const;
const std::vector<VisAttributesModifier>& GetVisAttributesModifiers() const;
@@ -196,6 +202,7 @@ public: // With description
void SetExplodeCentre (const G4Point3D& explodeCentre);
G4int SetNoOfSides (G4int); // Returns actual number set.
void SetSectionSolid (G4DisplacedSolid* pSectionSolid);
void SetCutawayMode (CutawayMode);
void SetCutawaySolid (G4DisplacedSolid* pCutawaySolid);
void SetEvent (const G4Event* pEvent);
void SetVisAttributesModifiers(const std::vector<VisAttributesModifier>&);
@@ -234,6 +241,7 @@ private:
G4Point3D fExplodeCentre; // ...about this centre.
G4int fNoOfSides; // ...if polygon approximates circle.
G4DisplacedSolid* fpSectionSolid; // For generic section (DCUT).
CutawayMode fCutawayMode; // Cutaway mode.
G4DisplacedSolid* fpCutawaySolid; // For generic cutaways.
const G4Event* fpEvent; // Event being processed.
std::vector<VisAttributesModifier> fVisAttributesModifiers;
@@ -94,6 +94,9 @@ inline G4int G4ModelingParameters::GetNoOfSides () const {
inline G4DisplacedSolid* G4ModelingParameters::GetSectionSolid () const
{return fpSectionSolid;}
inline G4ModelingParameters::CutawayMode G4ModelingParameters::GetCutawayMode () const
{ return fCutawayMode;}
inline G4DisplacedSolid* G4ModelingParameters::GetCutawaySolid () const
{return fpCutawaySolid;}
@@ -164,6 +167,11 @@ inline void G4ModelingParameters::SetExplodeCentre
fExplodeCentre = explodeCentre;
}
inline void G4ModelingParameters::SetCutawayMode
(G4ModelingParameters::CutawayMode cutawayMode) {
fCutawayMode = cutawayMode;
}
inline void G4ModelingParameters::SetEvent(const G4Event* pEvent) {
fpEvent = pEvent;
}
@@ -223,7 +223,11 @@ public: // With description
static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath
(const std::vector<G4PhysicalVolumeNodeID>&);
// Converts
// Converts to PVNameCopyNoPath
static G4String GetPVNamePathString(const std::vector<G4PhysicalVolumeNodeID>&);
// Converts to path string, e.g., " World 0 Envelope 0 Shape1 0".
// Note leading space character.
const std::map<G4String,G4AttDef>* GetAttDefs() const;
// Attribute definitions for current solid.
@@ -304,6 +308,7 @@ protected:
mutable G4bool fCurtailDescent;// Can be set to curtail descent.
G4VSolid* fpClippingSolid;
ClippingMode fClippingMode;
G4int fNClippers; // No of clipping/cutting solids - only 0 or 1 allowed
private:
@@ -51,11 +51,13 @@ class G4PseudoScene: public G4VGraphicsScene {
public:
G4PseudoScene(): fpCurrentObjectTransformation(0) {}
virtual ~G4PseudoScene () {}
G4PseudoScene() = default;
virtual ~G4PseudoScene() = default;
void PreAddSolid (const G4Transform3D& objectTransformation,
const G4VisAttributes&)
{fpCurrentObjectTransformation = &objectTransformation;}
const G4VisAttributes& visAttributes) {
fpCurrentObjectTransformation = &objectTransformation;
fpVisAttributes = &visAttributes;
}
void PostAddSolid () {}
// From geometry/solids/CSG
void AddSolid (const G4Box& solid) {ProcessVolume (solid);}
@@ -98,7 +100,8 @@ public:
protected:
virtual void ProcessVolume (const G4VSolid&);
const G4Transform3D* fpCurrentObjectTransformation;
const G4Transform3D* fpCurrentObjectTransformation = nullptr;
const G4VisAttributes* fpVisAttributes = nullptr;
};
#endif
@@ -34,8 +34,6 @@
// graphics-system-indepedent description of a Geant4 component.
// The key fuctionality of a model is to know how to describe itself
// 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().
#ifndef G4VMODEL_HH
#define G4VMODEL_HH
@@ -46,8 +44,6 @@
class G4VGraphicsScene;
class G4ModelingParameters;
class G4PhysicalVolumeModel; // Special case - see above.
class G4VModel {
public: // With description
@@ -57,6 +57,7 @@ G4ModelingParameters::G4ModelingParameters ():
fExplodeFactor (1.),
fNoOfSides (24),
fpSectionSolid (0),
fCutawayMode (cutawayUnion),
fpCutawaySolid (0),
fpEvent (0),
fSpecialMeshRendering (false)
@@ -85,6 +86,7 @@ G4ModelingParameters::G4ModelingParameters
fExplodeFactor (1.),
fNoOfSides (noOfSides),
fpSectionSolid (0),
fCutawayMode (cutawayUnion),
fpCutawaySolid (0),
fpEvent (0),
fSpecialMeshRendering (false)
@@ -226,6 +228,10 @@ std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp)
if (!mp.fpSectionSolid) os << "non-";
os << "null";
os << "\n Cutaway mode: ";
if (mp.GetCutawayMode() == G4ModelingParameters::cutawayUnion) os << "union";
else if (mp.GetCutawayMode() == G4ModelingParameters::cutawayIntersection) os << "intersection";
os << "\n Cutaway (DCUT) shape (G4DisplacedSolid) pointer: ";
if (!mp.fpCutawaySolid) os << "non-";
os << "null";
@@ -274,6 +280,7 @@ G4bool G4ModelingParameters::operator !=
(fExplodeCentre != mp.fExplodeCentre) ||
(fNoOfSides != mp.fNoOfSides) ||
(fpSectionSolid != mp.fpSectionSolid) ||
(fCutawayMode != mp.fCutawayMode) ||
(fpCutawaySolid != mp.fpCutawaySolid) ||
(fpEvent != mp.fpEvent) ||
(fSpecialMeshRendering != mp.fSpecialMeshRendering)
@@ -81,10 +81,12 @@ G4PhysicalVolumeModel::G4PhysicalVolumeModel
, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
, fCurrentTransform (modelTransform)
, fBaseFullPVPath (baseFullPVPath)
, fFullPVPath (fBaseFullPVPath)
, fAbort (false)
, fCurtailDescent (false)
, fpClippingSolid (0)
, fClippingMode (subtraction)
, fNClippers (0)
{
fType = "G4PhysicalVolumeModel";
@@ -132,6 +134,16 @@ G4ModelingParameters::PVNameCopyNoPath G4PhysicalVolumeModel::GetPVNameCopyNoPat
return PVNameCopyNoPath;
}
G4String G4PhysicalVolumeModel::GetPVNamePathString
(const std::vector<G4PhysicalVolumeNodeID>& path)
// Converts to path string, e.g., " World 0 Envelope 0 Shape1 0".
// Note leading space character.
{
std::ostringstream oss;
oss << path;
return oss.str();
}
void G4PhysicalVolumeModel::CalculateExtent ()
{
// To handle paramaterisations, set copy number and compute dimensions
@@ -181,13 +193,34 @@ void G4PhysicalVolumeModel::CalculateExtent ()
void G4PhysicalVolumeModel::DescribeYourselfTo
(G4VGraphicsScene& sceneHandler)
{
if (!fpTopPV) G4Exception
if (!fpTopPV) {
G4Exception
("G4PhysicalVolumeModel::DescribeYourselfTo",
"modeling0012", FatalException, "No model.");
return; // Should never reach here, but keeps Coverity happy.
}
if (!fpMP) G4Exception
if (!fpMP) {
G4Exception
("G4PhysicalVolumeModel::DescribeYourselfTo",
"modeling0003", FatalException, "No modeling parameters.");
"modeling0013", FatalException, "No modeling parameters.");
return; // Should never reach here, but keeps Coverity happy.
}
fNClippers = 0;
G4DisplacedSolid* pSectionSolid = fpMP->GetSectionSolid();
G4DisplacedSolid* pCutawaySolid = fpMP->GetCutawaySolid();
if (fpClippingSolid) fNClippers++;
if (pSectionSolid) fNClippers++;
if (pCutawaySolid) fNClippers++;
if (fNClippers > 1) {
G4ExceptionDescription ed;
ed << "More than one solid cutter/clipper:";
if (fpClippingSolid) ed << "\nclipper in force";
if (pSectionSolid) ed << "\nsectioner in force";
if (pCutawaySolid) ed << "\ncutaway in force";
G4Exception("G4PhysicalVolumeModel::DescribeSolid", "modeling0016", JustWarning, ed);
}
G4Transform3D startingTransformation = fTransform;
@@ -736,6 +769,49 @@ void G4PhysicalVolumeModel::DescribeAndDescend
}
}
namespace
{
G4bool SubtractionBoundingLimits(const G4VSolid* target)
{
// Algorithm from G4SubtractionSolid::BoundingLimits
// Since it is unclear how the shape of the first solid will be changed
// after subtraction, just return its original bounding box.
G4ThreeVector pMin, pMax;
const auto& pSolA = target;
pSolA->BoundingLimits(pMin,pMax);
// Check correctness of the bounding box
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z()) {
// Bad bounding box (min >= max)
// This signifies a subtraction of non-intersecting volumes
return false;
}
return true;
}
G4bool IntersectionBoundingLimits(const G4VSolid* target, const G4DisplacedSolid* intersector)
{
// Algorithm from G4IntersectionSolid::BoundingLimits
G4ThreeVector pMin, pMax;
G4ThreeVector minA,maxA, minB,maxB;
const auto& pSolA = target;
const auto& pSolB = intersector;
pSolA->BoundingLimits(minA,maxA);
pSolB->BoundingLimits(minB,maxB);
pMin.set(std::max(minA.x(),minB.x()),
std::max(minA.y(),minB.y()),
std::max(minA.z(),minB.z()));
pMax.set(std::min(maxA.x(),maxB.x()),
std::min(maxA.y(),maxB.y()),
std::min(maxA.z(),maxB.z()));
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z()) {
// Bad bounding box (min >= max)
// This signifies a subtraction of non-intersecting volumes
return false;
}
return true;
}
}
void G4PhysicalVolumeModel::DescribeSolid
(const G4Transform3D& theAT,
G4VSolid* pSol,
@@ -745,45 +821,65 @@ void G4PhysicalVolumeModel::DescribeSolid
G4DisplacedSolid* pSectionSolid = fpMP->GetSectionSolid();
G4DisplacedSolid* pCutawaySolid = fpMP->GetCutawaySolid();
if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
if (fNClippers <= 0 || fNClippers > 1) {
// Normal case - no clipping, etc. - or, illegally, more than one of those
sceneHandler.PreAddSolid (theAT, *pVisAttribs);
pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
sceneHandler.PostAddSolid ();
} else {
} else { // fNClippers == 1
G4VSolid* pResultantSolid = nullptr;
G4VSolid* pResultantSolid = nullptr;
G4DisplacedSolid* pDisplacedSolid = nullptr;
if (fpClippingSolid) {
pDisplacedSolid = new G4DisplacedSolid("clipper", fpClippingSolid, theAT.inverse());
switch (fClippingMode) {
default:
case subtraction:
pResultantSolid = new G4SubtractionSolid
("subtracted_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
if (SubtractionBoundingLimits(pSol)) {
pResultantSolid = new G4SubtractionSolid
("subtracted_clipped_solid", pSol, pDisplacedSolid);
}
break;
case intersection:
pResultantSolid = new G4IntersectionSolid
("intersected_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
pResultantSolid = new G4IntersectionSolid
("intersected_clipped_solid", pSol, pDisplacedSolid);
}
break;
}
} else if (pSectionSolid) {
pDisplacedSolid = new G4DisplacedSolid("intersector", pSectionSolid, theAT.inverse());
if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
pResultantSolid = new G4IntersectionSolid("sectioned_solid", pSol, pDisplacedSolid);
}
} else if (pCutawaySolid) {
pDisplacedSolid = new G4DisplacedSolid("cutaway", pCutawaySolid, theAT.inverse());
switch (fpMP->GetCutawayMode()) {
case G4ModelingParameters::cutawayUnion:
if (SubtractionBoundingLimits(pSol)) {
pResultantSolid = new G4SubtractionSolid("cutaway_solid", pSol, pDisplacedSolid);
}
break;
case G4ModelingParameters::cutawayIntersection:
if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
pResultantSolid = new G4IntersectionSolid("cutaway_solid", pSol, pDisplacedSolid);
}
break;
}
}
if (pSectionSolid) {
pResultantSolid = new G4IntersectionSolid
("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
if (pResultantSolid) {
sceneHandler.PreAddSolid (theAT, *pVisAttribs);
pResultantSolid -> DescribeYourselfTo (sceneHandler);
sceneHandler.PostAddSolid ();
}
if (pCutawaySolid) {
pResultantSolid = new G4SubtractionSolid
("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
}
sceneHandler.PreAddSolid (theAT, *pVisAttribs);
pResultantSolid -> DescribeYourselfTo (sceneHandler);
sceneHandler.PostAddSolid ();
delete pResultantSolid;
delete pDisplacedSolid;
}
}