is it possible to set the filename of the VRML2FILE visualization driver from within a Geant4 application? At the moment I am only able to get files with the default filename g4_xx.wrl, where xx is an increasing number between 00 and 99.
I am sure, that it would be possible to rename the generated file from within the Geant4 application via the standard file/disc methods of C++, but I would prefer to set the filename directly, if possible.
But looking at the code in G4VRML2FileSceneHandler.cc, it does seem the author has built in some flexibility using environment variables (for example, you can change the destination directory) but the filename itself seems to be fixed.
You could change
l.66: const char WRL_FILE_HEADER [] = "g4_";
or, if you want to be more flexible, make this change at l.166:
thank you for your quick and helpful reply! Your suggested solution is certainly of use for us, however, only if included to the Geant4 code base, since we do not want to patch every new Geant4 realease. So, if you could trigger, that this code is implemented into Geant4 I would really appreciate it.
Ideally it would be good if there is also a messenger command, e.g. /vis/vrml2file/setfilename output.wrl, then a more interactive work-flow would be possible. But the suggested method via the environment varible will do the trick for the moment.
A patch will go into the next release. Since the VRML drivers already use environment variables I will stick to that method. I introduce two variables: one to change the “header” (as in the code above); and one to change the whole filename. Let me know if you would like a pre-release patch.
Thanks John. For the moment it is OK for us to know, that there will be a solution in the next release. In order to spare you any extra effort, I therefore do not need a pre-release patch (unless you want me to test it).
Well, since you offer…I attach two cc files. The following augmented message tells you the names of the new environment variables. Thanks. Feedback welcome. G4VRML2FileSceneHandler.cc (8.4 KB) G4VRML1FileSceneHandler.cc (8.1 KB)
MESSAGE from VRML2FILE driver:
Set an environmental variable G4VRMLFILE_VIEWER
if you want to visualize the generated VRML file
automatically. For example,
setenv G4VRMLFILE_VIEWER vrweb
ALSO you may change the file header with G4VRMLFILE_HEADER
or the whole filename with G4VRMLFILE_FILE_NAME