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

Last change on this file since 1255 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 4.7 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.4 2008/11/12 08:44:07 arce Exp $
28// GEANT4 tag $Name: geant4-09-03 $
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 theInstance;
68}
69
70
71//---------------------------------------------------------------
72G4tgrFileReader* G4tgrFileReader::GetInstance()
73{
74 if( !theInstance ) {
75 theInstance = new G4tgrFileReader;
76 }
77 return theInstance;
78}
79
80//---------------------------------------------------------------
81G4bool 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}
Note: See TracBrowser for help on using the repository browser.