Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4GDMLParser inline methods << 27 // 26 // 28 // Author: Zoltan Torzsok, November 2007 << 27 // $Id: G4GDMLParser.icc,v 1.15 2010-11-17 10:47:02 gcosmo Exp $ 29 // ------------------------------------------- << 28 // GEANT4 tag $Name: geant4-09-04-patch-02 $ >> 29 // >> 30 // >> 31 // class G4GDMLParser inline methods >> 32 // >> 33 // ------------------------------------------------------------------------- 30 34 31 inline void G4GDMLParser::Read(const G4String& << 35 inline 32 { << 36 void G4GDMLParser::Read(const G4String& filename, G4bool validate) 33 if(G4Threading::IsMasterThread()) << 37 { 34 { << 38 reader->Read(filename,validate,false,strip); 35 reader->Read(filename, validate, false, st << 36 ImportRegions(); << 37 } << 38 } 39 } 39 40 40 // ------------------------------------------- << 41 inline 41 inline void G4GDMLParser::ReadModule(const G4S << 42 void G4GDMLParser::ReadModule(const G4String& filename, G4bool validate) 42 { << 43 { 43 if(G4Threading::IsMasterThread()) << 44 reader->Read(filename,validate,true); 44 { << 45 reader->Read(filename, validate, true); << 46 ImportRegions(); << 47 } << 48 } 45 } 49 46 50 // ------------------------------------------- << 47 inline 51 inline void G4GDMLParser::Write(const G4String << 48 void G4GDMLParser::Write(const G4String& filename, 52 const G4VPhysi << 49 const G4VPhysicalVolume* pvol, 53 const G4String << 50 G4bool refs, 54 { << 51 const G4String& schemaLocation) 55 if(G4Threading::IsMasterThread()) << 52 { 56 { << 53 const G4int depth = 0; 57 const G4int depth = 0; << 54 G4LogicalVolume* lvol = 0; 58 G4LogicalVolume* lvol = nullptr; << 59 55 60 if(pvol == nullptr) << 56 if (!pvol) 61 { << 57 { 62 lvol = G4TransportationManager::GetTrans << 58 lvol = G4TransportationManager::GetTransportationManager()-> 63 ->GetNavigatorForTracking() << 59 GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume(); 64 ->GetWorldVolume() << 65 ->GetLogicalVolume(); << 66 } << 67 else << 68 { << 69 lvol = pvol->GetLogicalVolume(); << 70 } << 71 << 72 if(rexp) << 73 { << 74 ExportRegions(refs); << 75 } << 76 writer->Write(filename, lvol, schemaLocati << 77 } 60 } 78 } << 61 else 79 << 80 // ------------------------------------------- << 81 inline void G4GDMLParser::Write(const G4String << 82 const G4Logica << 83 const G4String << 84 { << 85 if(G4Threading::IsMasterThread()) << 86 { 62 { 87 const G4int depth = 0; << 63 lvol = pvol->GetLogicalVolume(); 88 << 89 if(lvol == nullptr) << 90 { << 91 lvol = G4TransportationManager::GetTrans << 92 ->GetNavigatorForTracking() << 93 ->GetWorldVolume() << 94 ->GetLogicalVolume(); << 95 } << 96 if(rexp) << 97 { << 98 ExportRegions(refs); << 99 } << 100 writer->Write(filename, lvol, schemaLocati << 101 } 64 } >> 65 >> 66 writer->Write(filename,lvol,schemaLocation,depth,refs); 102 } 67 } 103 68 104 // ------------------------------------------- << 69 inline 105 inline G4LogicalVolume* G4GDMLParser::ParseST( << 70 void G4GDMLParser::Write(const G4String& filename, 106 << 71 const G4LogicalVolume* lvol, 107 << 72 G4bool refs, 108 { << 73 const G4String& schemaLocation) 109 if(G4Threading::IsMasterThread()) << 74 { 110 { << 75 const G4int depth = 0; 111 G4STRead STreader; << 76 112 return STreader.Read(filename, medium, sol << 77 if (!lvol) 113 } << 114 else << 115 { 78 { 116 return nullptr; << 79 lvol = G4TransportationManager::GetTransportationManager()-> >> 80 GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume(); 117 } 81 } >> 82 writer->Write(filename,lvol,schemaLocation,depth,refs); >> 83 } >> 84 >> 85 inline >> 86 G4LogicalVolume* G4GDMLParser::ParseST(const G4String& filename, >> 87 G4Material* medium, >> 88 G4Material* solid) >> 89 { >> 90 G4STRead reader; >> 91 return reader.Read(filename, medium, solid); 118 } 92 } 119 93 120 // ------------------------------------------- << 94 // 121 // Methods for Reader 95 // Methods for Reader 122 // ------------------------------------------- << 96 // 123 97 124 inline G4bool G4GDMLParser::IsValid(const G4St 98 inline G4bool G4GDMLParser::IsValid(const G4String& name) const 125 { 99 { 126 return reader->IsValidID(name); 100 return reader->IsValidID(name); 127 } 101 } 128 102 129 inline G4double G4GDMLParser::GetConstant(cons << 103 inline >> 104 G4double G4GDMLParser::GetConstant(const G4String& name) const 130 { 105 { 131 return reader->GetConstant(name); 106 return reader->GetConstant(name); 132 } 107 } 133 108 134 inline G4double G4GDMLParser::GetVariable(cons << 109 inline >> 110 G4double G4GDMLParser::GetVariable(const G4String& name) const 135 { 111 { 136 return reader->GetVariable(name); 112 return reader->GetVariable(name); 137 } 113 } 138 114 139 inline G4double G4GDMLParser::GetQuantity(cons << 115 inline >> 116 G4double G4GDMLParser::GetQuantity(const G4String& name) const 140 { 117 { 141 return reader->GetQuantity(name); 118 return reader->GetQuantity(name); 142 } 119 } 143 120 144 inline G4ThreeVector G4GDMLParser::GetPosition << 121 inline >> 122 G4ThreeVector G4GDMLParser::GetPosition(const G4String& name) const 145 { 123 { 146 return reader->GetPosition(name); 124 return reader->GetPosition(name); 147 } 125 } 148 126 149 inline G4ThreeVector G4GDMLParser::GetRotation << 127 inline >> 128 G4ThreeVector G4GDMLParser::GetRotation(const G4String& name) const 150 { 129 { 151 return reader->GetRotation(name); 130 return reader->GetRotation(name); 152 } 131 } 153 132 154 inline G4ThreeVector G4GDMLParser::GetScale(co << 133 inline >> 134 G4ThreeVector G4GDMLParser::GetScale(const G4String& name) const 155 { 135 { 156 return reader->GetScale(name); 136 return reader->GetScale(name); 157 } 137 } 158 138 159 inline G4GDMLMatrix G4GDMLParser::GetMatrix(co << 139 inline >> 140 G4GDMLMatrix G4GDMLParser::GetMatrix(const G4String& name) const 160 { 141 { 161 return reader->GetMatrix(name); 142 return reader->GetMatrix(name); 162 } 143 } 163 144 164 inline G4LogicalVolume* G4GDMLParser::GetVolum << 145 inline >> 146 G4LogicalVolume* G4GDMLParser::GetVolume(const G4String& name) const 165 { 147 { 166 return reader->GetVolume(name); 148 return reader->GetVolume(name); 167 } 149 } 168 150 169 inline G4VPhysicalVolume* 151 inline G4VPhysicalVolume* 170 G4GDMLParser::GetPhysVolume(const G4String& na << 171 { << 172 return reader->GetPhysvol(name); << 173 } << 174 << 175 inline G4VPhysicalVolume* << 176 G4GDMLParser::GetWorldVolume(const G4String& s 152 G4GDMLParser::GetWorldVolume(const G4String& setupName) const 177 { 153 { 178 return reader->GetWorldVolume(setupName); 154 return reader->GetWorldVolume(setupName); 179 } 155 } 180 156 181 inline G4GDMLAuxListType << 157 inline >> 158 G4GDMLAuxListType 182 G4GDMLParser::GetVolumeAuxiliaryInformation(G4 159 G4GDMLParser::GetVolumeAuxiliaryInformation(G4LogicalVolume* logvol) const 183 { 160 { 184 return reader->GetVolumeAuxiliaryInformation 161 return reader->GetVolumeAuxiliaryInformation(logvol); 185 } 162 } 186 163 187 inline const G4GDMLAuxMapType* G4GDMLParser::G << 164 inline >> 165 const G4GDMLAuxMapType* G4GDMLParser::GetAuxMap() const 188 { 166 { 189 return reader->GetAuxMap(); 167 return reader->GetAuxMap(); 190 } 168 } 191 169 192 inline const G4GDMLAuxListType* G4GDMLParser:: << 170 inline 193 { << 171 void G4GDMLParser::StripNamePointers() const 194 return reader->GetAuxList(); << 195 } << 196 << 197 inline void G4GDMLParser::AddAuxiliary(G4GDMLA << 198 { << 199 return writer->AddAuxiliary(myaux); << 200 } << 201 << 202 inline void G4GDMLParser::StripNamePointers() << 203 { 172 { 204 reader->StripNames(); 173 reader->StripNames(); 205 } 174 } 206 175 207 inline void G4GDMLParser::SetStripFlag(G4bool 176 inline void G4GDMLParser::SetStripFlag(G4bool flag) 208 { 177 { 209 strip = flag; 178 strip = flag; 210 } 179 } 211 180 212 inline void G4GDMLParser::SetOverlapCheck(G4bo 181 inline void G4GDMLParser::SetOverlapCheck(G4bool flag) 213 { 182 { 214 reader->OverlapCheck(flag); 183 reader->OverlapCheck(flag); 215 } 184 } 216 185 217 inline void G4GDMLParser::SetRegionExport(G4bo << 218 { << 219 rexp = flag; << 220 } << 221 << 222 inline void G4GDMLParser::SetEnergyCutsExport( << 223 { << 224 writer->SetEnergyCutsExport(flag); << 225 } << 226 << 227 inline void G4GDMLParser::SetSDExport(G4bool f << 228 { << 229 writer->SetSDExport(flag); << 230 } << 231 << 232 inline void G4GDMLParser::SetReverseSearch(G4b << 233 { << 234 reader->SetReverseSearch(flag); << 235 } << 236 << 237 inline G4int G4GDMLParser::GetMaxExportLevel() << 238 { << 239 return writer->GetMaxExportLevel(); << 240 } << 241 << 242 inline void G4GDMLParser::SetMaxExportLevel(G4 << 243 { << 244 writer->SetMaxExportLevel(level); << 245 } << 246 << 247 inline void G4GDMLParser::Clear() 186 inline void G4GDMLParser::Clear() 248 { 187 { 249 reader->Clear(); 188 reader->Clear(); 250 } 189 } 251 190 252 inline void G4GDMLParser::SetImportSchema(cons << 191 // 253 { << 254 reader->SetSchemaFile(path_and_filename); << 255 } << 256 << 257 // ------------------------------------------- << 258 // Methods for Writer 192 // Methods for Writer 259 // ------------------------------------------- << 193 // 260 194 261 inline void G4GDMLParser::AddModule(const G4VP << 195 inline >> 196 void G4GDMLParser::AddModule(const G4VPhysicalVolume* const physvol) 262 { 197 { 263 writer->AddModule(physvol); 198 writer->AddModule(physvol); 264 } 199 } 265 200 266 inline void G4GDMLParser::AddModule(const G4in << 201 inline >> 202 void G4GDMLParser::AddModule(const G4int depth) 267 { 203 { 268 writer->AddModule(depth); 204 writer->AddModule(depth); 269 } 205 } 270 206 271 inline void G4GDMLParser::SetAddPointerToName( << 207 inline >> 208 void G4GDMLParser::SetAddPointerToName(G4bool set) 272 { 209 { 273 writer->SetAddPointerToName(set); 210 writer->SetAddPointerToName(set); 274 } << 275 << 276 inline void G4GDMLParser::AddVolumeAuxiliary(G << 277 c << 278 { << 279 writer->AddVolumeAuxiliary(myaux, lvol); << 280 } << 281 << 282 inline void G4GDMLParser::SetOutputFileOverwri << 283 { << 284 writer->SetOutputFileOverwrite(flag); << 285 } 211 } 286 212