source: trunk/source/persistency/ascii/src/G4tgrFileReader.cc@ 1351

Last change on this file since 1351 was 1347, checked in by garnier, 15 years ago

geant4 tag 9.4

File size: 4.8 KB
Line 
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,v 1.7 2010/10/13 15:20:01 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31// class G4tgrFileReader
32
33// History:
34// - Created. P.Arce, CIEMAT (November 2007)
35// -------------------------------------------------------------------------
36
37#include "G4tgrFileReader.hh"
38#include "G4tgrParameterMgr.hh"
39#include "G4tgrFileIn.hh"
40#include "G4tgrElementSimple.hh"
41#include "G4tgrElementFromIsotopes.hh"
42#include "G4tgrVolume.hh"
43#include "G4tgrPlaceDivRep.hh"
44#include "G4tgrPlaceParameterisation.hh"
45#include "G4tgrVolumeDivision.hh"
46#include "G4tgrVolumeMgr.hh"
47#include "G4tgrUtils.hh"
48#include "G4tgrMaterialFactory.hh"
49#include "G4tgrRotationMatrixFactory.hh"
50#include "G4tgrLineProcessor.hh"
51#include "G4tgrMessenger.hh"
52
53
54G4tgrFileReader* G4tgrFileReader::theInstance = 0;
55
56
57//---------------------------------------------------------------
58G4tgrFileReader::G4tgrFileReader()
59{
60 theLineProcessor = new G4tgrLineProcessor;
61}
62
63
64//---------------------------------------------------------------
65G4tgrFileReader::~G4tgrFileReader()
66{
67 delete theLineProcessor;
68 delete theInstance;
69}
70
71
72//---------------------------------------------------------------
73G4tgrFileReader* G4tgrFileReader::GetInstance()
74{
75 if( !theInstance ) {
76 theInstance = new G4tgrFileReader;
77 }
78 return theInstance;
79}
80
81//---------------------------------------------------------------
82G4bool G4tgrFileReader::ReadFiles()
83{
84
85 std::vector< G4String > wl,wlnew;
86
87#ifdef G4VERBOSE
88 if( G4tgrMessenger::GetVerboseLevel() >= 2 )
89 {
90 G4cout << " Number of geometry data files = " << theTextFiles.size()
91 << G4endl;
92 }
93#endif
94
95 if( theTextFiles.size() == 0 )
96 {
97 G4Exception("G4tgrFileReader::ReadFiles()", "InvalidInput",
98 FatalException, "No files to read ...");
99 }
100
101 for( size_t ii = 0; ii < theTextFiles.size(); ii++ )
102 {
103#ifdef G4VERBOSE
104 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
105 {
106 G4cout << " Reading data file " << theTextFiles[ii] << G4endl;
107 }
108#endif
109
110 G4tgrFileIn fin = G4tgrFileIn::GetInstance( theTextFiles[ii] );
111
112 G4int nlines = 0;
113 for(;;)
114 {
115 nlines++;
116 if(! fin.GetWordsInLine( wlnew ) ) { break; }
117 // Check if it is continuation line or first line
118 if( wlnew[0].c_str()[0] != ':' )
119 {
120 wl.insert( wl.end(), wlnew.begin(), wlnew.end() );
121#ifdef G4VERBOSE
122 if( G4tgrMessenger::GetVerboseLevel() >= 4 )
123 {
124 G4tgrUtils::DumpVS(wl, "!!!! adding line");
125 }
126#endif
127 continue;
128 }
129 else
130 {
131 //----- Process previous tag
132#ifdef G4VERBOSE
133 if( G4tgrMessenger::GetVerboseLevel() >= 4 )
134 {
135 G4tgrUtils::DumpVS(wl, "!!!! line read");
136 }
137#endif
138 if( nlines != 1) // first line has no previous tag
139 {
140 if( ! theLineProcessor->ProcessLine( wl ) )
141 {
142 fin.DumpException( "Tag not found: " + wl[0]);
143 }
144 }
145 wl = wlnew;
146 }
147 }
148
149 if( wl.size() != 0 )
150 {
151 if( ! theLineProcessor->ProcessLine( wl ) )
152 {
153 fin.DumpException( "Tag not found: " + wl[0]);
154 }
155 }
156 }
157 return 1;
158}
Note: See TracBrowser for help on using the repository browser.