Geant4 11.4.0
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 ()
G4int GetMaxGeometryDepth () const
void SetMaxGeometryDepth (G4int maxDepth)

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 ProcessTransients ()
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
std::map< G4VPhysicalVolume *, G4StringfProblematicVolumes
Protected Attributes inherited from G4VGraphicsScene
G4int fMaxGeometryDepth = 0

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="")
G4VGraphicsSystem & fSystem

◆ ~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 135 of file G4VSceneHandler.cc.

430{
431 G4warn <<
432 "There has been an attempt to draw a mesh with option \""
433 << fpViewer->GetViewParameters().GetSpecialMeshRenderingOption()
434 << "\":\n" << mesh
435 << "but it is not of a recognised type or is not implemented"
436 "\nby the current graphics driver. Instead we draw its"
437 "\ncontainer \"" << mesh.GetContainerVolume()->GetName() << "\"."
438 << G4endl;
439 const auto& pv = mesh.GetContainerVolume();
440 const auto& lv = pv->GetLogicalVolume();
441 const auto& solid = lv->GetSolid();
442 const auto& transform = mesh.GetTransform();
443 // Make sure container is visible
444 G4VisAttributes tmpVisAtts; // Visible, white, not forced.
445 const auto& saveVisAtts = lv->GetVisAttributes();
446 if (saveVisAtts) {
447 tmpVisAtts = *saveVisAtts;
448 tmpVisAtts.SetVisibility(true);
449 auto colour = saveVisAtts->GetColour();
450 colour.SetAlpha(1.);
451 tmpVisAtts.SetColour(colour);
452 }
453 // Draw container
454 PreAddSolid(transform,tmpVisAtts);
455 solid->DescribeYourselfTo(*this);
456 PostAddSolid();
457 // Restore vis attributes
458 lv->SetVisAttributes(saveVisAtts);
459}
#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()
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 133 of file G4VSceneHandler.cc.

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

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

◆ AddCompound() [4/6]

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

Reimplemented from G4VSceneHandler.

Definition at line 132 of file G4VSceneHandler.cc.

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

◆ AddCompound() [5/6]

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

Reimplemented from G4VSceneHandler.

Definition at line 131 of file G4VSceneHandler.cc.

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

◆ AddCompound() [6/6]

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

Reimplemented from G4VSceneHandler.

Definition at line 130 of file G4VSceneHandler.cc.

323 {
324 G4TrajectoriesModel* trajectoriesModel =
325 dynamic_cast<G4TrajectoriesModel*>(fpModel);
326 if (trajectoriesModel)
327 traj.DrawTrajectory();
328 else {
330 ("G4VSceneHandler::AddCompound(const G4VTrajectory&)",
331 "visman0105", FatalException, "Not a G4TrajectoriesModel.");
332 }
333}
@ 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 195 of file G4VSceneHandler.cc.

508 {
509 G4warn << "WARNING: Plotter not implemented for " << fSystem.GetName() << G4endl;
510 G4warn << " Open a plotter-aware graphics system or remove plotter with" << G4endl;
511 G4warn << " /vis/scene/removeModel Plotter" << G4endl;
512}

◆ 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 193 of file G4VSceneHandler.cc.

465 {
466 switch (polymarker.GetMarkerType()) {
467 default:
469 {
470 G4Circle dot (polymarker);
471 dot.SetWorldSize (0.);
472 dot.SetScreenSize (0.1); // Very small circle.
473 for (const auto& iPoint : polymarker) {
474 dot.SetPosition (iPoint);
475 AddPrimitive (dot);
476 }
477 }
478 break;
480 {
481 G4Circle circle (polymarker); // Default circle
482 for (const auto& iPoint : polymarker) {
483 circle.SetPosition (iPoint);
484 AddPrimitive (circle);
485 }
486 }
487 break;
489 {
490 G4Square square (polymarker); // Default square
491 for (const auto& iPoint : polymarker) {
492 square.SetPosition (iPoint);
493 AddPrimitive (square);
494 }
495 }
496 break;
497 }
498}
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 112 of file G4VSceneHandler.cc.

303 {
304 AddSolidWithAuxiliaryEdges (ellipsoid);
305}
void AddSolidWithAuxiliaryEdges(const T &solid)

◆ AddSolid() [4/14]

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

Reimplemented from G4VSceneHandler.

Definition at line 103 of file G4VSceneHandler.cc.

275 {
277}

◆ 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 113 of file G4VSceneHandler.cc.

307 {
308 AddSolidT (polycone);
309}
void AddSolidT(const T &solid)

◆ AddSolid() [7/14]

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

Reimplemented from G4VSceneHandler.

Definition at line 114 of file G4VSceneHandler.cc.

311 {
312 AddSolidT (polyhedra);
313}

◆ 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 115 of file G4VSceneHandler.cc.

315 {
316 AddSolidT (tess);
317}

◆ 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 ( )

◆ G4VRML2FileViewer

friend class G4VRML2FileViewer
friend

Definition at line 45 of file G4VRML2FileSceneHandler.hh.

Referenced by G4VRML2FileViewer.

Member Data Documentation

◆ fDest

std::ofstream G4VRML2FileSceneHandler::fDest

Definition at line 122 of file G4VRML2FileSceneHandler.hh.

Referenced by closePort(), connectPort(), and G4VRML2FileSceneHandler().


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