77 fFlagDestOpen( false ),
78 fPVPickable ( false ),
82 strcpy(fVRMLFileName,
"");
86 strcpy( fVRMLFileDestDir,
"" );
94 if ( std::getenv(
"G4VRMLFILE_MAX_FILE_NUM" ) != NULL ) {
96 sscanf( std::getenv(
"G4VRMLFILE_MAX_FILE_NUM"),
"%d", &fMaxFileNum ) ;
101 if( fMaxFileNum < 1 ) { fMaxFileNum = 1; }
105 if( std::getenv(
"G4VRML_PV_PICKABLE" ) != NULL ) {
108 sscanf( std::getenv(
"G4VRML_PV_PICKABLE"),
"%d", &is_pickable ) ;
110 if ( is_pickable ) { SetPVPickability (
true ) ; }
114 SetPVTransparency ();
121#if defined DEBUG_FR_SCENE
129#define G4VRML2SCENEHANDLER G4VRML2FileSceneHandler
130#define IS_CONNECTED this->isConnected()
131#include "G4VRML2SceneHandlerFunc.icc"
133#undef G4VRML2SCENEHANDLER
139 const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
142 strcpy ( fVRMLFileName, fVRMLFileDestDir) ;
148 for(
int i = 0 ; i < fMaxFileNum ; i++) {
151 if( i == MAX_FILE_INDEX )
154 G4cout <<
"===========================================" <<
G4endl;
155 G4cout <<
"WARNING MESSAGE from VRML2FILE driver: " <<
G4endl;
156 G4cout <<
" This file name is the final one in the " <<
G4endl;
157 G4cout <<
" automatic updation of the output file name." <<
G4endl;
158 G4cout <<
" You may overwrite existing files, i.e. " <<
G4endl;
160 G4cout <<
"===========================================" <<
G4endl;
165 std::ostringstream filename;
168 << std::setw(2) << std::setfill(
'0') << i <<
".wrl";
169 strncpy(fVRMLFileName,filename.str().c_str(),
sizeof(fVRMLFileName)-1);
170 fVRMLFileName[
sizeof(fVRMLFileName)-1] =
'\0';
174 fin.open(fVRMLFileName) ;
188 G4cout <<
"===========================================" <<
G4endl;
189 G4cout <<
"Output VRML 2.0 file: " << fVRMLFileName <<
G4endl;
190 G4cout <<
"Maximum number of files in the destination directory: " << fMaxFileNum <<
G4endl;
191 G4cout <<
" (Customizable with the environment variable: G4VRMLFILE_MAX_FILE_NUM) " <<
G4endl;
192 G4cout <<
"===========================================" <<
G4endl;
194 fDest.open(fVRMLFileName) ; fFlagDestOpen = true ;
208 fDest.close(); fFlagDestOpen = false ;
210 G4cout <<
"*** VRML 2.0 File " << fVRMLFileName <<
" is generated." <<
G4endl;
218 G4cout <<
" Set an environmental variable " ;
220 G4cout <<
" if you want to visualize the generated VRML file" <<
G4endl;
225 std::ostringstream ossCommand;
226 ossCommand << viewer <<
' ' << fVRMLFileName;
227 strncpy(command,ossCommand.str().c_str(),
sizeof(command)-1);
228 command[
sizeof(command)-1] =
'\0';
229 int iErr = system( command );
232 ed <<
"Error " << iErr
233 <<
" when calling system with \"" << command
235 G4Exception(
"G4VRML2FileSceneHandler::closePort()",
241G4int 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 DEFAULT_WRL_FILE_NAME[]
const char WRL_FILE_HEADER[]
const char VRMLFILE_DEST_DIR[]
const char NO_VRML_VIEWER[]
const char ENV_VRML_VIEWER[]
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
G4VRML2FileSceneHandler(G4VRML2File &system, const G4String &name="")
virtual ~G4VRML2FileSceneHandler()
static Verbosity GetVerbosity()