Headless file export from VTK viewer

Hello All!

I have recently been playing with Geant4 11 and have enjoyed the addition of the VTK viewer.

My question is: is it possible to export OBJ files without having the graphical environment open? (similar to how one would use the VRML2FILE driver)

I am trying to use Geant4 in a headless container, with GDML input and OBJ output, and my approach so far has been to use a virtual framebuffer to host the display. However, both the VTKQt and VTKN drivers appear to block waiting for keyboard input once /run/beamOn has been called.

I would really appreciate any thoughts or advice.

Thank you and all the best,

Oliver

Dear Oliver,

Thanks for using the new VTK viewer. It is possible to use VTK to export to OBJ no problem but not in a headless fashion you require. So to export to OBJ/VRML

/vis/vtk/export obj filename

or

/vis/vtk/export vrml filename

Just to clarify. VTKQt is not keyboard IO blocking per-se, but VTKN is. Well for your information q will exit the VTKN display and return input to the terminal.

As for the headless version, it will require a new driver, which does not create the actual render windows etc. Easy enough to implement, but will be in the next G4-VTK update. Well now I know there is a need, I will definitely add it, so something like VTKHeadless. This has lots of benefits in general as I too have a lot of problems running my container test builds and getting some diagnostic visualisation out.

Are you happy to edit the G4 source to implement a quick a dirty hack to get non blocking behaviour? Happy to send you a patch.

Best
Stewart

Thanks for your reply Stewart!

“As for the headless version, it will require a new driver […] but will be in the next G4-VTK update.”

This is very exiting! I’ll keep an eye out for that.

“Are you happy to edit the G4 source to implement a quick a dirty hack to get non blocking behaviour? Happy to send you a patch.”

I am more than happy, that would be excellent.

Thanks,

Oliver

ok in

G4VtkViewer.cc around line 313 comment out or remove the line.

  _renderWindow->Render();
  renderWindowInteractor->Initialize();
  //renderWindowInteractor->Start();

I have just tested this and a VTKN window is not opened and export to OBJ is possible.

If this is the only change, I will probably add a /vis/vtk/interactive flag opposed to deriving a whole new driver, still it will still have to wait for the next release. Please let me know how you get on with this fix in your container.

Thank you very very much - that appears to work perfectly in my workflow!

Thank you for your quick responses and quick fix.

All the best,

Oliver

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