-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hiding subtraction volumes from Geant4 visualization #43
Conversation
…volumes from visualization (NOT deleting anything)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpp-linter Review
Used clang-format v12.0.1
Only 7 out of 8 clang-format concerns fit within this pull request's diff.
Click here for the full clang-format patch
diff --git a/src/g4app.h b/src/g4app.h
index 4f2db12..771938c 100644
--- a/src/g4app.h
+++ b/src/g4app.h
@@ -4,2 +3,0 @@
-#include "G4SubtractionSolid.hh"
-#include "G4LogicalVolumeStore.hh"
@@ -7,0 +6 @@
+#include "G4LogicalVolumeStore.hh"
@@ -12,0 +12 @@
+#include "G4SubtractionSolid.hh"
@@ -36,2 +36 @@
-
-bool IsSubtractionSolid(G4VSolid* solid)
+bool IsSubtractionSolid(G4VSolid *solid)
@@ -43 +42 @@ bool IsSubtractionSolid(G4VSolid* solid)
- if (dynamic_cast<G4SubtractionSolid*>(solid))
+ if (dynamic_cast<G4SubtractionSolid *>(solid))
@@ -47 +46 @@ bool IsSubtractionSolid(G4VSolid* solid)
- G4BooleanSolid* booleanSolid = dynamic_cast<G4BooleanSolid*>(solid);
+ G4BooleanSolid *booleanSolid = dynamic_cast<G4BooleanSolid *>(solid);
@@ -50,2 +49,2 @@ bool IsSubtractionSolid(G4VSolid* solid)
- G4VSolid* solidA = booleanSolid->GetConstituentSolid(0);
- G4VSolid* solidB = booleanSolid->GetConstituentSolid(1);
+ G4VSolid *solidA = booleanSolid->GetConstituentSolid(0);
+ G4VSolid *solidB = booleanSolid->GetConstituentSolid(1);
@@ -78,23 +77,23 @@ struct DetectorConstruction : G4VUserDetectorConstruction
- G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
-
- static G4VisAttributes invisibleVisAttr(false);
-
- // Check if the store is not empty
- if (lvStore && !lvStore->empty())
- {
- // Iterate over all logical volumes in the store
- for (auto& logicalVolume : *lvStore)
- {
- G4VSolid* solid = logicalVolume->GetSolid();
-
- // Check if the solid uses subtraction
- if (IsSubtractionSolid(solid))
- {
- // Assign the invisible visual attributes to the logical volume
- logicalVolume->SetVisAttributes(&invisibleVisAttr);
-
- // Optionally, print out the name of the logical volume
- G4cout << "Hiding logical volume: " << logicalVolume->GetName() << G4endl;
- }
- }
- }
+ G4LogicalVolumeStore *lvStore = G4LogicalVolumeStore::GetInstance();
+
+ static G4VisAttributes invisibleVisAttr(false);
+
+ // Check if the store is not empty
+ if (lvStore && !lvStore->empty())
+ {
+ // Iterate over all logical volumes in the store
+ for (auto &logicalVolume : *lvStore)
+ {
+ G4VSolid *solid = logicalVolume->GetSolid();
+
+ // Check if the solid uses subtraction
+ if (IsSubtractionSolid(solid))
+ {
+ // Assign the invisible visual attributes to the logical volume
+ logicalVolume->SetVisAttributes(&invisibleVisAttr);
+
+ // Optionally, print out the name of the logical volume
+ G4cout << "Hiding logical volume: " << logicalVolume->GetName() << G4endl;
+ }
+ }
+ }
Have any feedback or feature suggestions? Share it here.
src/g4app.h
Outdated
#include "G4SubtractionSolid.hh" | ||
#include "G4LogicalVolumeStore.hh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
Please remove the line(s)
- 4
- 5
src/g4app.h
Outdated
|
||
bool IsSubtractionSolid(G4VSolid* solid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
bool IsSubtractionSolid(G4VSolid* solid) | |
bool IsSubtractionSolid(G4VSolid *solid) |
src/g4app.h
Outdated
return false; | ||
|
||
// Check if the solid is directly a G4SubtractionSolid | ||
if (dynamic_cast<G4SubtractionSolid*>(solid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
if (dynamic_cast<G4SubtractionSolid*>(solid)) | |
if (dynamic_cast<G4SubtractionSolid *>(solid)) |
src/g4app.h
Outdated
return true; | ||
|
||
// If the solid is a Boolean solid, check its constituent solids | ||
G4BooleanSolid* booleanSolid = dynamic_cast<G4BooleanSolid*>(solid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
G4BooleanSolid* booleanSolid = dynamic_cast<G4BooleanSolid*>(solid); | |
G4BooleanSolid *booleanSolid = dynamic_cast<G4BooleanSolid *>(solid); |
src/g4app.h
Outdated
G4VSolid* solidA = booleanSolid->GetConstituentSolid(0); | ||
G4VSolid* solidB = booleanSolid->GetConstituentSolid(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
G4VSolid* solidA = booleanSolid->GetConstituentSolid(0); | |
G4VSolid* solidB = booleanSolid->GetConstituentSolid(1); | |
G4VSolid *solidA = booleanSolid->GetConstituentSolid(0); | |
G4VSolid *solidB = booleanSolid->GetConstituentSolid(1); |
src/g4app.h
Outdated
G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance(); | ||
|
||
static G4VisAttributes invisibleVisAttr(false); | ||
|
||
// Check if the store is not empty | ||
if (lvStore && !lvStore->empty()) | ||
{ | ||
// Iterate over all logical volumes in the store | ||
for (auto& logicalVolume : *lvStore) | ||
{ | ||
G4VSolid* solid = logicalVolume->GetSolid(); | ||
|
||
// Check if the solid uses subtraction | ||
if (IsSubtractionSolid(solid)) | ||
{ | ||
// Assign the invisible visual attributes to the logical volume | ||
logicalVolume->SetVisAttributes(&invisibleVisAttr); | ||
|
||
// Optionally, print out the name of the logical volume | ||
G4cout << "Hiding logical volume: " << logicalVolume->GetName() << G4endl; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format suggestion
G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance(); | |
static G4VisAttributes invisibleVisAttr(false); | |
// Check if the store is not empty | |
if (lvStore && !lvStore->empty()) | |
{ | |
// Iterate over all logical volumes in the store | |
for (auto& logicalVolume : *lvStore) | |
{ | |
G4VSolid* solid = logicalVolume->GetSolid(); | |
// Check if the solid uses subtraction | |
if (IsSubtractionSolid(solid)) | |
{ | |
// Assign the invisible visual attributes to the logical volume | |
logicalVolume->SetVisAttributes(&invisibleVisAttr); | |
// Optionally, print out the name of the logical volume | |
G4cout << "Hiding logical volume: " << logicalVolume->GetName() << G4endl; | |
} | |
} | |
} | |
G4LogicalVolumeStore *lvStore = G4LogicalVolumeStore::GetInstance(); | |
static G4VisAttributes invisibleVisAttr(false); | |
// Check if the store is not empty | |
if (lvStore && !lvStore->empty()) | |
{ | |
// Iterate over all logical volumes in the store | |
for (auto &logicalVolume : *lvStore) | |
{ | |
G4VSolid *solid = logicalVolume->GetSolid(); | |
// Check if the solid uses subtraction | |
if (IsSubtractionSolid(solid)) | |
{ | |
// Assign the invisible visual attributes to the logical volume | |
logicalVolume->SetVisAttributes(&invisibleVisAttr); | |
// Optionally, print out the name of the logical volume | |
G4cout << "Hiding logical volume: " << logicalVolume->GetName() << G4endl; | |
} | |
} | |
} |
Thank you for the patch Gabor! I am now able to visualize
|
Added code to check if any solids are subtraction solids. Hide these volumes from visualization (NOT deleting anything)
This is needed as QT and OGL fails to plot these properly.