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