| Summary: | Cannot draw twisted solids with negative twist angle | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | suhl |
| Component: | visualization | Assignee: | John.Allison |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | ||
| Priority: | P4 | ||
| Version: | 10.3 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | minimal example | ||
Thanks for reporting this. I can see the problem. We will look into it. A fix has been found and will be part of the next release. The problem only affected visualisation. Tracking is and was OK (tested with RayTracer). It is a relatively small fix - see below - which you may apply yourself if you have the ability to rebuild Geant4.
Index: src/G4TwistedTubs.cc
===================================================================
--- src/G4TwistedTubs.cc (.../geom-specific-V10-03-12) (revision 105798)
+++ src/G4TwistedTubs.cc (.../geom-specific-V10-03-13) (revision 105798)
@@ -906,11 +906,12 @@
{
// number of meshes
//
- G4double dA = std::max(fDPhi,fPhiTwist);
+ G4double absPhiTwist = std::abs(fPhiTwist);
+ G4double dA = std::max(fDPhi,absPhiTwist);
const G4int k =
G4int(G4Polyhedron::GetNumberOfRotationSteps() * dA / twopi) + 2;
const G4int n =
- G4int(G4Polyhedron::GetNumberOfRotationSteps() * fPhiTwist / twopi) + 2;
+ G4int(G4Polyhedron::GetNumberOfRotationSteps() * absPhiTwist / twopi) + 2;
const G4int nnodes = 4*(k-1)*(n-2) + 2*k*k ;
const G4int nfaces = 4*(k-1)*(n-1) + 2*(k-1)*(k-1) ;
Index: src/G4VTwistedFaceted.cc
===================================================================
--- src/G4VTwistedFaceted.cc (.../geom-specific-V10-03-12) (revision 105798)
+++ src/G4VTwistedFaceted.cc (.../geom-specific-V10-03-13) (revision 105798)
@@ -1152,7 +1152,8 @@
{
// number of meshes
const G4int k =
- G4int(G4Polyhedron::GetNumberOfRotationSteps() * fPhiTwist / twopi) + 2;
+ G4int(G4Polyhedron::GetNumberOfRotationSteps() *
+ std::abs(fPhiTwist) / twopi) + 2;
const G4int n = k;
const G4int nnodes = 4*(k-1)*(n-2) + 2*k*k ;
|
Created attachment 467 [details] minimal example Using Geant4 10.3p1 (I did not try other versions) I cannot draw twisted solids with a negative twist angle. The attachment contains a minimal example trying to draw a G4TwistedBox with a negative twist angle. It can be compiled with the command: g++ test.cc -o test `geant4-config --cflags --libs` The example crashes with the message [...] Polyhedron::SetReferences: different edge visibility 1/1/56 and 1/0/-1541871320 Polyhedron::SetReferences: different edge visibility 1/3/56 and 1/2/-1541871320 Segmentation fault (core dumped) If in line 15 the twist angle is made positive, the example runs without an issue. I also could not draw G4TwistedTubs and G4TwistedTrap with a negative twist angle, in these cases the test just crashes without any message.