76 , fFlagDestOpen(false)
81 strcpy(fVRMLFileName,
"");
86 strcpy(fVRMLFileDestDir,
"");
95 if(std::getenv(
"G4VRMLFILE_MAX_FILE_NUM") != NULL)
97 sscanf(std::getenv(
"G4VRMLFILE_MAX_FILE_NUM"),
"%d", &fMaxFileNum);
109 if(std::getenv(
"G4VRML_PV_PICKABLE") != NULL)
112 sscanf(std::getenv(
"G4VRML_PV_PICKABLE"),
"%d", &is_pickable);
116 SetPVPickability(
true);
126#if defined DEBUG_FR_SCENE
133#define G4VRML2SCENEHANDLER G4VRML2FileSceneHandler
134#define IS_CONNECTED this->isConnected()
135#include "G4VRML2SceneHandlerFunc.icc"
137#undef G4VRML2SCENEHANDLER
142 const int MAX_FILE_INDEX = fMaxFileNum - 1;
145 strcpy(fVRMLFileName, fVRMLFileDestDir);
154 for(
int i = 0; i < fMaxFileNum; i++)
157 if(i == MAX_FILE_INDEX)
161 G4cout <<
"===========================================" <<
G4endl;
162 G4cout <<
"WARNING MESSAGE from VRML2FILE driver: " <<
G4endl;
163 G4cout <<
" This file name is the final one in the " <<
G4endl;
164 G4cout <<
" automatic updation of the output file name." <<
G4endl;
165 G4cout <<
" You may overwrite existing files, i.e. " <<
G4endl;
167 G4cout <<
"===========================================" <<
G4endl;
172 std::ostringstream filename;
173 filename << fVRMLFileDestDir;
182 filename << std::setw(2) << std::setfill(
'0') << i <<
".wrl";
183 strncpy(fVRMLFileName, filename.str().c_str(),
sizeof(fVRMLFileName) - 1);
184 fVRMLFileName[
sizeof(fVRMLFileName) - 1] =
'\0';
188 fin.open(fVRMLFileName);
207 G4cout <<
"===========================================" <<
G4endl;
208 G4cout <<
"Output VRML 2.0 file: " << fVRMLFileName <<
G4endl;
209 G4cout <<
"Maximum number of files in the destination directory: "
211 G4cout <<
" (Customizable with the environment variable: "
212 "G4VRMLFILE_MAX_FILE_NUM) "
214 G4cout <<
"===========================================" <<
G4endl;
216 fDest.open(fVRMLFileName);
217 fFlagDestOpen =
true;
232 fFlagDestOpen =
false;
234 G4cout <<
"*** VRML 2.0 File " << fVRMLFileName <<
" is generated."
244 G4cout <<
" Set an environmental variable ";
246 G4cout <<
" if you want to visualize the generated VRML file"
250 G4cout <<
"ALSO you may change the file header with "
258 std::ostringstream ossCommand;
259 ossCommand << viewer <<
' ' << fVRMLFileName;
260 strncpy(command, ossCommand.str().c_str(),
sizeof(command) - 1);
261 command[
sizeof(command) - 1] =
'\0';
262 int iErr = system(command);
266 ed <<
"Error " << iErr <<
" when calling system with \"" << command
268 G4Exception(
"G4VRML2FileSceneHandler::closePort()",
"VRML-2006",
274G4int G4VRML2FileSceneHandler::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 ENV_WRL_FILE_NAME[]
const char WRL_FILE_HEADER[]
const char VRMLFILE_DEST_DIR[]
const char NO_VRML_VIEWER[]
const char ENV_WRL_FILE_HEADER[]
const char ENV_VRML_VIEWER[]
G4GLOB_DLL std::ostream G4cout
G4VRML2FileSceneHandler(G4VRML2File &system, const G4String &name="")
virtual ~G4VRML2FileSceneHandler()
static Verbosity GetVerbosity()