3D Viewer : *.stl/*.tring file

Hi,
I am trying to develop a complete STL file Viewer which use PyROOT and OpenGL.

After some researchs i found the triangleset tutorial : TEveTriangleSet Tutorial.
I tried to adapt it with python code (still using the same file as the tutorial : “broken_torus.tring”) but the viewer do not display.
Here is a MWE of my code :

import ROOT
import time

eveManager = ROOT.TEveManager(800,400)
triangleSet = ROOT.TEveTriangleSet.ReadTrivialFile("/usr/share/doc/root/tutorials/eve/broken_torus.tring")
triangleSet.SetName("test")
triangleSet.GenerateTriangleNormals()
triangleSet.GenerateRandomColors()
triangleSet.SetMainColor(0)
eveManager.AddElement(triangleSet)
eveManager.Redraw3D()
while triangleSet:
    time.sleep(1)

Currently, i have two tracks :

  • I have to configure correctly the eveManager but i found no information in the root user guide (User guide)
  • The triangleset.c tutorial use a gEve field/instance (available at triangleSetTutorial and gEveLink) and i have no idea how to access it and what it is supposed to be.
  1. Can you help me figure out where i did a mistake ?

  2. Is there a better approach or another class, that could be better for my purpose of developping a *.stl/*.tring file viewer ?

Thank you,
Regards,
Johann

I think this needs help from our eve-expert: @matevz - could you have a look?

gEve is global instance of TEveManager. Please call static TEveManager::Create() instead of direct constructor invocation.

There is no gEveLink that I know of :slight_smile:

I never used python so I might be wrong … but isn’t your while loop at the bottom hogging the root even loop? TEveManager::Redraw3D() only schedules a redraw, it only happens when the event loop in root resumes.

\m

Hi matevz,
Thank you for your answer.
I use both of your remarks and i finally succeed in displaying viewer :sunglasses:
I put the MWE if someone need it :

import ROOT
import time

eveManager = ROOT.TEveManager.Create()
triangleSet = ROOT.TEveTriangleSet.ReadTrivialFile("/usr/share/doc/root/tutorials/eve/broken_torus.tring")
triangleSet.SetName("test")
triangleSet.GenerateTriangleNormals()
triangleSet.GenerateRandomColors()
triangleSet.SetMainColor(0)
eveManager.AddElement(triangleSet)
eveManager.DoRedraw3D()
while triangleSet:
    time.sleep(1)

I just use the static way to create my eveManager and i force the manager to redraw with DoRedraw3D()

Thank you one more time,
Best,
Johann