Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4tgrFileReader.cc
이 파일의 문서화 페이지로 가기
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 66872 2013-01-15 01:25:57Z japost $
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"
41 #include "G4tgrVolume.hh"
42 #include "G4tgrPlaceDivRep.hh"
44 #include "G4tgrVolumeDivision.hh"
45 #include "G4tgrVolumeMgr.hh"
46 #include "G4tgrUtils.hh"
47 #include "G4tgrMaterialFactory.hh"
49 #include "G4tgrLineProcessor.hh"
50 #include "G4tgrMessenger.hh"
51 
52 
54 
55 
56 //---------------------------------------------------------------
58 {
60 }
61 
62 
63 //---------------------------------------------------------------
65 {
66  delete theLineProcessor;
67  delete theInstance;
68 }
69 
70 
71 //---------------------------------------------------------------
73 {
74  if( !theInstance ) {
76  }
77  return theInstance;
78 }
79 
80 //---------------------------------------------------------------
82 {
83 
84  std::vector< G4String > wl,wlnew;
85 
86 #ifdef G4VERBOSE
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
104  {
105  G4cout << " Reading data file " << theTextFiles[ii] << G4endl;
106  }
107 #endif
108 
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
122  {
123  G4tgrUtils::DumpVS(wl, "!!!! adding line");
124  }
125 #endif
126  continue;
127  }
128  else
129  {
130  //----- Process previous tag
131 #ifdef G4VERBOSE
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 }
static G4tgrFileReader * GetInstance()
static G4int GetVerboseLevel()
std::vector< G4String > theTextFiles
G4tgrLineProcessor * theLineProcessor
#define G4endl
Definition: G4ios.hh:61
virtual G4bool ProcessLine(const std::vector< G4String > &wl)
#define G4ThreadLocal
Definition: tls.hh:69
void DumpException(const G4String &sent)
Definition: G4tgrFileIn.cc:432
static G4ThreadLocal G4tgrFileReader * theInstance
fin
Definition: AddMC.C:2
nlines
virtual ~G4tgrFileReader()
bool G4bool
Definition: G4Types.hh:79
static G4tgrFileIn & GetInstance(const G4String &name)
Definition: G4tgrFileIn.cc:72
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
Definition: G4tgrUtils.cc:158
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int GetWordsInLine(std::vector< G4String > &wl)
Definition: G4tgrFileIn.cc:141