Belle II Software development
FBXWriterModule.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 {
37 class FBXWriterModule: public Module {
38
39 public:
40
43
45 void initialize() override;
46
48 void event() override;
49
50 private:
51
53 void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
54
56 void writeGeometryNode(G4VSolid*, const std::string&, unsigned long long);
57
59 void writeMaterialNode(int, const std::string&);
60
62 void writeLVModelNode(G4LogicalVolume*, const std::string&, unsigned long long);
63
65 void writePVModelNode(G4VPhysicalVolume*, const std::string&, unsigned long long);
66
68 void countEntities(G4VPhysicalVolume*);
69
71 void addModels(G4VPhysicalVolume*, int);
72
74 void addConnections(G4VPhysicalVolume*, int);
75
77 void writePreamble(int, int, int);
78
80 void writePolyhedron(G4VSolid*, G4Polyhedron*, const std::string&, unsigned long long);
81
83 void writeSolidToLV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
84
86 void writeSolidToPV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
87
89 void writeLVToPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
90
92 void writePVToParentLV(const std::string&, const std::string&, unsigned long long, unsigned long long);
93
95 void writePVToParentPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
96
98 HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
99
101 bool m_First{true};
102
105 bool m_UsePrototypes{false};
106
108 std::string m_Filename{"belle2.fbx"};
109
111 std::ofstream m_File;
112
114 std::vector<std::string>* m_PVName{nullptr};
115
117 std::vector<std::string>* m_LVName{nullptr};
118
120 std::vector<std::string>* m_SolidName{nullptr};
121
123 std::vector<unsigned long long>* m_PVID{nullptr};
124
126 std::vector<unsigned long long>* m_LVID{nullptr};
127
129 std::vector<unsigned long long>* m_MatID{nullptr};
130
132 std::vector<unsigned long long>* m_SolidID{nullptr};
133
135 std::vector<bool>* m_Visible{nullptr};
136
138 std::vector<unsigned int>* m_PVCount{nullptr};
139
141 std::vector<unsigned int>* m_LVCount{nullptr};
142
144 std::vector<unsigned int>* m_SolidCount{nullptr};
145
147 std::vector<unsigned int>* m_PVReplicas{nullptr};
148
150 std::vector<unsigned int>* m_LVReplicas{nullptr};
151
153 std::vector<unsigned int>* m_SolidReplicas{nullptr};
154
156 std::vector<bool>* m_LVUnique{nullptr};
157
158 };
159
161} //Belle2 namespace
The FBX-writer module.
std::vector< unsigned int > * m_PVCount
Count of number of instances of each physical volume.
void writePVToParentLV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for each physical-volume daughter of a parent logical volume.
std::vector< unsigned long long > * m_LVID
Unique identifiers for logical volumes (Model nodes with links to Geometry and Material)
void writeLVToPV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for the (unique) logical volume of a physical volume.
void addConnections(G4VPhysicalVolume *, int)
Write FBX connections among all of the nodes in the tree (recursive)
FBXWriterModule()
Constructor of the module.
void initialize() override
Initialize at the start of a job.
std::vector< unsigned int > * m_LVReplicas
Count of number of replicas of each logical volume associated with a replicated physical volume.
void event() override
Called for each event: this runs the FBX writer only for the first event.
void addModels(G4VPhysicalVolume *, int)
Process one physical volume for FBX-node writing (recursive)
std::vector< unsigned int > * m_PVReplicas
Count of number of replicas of each replicated physical volume.
std::ofstream m_File
Output file.
void writeSolidToPV(const std::string &, const std::string &, bool, unsigned long long, unsigned long long, unsigned long long)
Write FBX connection for each physical volume's solid and color info (bypass singleton logical volume...
bool m_UsePrototypes
User-specified flag to select whether to write and re-use logical- and physical-volume prototypes onc...
std::vector< unsigned long long > * m_PVID
Unique identifiers for physical volumes (Model nodes with transformation information)
bool m_First
Once-only flag to write FBX only on the first event.
void writePreamble(int, int, int)
Write FBX at the start of the file.
std::vector< bool > * m_Visible
Flag to indicate that the logical volume is visible.
void writePVModelNode(G4VPhysicalVolume *, const std::string &, unsigned long long)
Write FBX definition for each physical volume.
std::vector< bool > * m_LVUnique
Flag to indicate that a logical volume is referenced at most once (eligible for bypass)
void assignName(std::vector< std::string > *, unsigned int, const G4String &, int)
Create unique and legal name for each solid, logical volume, physical volume.
std::vector< unsigned int > * m_SolidCount
Count of number of instances of each solid (typically 1)
void writeLVModelNode(G4LogicalVolume *, const std::string &, unsigned long long)
Write FBX definition for each logical volume.
void countEntities(G4VPhysicalVolume *)
Count the physical volumes, logical volumes, materials and solids (recursive)
std::string m_Filename
User-specified output filename.
std::vector< std::string > * m_PVName
Modified (legal-character and unique) physical-volume name.
std::vector< unsigned int > * m_SolidReplicas
Count of number of replicas of each solid (extras for replicas with modified solids)
std::vector< std::string > * m_SolidName
Modified (legal-character and unique) solid name.
std::vector< unsigned long long > * m_SolidID
Unique identifiers for solids (Geometry nodes)
std::vector< unsigned int > * m_LVCount
Count of number of instances of each logical volume.
std::vector< unsigned long long > * m_MatID
Unique identifiers for logical volumes' color information (Material nodes)
void writeMaterialNode(int, const std::string &)
Write FBX definition for each logical volume's color information.
void writePVToParentPV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for each physical-volume daughter of a parent physical volume (bypass singleton ...
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 writeGeometryNode(G4VSolid *, const std::string &, unsigned long long)
Write FBX definition for each solid's polyhedron.
void writePolyhedron(G4VSolid *, G4Polyhedron *, const std::string &, unsigned long long)
Write FBX definition for the solid's polyhedron.
void writeSolidToLV(const std::string &, const std::string &, bool, unsigned long long, unsigned long long, unsigned long long)
Write FBX connection for each logical volume's solid and color info.
Base class for Modules.
Definition: Module.h:72
Abstract base class for different kinds of events.