Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VRML2FileSceneHandler Class Reference

#include <G4VRML2FileSceneHandler.hh>

+ Inheritance diagram for G4VRML2FileSceneHandler:

Public Member Functions

 G4VRML2FileSceneHandler (G4VRML2File &system, const G4String &name="")
 
virtual ~G4VRML2FileSceneHandler ()
 
void AddSolid (const G4Box &)
 
void AddSolid (const G4Cons &)
 
void AddSolid (const G4Tubs &)
 
void AddSolid (const G4Trd &)
 
void AddSolid (const G4Trap &)
 
void AddSolid (const G4Sphere &)
 
void AddSolid (const G4Para &)
 
void AddSolid (const G4Torus &)
 
void AddSolid (const G4VSolid &)
 
void BeginPrimitives (const G4Transform3D &objectTransformation)
 
void EndPrimitives ()
 
void AddPrimitive (const G4Polyline &)
 
void AddPrimitive (const G4Polyhedron &)
 
void AddPrimitive (const G4Text &)
 
void AddPrimitive (const G4Circle &)
 
void AddPrimitive (const G4Square &)
 
void ClearTransientStore ()
 
void BeginModeling ()
 
void EndModeling ()
 
void VRMLBeginModeling ()
 
void VRMLEndModeling ()
 
void connectPort ()
 
void closePort ()
 
virtual void AddSolid (const G4Orb &)
 
virtual void AddSolid (const G4Ellipsoid &)
 
virtual void AddSolid (const G4Polycone &)
 
virtual void AddSolid (const G4Polyhedra &)
 
virtual void AddSolid (const G4TessellatedSolid &)
 
virtual void AddCompound (const G4VTrajectory &)
 
virtual void AddCompound (const G4VHit &)
 
virtual void AddCompound (const G4VDigi &)
 
virtual void AddCompound (const G4THitsMap< G4double > &)
 
virtual void AddCompound (const G4THitsMap< G4StatDouble > &)
 
virtual void AddCompound (const G4Mesh &)
 
virtual void AddPrimitive (const G4Polymarker &)
 
virtual void AddPrimitive (const G4Plotter &)
 
- Public Member Functions inherited from G4VSceneHandler
 G4VSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
 
virtual ~G4VSceneHandler ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual void PostAddSolid ()
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())
 
virtual void EndPrimitives2D ()
 
virtual const G4VisExtentGetExtent () const
 
const G4StringGetName () const
 
G4int GetSceneHandlerId () const
 
G4int GetViewCount () const
 
G4VGraphicsSystemGetGraphicsSystem () const
 
G4SceneGetScene () const
 
const G4ViewerListGetViewerList () const
 
G4VModelGetModel () const
 
G4VViewerGetCurrentViewer () const
 
G4bool GetMarkForClearingTransientStore () const
 
G4bool IsReadyForTransients () const
 
G4bool GetTransientsDrawnThisEvent () const
 
G4bool GetTransientsDrawnThisRun () const
 
const G4Transform3DGetObjectTransformation () const
 
void SetName (const G4String &)
 
void SetCurrentViewer (G4VViewer *)
 
virtual void SetScene (G4Scene *)
 
G4ViewerListSetViewerList ()
 
void SetModel (G4VModel *)
 
void SetMarkForClearingTransientStore (G4bool)
 
void SetTransientsDrawnThisEvent (G4bool)
 
void SetTransientsDrawnThisRun (G4bool)
 
void SetObjectTransformation (const G4Transform3D &)
 
const G4ColourGetColour ()
 
const G4ColourGetColor ()
 
const G4ColourGetColour (const G4Visible &)
 
const G4ColourGetColor (const G4Visible &)
 
const G4ColourGetTextColour (const G4Text &)
 
const G4ColourGetTextColor (const G4Text &)
 
G4double GetLineWidth (const G4VisAttributes *)
 
G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes *)
 
G4int GetNumberOfCloudPoints (const G4VisAttributes *) const
 
G4bool GetAuxEdgeVisible (const G4VisAttributes *)
 
G4int GetNoOfSides (const G4VisAttributes *)
 
G4double GetMarkerSize (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerDiameter (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerRadius (const G4VMarker &, MarkerSizeType &)
 
G4ModelingParametersCreateModelingParameters ()
 
void DrawEvent (const G4Event *)
 
void DrawEndOfRunModels ()
 
template<class T >
void AddSolidT (const T &solid)
 
template<class T >
void AddSolidWithAuxiliaryEdges (const T &solid)
 
G4int IncrementViewCount ()
 
virtual void ClearStore ()
 
void AddViewerToList (G4VViewer *pView)
 
void RemoveViewerFromList (G4VViewer *pView)
 
- Public Member Functions inherited from G4VGraphicsScene
 G4VGraphicsScene ()
 
virtual ~G4VGraphicsScene ()
 

Public Attributes

std::ofstream fDest
 

Friends

class G4VRML2FileViewer
 

Additional Inherited Members

- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
virtual void RequestPrimitives (const G4VSolid &solid)
 
virtual G4DisplacedSolidCreateSectionSolid ()
 
virtual G4DisplacedSolidCreateCutawaySolid ()
 
void LoadAtts (const G4Visible &, G4AttHolder *)
 
void StandardSpecialMeshRendering (const G4Mesh &)
 
void Draw3DRectMeshAsDots (const G4Mesh &)
 
void Draw3DRectMeshAsSurfaces (const G4Mesh &)
 
void DrawTetMeshAsDots (const G4Mesh &)
 
void DrawTetMeshAsSurfaces (const G4Mesh &)
 
G4ThreeVector GetPointInBox (const G4ThreeVector &pos, G4double halfX, G4double halfY, G4double halfZ) const
 
G4ThreeVector GetPointInTet (const std::vector< G4ThreeVector > &vertices) const
 
- Protected Attributes inherited from G4VSceneHandler
G4VGraphicsSystemfSystem
 
const G4int fSceneHandlerId
 
G4String fName
 
G4int fViewCount
 
G4ViewerList fViewerList
 
G4VViewerfpViewer
 
G4ScenefpScene
 
G4bool fMarkForClearingTransientStore
 
G4bool fReadyForTransients
 
G4bool fTransientsDrawnThisEvent
 
G4bool fTransientsDrawnThisRun
 
G4bool fProcessingSolid
 
G4bool fProcessing2D
 
G4VModelfpModel
 
G4Transform3D fObjectTransformation
 
G4int fNestingDepth
 
const G4VisAttributesfpVisAttribs
 
const G4Transform3D fIdentityTransformation
 

Detailed Description

Definition at line 43 of file G4VRML2FileSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4VRML2FileSceneHandler()

G4VRML2FileSceneHandler::G4VRML2FileSceneHandler ( G4VRML2File & system,
const G4String & name = "" )

Definition at line 72 of file G4VRML2FileSceneHandler.cc.

74 : G4VSceneHandler(system, fSceneIdCount++, name)
75 , fSystem(system)
76 , fFlagDestOpen(false)
77 , fPVPickable(false)
78 , fDest()
79{
80 // output file name
81 strcpy(fVRMLFileName, "");
82
83 // destination directory
84 if(std::getenv(VRMLFILE_DEST_DIR) == NULL)
85 {
86 strcpy(fVRMLFileDestDir, "");
87 }
88 else
89 {
90 strcpy(fVRMLFileDestDir, std::getenv(VRMLFILE_DEST_DIR));
91 }
92
93 // maximum number of g4.prim files in the dest directory
94 fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM; // initialization
95 if(std::getenv("G4VRMLFILE_MAX_FILE_NUM") != NULL)
96 {
97 sscanf(std::getenv("G4VRMLFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum);
98 }
99 else
100 {
101 fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM;
102 }
103 if(fMaxFileNum < 1)
104 {
105 fMaxFileNum = 1;
106 }
107
108 // PV name pickability
109 if(std::getenv("G4VRML_PV_PICKABLE") != NULL)
110 {
111 int is_pickable;
112 sscanf(std::getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable);
113
114 if(is_pickable)
115 {
116 SetPVPickability(true);
117 }
118 }
119
120 // PV Transparency
121 SetPVTransparency();
122}
const int DEFAULT_MAX_WRL_FILE_NUM
const char VRMLFILE_DEST_DIR[]
G4VSceneHandler(G4VGraphicsSystem &system, G4int id, const G4String &name="")

◆ ~G4VRML2FileSceneHandler()

G4VRML2FileSceneHandler::~G4VRML2FileSceneHandler ( )
virtual

Definition at line 124 of file G4VRML2FileSceneHandler.cc.

125{
126#if defined DEBUG_FR_SCENE
128 G4cout << "***** ~G4VRML2FileSceneHandler" << G4endl;
129#endif
131}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()

Member Function Documentation

◆ AddCompound() [1/6]

void G4VSceneHandler::AddCompound ( const G4Mesh & mesh)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 133 of file G4VSceneHandler.cc.

434{
435 G4warn <<
436 "There has been an attempt to draw a mesh with option \""
438 << "\":\n" << mesh
439 << "but it is not of a recognised type or is not implemented"
440 "\nby the current graphics driver. Instead we draw its"
441 "\ncontainer \"" << mesh.GetContainerVolume()->GetName() << "\"."
442 << G4endl;
443 const auto& pv = mesh.GetContainerVolume();
444 const auto& lv = pv->GetLogicalVolume();
445 const auto& solid = lv->GetSolid();
446 const auto& transform = mesh.GetTransform();
447 // Make sure container is visible
448 G4VisAttributes tmpVisAtts; // Visible, white, not forced.
449 const auto& saveVisAtts = lv->GetVisAttributes();
450 if (saveVisAtts) {
451 tmpVisAtts = *saveVisAtts;
452 tmpVisAtts.SetVisibility(true);
453 auto colour = saveVisAtts->GetColour();
454 colour.SetAlpha(1.);
455 tmpVisAtts.SetColour(colour);
456 }
457 // Draw container
458 PreAddSolid(transform,tmpVisAtts);
459 solid->DescribeYourselfTo(*this);
460 PostAddSolid();
461 // Restore vis attributes
462 lv->SetVisAttributes(saveVisAtts);
463}
#define G4warn
Definition G4Scene.cc:41
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetContainerVolume() const
Definition G4Mesh.hh:73
const G4Transform3D & GetTransform() const
Definition G4Mesh.hh:77
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void PostAddSolid()
const G4ViewParameters & GetViewParameters() const
SMROption GetSpecialMeshRenderingOption() const
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)

◆ AddCompound() [2/6]

void G4VSceneHandler::AddCompound ( const G4THitsMap< G4double > & hits)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 131 of file G4VSceneHandler.cc.

347 {
348 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
349 //G4cout << "AddCompound: hits: " << &hits << G4endl;
350 G4bool scoreMapHits = false;
352 if (scoringManager) {
353 std::size_t nMeshes = scoringManager->GetNumberOfMesh();
354 for (std::size_t iMesh = 0; iMesh < nMeshes; ++iMesh) {
355 G4VScoringMesh* mesh = scoringManager->GetMesh((G4int)iMesh);
356 if (mesh && mesh->IsActive()) {
357 MeshScoreMap scoreMap = mesh->GetScoreMap();
358 const G4String& mapNam = const_cast<G4THitsMap<G4double>&>(hits).GetName();
359 for(MeshScoreMap::const_iterator i = scoreMap.cbegin();
360 i != scoreMap.cend(); ++i) {
361 const G4String& scoreMapName = i->first;
362 if (scoreMapName == mapNam) {
363 G4DefaultLinearColorMap colorMap("G4VSceneHandlerColorMap");
364 scoreMapHits = true;
365 mesh->DrawMesh(scoreMapName, &colorMap);
366 }
367 }
368 }
369 }
370 }
371 if (scoreMapHits) {
372 static G4bool first = true;
373 if (first) {
374 first = false;
375 G4cout <<
376 "Scoring map drawn with default parameters."
377 "\n To get gMocren file for gMocren browser:"
378 "\n /vis/open gMocrenFile"
379 "\n /vis/viewer/flush"
380 "\n Many other options available with /score/draw... commands."
381 "\n You might want to \"/vis/viewer/set/autoRefresh false\"."
382 << G4endl;
383 }
384 } else { // Not score map hits. Just call DrawAllHits.
385 // Cast away const because DrawAllHits is non-const!!!!
386 const_cast<G4THitsMap<G4double>&>(hits).DrawAllHits();
387 }
388}
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4VScoringMesh * GetMesh(G4int i) const
size_t GetNumberOfMesh() const
static G4ScoringManager * GetScoringManagerIfExist()
const G4String & GetName() const
G4bool IsActive() const
std::map< G4String, RunScore * > MeshScoreMap
void DrawMesh(const G4String &psName, G4VScoreColorMap *colorMap, G4int axflg=111)
MeshScoreMap GetScoreMap() const

◆ AddCompound() [3/6]

void G4VSceneHandler::AddCompound ( const G4THitsMap< G4StatDouble > & hits)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 132 of file G4VSceneHandler.cc.

390 {
391 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
392 //G4cout << "AddCompound: hits: " << &hits << G4endl;
393 G4bool scoreMapHits = false;
395 if (scoringManager) {
396 std::size_t nMeshes = scoringManager->GetNumberOfMesh();
397 for (std::size_t iMesh = 0; iMesh < nMeshes; ++iMesh) {
398 G4VScoringMesh* mesh = scoringManager->GetMesh((G4int)iMesh);
399 if (mesh && mesh->IsActive()) {
400 MeshScoreMap scoreMap = mesh->GetScoreMap();
401 for(MeshScoreMap::const_iterator i = scoreMap.cbegin();
402 i != scoreMap.cend(); ++i) {
403 const G4String& scoreMapName = i->first;
404 const G4THitsMap<G4StatDouble>* foundHits = i->second;
405 if (foundHits == &hits) {
406 G4DefaultLinearColorMap colorMap("G4VSceneHandlerColorMap");
407 scoreMapHits = true;
408 mesh->DrawMesh(scoreMapName, &colorMap);
409 }
410 }
411 }
412 }
413 }
414 if (scoreMapHits) {
415 static G4bool first = true;
416 if (first) {
417 first = false;
418 G4cout <<
419 "Scoring map drawn with default parameters."
420 "\n To get gMocren file for gMocren browser:"
421 "\n /vis/open gMocrenFile"
422 "\n /vis/viewer/flush"
423 "\n Many other options available with /score/draw... commands."
424 "\n You might want to \"/vis/viewer/set/autoRefresh false\"."
425 << G4endl;
426 }
427 } else { // Not score map hits. Just call DrawAllHits.
428 // Cast away const because DrawAllHits is non-const!!!!
429 const_cast<G4THitsMap<G4StatDouble>&>(hits).DrawAllHits();
430 }
431}

◆ AddCompound() [4/6]

void G4VSceneHandler::AddCompound ( const G4VDigi & digi)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 130 of file G4VSceneHandler.cc.

342 {
343 // Cast away const because Draw is non-const!!!!
344 const_cast<G4VDigi&>(digi).Draw();
345}

◆ AddCompound() [5/6]

void G4VSceneHandler::AddCompound ( const G4VHit & hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 129 of file G4VSceneHandler.cc.

337 {
338 // Cast away const because Draw is non-const!!!!
339 const_cast<G4VHit&>(hit).Draw();
340}

◆ AddCompound() [6/6]

void G4VSceneHandler::AddCompound ( const G4VTrajectory & traj)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 128 of file G4VSceneHandler.cc.

325 {
326 G4TrajectoriesModel* trajectoriesModel =
327 dynamic_cast<G4TrajectoriesModel*>(fpModel);
328 if (trajectoriesModel)
329 traj.DrawTrajectory();
330 else {
332 ("G4VSceneHandler::AddCompound(const G4VTrajectory&)",
333 "visman0105", FatalException, "Not a G4TrajectoriesModel.");
334 }
335}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
virtual void DrawTrajectory() const

◆ AddPrimitive() [1/7]

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Circle & )
virtual

Implements G4VSceneHandler.

◆ AddPrimitive() [2/7]

void G4VSceneHandler::AddPrimitive ( const G4Plotter & )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 193 of file G4VSceneHandler.cc.

512 {
513 G4warn << "WARNING: Plotter not implemented for " << fSystem.GetName() << G4endl;
514 G4warn << " Open a plotter-aware graphics system or remove plotter with" << G4endl;
515 G4warn << " /vis/scene/removeModel Plotter" << G4endl;
516}
const G4String & GetName() const

◆ AddPrimitive() [3/7]

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Polyhedron & )
virtual

Implements G4VSceneHandler.

◆ AddPrimitive() [4/7]

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Polyline & )
virtual

Implements G4VSceneHandler.

◆ AddPrimitive() [5/7]

void G4VSceneHandler::AddPrimitive ( const G4Polymarker & polymarker)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 191 of file G4VSceneHandler.cc.

469 {
470 switch (polymarker.GetMarkerType()) {
471 default:
473 {
474 G4Circle dot (polymarker);
475 dot.SetWorldSize (0.);
476 dot.SetScreenSize (0.1); // Very small circle.
477 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
478 dot.SetPosition (polymarker[iPoint]);
479 AddPrimitive (dot);
480 }
481 }
482 break;
484 {
485 G4Circle circle (polymarker); // Default circle
486 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
487 circle.SetPosition (polymarker[iPoint]);
488 AddPrimitive (circle);
489 }
490 }
491 break;
493 {
494 G4Square square (polymarker); // Default square
495 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
496 square.SetPosition (polymarker[iPoint]);
497 AddPrimitive (square);
498 }
499 }
500 break;
501 }
502}
MarkerType GetMarkerType() const
void AddPrimitive(const G4Polyline &)

◆ AddPrimitive() [6/7]

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Square & )
virtual

Implements G4VSceneHandler.

◆ AddPrimitive() [7/7]

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Text & )
virtual

Implements G4VSceneHandler.

◆ AddSolid() [1/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Box & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [2/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Cons & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [3/14]

void G4VSceneHandler::AddSolid ( const G4Ellipsoid & ellipsoid)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 110 of file G4VSceneHandler.cc.

305 {
306 AddSolidWithAuxiliaryEdges (ellipsoid);
307}
void AddSolidWithAuxiliaryEdges(const T &solid)

◆ AddSolid() [4/14]

void G4VSceneHandler::AddSolid ( const G4Orb & orb)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 101 of file G4VSceneHandler.cc.

277 {
279}

◆ AddSolid() [5/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Para & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [6/14]

void G4VSceneHandler::AddSolid ( const G4Polycone & polycone)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 111 of file G4VSceneHandler.cc.

309 {
310 AddSolidT (polycone);
311}
void AddSolidT(const T &solid)

◆ AddSolid() [7/14]

void G4VSceneHandler::AddSolid ( const G4Polyhedra & polyhedra)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 112 of file G4VSceneHandler.cc.

313 {
314 AddSolidT (polyhedra);
315}

◆ AddSolid() [8/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Sphere & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [9/14]

void G4VSceneHandler::AddSolid ( const G4TessellatedSolid & tess)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 113 of file G4VSceneHandler.cc.

317 {
318 AddSolidT (tess);
319}

◆ AddSolid() [10/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Torus & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [11/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Trap & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [12/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Trd & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [13/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4Tubs & )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [14/14]

void G4VRML2FileSceneHandler::AddSolid ( const G4VSolid & )
virtual

Reimplemented from G4VSceneHandler.

◆ BeginModeling()

void G4VRML2FileSceneHandler::BeginModeling ( )
virtual

Reimplemented from G4VSceneHandler.

◆ BeginPrimitives()

void G4VRML2FileSceneHandler::BeginPrimitives ( const G4Transform3D & objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

◆ ClearTransientStore()

void G4VRML2FileSceneHandler::ClearTransientStore ( )
virtual

Reimplemented from G4VSceneHandler.

◆ closePort()

void G4VRML2FileSceneHandler::closePort ( )

Definition at line 220 of file G4VRML2FileSceneHandler.cc.

221{
222 char command[256];
223 char viewer[256];
224 strcpy(viewer, NO_VRML_VIEWER); // initialization
225 if(std::getenv(ENV_VRML_VIEWER))
226 {
227 strcpy(viewer, std::getenv(ENV_VRML_VIEWER));
228 }
229
230 // close VRML file
231 fDest.close();
232 fFlagDestOpen = false;
234 G4cout << "*** VRML 2.0 File " << fVRMLFileName << " is generated."
235 << G4endl;
236
237 // Invoke viewer
238
239 if(!strcmp(viewer, NO_VRML_VIEWER))
240 {
242 {
243 G4cout << "MESSAGE from VRML2FILE driver:" << G4endl;
244 G4cout << " Set an environmental variable ";
246 G4cout << " if you want to visualize the generated VRML file"
247 << G4endl;
248 G4cout << " automatically. For example, " << G4endl;
249 G4cout << " setenv " << ENV_VRML_VIEWER << " vrwave " << G4endl;
250 G4cout << "ALSO you may change the file header with "
252 G4cout << " or the whole filename with " << ENV_WRL_FILE_NAME
253 << G4endl;
254 }
255 }
256 else
257 {
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);
263 if(iErr != 0)
264 {
266 ed << "Error " << iErr << " when calling system with \"" << command
267 << "\".";
268 G4Exception("G4VRML2FileSceneHandler::closePort()", "VRML-2006",
269 JustWarning, ed);
270 }
271 }
272}
@ JustWarning
std::ostringstream G4ExceptionDescription
const char ENV_WRL_FILE_NAME[]
const char NO_VRML_VIEWER[]
const char ENV_WRL_FILE_HEADER[]
const char ENV_VRML_VIEWER[]

◆ connectPort()

void G4VRML2FileSceneHandler::connectPort ( )

Definition at line 139 of file G4VRML2FileSceneHandler.cc.

140{
141 // g4_00.wrl, g4_01.wrl, ..., g4_MAX_FILE_INDEX.wrl
142 const int MAX_FILE_INDEX = fMaxFileNum - 1;
143
144 // dest directory (null if no environmental variables is set)
145 strcpy(fVRMLFileName, fVRMLFileDestDir);
146 // add filename if environment variable supplied
147 if(std::getenv(ENV_WRL_FILE_NAME))
148 {
149 strcat(fVRMLFileName, std::getenv(ENV_WRL_FILE_NAME));
150 }
151 else
152 {
153 // Determine VRML file name
154 for(int i = 0; i < fMaxFileNum; i++)
155 {
156 // Message in the final execution
157 if(i == MAX_FILE_INDEX)
158 {
160 {
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;
166 G4cout << " g4_XX.wrl. " << G4endl;
167 G4cout << "===========================================" << G4endl;
168 }
169 }
170
171 // re-determine file name as G4VRMLFILE_DEST_DIR/g4_XX.wrl
172 std::ostringstream filename;
173 filename << fVRMLFileDestDir;
174 if(std::getenv(ENV_WRL_FILE_HEADER) == NULL)
175 {
176 filename << WRL_FILE_HEADER;
177 }
178 else
179 {
180 filename << std::getenv(ENV_WRL_FILE_HEADER) << '_';
181 }
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';
185
186 // check validity of the file name
187 std::ifstream fin;
188 fin.open(fVRMLFileName);
189 if(!fin)
190 {
191 // new file
192 fin.close();
193 break;
194 }
195 else
196 {
197 // already exists (try next)
198 fin.close();
199 }
200
201 } // for
202 }
203
204 // open a VRML 2.0 file with determined file name
206 {
207 G4cout << "===========================================" << G4endl;
208 G4cout << "Output VRML 2.0 file: " << fVRMLFileName << G4endl;
209 G4cout << "Maximum number of files in the destination directory: "
210 << fMaxFileNum << G4endl;
211 G4cout << " (Customizable with the environment variable: "
212 "G4VRMLFILE_MAX_FILE_NUM) "
213 << G4endl;
214 G4cout << "===========================================" << G4endl;
215 }
216 fDest.open(fVRMLFileName);
217 fFlagDestOpen = true;
218}
const char WRL_FILE_HEADER[]

◆ EndModeling()

void G4VRML2FileSceneHandler::EndModeling ( )
virtual

Reimplemented from G4VSceneHandler.

◆ EndPrimitives()

void G4VRML2FileSceneHandler::EndPrimitives ( )
virtual

Reimplemented from G4VSceneHandler.

◆ VRMLBeginModeling()

void G4VRML2FileSceneHandler::VRMLBeginModeling ( )

◆ VRMLEndModeling()

void G4VRML2FileSceneHandler::VRMLEndModeling ( )

Friends And Related Symbol Documentation

◆ G4VRML2FileViewer

friend class G4VRML2FileViewer
friend

Definition at line 45 of file G4VRML2FileSceneHandler.hh.

Member Data Documentation

◆ fDest

std::ofstream G4VRML2FileSceneHandler::fDest

The documentation for this class was generated from the following files: