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 89698 2015-04-27 13:25:23Z gcosmo $ 29 // ------------------------------------------- << 28 // >> 29 // >> 30 // class G4GDMLParser inline methods >> 31 // >> 32 // ------------------------------------------------------------------------- 30 33 31 inline void G4GDMLParser::Read(const G4String& << 34 inline 32 { << 35 void G4GDMLParser::Read(const G4String& filename, G4bool validate) 33 if(G4Threading::IsMasterThread()) << 36 { 34 { << 37 reader->Read(filename,validate,false,strip); 35 reader->Read(filename, validate, false, st << 38 ImportRegions(); 36 ImportRegions(); << 39 } 37 } << 40 38 } << 41 inline >> 42 void G4GDMLParser::ReadModule(const G4String& filename, G4bool validate) >> 43 { >> 44 reader->Read(filename,validate,true); >> 45 ImportRegions(); >> 46 } >> 47 >> 48 inline >> 49 void G4GDMLParser::Write(const G4String& filename, >> 50 const G4VPhysicalVolume* pvol, >> 51 G4bool refs, >> 52 const G4String& schemaLocation) >> 53 { >> 54 const G4int depth = 0; >> 55 G4LogicalVolume* lvol = 0; 39 56 40 // ------------------------------------------- << 57 if (!pvol) 41 inline void G4GDMLParser::ReadModule(const G4S << 42 { << 43 if(G4Threading::IsMasterThread()) << 44 { 58 { 45 reader->Read(filename, validate, true); << 59 lvol = G4TransportationManager::GetTransportationManager()-> 46 ImportRegions(); << 60 GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume(); 47 } 61 } 48 } << 62 else 49 << 50 // ------------------------------------------- << 51 inline void G4GDMLParser::Write(const G4String << 52 const G4VPhysi << 53 const G4String << 54 { << 55 if(G4Threading::IsMasterThread()) << 56 { 63 { 57 const G4int depth = 0; << 64 lvol = pvol->GetLogicalVolume(); 58 G4LogicalVolume* lvol = nullptr; << 59 << 60 if(pvol == nullptr) << 61 { << 62 lvol = G4TransportationManager::GetTrans << 63 ->GetNavigatorForTracking() << 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 } 65 } >> 66 >> 67 if (rexp) { ExportRegions(refs); } >> 68 writer->Write(filename,lvol,schemaLocation,depth,refs); 78 } 69 } 79 70 80 // ------------------------------------------- << 71 inline 81 inline void G4GDMLParser::Write(const G4String << 72 void G4GDMLParser::Write(const G4String& filename, 82 const G4Logica << 73 const G4LogicalVolume* lvol, 83 const G4String << 74 G4bool refs, 84 { << 75 const G4String& schemaLocation) 85 if(G4Threading::IsMasterThread()) << 76 { 86 { << 77 const G4int depth = 0; 87 const G4int depth = 0; << 88 78 89 if(lvol == nullptr) << 79 if (!lvol) 90 { << 80 { 91 lvol = G4TransportationManager::GetTrans << 81 lvol = G4TransportationManager::GetTransportationManager()-> 92 ->GetNavigatorForTracking() << 82 GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume(); 93 ->GetWorldVolume() << 94 ->GetLogicalVolume(); << 95 } << 96 if(rexp) << 97 { << 98 ExportRegions(refs); << 99 } << 100 writer->Write(filename, lvol, schemaLocati << 101 } 83 } >> 84 if (rexp) { ExportRegions(refs); } >> 85 writer->Write(filename,lvol,schemaLocation,depth,refs); 102 } 86 } 103 87 104 // ------------------------------------------- << 88 inline 105 inline G4LogicalVolume* G4GDMLParser::ParseST( << 89 G4LogicalVolume* G4GDMLParser::ParseST(const G4String& filename, 106 << 90 G4Material* medium, 107 << 91 G4Material* solid) 108 { << 92 { 109 if(G4Threading::IsMasterThread()) << 93 G4STRead STreader; 110 { << 94 return STreader.Read(filename, medium, solid); 111 G4STRead STreader; << 112 return STreader.Read(filename, medium, sol << 113 } << 114 else << 115 { << 116 return nullptr; << 117 } << 118 } 95 } 119 96 120 // ------------------------------------------- << 97 // 121 // Methods for Reader 98 // Methods for Reader 122 // ------------------------------------------- << 99 // 123 100 124 inline G4bool G4GDMLParser::IsValid(const G4St 101 inline G4bool G4GDMLParser::IsValid(const G4String& name) const 125 { 102 { 126 return reader->IsValidID(name); 103 return reader->IsValidID(name); 127 } 104 } 128 105 129 inline G4double G4GDMLParser::GetConstant(cons << 106 inline >> 107 G4double G4GDMLParser::GetConstant(const G4String& name) const 130 { 108 { 131 return reader->GetConstant(name); 109 return reader->GetConstant(name); 132 } 110 } 133 111 134 inline G4double G4GDMLParser::GetVariable(cons << 112 inline >> 113 G4double G4GDMLParser::GetVariable(const G4String& name) const 135 { 114 { 136 return reader->GetVariable(name); 115 return reader->GetVariable(name); 137 } 116 } 138 117 139 inline G4double G4GDMLParser::GetQuantity(cons << 118 inline >> 119 G4double G4GDMLParser::GetQuantity(const G4String& name) const 140 { 120 { 141 return reader->GetQuantity(name); 121 return reader->GetQuantity(name); 142 } 122 } 143 123 144 inline G4ThreeVector G4GDMLParser::GetPosition << 124 inline >> 125 G4ThreeVector G4GDMLParser::GetPosition(const G4String& name) const 145 { 126 { 146 return reader->GetPosition(name); 127 return reader->GetPosition(name); 147 } 128 } 148 129 149 inline G4ThreeVector G4GDMLParser::GetRotation << 130 inline >> 131 G4ThreeVector G4GDMLParser::GetRotation(const G4String& name) const 150 { 132 { 151 return reader->GetRotation(name); 133 return reader->GetRotation(name); 152 } 134 } 153 135 154 inline G4ThreeVector G4GDMLParser::GetScale(co << 136 inline >> 137 G4ThreeVector G4GDMLParser::GetScale(const G4String& name) const 155 { 138 { 156 return reader->GetScale(name); 139 return reader->GetScale(name); 157 } 140 } 158 141 159 inline G4GDMLMatrix G4GDMLParser::GetMatrix(co << 142 inline >> 143 G4GDMLMatrix G4GDMLParser::GetMatrix(const G4String& name) const 160 { 144 { 161 return reader->GetMatrix(name); 145 return reader->GetMatrix(name); 162 } 146 } 163 147 164 inline G4LogicalVolume* G4GDMLParser::GetVolum << 148 inline >> 149 G4LogicalVolume* G4GDMLParser::GetVolume(const G4String& name) const 165 { 150 { 166 return reader->GetVolume(name); 151 return reader->GetVolume(name); 167 } 152 } 168 153 169 inline G4VPhysicalVolume* 154 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 155 G4GDMLParser::GetWorldVolume(const G4String& setupName) const 177 { 156 { 178 return reader->GetWorldVolume(setupName); 157 return reader->GetWorldVolume(setupName); 179 } 158 } 180 159 181 inline G4GDMLAuxListType << 160 inline >> 161 G4GDMLAuxListType 182 G4GDMLParser::GetVolumeAuxiliaryInformation(G4 162 G4GDMLParser::GetVolumeAuxiliaryInformation(G4LogicalVolume* logvol) const 183 { 163 { 184 return reader->GetVolumeAuxiliaryInformation 164 return reader->GetVolumeAuxiliaryInformation(logvol); 185 } 165 } 186 166 187 inline const G4GDMLAuxMapType* G4GDMLParser::G << 167 inline >> 168 const G4GDMLAuxMapType* G4GDMLParser::GetAuxMap() const 188 { 169 { 189 return reader->GetAuxMap(); 170 return reader->GetAuxMap(); 190 } 171 } 191 172 192 inline const G4GDMLAuxListType* G4GDMLParser:: << 173 inline >> 174 const G4GDMLAuxListType* G4GDMLParser::GetAuxList() const 193 { 175 { 194 return reader->GetAuxList(); 176 return reader->GetAuxList(); 195 } 177 } 196 178 197 inline void G4GDMLParser::AddAuxiliary(G4GDMLA << 179 inline >> 180 void G4GDMLParser::AddAuxiliary(G4GDMLAuxStructType myaux) 198 { 181 { 199 return writer->AddAuxiliary(myaux); 182 return writer->AddAuxiliary(myaux); 200 } 183 } 201 184 202 inline void G4GDMLParser::StripNamePointers() << 185 inline >> 186 void G4GDMLParser::StripNamePointers() const 203 { 187 { 204 reader->StripNames(); 188 reader->StripNames(); 205 } 189 } 206 190 207 inline void G4GDMLParser::SetStripFlag(G4bool 191 inline void G4GDMLParser::SetStripFlag(G4bool flag) 208 { 192 { 209 strip = flag; 193 strip = flag; 210 } 194 } 211 195 212 inline void G4GDMLParser::SetOverlapCheck(G4bo 196 inline void G4GDMLParser::SetOverlapCheck(G4bool flag) 213 { 197 { 214 reader->OverlapCheck(flag); 198 reader->OverlapCheck(flag); 215 } 199 } 216 200 217 inline void G4GDMLParser::SetRegionExport(G4bo 201 inline void G4GDMLParser::SetRegionExport(G4bool flag) 218 { 202 { 219 rexp = flag; 203 rexp = flag; 220 } 204 } 221 205 222 inline void G4GDMLParser::SetEnergyCutsExport( 206 inline void G4GDMLParser::SetEnergyCutsExport(G4bool flag) 223 { 207 { 224 writer->SetEnergyCutsExport(flag); 208 writer->SetEnergyCutsExport(flag); 225 } 209 } 226 210 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() 211 inline void G4GDMLParser::Clear() 248 { 212 { 249 reader->Clear(); 213 reader->Clear(); 250 } 214 } 251 215 252 inline void G4GDMLParser::SetImportSchema(cons << 216 // 253 { << 254 reader->SetSchemaFile(path_and_filename); << 255 } << 256 << 257 // ------------------------------------------- << 258 // Methods for Writer 217 // Methods for Writer 259 // ------------------------------------------- << 218 // 260 219 261 inline void G4GDMLParser::AddModule(const G4VP << 220 inline >> 221 void G4GDMLParser::AddModule(const G4VPhysicalVolume* const physvol) 262 { 222 { 263 writer->AddModule(physvol); 223 writer->AddModule(physvol); 264 } 224 } 265 225 266 inline void G4GDMLParser::AddModule(const G4in << 226 inline >> 227 void G4GDMLParser::AddModule(const G4int depth) 267 { 228 { 268 writer->AddModule(depth); 229 writer->AddModule(depth); 269 } 230 } 270 231 271 inline void G4GDMLParser::SetAddPointerToName( << 232 inline >> 233 void G4GDMLParser::SetAddPointerToName(G4bool set) 272 { 234 { 273 writer->SetAddPointerToName(set); 235 writer->SetAddPointerToName(set); 274 } 236 } 275 237 276 inline void G4GDMLParser::AddVolumeAuxiliary(G << 238 inline 277 c << 239 void G4GDMLParser::AddVolumeAuxiliary(G4GDMLAuxStructType myaux, >> 240 const G4LogicalVolume* const lvol) 278 { 241 { 279 writer->AddVolumeAuxiliary(myaux, lvol); 242 writer->AddVolumeAuxiliary(myaux, lvol); 280 } << 281 << 282 inline void G4GDMLParser::SetOutputFileOverwri << 283 { << 284 writer->SetOutputFileOverwrite(flag); << 285 } 243 } 286 244