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 // G4GDMLWriteMaterials implementation 26 // G4GDMLWriteMaterials implementation 27 // 27 // 28 // Author: Zoltan Torzsok, November 2007 28 // Author: Zoltan Torzsok, November 2007 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include <sstream> 31 #include <sstream> 32 32 33 #include "G4GDMLWriteMaterials.hh" 33 #include "G4GDMLWriteMaterials.hh" 34 34 35 #include "G4PhysicalConstants.hh" 35 #include "G4PhysicalConstants.hh" 36 #include "G4SystemOfUnits.hh" 36 #include "G4SystemOfUnits.hh" 37 #include "G4Element.hh" 37 #include "G4Element.hh" 38 #include "G4Isotope.hh" 38 #include "G4Isotope.hh" 39 #include "G4Material.hh" 39 #include "G4Material.hh" 40 40 41 // ------------------------------------------- 41 // -------------------------------------------------------------------- 42 G4GDMLWriteMaterials::G4GDMLWriteMaterials() 42 G4GDMLWriteMaterials::G4GDMLWriteMaterials() 43 : G4GDMLWriteDefine() 43 : G4GDMLWriteDefine() 44 { 44 { 45 } 45 } 46 46 47 // ------------------------------------------- 47 // -------------------------------------------------------------------- 48 G4GDMLWriteMaterials::~G4GDMLWriteMaterials() 48 G4GDMLWriteMaterials::~G4GDMLWriteMaterials() 49 { 49 { 50 } 50 } 51 51 52 // ------------------------------------------- 52 // -------------------------------------------------------------------- 53 void G4GDMLWriteMaterials::AtomWrite(xercesc:: 53 void G4GDMLWriteMaterials::AtomWrite(xercesc::DOMElement* element, 54 const G4d 54 const G4double& a) 55 { 55 { 56 xercesc::DOMElement* atomElement = NewElemen 56 xercesc::DOMElement* atomElement = NewElement("atom"); 57 atomElement->setAttributeNode(NewAttribute(" 57 atomElement->setAttributeNode(NewAttribute("unit", "g/mole")); 58 atomElement->setAttributeNode(NewAttribute(" 58 atomElement->setAttributeNode(NewAttribute("value", a * mole / g)); 59 element->appendChild(atomElement); 59 element->appendChild(atomElement); 60 } 60 } 61 61 62 // ------------------------------------------- 62 // -------------------------------------------------------------------- 63 void G4GDMLWriteMaterials::DWrite(xercesc::DOM 63 void G4GDMLWriteMaterials::DWrite(xercesc::DOMElement* element, 64 const G4doub 64 const G4double& d) 65 { 65 { 66 xercesc::DOMElement* DElement = NewElement(" 66 xercesc::DOMElement* DElement = NewElement("D"); 67 DElement->setAttributeNode(NewAttribute("uni 67 DElement->setAttributeNode(NewAttribute("unit", "g/cm3")); 68 DElement->setAttributeNode(NewAttribute("val 68 DElement->setAttributeNode(NewAttribute("value", d * cm3 / g)); 69 element->appendChild(DElement); 69 element->appendChild(DElement); 70 } 70 } 71 71 72 // ------------------------------------------- 72 // -------------------------------------------------------------------- 73 void G4GDMLWriteMaterials::PWrite(xercesc::DOM 73 void G4GDMLWriteMaterials::PWrite(xercesc::DOMElement* element, 74 const G4doub 74 const G4double& P) 75 { 75 { 76 xercesc::DOMElement* PElement = NewElement(" 76 xercesc::DOMElement* PElement = NewElement("P"); 77 PElement->setAttributeNode(NewAttribute("uni 77 PElement->setAttributeNode(NewAttribute("unit", "pascal")); 78 PElement->setAttributeNode(NewAttribute("val 78 PElement->setAttributeNode(NewAttribute("value", P / hep_pascal)); 79 element->appendChild(PElement); 79 element->appendChild(PElement); 80 } 80 } 81 81 82 // ------------------------------------------- 82 // -------------------------------------------------------------------- 83 void G4GDMLWriteMaterials::TWrite(xercesc::DOM 83 void G4GDMLWriteMaterials::TWrite(xercesc::DOMElement* element, 84 const G4doub 84 const G4double& T) 85 { 85 { 86 xercesc::DOMElement* TElement = NewElement(" 86 xercesc::DOMElement* TElement = NewElement("T"); 87 TElement->setAttributeNode(NewAttribute("uni 87 TElement->setAttributeNode(NewAttribute("unit", "K")); 88 TElement->setAttributeNode(NewAttribute("val 88 TElement->setAttributeNode(NewAttribute("value", T / kelvin)); 89 element->appendChild(TElement); 89 element->appendChild(TElement); 90 } 90 } 91 91 92 // ------------------------------------------- 92 // -------------------------------------------------------------------- 93 void G4GDMLWriteMaterials::MEEWrite(xercesc::D 93 void G4GDMLWriteMaterials::MEEWrite(xercesc::DOMElement* element, 94 const G4do 94 const G4double& MEE) 95 { 95 { 96 xercesc::DOMElement* PElement = NewElement(" 96 xercesc::DOMElement* PElement = NewElement("MEE"); 97 PElement->setAttributeNode(NewAttribute("uni 97 PElement->setAttributeNode(NewAttribute("unit", "eV")); 98 PElement->setAttributeNode(NewAttribute("val 98 PElement->setAttributeNode(NewAttribute("value", MEE / electronvolt)); 99 element->appendChild(PElement); 99 element->appendChild(PElement); 100 } 100 } 101 101 102 // ------------------------------------------- 102 // -------------------------------------------------------------------- 103 void G4GDMLWriteMaterials::IsotopeWrite(const 103 void G4GDMLWriteMaterials::IsotopeWrite(const G4Isotope* const isotopePtr) 104 { 104 { 105 const G4String name = GenerateName(isotopePt 105 const G4String name = GenerateName(isotopePtr->GetName(), isotopePtr); 106 106 107 xercesc::DOMElement* isotopeElement = NewEle 107 xercesc::DOMElement* isotopeElement = NewElement("isotope"); 108 isotopeElement->setAttributeNode(NewAttribut 108 isotopeElement->setAttributeNode(NewAttribute("name", name)); 109 isotopeElement->setAttributeNode(NewAttribut 109 isotopeElement->setAttributeNode(NewAttribute("N", isotopePtr->GetN())); 110 isotopeElement->setAttributeNode(NewAttribut 110 isotopeElement->setAttributeNode(NewAttribute("Z", isotopePtr->GetZ())); 111 materialsElement->appendChild(isotopeElement 111 materialsElement->appendChild(isotopeElement); 112 AtomWrite(isotopeElement, isotopePtr->GetA() 112 AtomWrite(isotopeElement, isotopePtr->GetA()); 113 } 113 } 114 114 115 // ------------------------------------------- 115 // -------------------------------------------------------------------- 116 void G4GDMLWriteMaterials::ElementWrite(const 116 void G4GDMLWriteMaterials::ElementWrite(const G4Element* const elementPtr) 117 { 117 { 118 const G4String name = GenerateName(elementPt 118 const G4String name = GenerateName(elementPtr->GetName(), elementPtr); 119 119 120 xercesc::DOMElement* elementElement = NewEle 120 xercesc::DOMElement* elementElement = NewElement("element"); 121 elementElement->setAttributeNode(NewAttribut 121 elementElement->setAttributeNode(NewAttribute("name", name)); 122 122 123 const G4int NumberOfIsotopes = (G4int)elemen << 123 const std::size_t NumberOfIsotopes = elementPtr->GetNumberOfIsotopes(); 124 124 125 if(NumberOfIsotopes > 0) 125 if(NumberOfIsotopes > 0) 126 { 126 { 127 const G4double* RelativeAbundanceVector 127 const G4double* RelativeAbundanceVector 128 = elementPtr->GetRelativeAbundanceVector 128 = elementPtr->GetRelativeAbundanceVector(); 129 for(G4int i = 0; i < NumberOfIsotopes; ++i << 129 for(std::size_t i = 0; i < NumberOfIsotopes; ++i) 130 { 130 { 131 G4String fractionref = GenerateName(elem 131 G4String fractionref = GenerateName(elementPtr->GetIsotope(i)->GetName(), 132 elem 132 elementPtr->GetIsotope(i)); 133 xercesc::DOMElement* fractionElement = N 133 xercesc::DOMElement* fractionElement = NewElement("fraction"); 134 fractionElement->setAttributeNode( 134 fractionElement->setAttributeNode( 135 NewAttribute("n", RelativeAbundanceVec 135 NewAttribute("n", RelativeAbundanceVector[i])); 136 fractionElement->setAttributeNode(NewAtt 136 fractionElement->setAttributeNode(NewAttribute("ref", fractionref)); 137 elementElement->appendChild(fractionElem 137 elementElement->appendChild(fractionElement); 138 AddIsotope(elementPtr->GetIsotope(i)); 138 AddIsotope(elementPtr->GetIsotope(i)); 139 } 139 } 140 } 140 } 141 else 141 else 142 { 142 { 143 elementElement->setAttributeNode(NewAttrib 143 elementElement->setAttributeNode(NewAttribute("Z", elementPtr->GetZ())); 144 AtomWrite(elementElement, elementPtr->GetA 144 AtomWrite(elementElement, elementPtr->GetA()); 145 } 145 } 146 146 147 materialsElement->appendChild(elementElement 147 materialsElement->appendChild(elementElement); 148 // Append the element AFTER all the possible 148 // Append the element AFTER all the possible components are appended! 149 } 149 } 150 150 151 // ------------------------------------------- 151 // -------------------------------------------------------------------- 152 void G4GDMLWriteMaterials::MaterialWrite(const 152 void G4GDMLWriteMaterials::MaterialWrite(const G4Material* const materialPtr) 153 { 153 { 154 G4String state_str("undefined"); 154 G4String state_str("undefined"); 155 const G4State state = materialPtr->GetState( 155 const G4State state = materialPtr->GetState(); 156 if(state == kStateSolid) 156 if(state == kStateSolid) 157 { 157 { 158 state_str = "solid"; 158 state_str = "solid"; 159 } 159 } 160 else if(state == kStateLiquid) 160 else if(state == kStateLiquid) 161 { 161 { 162 state_str = "liquid"; 162 state_str = "liquid"; 163 } 163 } 164 else if(state == kStateGas) 164 else if(state == kStateGas) 165 { 165 { 166 state_str = "gas"; 166 state_str = "gas"; 167 } 167 } 168 168 169 const G4String name = GenerateName(materialP 169 const G4String name = GenerateName(materialPtr->GetName(), materialPtr); 170 170 171 xercesc::DOMElement* materialElement = NewEl 171 xercesc::DOMElement* materialElement = NewElement("material"); 172 materialElement->setAttributeNode(NewAttribu 172 materialElement->setAttributeNode(NewAttribute("name", name)); 173 materialElement->setAttributeNode(NewAttribu 173 materialElement->setAttributeNode(NewAttribute("state", state_str)); 174 174 175 // Write any property attached to the materi 175 // Write any property attached to the material... 176 // 176 // 177 if(materialPtr->GetMaterialPropertiesTable() 177 if(materialPtr->GetMaterialPropertiesTable()) 178 { 178 { 179 PropertyWrite(materialElement, materialPtr 179 PropertyWrite(materialElement, materialPtr); 180 } 180 } 181 181 182 if(materialPtr->GetTemperature() != STP_Temp 182 if(materialPtr->GetTemperature() != STP_Temperature) 183 { 183 { 184 TWrite(materialElement, materialPtr->GetTe 184 TWrite(materialElement, materialPtr->GetTemperature()); 185 } 185 } 186 186 187 if(materialPtr->GetPressure() != STP_Pressur 187 if(materialPtr->GetPressure() != STP_Pressure) 188 { 188 { 189 PWrite(materialElement, materialPtr->GetPr 189 PWrite(materialElement, materialPtr->GetPressure()); 190 } 190 } 191 191 192 // Write Ionisation potential (mean excitati 192 // Write Ionisation potential (mean excitation energy) 193 MEEWrite(materialElement, 193 MEEWrite(materialElement, 194 materialPtr->GetIonisation()->GetMe 194 materialPtr->GetIonisation()->GetMeanExcitationEnergy()); 195 195 196 DWrite(materialElement, materialPtr->GetDens 196 DWrite(materialElement, materialPtr->GetDensity()); 197 197 198 const G4int NumberOfElements = (G4int)materi << 198 const std::size_t NumberOfElements = materialPtr->GetNumberOfElements(); 199 199 200 if((NumberOfElements > 1) || 200 if((NumberOfElements > 1) || 201 (materialPtr->GetElement(0) != nullptr && 201 (materialPtr->GetElement(0) != nullptr && 202 materialPtr->GetElement(0)->GetNumberOfI 202 materialPtr->GetElement(0)->GetNumberOfIsotopes() > 1)) 203 { 203 { 204 const G4double* MassFractionVector = mater 204 const G4double* MassFractionVector = materialPtr->GetFractionVector(); 205 205 206 for(G4int i = 0; i < NumberOfElements; ++i << 206 for(std::size_t i = 0; i < NumberOfElements; ++i) 207 { 207 { 208 const G4String fractionref = GenerateNam 208 const G4String fractionref = GenerateName( 209 materialPtr->GetElement(i)->GetName(), 209 materialPtr->GetElement(i)->GetName(), materialPtr->GetElement(i)); 210 xercesc::DOMElement* fractionElement = N 210 xercesc::DOMElement* fractionElement = NewElement("fraction"); 211 fractionElement->setAttributeNode( 211 fractionElement->setAttributeNode( 212 NewAttribute("n", MassFractionVector[i 212 NewAttribute("n", MassFractionVector[i])); 213 fractionElement->setAttributeNode(NewAtt 213 fractionElement->setAttributeNode(NewAttribute("ref", fractionref)); 214 materialElement->appendChild(fractionEle 214 materialElement->appendChild(fractionElement); 215 AddElement(materialPtr->GetElement(i)); 215 AddElement(materialPtr->GetElement(i)); 216 } 216 } 217 } 217 } 218 else 218 else 219 { 219 { 220 materialElement->setAttributeNode(NewAttri 220 materialElement->setAttributeNode(NewAttribute("Z", materialPtr->GetZ())); 221 AtomWrite(materialElement, materialPtr->Ge 221 AtomWrite(materialElement, materialPtr->GetA()); 222 } 222 } 223 223 224 // Append the material AFTER all the possibl 224 // Append the material AFTER all the possible components are appended! 225 // 225 // 226 materialsElement->appendChild(materialElemen 226 materialsElement->appendChild(materialElement); 227 } 227 } 228 228 229 // ------------------------------------------- 229 // -------------------------------------------------------------------- 230 void G4GDMLWriteMaterials::PropertyVectorWrite 230 void G4GDMLWriteMaterials::PropertyVectorWrite( 231 const G4String& key, const G4PhysicsFreeVect << 231 const G4String& key, const G4PhysicsOrderedFreeVector* const pvec) 232 { 232 { 233 for(std::size_t i = 0; i < propertyList.size 233 for(std::size_t i = 0; i < propertyList.size(); ++i) // Check if property is 234 { 234 { // already in the list! 235 if(propertyList[i] == pvec) 235 if(propertyList[i] == pvec) 236 { 236 { 237 return; 237 return; 238 } 238 } 239 } 239 } 240 propertyList.push_back(pvec); 240 propertyList.push_back(pvec); 241 241 242 const G4String matrixref = GenerateName(key, 242 const G4String matrixref = GenerateName(key, pvec); 243 xercesc::DOMElement* matrixElement = NewElem 243 xercesc::DOMElement* matrixElement = NewElement("matrix"); 244 matrixElement->setAttributeNode(NewAttribute 244 matrixElement->setAttributeNode(NewAttribute("name", matrixref)); 245 matrixElement->setAttributeNode(NewAttribute 245 matrixElement->setAttributeNode(NewAttribute("coldim", "2")); 246 std::ostringstream pvalues; 246 std::ostringstream pvalues; 247 for(std::size_t i = 0; i < pvec->GetVectorLe 247 for(std::size_t i = 0; i < pvec->GetVectorLength(); ++i) 248 { 248 { 249 if(i != 0) 249 if(i != 0) 250 { 250 { 251 pvalues << " "; 251 pvalues << " "; 252 } 252 } 253 pvalues << pvec->Energy(i) << " " << (*pve 253 pvalues << pvec->Energy(i) << " " << (*pvec)[i]; 254 } 254 } 255 matrixElement->setAttributeNode(NewAttribute 255 matrixElement->setAttributeNode(NewAttribute("values", pvalues.str())); 256 256 257 defineElement->appendChild(matrixElement); 257 defineElement->appendChild(matrixElement); 258 } 258 } 259 259 260 // ------------------------------------------- 260 // -------------------------------------------------------------------- 261 void G4GDMLWriteMaterials::PropertyConstWrite( 261 void G4GDMLWriteMaterials::PropertyConstWrite( 262 const G4String& key, const G4double pval, 262 const G4String& key, const G4double pval, 263 const G4MaterialPropertiesTable* ptable) 263 const G4MaterialPropertiesTable* ptable) 264 { 264 { 265 const G4String matrixref = Generat 265 const G4String matrixref = GenerateName(key, ptable); 266 xercesc::DOMElement* matrixElement = NewElem 266 xercesc::DOMElement* matrixElement = NewElement("matrix"); 267 matrixElement->setAttributeNode(NewAttribute 267 matrixElement->setAttributeNode(NewAttribute("name", matrixref)); 268 matrixElement->setAttributeNode(NewAttribute 268 matrixElement->setAttributeNode(NewAttribute("coldim", "1")); 269 std::ostringstream pvalues; 269 std::ostringstream pvalues; 270 270 271 pvalues << pval; 271 pvalues << pval; 272 matrixElement->setAttributeNode(NewAttribute 272 matrixElement->setAttributeNode(NewAttribute("values", pvalues.str())); 273 273 274 defineElement->appendChild(matrixElement); 274 defineElement->appendChild(matrixElement); 275 } 275 } 276 276 277 // ------------------------------------------- 277 // -------------------------------------------------------------------- 278 void G4GDMLWriteMaterials::PropertyWrite(xerce 278 void G4GDMLWriteMaterials::PropertyWrite(xercesc::DOMElement* matElement, 279 const 279 const G4Material* const mat) 280 { 280 { 281 xercesc::DOMElement* propElement; 281 xercesc::DOMElement* propElement; 282 G4MaterialPropertiesTable* ptable = mat->Get 282 G4MaterialPropertiesTable* ptable = mat->GetMaterialPropertiesTable(); 283 283 284 auto pvec = ptable->GetProperties(); << 284 auto pmap = ptable->GetPropertyMap(); 285 auto cvec = ptable->GetConstProperties(); << 285 auto cmap = ptable->GetConstPropertyMap(); 286 286 287 for(size_t i = 0; i < pvec.size(); ++i) << 287 for(auto mpos = pmap->cbegin(); mpos != pmap->cend(); ++mpos) 288 { 288 { 289 if (pvec[i] != nullptr) << 289 propElement = NewElement("property"); >> 290 propElement->setAttributeNode( >> 291 NewAttribute("name", ptable->GetMaterialPropertyNames()[mpos->first])); >> 292 propElement->setAttributeNode(NewAttribute( >> 293 "ref", GenerateName(ptable->GetMaterialPropertyNames()[mpos->first], >> 294 mpos->second))); >> 295 if(mpos->second) 290 { 296 { 291 propElement = NewElement("property"); << 297 PropertyVectorWrite(ptable->GetMaterialPropertyNames()[mpos->first], 292 propElement->setAttributeNode( << 298 mpos->second); 293 NewAttribute("name", ptable->GetMateri << 294 propElement->setAttributeNode(NewAttribu << 295 "ref", GenerateName(ptable->GetMateria << 296 pvec[i]))); << 297 PropertyVectorWrite(ptable->GetMaterialP << 298 pvec[i]); << 299 matElement->appendChild(propElement); 299 matElement->appendChild(propElement); 300 } 300 } >> 301 else >> 302 { >> 303 G4String warn_message = "Null pointer for material property -" + >> 304 ptable->GetMaterialPropertyNames()[mpos->first] + >> 305 "- of material -" + mat->GetName() + "- !"; >> 306 G4Exception("G4GDMLWriteMaterials::PropertyWrite()", "NullPointer", >> 307 JustWarning, warn_message); >> 308 continue; >> 309 } 301 } 310 } 302 311 303 for(size_t i = 0; i < cvec.size(); ++i) << 312 for(auto cpos = cmap->cbegin(); cpos != cmap->cend(); ++cpos) 304 { 313 { 305 if (cvec[i].second == true) << 314 propElement = NewElement("property"); 306 { << 315 propElement->setAttributeNode(NewAttribute( 307 propElement = NewElement("property"); << 316 "name", ptable->GetMaterialConstPropertyNames()[cpos->first])); 308 propElement->setAttributeNode(NewAttribu << 317 propElement->setAttributeNode(NewAttribute( 309 "name", ptable->GetMaterialConstProper << 318 "ref", GenerateName(ptable->GetMaterialConstPropertyNames()[cpos->first], 310 propElement->setAttributeNode(NewAttribu << 319 ptable))); 311 "ref", GenerateName(ptable->GetMateria << 320 312 ptable))); << 321 PropertyConstWrite(ptable->GetMaterialConstPropertyNames()[cpos->first], 313 PropertyConstWrite(ptable->GetMaterialCo << 322 cpos->second, ptable); 314 cvec[i].first, ptable << 323 315 matElement->appendChild(propElement); << 324 matElement->appendChild(propElement); 316 } << 317 } 325 } 318 } 326 } 319 327 320 // ------------------------------------------- 328 // -------------------------------------------------------------------- 321 void G4GDMLWriteMaterials::MaterialsWrite(xerc 329 void G4GDMLWriteMaterials::MaterialsWrite(xercesc::DOMElement* element) 322 { 330 { 323 #ifdef G4VERBOSE 331 #ifdef G4VERBOSE 324 G4cout << "G4GDML: Writing materials..." << 332 G4cout << "G4GDML: Writing materials..." << G4endl; 325 #endif 333 #endif 326 materialsElement = NewElement("materials"); 334 materialsElement = NewElement("materials"); 327 element->appendChild(materialsElement); 335 element->appendChild(materialsElement); 328 336 329 isotopeList.clear(); 337 isotopeList.clear(); 330 elementList.clear(); 338 elementList.clear(); 331 materialList.clear(); 339 materialList.clear(); 332 propertyList.clear(); 340 propertyList.clear(); 333 } 341 } 334 342 335 // ------------------------------------------- 343 // -------------------------------------------------------------------- 336 void G4GDMLWriteMaterials::AddIsotope(const G4 344 void G4GDMLWriteMaterials::AddIsotope(const G4Isotope* const isotopePtr) 337 { 345 { 338 for(std::size_t i = 0; i < isotopeList.size( 346 for(std::size_t i = 0; i < isotopeList.size(); ++i) // Check if isotope is 339 { 347 { // already in the list! 340 if(isotopeList[i] == isotopePtr) 348 if(isotopeList[i] == isotopePtr) 341 { 349 { 342 return; 350 return; 343 } 351 } 344 } 352 } 345 isotopeList.push_back(isotopePtr); 353 isotopeList.push_back(isotopePtr); 346 IsotopeWrite(isotopePtr); 354 IsotopeWrite(isotopePtr); 347 } 355 } 348 356 349 // ------------------------------------------- 357 // -------------------------------------------------------------------- 350 void G4GDMLWriteMaterials::AddElement(const G4 358 void G4GDMLWriteMaterials::AddElement(const G4Element* const elementPtr) 351 { 359 { 352 for(std::size_t i = 0; i < elementList.size( 360 for(std::size_t i = 0; i < elementList.size(); ++i) // Check if element is 353 { 361 { // already in the list! 354 if(elementList[i] == elementPtr) 362 if(elementList[i] == elementPtr) 355 { 363 { 356 return; 364 return; 357 } 365 } 358 } 366 } 359 elementList.push_back(elementPtr); 367 elementList.push_back(elementPtr); 360 ElementWrite(elementPtr); 368 ElementWrite(elementPtr); 361 } 369 } 362 370 363 // ------------------------------------------- 371 // -------------------------------------------------------------------- 364 void G4GDMLWriteMaterials::AddMaterial(const G 372 void G4GDMLWriteMaterials::AddMaterial(const G4Material* const materialPtr) 365 { 373 { 366 for(std::size_t i = 0; i < materialList.size 374 for(std::size_t i = 0; i < materialList.size(); ++i) // Check if material is 367 { 375 { // already in the list! 368 if(materialList[i] == materialPtr) 376 if(materialList[i] == materialPtr) 369 { 377 { 370 return; 378 return; 371 } 379 } 372 } 380 } 373 materialList.push_back(materialPtr); 381 materialList.push_back(materialPtr); 374 MaterialWrite(materialPtr); 382 MaterialWrite(materialPtr); 375 } 383 } 376 384