Python & geometry package

From: Michal Dwuznik <Michal.Dwuznik_at_cern.ch>
Date: Fri, 18 Jul 2008 01:31:10 +0200


Hi,

I got a bit strange behaviour using python with ROOT geometry & OpenGL classes, minimum example follows:

import ROOT
ROOT.TGeoManager()
vac = ROOT.TGeoMaterial('vac')

sol1 = ROOT.TGeoMaterial('sol1')
sol2 = ROOT.TGeoMaterial('sol2')
vacuum = ROOT.TGeoMedium('vacuum', 1, vac)
solid1 = ROOT.TGeoMedium('solid1', 1, sol1)
solid2 = ROOT.TGeoMedium('solid2', 1, sol2)
top = ROOT.gGeoManager.MakeBox('top' , vacuum, 100, 100, 100)
box1 = ROOT.gGeoManager.MakeBox('box1', solid1, 10, 20, 30) box2 = ROOT.gGeoManager.MakeBox('box2', solid1, 20, 20, 20) box2.SetLineColor(ROOT.kYellow)
ROOT.gGeoManager.SetTopVolume(top)
top.AddNode(box1, 1)
top.AddNode(box2, 2)
ROOT.gGeoManager.CloseGeometry()
ROOT.gGeoManager.GetTopVolume().Draw('ogl')
#two boxes visible, overlapping, default and yellow colour, as expected
vols = [i for i in ROOT.gGeoManager.GetListOfUVolumes()] b1 = vols[-2]
print b1.GetName()
b2 = vols[-1]
print b2.GetName()
whatever = raw_input("Press Enter")
ROOT.gPad.GetViewer3D().UpdateScene()
b1.SetTransparency(80)
# Changing the transparency of _one_ of the two boxes
b1.SetLineColor(ROOT.kGreen)
# and colour for one, too

ROOT.gPad.GetViewer3D().UpdateScene()
# The result on i810 notebook is a bit different from expectations
# one box has colour changed to green (expected)
# and _both_ boxes made of different media/material are transparent
instead of one
whatever = raw_input("Press Enter")
p1 = ROOT.gGeoManager.MakePhysicalNode('/top_1/box1_1')
p2 = ROOT.gGeoManager.MakePhysicalNode('/top_1/box2_2')
p=[i for i in ROOT.gGeoManager.GetListOfPhysicalNodes()]
p[0].Align(ROOT.TGeoTranslation(10,0,0))
p[1].Align(ROOT.TGeoTranslation(0,30,0)) ROOT.gPad.GetViewer3D().UpdateScene()
# Ok, aligning the nodes works ok, the boxes move around as expected, but
whatever = raw_input("Press Enter")
b1.SetLineColor(ROOT.kWhite)
b1.SetTransparency(0)
ROOT.gPad.GetViewer3D().UpdateScene()
#Transparency changes, again for _both_ volumes
#colour does not - b1 is still green, not white.
#I would expect both functions to work, or both to fail
# is no longer changing the attributes of visible boxes...
#recreating the volume references 'just in case'
whatever = raw_input("Press Enter")
vols = [i for i in ROOT.gGeoManager.GetListOfUVolumes()] b1 = vols[-2]
print b1.GetName()
b2 = vols[-1]
print b2.GetName()
b1.SetLineColor(ROOT.kCyan)
b1.SetTransparency(0)
#does not help at all

Could someone pinpoint my mistake?

Regards
Michal Dwuznik
~ Received on Fri Jul 18 2008 - 01:31:33 CEST

This archive was generated by hypermail 2.2.0 : Fri Jul 18 2008 - 11:50:02 CEST