The visualization of G4Hype is not correct

Dear Geant4 experts,

I have found a bug in the visualization of G4Hype. Please see following figure with line segment set to 3:

The inner vertex is not correct at -halfZ.

I have a look at the source code of HepPolyhedronHype (source/graphics_reps/src/ and found the problem is due to the wrong size of the inner polyline.

  • Following is the outer polyline, the size is n and the index is from 0 to n-1. It’s correct.

    zz[0] = halfZ;
    rr[0] = std::sqrt(sqrtan2halfZhalfZ+k2);
    for(G4int i = 1; i < n-1; i++)
    zz[i] = zz[i-1] - dz;
    rr[i] =std::sqrt(sqrtan2*zz[i]*zz[i]+k2);
    zz[n-1] = -halfZ;
    rr[n-1] = rr[0];

  • However, for the inner polylines, the size is n+1, which is wrong:

    zz[n] = halfZ;
    rr[n] = std::sqrt(sqrtan1halfZhalfZ+k1);
    for(G4int i = n+1; i < n+n; i++) // fix1: n+n -> n+n-1
    zz[i] = zz[i-1] - dz;
    rr[i] =std::sqrt(sqrtan1*zz[i]*zz[i]+k1);
    zz[n+n] = -halfZ; // fix2: this should be n+n-1
    rr[n+n] = rr[n]; // fix3: also n+n-1

Thank you!
Tao Lin
IHEP, Beijing

Thank you for spotting the problem!
Could you to open a bug report in the Geant4 Problem Tracking System:

Thank you. I have created a bug report: