Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
persistency
ascii
src
G4tgrFileReader.cc
Go to the documentation of this file.
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
// $Id: G4tgrFileReader.cc 69803 2013-05-15 15:24:50Z gcosmo $
28
//
29
//
30
// class G4tgrFileReader
31
32
// History:
33
// - Created. P.Arce, CIEMAT (November 2007)
34
// -------------------------------------------------------------------------
35
36
#include "
G4tgrFileReader.hh
"
37
#include "
G4tgrParameterMgr.hh
"
38
#include "
G4tgrFileIn.hh
"
39
#include "
G4tgrElementSimple.hh
"
40
#include "
G4tgrElementFromIsotopes.hh
"
41
#include "
G4tgrVolume.hh
"
42
#include "
G4tgrPlaceDivRep.hh
"
43
#include "
G4tgrPlaceParameterisation.hh
"
44
#include "
G4tgrVolumeDivision.hh
"
45
#include "
G4tgrVolumeMgr.hh
"
46
#include "
G4tgrUtils.hh
"
47
#include "
G4tgrMaterialFactory.hh
"
48
#include "
G4tgrRotationMatrixFactory.hh
"
49
#include "
G4tgrLineProcessor.hh
"
50
#include "
G4tgrMessenger.hh
"
51
52
53
G4tgrFileReader
* G4tgrFileReader::theInstance = 0;
54
55
56
//---------------------------------------------------------------
57
G4tgrFileReader::G4tgrFileReader
()
58
{
59
theLineProcessor =
new
G4tgrLineProcessor
;
60
}
61
62
63
//---------------------------------------------------------------
64
G4tgrFileReader::~G4tgrFileReader
()
65
{
66
delete
theLineProcessor;
67
delete
theInstance;
68
}
69
70
71
//---------------------------------------------------------------
72
G4tgrFileReader
*
G4tgrFileReader::GetInstance
()
73
{
74
if
( !theInstance ) {
75
theInstance =
new
G4tgrFileReader
;
76
}
77
return
theInstance;
78
}
79
80
//---------------------------------------------------------------
81
G4bool
G4tgrFileReader::ReadFiles
()
82
{
83
84
std::vector< G4String > wl,wlnew;
85
86
#ifdef G4VERBOSE
87
if
(
G4tgrMessenger::GetVerboseLevel
() >= 2 )
88
{
89
G4cout
<<
" Number of geometry data files = "
<< theTextFiles.size()
90
<<
G4endl
;
91
}
92
#endif
93
94
if
( theTextFiles.size() == 0 )
95
{
96
G4Exception
(
"G4tgrFileReader::ReadFiles()"
,
"InvalidInput"
,
97
FatalException
,
"No files to read ..."
);
98
}
99
100
for
(
size_t
ii = 0; ii < theTextFiles.size(); ii++ )
101
{
102
#ifdef G4VERBOSE
103
if
(
G4tgrMessenger::GetVerboseLevel
() >= 1 )
104
{
105
G4cout
<<
" Reading data file "
<< theTextFiles[ii] <<
G4endl
;
106
}
107
#endif
108
109
G4tgrFileIn
fin
=
G4tgrFileIn::GetInstance
( theTextFiles[ii] );
110
111
G4int
nlines
= 0;
112
for
(;;)
113
{
114
nlines++;
115
if
(! fin.
GetWordsInLine
( wlnew ) ) {
break
; }
116
// Check if it is continuation line or first line
117
if
( wlnew[0].c_str()[0] !=
':'
)
118
{
119
wl.insert( wl.end(), wlnew.begin(), wlnew.end() );
120
#ifdef G4VERBOSE
121
if
(
G4tgrMessenger::GetVerboseLevel
() >= 4 )
122
{
123
G4tgrUtils::DumpVS
(wl,
"!!!! adding line"
);
124
}
125
#endif
126
continue
;
127
}
128
else
129
{
130
//----- Process previous tag
131
#ifdef G4VERBOSE
132
if
(
G4tgrMessenger::GetVerboseLevel
() >= 4 )
133
{
134
G4tgrUtils::DumpVS
(wl,
"!!!! line read"
);
135
}
136
#endif
137
if
( nlines != 1)
// first line has no previous tag
138
{
139
if
( ! theLineProcessor->
ProcessLine
( wl ) )
140
{
141
fin.
DumpException
(
"Tag not found: "
+ wl[0]);
142
}
143
}
144
wl = wlnew;
145
}
146
}
147
148
if
( wl.size() != 0 )
149
{
150
if
( ! theLineProcessor->
ProcessLine
( wl ) )
151
{
152
fin.
DumpException
(
"Tag not found: "
+ wl[0]);
153
}
154
}
155
}
156
return
1;
157
}
Generated on Sat May 25 2013 14:33:24 for Geant4 by
1.8.4