3D Shapes : Cylinder/Sphere


I am a beginner with ROOT and i currently use PyROOT as a visualization tool for 3D geometry.
I am trying to visualize spheres and cylinders and i use TTUBE and TSPHE classes. When i visualize them with OpenGL, these shapes are divided into sectors and i would like to refine this number of sectors.
Is there a way to draw perfect cylinders/spheres ?
Can you help me figure out how i am supposed to do it ?
I made some research and i tried pyroot/shapes.py tutorial but do not hesitate to give me a link to a topic/documentation i would have missed.

Last question, is it possible to make these shapes “solid”. I mean is it possible to create shape which are not empty when i clip with OpenGL tool ?

Hi Johann,

For this purpose (and many others) you should better use the TGeoXXX classes. The full documentation can be found at [https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#the-geometry-package](ROOT geometry package) For usage examples, have a look in the tutorials/geom folder; there are no PyROOT specific examples but the conversion of most macros to it is straightforward. Tubes and full spheres are rendered natively in OpenGL, most other shapes are drawn in a tessellated representation. There are several options in the GL viewer (check its help menu) to render in solid mode (default), wireframe or hidden line removal.


1 Like

Hi Andrei,

Thank you for your response, i will give it a shot


I got it and i succeed in creating simple shapes with this code (MWE) :

geoManager = ROOT.TGeoManager("toto","toto")
material = ROOT.TGeoMaterial("Vaccum",0,0,0)
medium = ROOT.TGeoMedium("Vaccum",1,material)
# worldShape = ROOT.TGeoSphere(0.,10.)
worldShape = ROOT.TGeoCone(10.,0.,0.,0.,10.)
world = ROOT.TGeoVolume("top",worldShape,medium)

For sphere and cylinder this is fine but like in my example, i use a cone and it’s a tessellated representation. How can i refine this representation (i will also use torus)?
I found (with documentation) in the pad that i can use raytrace but i am trying to do it in opengl viewer (view with>opengl)

Like Andrei suggested me i checked openGL help menu but i did not find a solution.
Thank you,

Just to give the final answer, for refining the number of sector in tesselated representation, we should use :



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.