VGM
Version 5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
packages
XmlVGM
source
AGDDExporter.cxx
Go to the documentation of this file.
1
// $Id$
2
3
// -----------------------------------------------------------------------
4
// The XmlVGM package of the Virtual Geometry Model
5
// Copyright (C) 2007, Ivana Hrivnacova
6
// All rights reserved.
7
//
8
// For the licensing terms see vgm/LICENSE.
9
// Contact: ivana@ipno.in2p3.fr
10
// -----------------------------------------------------------------------
11
12
//
13
// Author: I. Hrivnacova, 27.07.2000
14
// (redesigned 31.03.2004)
15
//
16
// Class AGDDExporter
17
// -------------------
18
// See the class description in the header file.
19
20
#include "
VGM/volumes/IFactory.h
"
21
#include "
VGM/volumes/IPlacement.h
"
22
#include "
VGM/volumes/IVolume.h
"
23
24
#include "
ClhepVGM/transform.h
"
25
26
#include "
XmlVGM/AGDDExporter.h
"
27
#include "
XmlVGM/AGDDWriter.h
"
28
29
//_____________________________________________________________________________
30
XmlVGM::AGDDExporter::AGDDExporter
(
const
VGM::IFactory
* factory)
31
:
VExporter
(factory, new
AGDDWriter
())
32
{
34
}
35
36
//_____________________________________________________________________________
37
XmlVGM::AGDDExporter::AGDDExporter
() :
VExporter
()
38
{
40
}
41
42
//_____________________________________________________________________________
43
XmlVGM::AGDDExporter::AGDDExporter
(
const
AGDDExporter
& right) :
VExporter
(right)
44
{
46
}
47
48
//_____________________________________________________________________________
49
XmlVGM::AGDDExporter::~AGDDExporter
()
50
{
51
//
52
}
53
54
// operators
55
56
//_____________________________________________________________________________
57
XmlVGM::AGDDExporter
&
XmlVGM::AGDDExporter::operator=
(
const
AGDDExporter
& right)
58
{
60
61
// check assignement to self
62
if
(
this
== &right)
return
*
this
;
63
64
// call assignement of the base class
65
VExporter::operator=
(right);
66
67
return
*
this
;
68
}
69
70
//
71
// private methods
72
//
73
74
//_____________________________________________________________________________
75
XmlVGM::ThreeVector
XmlVGM::AGDDExporter::Identity()
const
76
{
78
79
ThreeVector
rotation(3);
80
rotation[0] = 0.;
81
rotation[1] = 0.;
82
rotation[2] = 0.;
83
84
return
rotation;
85
}
86
87
//
88
// protected methods
89
//
90
91
//_____________________________________________________________________________
92
void
XmlVGM::AGDDExporter::GenerateGeometry
(
VGM::IVolume
* volume)
93
{
94
// Generate XML geometry file for the geometry tree
95
// starting from the specified VGM volume.
96
97
// filename
98
std::string fileName;
99
if
(
fFileName
==
fgkUndefinedFileName
) {
100
fileName = volume->
Name
();
101
fileName = fileName +
".agdd"
;
102
}
103
else
104
fileName =
fFileName
;
105
106
// Open XML file and document
107
fWriter
->OpenFile(fileName);
108
fWriter
->OpenDocument();
109
110
// generate materials
111
GenerateMaterials
(volume);
112
113
// generate media
114
GenerateMedia
(volume);
115
116
// generate volumes tree
117
GenerateSection
(volume);
118
119
// Close XML file and document
120
fWriter
->CloseDocument();
121
fWriter
->CloseFile();
122
123
if
(
fDebug
> 0)
124
std::cout <<
"File "
<< fileName <<
" has been generated."
<< std::endl;
125
}
126
127
//_____________________________________________________________________________
128
void
XmlVGM::AGDDExporter::GenerateSection
(
VGM::IVolume
* volume)
129
{
133
134
// create section
135
fWriter
->OpenSection(volume->
Name
());
136
fWriter
->WriteEmptyLine();
137
138
// process solids
139
GenerateSolids
(volume);
140
141
// process geometry tree
142
ProcessVolume
(volume);
143
fWriter
->WriteEmptyLine();
144
ClearVolumeNames
();
145
146
// close section
147
fWriter
->CloseSection(volume->
Name
());
148
}
149
150
//_____________________________________________________________________________
151
void
XmlVGM::AGDDExporter::ProcessVolume
(
VGM::IVolume
* volume)
152
{
154
155
int
nofDaughters = volume->
NofDaughters
();
156
if
(nofDaughters == 0)
return
;
157
158
// open composition
159
fWriter
->OpenComposition(volume->
Name
(), volume->
MaterialName
());
160
161
// write positions
162
int
i;
163
for
(i = 0; i < nofDaughters; i++) {
164
165
if
(
fDebug
> 1) {
166
std::cout <<
"processing "
<< i <<
"th daughter of "
<< volume->
Name
()
167
<< std::endl;
168
}
169
170
fWriter
->WritePlacement(*volume->
Daughter
(i));
171
}
172
173
// close composition
174
fWriter
->CloseComposition();
175
fWriter
->WriteEmptyLine();
176
177
// store the name of logical volume in the set
178
fVolumeNames
.insert(
fVolumeNames
.begin(), volume->
Name
());
179
180
// process daughters
181
for
(i = 0; i < nofDaughters; i++) {
182
VGM::IVolume
* dVolume = volume->
Daughter
(i)->
Volume
();
183
std::string dVolumeName = dVolume->
Name
();
184
185
if
(
fVolumeNames
.find(dVolumeName) ==
fVolumeNames
.end()) {
186
// process dVolume only if it was not yet processed
187
ProcessVolume
(dVolume);
188
}
189
}
190
}
AGDDExporter.h
AGDDWriter.h
transform.h
IFactory.h
IPlacement.h
IVolume.h
VGM::IFactory
The VGM interface to geometry factory providing functions for geometry construction and conversions.
Definition
IFactory.h:50
VGM::IPlacement::Volume
virtual IVolume * Volume() const =0
Return the associated volume.
VGM::IVolume
The VGM interface to volumes.
Definition
IVolume.h:32
VGM::IVolume::MaterialName
virtual std::string MaterialName() const =0
Return the name of the associated material.
VGM::IVolume::Name
virtual std::string Name() const =0
Return the name of this volume.
VGM::IVolume::Daughter
virtual IPlacement * Daughter(int i) const =0
Return the i-th daughter.
VGM::IVolume::NofDaughters
virtual int NofDaughters() const =0
Return the number of volume daughters.
XmlVGM::AGDDExporter
Class for generation of geometry data files in XML, in the AGDD XML format.
Definition
AGDDExporter.h:34
XmlVGM::AGDDExporter::GenerateSection
virtual void GenerateSection(VGM::IVolume *volume)
Definition
AGDDExporter.cxx:128
XmlVGM::AGDDExporter::AGDDExporter
AGDDExporter(const VGM::IFactory *factory)
Definition
AGDDExporter.cxx:30
XmlVGM::AGDDExporter::~AGDDExporter
virtual ~AGDDExporter()
Definition
AGDDExporter.cxx:49
XmlVGM::AGDDExporter::GenerateGeometry
virtual void GenerateGeometry(VGM::IVolume *volume)
Generate XML geometry file for the geometry tree starting from the specified VGM volume.
Definition
AGDDExporter.cxx:92
XmlVGM::AGDDExporter::operator=
AGDDExporter & operator=(const AGDDExporter &right)
Definition
AGDDExporter.cxx:57
XmlVGM::AGDDExporter::ProcessVolume
virtual void ProcessVolume(VGM::IVolume *volume)
Definition
AGDDExporter.cxx:151
XmlVGM::AGDDExporter::AGDDExporter
AGDDExporter()
Definition
AGDDExporter.cxx:37
XmlVGM::AGDDWriter
The implementation of the interface for the XML writer that writes VGM geometry objects to XML define...
Definition
AGDDWriter.h:57
XmlVGM::VExporter::GenerateMedia
void GenerateMedia(VGM::IVolume *volume)
Definition
VExporter.cxx:591
XmlVGM::VExporter::fDebug
int fDebug
Definition
VExporter.h:107
XmlVGM::VExporter::VExporter
VExporter(const VGM::IFactory *factory, IWriter *writer)
Definition
VExporter.cxx:44
XmlVGM::VExporter::fWriter
IWriter * fWriter
Definition
VExporter.h:104
XmlVGM::VExporter::GenerateMaterials
void GenerateMaterials(VGM::IVolume *volume)
Definition
VExporter.cxx:556
XmlVGM::VExporter::operator=
VExporter & operator=(const VExporter &)
Definition
VExporter.cxx:102
XmlVGM::VExporter::fVolumeNames
StringSet fVolumeNames
Definition
VExporter.h:106
XmlVGM::VExporter::ClearVolumeNames
void ClearVolumeNames()
Definition
VExporter.cxx:634
XmlVGM::VExporter::fFileName
std::string fFileName
Definition
VExporter.h:105
XmlVGM::VExporter::GenerateSolids
void GenerateSolids(VGM::IVolume *volume)
Definition
VExporter.cxx:621
XmlVGM::VExporter::fgkUndefinedFileName
static const std::string fgkUndefinedFileName
Definition
VExporter.h:99
XmlVGM::ThreeVector
std::vector< double > ThreeVector
Definition
VExporter.h:43
Generated on
for VGM by
1.17.0