Ellipsoids in OpenGL

I am working on visualizing a geometry with ROOT, and I need an Ellipsoid.
According to the GDML translation (TGDMLParse.cxx), an Ellipsoid can be created by scaling a sphere, however, when I try to render the resulting object, I do not see a scaled sphere.
There is a question dating back to 2003 (TGeoVolume and scale transformations) that states scaling is not working.

Is this still not working? :frowning:
If so, any idea how I can get an ellipsoid to show up in a rendering of my geometry?

I added a little script to show what I mean.

Thanks!
TestEllipsoid.C (780 Bytes)

It seems that the Ellipsoid wasn’t “complete”. I found that putting the bounding box around it, even if it is not cutting anything, DOES create a proper ellipsoid. :smiley:

Here’s the Python version that works:

# Test an Ellipsoid in ROOT
#
import ROOT
geom = ROOT.TGeoManager("Test","Test Ellipsoid Shape")
geom.SetVisOption(0)
mat_fe=ROOT.TGeoMaterial("Fe",55.845,26,7.87);
fe = ROOT.TGeoMedium("Fe",1,mat_fe)
mat_vac= ROOT.TGeoMaterial("Vacuum", 0,0,0)
vac = ROOT.TGeoMedium("Vacuum",0,mat_vac)
root = geom.MakeBox("root",vac,1000.,1000.,1000.)
tmp_sp=ROOT.TGeoSphere("sphere",0.,500.)
tmp_scale=ROOT.TGeoScale("scale",0.2,0.4,1.)
tmp_shape = ROOT.TGeoScaledShape("elle",tmp_sp,tmp_scale)

tmp_box=ROOT.TGeoBBox("cutbox",500.*0.2,500.*0.4,500.*1.)
pboolNode = ROOT.TGeoIntersection(tmp_shape,tmp_box,0,0)
ellip     = ROOT.TGeoCompositeShape("ellip",pboolNode)
ellipsoid = ROOT.TGeoVolume("ellipsoid",ellip,fe)
root.AddNode(ellipsoid,1,0)
ROOT.gGeoManager.SetTopVolume(root)
ROOT.gGeoManager.CloseGeometry()
ROOT.gGeoManager.GetTopVolume().Draw()

Hi,
The following should also do it in GL. Note that due to an optimisation that transforms a full orb into a GL sphere, you have to set the inner radius non-zero to get the proper scaling in GL rendering.

   TGeoManager *geom = new TGeoManager("ellipsoid", "");
   geom->SetNsegments(80);
   TGeoSphere *sphere = new TGeoSphere("sph", 0.01, 50.);
   TGeoScaledShape *scaled = new TGeoScaledShape("ell", sphere, new TGeoScale(0.2,0.4,1.));
   scaled->Draw("ogl");

Best,