3D geometry, only leaves drawn

Hi,

I am developping a program with pyroot visualisation, and when i ask for draw, only leaves are visible (according to the anology with trees).

I found in the documentation (Geometry documentation; section 20.7.1) if i want to force representation of all volumes i have to put :

geoManager.SetVisOption(0)

However medium volumes (= branch) are not drawn.

I put a MWE :

import ROOT
import time
geoManager = ROOT.TGeoManager("Toto","toto")
# Create 3 volumes
tubeShape = ROOT.TGeoTube(0.,10.,10.)
tube = ROOT.TGeoVolume("Pepito", tubeShape)
cubeShape = ROOT.TGeoBBox(2.,2.,2.)
cube = ROOT.TGeoVolume("Pepita", cubeShape)
sphereShape = ROOT.TGeoSphere(0.,1.)
sphere = ROOT.TGeoVolume("Pepignito", sphereShape)

# Create the tree like : Tube > Cube > Sphere
tube.AddNode(cube,1)
cube.AddNode(sphere,1)

#Configure geoManager
geoManager.SetTopVolume(tube)
geoManager.CloseGeometry()
tube.SetLineColor(8)
geoManager.SetVisLevel(10)
geoManager.SetVisOption(0)
geoManager.SetTopVisible()

# Draw
tube.Draw()
while tube:
    time.sleep(1)

Can you help me figure out where i did a mistake ?
Thank you,
Regards,
Johann

I think @agheata can help you.

Hi, SetVisOption is deprecated, you should use SetVisContainers() for the volume you are going to draw. The default is SetVisLeaves(). Your example becomes:

import ROOT
import time
geoManager = ROOT.TGeoManager("Toto","toto")
# Create 3 volumes
tubeShape = ROOT.TGeoTube(0.,10.,10.)
tube = ROOT.TGeoVolume("Pepito", tubeShape)
cubeShape = ROOT.TGeoBBox(2.,2.,2.)
cube = ROOT.TGeoVolume("Pepita", cubeShape)
sphereShape = ROOT.TGeoSphere(0.,1.)
sphere = ROOT.TGeoVolume("Pepignito", sphereShape)

# Create the tree like : Tube > Cube > Sphere
tube.AddNode(cube,1)
cube.AddNode(sphere,1)

#Configure geoManager
geoManager.SetTopVolume(tube)
geoManager.CloseGeometry()
tube.SetLineColor(8)
geoManager.SetVisLevel(10)
geoManager.SetVisOption(0)
geoManager.SetTopVisible()

# Draw making all containers visible, down to geoManager->SetVisLevel()
tube.SetVisContainers()
tube.Draw()
while tube:
    time.sleep(1)

Best, Andrei

1 Like

Hi Andrei,
Thank you very much one more time :grinning:!
Best,
Johann

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