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