Belle II Software  release-05-02-19
VRMLWriterModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Leo Piilonen *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef VRMLWRITERMODULE_H
12 #define VRMLWRITERMODULE_H
13 
14 #include <framework/core/Module.h>
15 
16 #include <string>
17 #include <fstream>
18 
19 class G4VPhysicalVolume;
20 class G4LogicalVolume;
21 class G4VSolid;
22 class G4Polyhedron;
23 class G4String;
24 class HepPolyhedron;
25 
26 namespace Belle2 {
44  class VRMLWriterModule: public Module {
45 
46  public:
47 
50 
52  void initialize() override;
53 
55  void event() override;
56 
57  private:
58 
60  void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
61 
63  void describeSolid(G4VSolid*, const std::string&, bool);
64 
66  void describeLogicalVolume(G4LogicalVolume*, const std::string&, const std::string&, bool);
67 
69  void describePhysicalVolume(G4VPhysicalVolume*);
70 
72  void descendAndDescribe(G4VPhysicalVolume*, const std::string&, int);
73 
75  void writePreamble(void);
76 
78  void writePolyhedron(const G4Polyhedron*, const std::string&);
79 
81  void writePhysicalVolume(const G4VPhysicalVolume*, const std::string&, const std::string&, bool);
82 
84  HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
85 
87  bool m_First{true};
88 
90  std::string m_Filename{"belle2.wrl"};
91 
93  std::ofstream m_File;
94 
96  std::vector<std::string>* m_PVName{nullptr};
97 
99  std::vector<std::string>* m_LVName{nullptr};
100 
102  std::vector<std::string>* m_SolidName{nullptr};
103 
105  std::vector<bool>* m_IsCylinder{nullptr};
106 
108  std::vector<std::vector<int> >* m_PVIndex{nullptr};
109 
111  std::vector<bool>* m_LVWritten{nullptr};
112 
114  std::vector<bool>* m_PVWritten{nullptr};
115 
116  };
117 
119 } //Belle2 namespace
120 #endif
Belle2::VRMLWriterModule::assignName
void assignName(std::vector< std::string > *, unsigned int, const G4String &, int)
Create unique and legal name for each solid.
Definition: VRMLWriterModule.cc:128
Belle2::VRMLWriterModule::writePreamble
void writePreamble(void)
Emit VRML for the start of the file.
Definition: VRMLWriterModule.cc:447
Belle2::VRMLWriterModule::m_First
bool m_First
Once-only flag to write VRML only on the first event.
Definition: VRMLWriterModule.h:87
Belle2::VRMLWriterModule::m_IsCylinder
std::vector< bool > * m_IsCylinder
Flag to indicate that a solid can be rendered as a VMRL cylinder.
Definition: VRMLWriterModule.h:105
Belle2::VRMLWriterModule::m_File
std::ofstream m_File
Output file.
Definition: VRMLWriterModule.h:93
Belle2::VRMLWriterModule::m_Filename
std::string m_Filename
User-specified output filename.
Definition: VRMLWriterModule.h:90
Belle2::VRMLWriterModule
The VRML-writer module.
Definition: VRMLWriterModule.h:44
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::VRMLWriterModule::VRMLWriterModule
VRMLWriterModule()
Constructor of the module.
Definition: VRMLWriterModule.cc:38
Belle2::VRMLWriterModule::m_SolidName
std::vector< std::string > * m_SolidName
Modified (legal-character and unique) solid name.
Definition: VRMLWriterModule.h:102
Belle2::VRMLWriterModule::m_LVWritten
std::vector< bool > * m_LVWritten
Flag to indicate that the logical volume has already been written.
Definition: VRMLWriterModule.h:111
Belle2::VRMLWriterModule::writePhysicalVolume
void writePhysicalVolume(const G4VPhysicalVolume *, const std::string &, const std::string &, bool)
Emit VRML for each daughter of a logical volume.
Definition: VRMLWriterModule.cc:518
Belle2::VRMLWriterModule::event
void event() override
Called for each event: this runs the VRML writer only for the first event.
Definition: VRMLWriterModule.cc:52
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VRMLWriterModule::describeSolid
void describeSolid(G4VSolid *, const std::string &, bool)
Emit VRML for each solid.
Definition: VRMLWriterModule.cc:163
Belle2::VRMLWriterModule::getBooleanSolidPolyhedron
HepPolyhedron * getBooleanSolidPolyhedron(G4VSolid *)
Create polyhedron for a boolean solid (recursive)
Definition: VRMLWriterModule.cc:570
Belle2::VRMLWriterModule::m_LVName
std::vector< std::string > * m_LVName
Modified (legal-character and unique) logical-volume name.
Definition: VRMLWriterModule.h:99
Belle2::VRMLWriterModule::describeLogicalVolume
void describeLogicalVolume(G4LogicalVolume *, const std::string &, const std::string &, bool)
Emit VRML for each logical volume.
Definition: VRMLWriterModule.cc:198
Belle2::VRMLWriterModule::m_PVName
std::vector< std::string > * m_PVName
Modified (legal-character and unique) physical-volume name.
Definition: VRMLWriterModule.h:96
Belle2::VRMLWriterModule::descendAndDescribe
void descendAndDescribe(G4VPhysicalVolume *, const std::string &, int)
Emit VRML for a physical volume (recursive)
Definition: VRMLWriterModule.cc:425
Belle2::VRMLWriterModule::initialize
void initialize() override
Initialize at the start of a job.
Definition: VRMLWriterModule.cc:47
Belle2::VRMLWriterModule::describePhysicalVolume
void describePhysicalVolume(G4VPhysicalVolume *)
Access next physical volume in the tree (recursive)
Definition: VRMLWriterModule.cc:358
Belle2::VRMLWriterModule::writePolyhedron
void writePolyhedron(const G4Polyhedron *, const std::string &)
Emit VRML for the solid's polyhedron.
Definition: VRMLWriterModule.cc:485
Belle2::VRMLWriterModule::m_PVWritten
std::vector< bool > * m_PVWritten
Flag to indicate that the physical volume has already been written.
Definition: VRMLWriterModule.h:114
Belle2::VRMLWriterModule::m_PVIndex
std::vector< std::vector< int > > * m_PVIndex
Indices (in G4PhysicalVolumeStore) of the logical volume's physical-volume daughters.
Definition: VRMLWriterModule.h:108