Belle II Software light-2406-ragdoll
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 {
41 class VRMLWriterModule: public Module {
42
43 public:
44
47
49 void initialize() override;
50
52 void event() override;
53
54 private:
55
57 void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
58
60 void describeSolid(G4VSolid*, const std::string&, bool);
61
63 void describeLogicalVolume(G4LogicalVolume*, const std::string&, const std::string&, bool);
64
66 void describePhysicalVolume(G4VPhysicalVolume*);
67
69 void descendAndDescribe(G4VPhysicalVolume*, const std::string&, int);
70
72 void writePreamble(void);
73
75 void writePolyhedron(const G4Polyhedron*, const std::string&);
76
78 void writePhysicalVolume(const G4VPhysicalVolume*, const std::string&, const std::string&, bool);
79
81 HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
82
84 bool m_First{true};
85
87 std::string m_Filename{"belle2.wrl"};
88
90 std::ofstream m_File;
91
93 std::vector<std::string>* m_PVName{nullptr};
94
96 std::vector<std::string>* m_LVName{nullptr};
97
99 std::vector<std::string>* m_SolidName{nullptr};
100
102 std::vector<bool>* m_IsCylinder{nullptr};
103
105 std::vector<std::vector<int> >* m_PVIndex{nullptr};
106
108 std::vector<bool>* m_LVWritten{nullptr};
109
111 std::vector<bool>* m_PVWritten{nullptr};
112
113 };
114
116} //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.
Definition: ClusterUtils.h:24