Belle II Software light-2406-ragdoll
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 {
40 class FBXWriterModule: public Module {
41
42 public:
43
46
48 void initialize() override;
49
51 void event() override;
52
53 private:
54
56 void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
57
59 void writeGeometryNode(G4VSolid*, const std::string&, unsigned long long);
60
62 void writeMaterialNode(int, const std::string&);
63
65 void writeLVModelNode(G4LogicalVolume*, const std::string&, unsigned long long);
66
68 void writePVModelNode(G4VPhysicalVolume*, const std::string&, unsigned long long);
69
71 void countEntities(G4VPhysicalVolume*);
72
74 void addModels(G4VPhysicalVolume*, int);
75
77 void addConnections(G4VPhysicalVolume*, int);
78
80 void writePreamble(int, int, int);
81
83 void writePolyhedron(G4VSolid*, G4Polyhedron*, const std::string&, unsigned long long);
84
86 void writeSolidToLV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
87
89 void writeSolidToPV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
90
92 void writeLVToPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
93
95 void writePVToParentLV(const std::string&, const std::string&, unsigned long long, unsigned long long);
96
98 void writePVToParentPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
99
101 HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
102
104 bool m_First{true};
105
108 bool m_UsePrototypes{false};
109
111 std::string m_Filename{"belle2.fbx"};
112
114 std::ofstream m_File;
115
117 std::vector<std::string>* m_PVName{nullptr};
118
120 std::vector<std::string>* m_LVName{nullptr};
121
123 std::vector<std::string>* m_SolidName{nullptr};
124
126 std::vector<unsigned long long>* m_PVID{nullptr};
127
129 std::vector<unsigned long long>* m_LVID{nullptr};
130
132 std::vector<unsigned long long>* m_MatID{nullptr};
133
135 std::vector<unsigned long long>* m_SolidID{nullptr};
136
138 std::vector<bool>* m_Visible{nullptr};
139
141 std::vector<unsigned int>* m_PVCount{nullptr};
142
144 std::vector<unsigned int>* m_LVCount{nullptr};
145
147 std::vector<unsigned int>* m_SolidCount{nullptr};
148
150 std::vector<unsigned int>* m_PVReplicas{nullptr};
151
153 std::vector<unsigned int>* m_LVReplicas{nullptr};
154
156 std::vector<unsigned int>* m_SolidReplicas{nullptr};
157
159 std::vector<bool>* m_LVUnique{nullptr};
160
161 };
162
164} //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.
Definition: ClusterUtils.h:24