Belle II Software development
VRMLWriterModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12
13#include <string>
14#include <fstream>
15
16class G4VPhysicalVolume;
17class G4LogicalVolume;
18class G4VSolid;
19class G4Polyhedron;
20class G4String;
21class HepPolyhedron;
22
23namespace Belle2 {
38 class VRMLWriterModule: public Module {
39
40 public:
41
44
46 void initialize() override;
47
49 void event() override;
50
51 private:
52
54 void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
55
57 void describeSolid(G4VSolid*, const std::string&, bool);
58
60 void describeLogicalVolume(G4LogicalVolume*, const std::string&, const std::string&, bool);
61
63 void describePhysicalVolume(G4VPhysicalVolume*);
64
66 void descendAndDescribe(G4VPhysicalVolume*, const std::string&, int);
67
69 void writePreamble(void);
70
72 void writePolyhedron(const G4Polyhedron*, const std::string&);
73
75 void writePhysicalVolume(const G4VPhysicalVolume*, const std::string&, const std::string&, bool);
76
78 HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
79
81 bool m_First{true};
82
84 std::string m_Filename{"belle2.wrl"};
85
87 std::ofstream m_File;
88
90 std::vector<std::string>* m_PVName{nullptr};
91
93 std::vector<std::string>* m_LVName{nullptr};
94
96 std::vector<std::string>* m_SolidName{nullptr};
97
99 std::vector<bool>* m_IsCylinder{nullptr};
100
102 std::vector<std::vector<int> >* m_PVIndex{nullptr};
103
105 std::vector<bool>* m_LVWritten{nullptr};
106
108 std::vector<bool>* m_PVWritten{nullptr};
109
110 };
111
113} //Belle2 namespace
Base class for Modules.
Definition: Module.h:72
The VRML-writer module.
void describeSolid(G4VSolid *, const std::string &, bool)
Emit VRML for each solid.
VRMLWriterModule()
Constructor of the module.
void writePolyhedron(const G4Polyhedron *, const std::string &)
Emit VRML for the solid's polyhedron.
void initialize() override
Initialize at the start of a job.
void event() override
Called for each event: this runs the VRML writer only for the first event.
void writePhysicalVolume(const G4VPhysicalVolume *, const std::string &, const std::string &, bool)
Emit VRML for each daughter of a logical volume.
void descendAndDescribe(G4VPhysicalVolume *, const std::string &, int)
Emit VRML for a physical volume (recursive)
std::ofstream m_File
Output file.
void writePreamble(void)
Emit VRML for the start of the file.
bool m_First
Once-only flag to write VRML only on the first event.
std::vector< std::vector< int > > * m_PVIndex
Indices (in G4PhysicalVolumeStore) of the logical volume's physical-volume daughters.
void assignName(std::vector< std::string > *, unsigned int, const G4String &, int)
Create unique and legal name for each solid.
std::vector< bool > * m_IsCylinder
Flag to indicate that a solid can be rendered as a VMRL cylinder.
std::string m_Filename
User-specified output filename.
std::vector< bool > * m_PVWritten
Flag to indicate that the physical volume has already been written.
std::vector< std::string > * m_PVName
Modified (legal-character and unique) physical-volume name.
std::vector< std::string > * m_SolidName
Modified (legal-character and unique) solid name.
void describeLogicalVolume(G4LogicalVolume *, const std::string &, const std::string &, bool)
Emit VRML for each logical volume.
std::vector< bool > * m_LVWritten
Flag to indicate that the logical volume has already been written.
HepPolyhedron * getBooleanSolidPolyhedron(G4VSolid *)
Create polyhedron for a boolean solid (recursive)
std::vector< std::string > * m_LVName
Modified (legal-character and unique) logical-volume name.
void describePhysicalVolume(G4VPhysicalVolume *)
Access next physical volume in the tree (recursive)
Abstract base class for different kinds of events.