VGM Version 5.3
Loading...
Searching...
No Matches
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
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//_____________________________________________________________________________
31 : VExporter(factory, new AGDDWriter())
32{
34}
35
36//_____________________________________________________________________________
41
42//_____________________________________________________________________________
47
48//_____________________________________________________________________________
53
54// operators
55
56//_____________________________________________________________________________
58{
60
61 // check assignement to self
62 if (this == &right) return *this;
63
64 // call assignement of the base class
66
67 return *this;
68}
69
70//
71// private methods
72//
73
74//_____________________________________________________________________________
75XmlVGM::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//_____________________________________________________________________________
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//_____________________________________________________________________________
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//_____________________________________________________________________________
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}
The VGM interface to geometry factory providing functions for geometry construction and conversions.
Definition IFactory.h:50
virtual IVolume * Volume() const =0
Return the associated volume.
The VGM interface to volumes.
Definition IVolume.h:32
virtual std::string MaterialName() const =0
Return the name of the associated material.
virtual std::string Name() const =0
Return the name of this volume.
virtual IPlacement * Daughter(int i) const =0
Return the i-th daughter.
virtual int NofDaughters() const =0
Return the number of volume daughters.
Class for generation of geometry data files in XML, in the AGDD XML format.
virtual void GenerateSection(VGM::IVolume *volume)
virtual void GenerateGeometry(VGM::IVolume *volume)
Generate XML geometry file for the geometry tree starting from the specified VGM volume.
AGDDExporter & operator=(const AGDDExporter &right)
virtual void ProcessVolume(VGM::IVolume *volume)
The implementation of the interface for the XML writer that writes VGM geometry objects to XML define...
Definition AGDDWriter.h:57
Class for generation of geometry data files in XML, the XML format is independent from the geometry o...
Definition VExporter.h:48
VExporter & operator=(const VExporter &)
std::vector< double > ThreeVector
Definition VExporter.h:43