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