79 fFlagDestOpen( false )
82 strcpy(fVRMLFileName,
"");
85 strcpy( fVRMLFileDestDir,
"" );
92 if ( std::getenv(
"G4VRMLFILE_MAX_FILE_NUM" ) != NULL ) {
94 sscanf( std::getenv(
"G4VRMLFILE_MAX_FILE_NUM"),
"%d", &fMaxFileNum ) ;
99 if( fMaxFileNum < 1 ) { fMaxFileNum = 1; }
106#if defined DEBUG_FR_SCENE
114#define G4VRML1SCENEHANDLER G4VRML1FileSceneHandler
115#define IS_CONNECTED this->isConnected()
116#include "G4VRML1SceneHandlerFunc.icc"
118#undef G4VRML1SCENEHANDLER
124 const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
127 strcpy ( fVRMLFileName, fVRMLFileDestDir) ;
133 for(
int i = 0 ; i < fMaxFileNum ; i++) {
136 if( i == MAX_FILE_INDEX )
139 G4cout <<
"===========================================" <<
G4endl;
140 G4cout <<
"WARNING MESSAGE from VRML1FILE driver: " <<
G4endl;
141 G4cout <<
" This file name is the final one in the " <<
G4endl;
142 G4cout <<
" automatic updation of the output file name." <<
G4endl;
143 G4cout <<
" You may overwrite existing files, i.e. " <<
G4endl;
145 G4cout <<
"===========================================" <<
G4endl;
150 std::ostringstream filename;
153 << std::setw(2) << std::setfill(
'0') << i <<
".wrl";
154 strncpy(fVRMLFileName,filename.str().c_str(),
sizeof(fVRMLFileName)-1);
155 fVRMLFileName[
sizeof(fVRMLFileName)-1] =
'\0';
159 fin.open(fVRMLFileName) ;
174 G4cout <<
"===========================================" <<
G4endl;
175 G4cout <<
"Output VRML 1.0 file: " << fVRMLFileName <<
G4endl;
176 G4cout <<
"Maximum number of files in the destination directory: " << fMaxFileNum <<
G4endl;
177 G4cout <<
" (Customizable with the environment variable: G4VRMLFILE_MAX_FILE_NUM) " <<
G4endl;
178 G4cout <<
"===========================================" <<
G4endl;
180 fDest.open(fVRMLFileName) ; fFlagDestOpen = true ;
194 fDest.close(); fFlagDestOpen = false ;
196 G4cout <<
"*** VRML 1.0 File " << fVRMLFileName <<
" is generated." <<
G4endl;
204 G4cout <<
" Set an environmental variable " ;
206 G4cout <<
" if you want to visualize the generated VRML file" <<
G4endl;
211 std::ostringstream ossCommand;
212 ossCommand << viewer <<
' ' << fVRMLFileName;
213 strncpy(command,ossCommand.str().c_str(),
sizeof(command)-1);
214 command[
sizeof(command)-1] =
'\0';
215 int iErr = system( command );
218 ed <<
"Error " << iErr
219 <<
" when calling system with \"" << command
221 G4Exception(
"G4VRML1FileSceneHandler::closePort()",
227G4int G4VRML1FileSceneHandler::fSceneIdCount = 0;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
const int DEFAULT_MAX_WRL_FILE_NUM
const char DEFAULT_WRL_FILE_NAME[]
const char WRL_FILE_HEADER[]
const char VRMLFILE_DEST_DIR[]
const char NO_VRML_VIEWER[]
const char ENV_VRML_VIEWER[]
G4GLOB_DLL std::ostream G4cout
virtual ~G4VRML1FileSceneHandler()
G4VRML1FileSceneHandler(G4VRML1File &system, const G4String &name="")
static Verbosity GetVerbosity()