Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
+2 -3
View File
@@ -1,4 +1,3 @@
# - G4visQt3D category build
geant4_global_library_target(COMPONENTS sources.cmake)
include(sources.cmake)
geant4_add_category(G4visQt3D MODULES G4visQt3D)
+55 -16
View File
@@ -1,23 +1,62 @@
-------------------------------------------------------------------
# Category visQt3D History
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
## 2022-04-06 John Allison (visQt3D-V11-00-07)
- Fix compiler warnings:
- G4Qt3DSceneHandler.hh: Add `using G4VSceneHandler::AddCompound` to
avoid warnings.
- G4Qt3DSceneHandler.cc: Change `world` to `wrld` to avoid warnings.
- `world` shadows an `enum` in `G4VSceneHandler`. Maybe a better solution
is to encapsulate the enum.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2022-05-03 Ben Morgan (visQt3D-V11-00-06)
- Preliminary build support for Qt5 and Qt6
## 2022-04-06 John Allison (visQt3D-V11-00-05)
- `G4Qt3DSceneHandler`:
- `void G4Qt3DSceneHandler::AddPrimitive (const G4Polymarker& polymarker)`:
- Update to current usage.
- `void G4Qt3DSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron)`:
- Comment out common line elimination - too expensive for a large
polyhedron.
- Maybe eliminate altogether in future?.
- Allow the graphics-reps utilities to optimise things like this.
- Use StandardSpecialMeshRendering(mesh).
- Of course, only if special mesh rendering is requested.
## 2022-03-05 John Allison (visQt3D-V11-00-04)
- G4Qt3DSceneHandler::AddCompound(const G4Mesh& mesh):
- For parameterised tetrahedron mesh, call default
G4VSceneHandler::DrawTetMeshAsDots(mesh).
- Tested on "ICRP145", a Geant4 application that we hope can become
a Geant4 advanced example, downloaded from the supplementary material
of Kim et al, ICRP, 2020. Adult mesh-type reference computational phantoms,
ICRP Publication 145, Ann. ICRP 49(3).
## 2022-01-28 Ben Morgan (visQt3D-V11-00-03)
- Replace `geant4_global_library_target` with direct file inclusion and
call to `geant4_add_category` to define library build from source modules.
## 2022-01-16 John Allison (visQt3D-V11-00-02)
- G4Qt3DViewer::wheelEvent:
- Re-program wheelEvent for perspective projection:
- Takes into account the extent of the scene.
## 2021-12-16 John Allison (visQt3D-V11-00-01)
- G4Qt3DSceneHandler.cc:
- AddCompound(const G4Mesh& mesh):
- Use base class utility G4VSceneHandler::Draw3DRectMeshAsDots(mesh);
## 2021-12-10 Ben Morgan (visQt3D-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
History file for visualization/Qt3D sub-category
-----------------------------------------------
12 November 2021 - Ben Morgan (visQt3D-V10-07-12)
- Retire G4VIS_... preprocessor symbols in toolkit build, only required
by obsolete GNUmake system
@@ -65,6 +65,7 @@ public:
void AddPrimitive(const G4Square&);
void AddPrimitive(const G4Polyhedron&);
using G4VSceneHandler::AddCompound;
void AddCompound(const G4Mesh&);
void ClearStore ();
+5 -5
View File
@@ -22,11 +22,11 @@ geant4_module_link_libraries(G4visQt3D
G4globman
G4hepgeometry
G4vis_management
Qt5::Gui
Qt5::Widgets
Qt5::3DCore
Qt5::3DExtras
Qt5::3DRender
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::3DCore
Qt${QT_VERSION_MAJOR}::3DExtras
Qt${QT_VERSION_MAJOR}::3DRender
PRIVATE
G4csg
G4graphics_reps
@@ -110,10 +110,10 @@ void G4Qt3DSceneHandler::EstablishG4Qt3DQEntities()
= transportationManager->GetWorldsIterator();
fpPhysicalVolumeObjects.resize(nWorlds);
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
G4VPhysicalVolume* world = (*iterWorld);
G4VPhysicalVolume* wrld = (*iterWorld);
auto entity = new G4Qt3DQEntity(fpPersistentObjects);
entity->setObjectName("G4Qt3DPORoot_"+QString(world->GetName()));
entity->SetPVNodeID(G4PhysicalVolumeModel::G4PhysicalVolumeNodeID(world));
entity->setObjectName("G4Qt3DPORoot_"+QString(wrld->GetName()));
entity->SetPVNodeID(G4PhysicalVolumeModel::G4PhysicalVolumeNodeID(wrld));
fpPhysicalVolumeObjects[i] = entity;
}
}
@@ -169,11 +169,11 @@ G4Qt3DQEntity* G4Qt3DSceneHandler::CreateNewNode()
}
// (Re-)establish pv path of root entity
G4Qt3DQEntity* world = fpPhysicalVolumeObjects[iWorld];
world->SetPVNodeID(fullPVPath[0]);
G4Qt3DQEntity* wrld = fpPhysicalVolumeObjects[iWorld];
wrld->SetPVNodeID(fullPVPath[0]);
// Create nodes as required
G4Qt3DQEntity* node = world;
G4Qt3DQEntity* node = wrld;
newNode = node;
const size_t depth = fullPVPath.size();
size_t iDepth = 1;
@@ -355,6 +355,9 @@ void G4Qt3DSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
fpVisAttribs = fpViewer->GetApplicableVisAttributes(polymarker.GetVisAttributes());
MarkerSizeType markerSizeType;
G4double markerSize = GetMarkerSize(polymarker, markerSizeType);
switch (polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:
@@ -427,13 +430,11 @@ void G4Qt3DSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
auto sphereMesh = new Qt3DExtras::QSphereMesh;
sphereMesh->setObjectName("sphereMesh");
G4double radius;
if (circle.GetSizeType() == G4VMarker::world ) {
radius =circle.GetWorldRadius();
} else { // Screen-size or none
G4double radius = markerSize/2.;
if (markerSizeType == G4VSceneHandler::screen ) {
// Not figured out how to do screen-size, so use scene extent
const G4double scale = 200.; // Roughly pixels per scene
radius = circle.GetScreenRadius()*fpScene->GetExtent().GetExtentRadius()/scale;
radius *= fpScene->GetExtent().GetExtentRadius()/scale;
}
sphereMesh->setRadius(radius);
// sphereMesh->setInstanceCount(polymarker.size()); // Not undertood instancing yet
@@ -461,13 +462,11 @@ void G4Qt3DSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
auto boxMesh = new Qt3DExtras::QCuboidMesh();
boxMesh->setObjectName("boxMesh");
G4double side;
if (square.GetSizeType() == G4VMarker::world ) {
side = square.GetWorldDiameter();
} else { // Screen-size or none
G4double side = markerSize;
if (markerSizeType == G4VSceneHandler::screen ) {
// Not figured out how to do screen-size, so use scene extent
const G4double scale = 200.; // Roughly pixles per scene
side = square.GetScreenDiameter()*fpScene->GetExtent().GetExtentRadius()/scale;
side *= fpScene->GetExtent().GetExtentRadius()/scale;
}
boxMesh->setXExtent(side);
boxMesh->setYExtent(side);
@@ -726,11 +725,14 @@ void G4Qt3DSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron)
typedef std::pair<G4Point3D,G4Point3D> Line;
std::vector<Line> lines;
auto insertIfNew = [&lines](const Line& newLine) {
for (const auto& line: lines) {
if ((newLine.first==line.first && newLine.second==line.second) ||
(newLine.first==line.second && newLine.second==line.first))
return;
}
// For a large polyhedron, eliminating lines like this is prohibitively
// expensive. Comment out for now, and maybe unwind altogether in future.
// Allow the graphics-reps utilities to optimise things like this.
// for (const auto& line: lines) {
// if ((newLine.first==line.first && newLine.second==line.second) ||
// (newLine.first==line.second && newLine.second==line.first))
// return;
// }
lines.push_back(newLine);
};
@@ -1052,115 +1054,7 @@ void G4Qt3DSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron)
void G4Qt3DSceneHandler::AddCompound(const G4Mesh& mesh)
{
// Special mesh rendering
// Limited to rectangular 3-deep meshes
if (mesh.GetMeshType() != G4Mesh::rectangle ||
mesh.GetMeshDepth() != 3) {
G4VSceneHandler::AddCompound(mesh);
}
auto container = mesh.GetContainerVolume();
static G4bool firstPrint = true;
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
G4bool print = firstPrint && verbosity >= G4VisManager::confirmations;
if (print) {
G4cout
<< "Special case drawing of G4VNestedParameterisation in G4OpenGLSceneHandler"
<< '\n' << mesh
<< G4endl;
}
// Instantiate a temporary G4PhysicalVolumeModel
G4ModelingParameters tmpMP;
tmpMP.SetCulling(true); // This avoids drawing transparent...
tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
const G4bool useFullExtent = true; // To avoid calculating the extent
G4PhysicalVolumeModel tmpPVModel
(container,
G4PhysicalVolumeModel::UNLIMITED,
G4Transform3D(),
&tmpMP,
useFullExtent);
// Instantiate a pseudo scene so that we can make a "private" descent
// into the nested parameterisation and fill a multimap...
std::multimap<const G4Colour,G4ThreeVector> positionByColour;
G4double halfX = 0., halfY = 0., halfZ = 0.;
struct PseudoScene: public G4PseudoScene {
PseudoScene
(G4PhysicalVolumeModel* pvModel // input...the following are outputs
, std::multimap<const G4Colour,G4ThreeVector>& positionByColour
, G4double& halfX, G4double& halfY, G4double& halfZ)
: fpPVModel(pvModel)
, fPositionByColour(positionByColour)
, fHalfX(halfX), fHalfY(halfY), fHalfZ(halfZ)
{}
using G4PseudoScene::AddSolid; // except for...
void AddSolid(const G4Box& box) {
const G4Colour& colour = fpPVModel->GetCurrentLV()->GetVisAttributes()->GetColour();
const G4ThreeVector& position = fpCurrentObjectTransformation->getTranslation();
fPositionByColour.insert(std::make_pair(colour,position));
fHalfX = box.GetXHalfLength();
fHalfY = box.GetYHalfLength();
fHalfZ = box.GetZHalfLength();
}
G4PhysicalVolumeModel* fpPVModel;
std::multimap<const G4Colour,G4ThreeVector>& fPositionByColour;
G4double &fHalfX, &fHalfY, &fHalfZ;
}
pseudoScene(&tmpPVModel,positionByColour,halfX,halfY,halfZ);
// Make private descent into the nested parameterisation
tmpPVModel.DescribeYourselfTo(pseudoScene);
// Make list of found colours
std::set<G4Colour> setOfColours;
for (const auto& entry: positionByColour) {
setOfColours.insert(entry.first);
}
if (print) {
for (const auto& colour: setOfColours) {
G4cout << "setOfColours: " << colour << G4endl;
}
}
// Draw as dots
BeginPrimitives (mesh.GetTransform());
G4int nDotsTotal = 0;
for (const auto& colour: setOfColours) {
G4int nDots = 0;
G4Polymarker dots;
dots.SetVisAttributes(G4Colour(colour));
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
dots.SetInfo(container->GetName());
const auto range = positionByColour.equal_range(colour);
for (auto posByCol = range.first; posByCol != range.second; ++posByCol) {
const G4double x = posByCol->second.getX() + (2.*G4UniformRand()-1.)*halfX;
const G4double y = posByCol->second.getY() + (2.*G4UniformRand()-1.)*halfY;
const G4double z = posByCol->second.getZ() + (2.*G4UniformRand()-1.)*halfZ;
dots.push_back(G4ThreeVector(x,y,z));
++nDots;
}
AddPrimitive(dots);
if (print) {
G4cout
<< "Number of dots for colour " << colour
<< ": " << nDots << G4endl;
}
nDotsTotal += nDots;
}
if (print) {
G4cout << "Total number of dots: " << nDotsTotal << G4endl;
}
EndPrimitives ();
firstPrint = false;
return;
StandardSpecialMeshRendering(mesh);
}
void G4Qt3DSceneHandler::ClearStore ()
@@ -376,8 +376,8 @@ void G4Qt3DViewer::wheelEvent(QWheelEvent* ev)
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1.+angleY/scale);
} else { // Perspective projection
const G4double scale = fVP.GetFieldHalfAngle()/(10.*deg); // Empirical
fVP.SetDolly(fVP.GetDolly()+angleY/scale);
const G4double delta = fSceneHandler.GetExtent().GetExtentRadius()/200.; // Empirical
fVP.SetDolly(fVP.GetDolly()+angleY*delta);
}
SetView();