With Voxelize(), OGL in Qt is too slow while opening the visualisation

Hello, i hope someone can help me…
I’m creating a 3D structure on my geometry, made by G4Tubs, like a tree structure. I provided overlays and my need is to add each solid into one, for creating one logical volume.
Following the prescription provided here at paragraph Unified Solids, i used the MULTI UNION approach:

munion_solid->AddNode(*tubs[s], transform);  // for cicle with multiple tubs in an array
G4LogicalVolume* logic_munion_solid = new G4LogicalVolume(...
G4VPhysicalVolume* physical_munion_solid = new G4PVPlacement(...

It works, and the geometry is like expected, but the problem is that
visualisation is too slow. OpenGL in Qt takes about 30-60seconds to show me the visualisation, making difficult working on it.
More precisely, the working thread works on 100% until it opens the visualisation.
Maybe the problem derived from the Voxelize() method and something should be semplificated, but for now i use only 10 solids…!
Thank you in advance!

Mmm. Maybe the problem is that Qt makes its own “scene tree” of “touchables”. A touchable is a volume at the end of the geometry roll-out, which may generate many touchables from a simple hierarchical geometry structure.

Do you have the option of opening a simple OGL viewer (/vis/open OGLSX)? That might work faster.

Or…you can be more selective in what you view:

/vis/open OGL
/vis/drawVolume <name-of-your-volume-of-interest> <copy-number> <depth-of-descent>

(See guidance for /vis/drawVolume and “Debugging geometry with vis” in the Application Developers Guide.

Hello, first of all thank you for your response.
I tryed to use as you suggested /vis/open OGLSX but Qt did not open.
I also tryed all the list:
OGLI OGLIX OGLS OGLSQt and the problem still occurs
( i don’t have RayTracer and gMocrenFile yet but i’ll try them too…)

However, from many tests based on the manual, by specifying
/vis/drawVolume /physical_munion_solid /
i get the error shown in the images:
“too many edges”
regarding this problem i found a similar question here regarding an old version of Geant4, where your answer was to try RayTracer… so i’ll try this way :slight_smile:

/vis/open OGLSX should open a separate window. It does not use Qt. It uses the X11 window system.

“Too many edges”: Your solid is a boolean solid. Sometimes, there are problems creating a polyhedron for visualisation. This does not affect tracking - it is purely a visualisation problem. You can maybe reduce the number of edges with /vis/viewer/set/lineSegmentsPerCircle. You can try moving the component solids relative to each other by a small amount. You can try visualising the solid as a cloud of points (/vis/viewer/set/style cloud, which does not use the polyhedron representation). You can try visualising with RayTracer or RayTracerX (which also does not user the polyhedron representation).

Did you look at “Debugging geometry with vis” in the Application Developers Guide?

Finally, I’m curious as to why you used ‘/’ around your volume name?

Good luck


Hello, thank you for all these tips. I took time for trying all these possibilities.
Maybe it can be useful for you what i found…

  • i don’t know why, but /vis/open OGLSX did not open the X11 viewer…
    (I already built in the build directory with -DGEANT4_USE_OPENGL_X11=ON . then make && make install)

  • by reducing the number of edges /vis/viewer/set/lineSegmentsPerCircle 10
    i reduce just a bit the visualisation time but i was hoping better…

  • I use for my tree random numbers and i found that sometimes the visualisation is fast, because solids move to each other by a small amount, but i can’t control it, bacause to improve the geometry i’m working on the code yet.

  • I have problem on working on with Raytracer, and i need more time to do it

  • using /vis/viewer/set/style cloud i get:
    parameter value (cloud) is not listed in the candidate List.
    ***** Illegal parameter (0) </vis/viewer/set/style cloud> *****
    ***** Batch is interrupted!! *****
    i use 10.5 version and maybe it has been introduced in 10.6.
    but i found in the manual at “8.5.12 Drawing a solid as a cloud of points” an alternative way, that works with a simple test but i’ll work on it better to solve my problem.

  • yes i looked at the “Debugging geometry with vis” in the Application Developers Guide and i used ‘/’ around your volume name as the manual suggested. In this way is shown only that physical volume and its doughter volumes, while without ‘/’ all the world is included…

I also tried the strategy using G4UnionSolid but has the same problem.
I think my only chance is to try the cloud strategy suggested in par. 8.5.12.
If i can’t do it i think i’ll have to wait the time required by the visualisation…

If you don’t have any corrections to notify me, i really thank you for helping me.
Best regards!

Hi Raffaele

It sounds like you are doing well. Well done.

Here are some comments as I see things…

That is a mystery. Maybe try again next time you rebuild from scratch.


Not sure I understand, but OK.

May be OK after a rebuild.

You’re right. /vis/viewer/set/style cloud is not available until 10.6. “8.5.12 Drawing a solid as a cloud of points” will still work but has been largely obviated in 10.6. Note: cloud drawing does take extra CPU, so maybe you need to be selective. Again, advice in “Debugging geometry with vis” might help.

I think you have misinterpreted the documentation/guidance here. (Please tell us how it may be improved. Where did you get this impression?) The ‘/’ is only used for regular expression matching. Even without the ‘/’ you can say /vis/drawVolume my-sub-detector-physical-volume-name and you only see the sub detector. Tell me if I am wrong.


Dear John Allison,
sorry for the delay of my response. This is just to close the discussion since i reached a conclusion in my code development. This is also the occasion to thank you for your timely replies!

The problem was the too slow visualisation after having performed the voxelize() method for multiple solids. So i decided to visualize without voxelinzing process, and to perform voxelizing only for simulation purposes. This was acceptable, so ok…

But i found another big problem. Voxelinzing took too much RAM memory for many solids! 32GB were not enough, maybe hundreds of GB, so it was not a plausible path. I solved the problem by exporting the geometry via GDML and by summing all the solids using an external CAD software. Then i proceeded to import the whole solid (unified now) in Geant4 and finally executing the simulation.
I tried to investigate other solutions but i found this was the “best” way to reach my purpose.

Thank you again!
Best Regards

Hi Raffaele.

Thanks for coming back in this. It’s always good to know if problems have been solved.

It does look like voxelisation of Unified Solids is an issue.