Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GDMLReadDefine Class Reference

#include <G4GDMLReadDefine.hh>

+ Inheritance diagram for G4GDMLReadDefine:

Public Member Functions

G4bool IsValidID (const G4String &) const
 
G4double GetConstant (const G4String &)
 
G4double GetVariable (const G4String &)
 
G4double GetQuantity (const G4String &)
 
G4ThreeVector GetPosition (const G4String &)
 
G4ThreeVector GetRotation (const G4String &)
 
G4ThreeVector GetScale (const G4String &)
 
G4GDMLMatrix GetMatrix (const G4String &)
 
virtual void DefineRead (const xercesc::DOMElement *const)
 
- Public Member Functions inherited from G4GDMLRead
virtual void DefineRead (const xercesc::DOMElement *const)=0
 
virtual void MaterialsRead (const xercesc::DOMElement *const)=0
 
virtual void SetupRead (const xercesc::DOMElement *const)=0
 
virtual void SolidsRead (const xercesc::DOMElement *const)=0
 
virtual void Paramvol_contentRead (const xercesc::DOMElement *const)=0
 
virtual void Volume_contentRead (const xercesc::DOMElement *const)=0
 
virtual void StructureRead (const xercesc::DOMElement *const)=0
 
virtual void ExtensionRead (const xercesc::DOMElement *const)
 
virtual G4LogicalVolumeGetVolume (const G4String &) const =0
 
virtual G4String GetSetup (const G4String &)=0
 
void Read (const G4String &, G4bool validation, G4bool isModule, G4bool strip=true)
 
void StripNames () const
 
void OverlapCheck (G4bool)
 

Protected Member Functions

 G4GDMLReadDefine ()
 
virtual ~G4GDMLReadDefine ()
 
G4RotationMatrix GetRotationMatrix (const G4ThreeVector &)
 
void VectorRead (const xercesc::DOMElement *const, G4ThreeVector &)
 
G4String RefRead (const xercesc::DOMElement *const)
 
void ConstantRead (const xercesc::DOMElement *const)
 
void MatrixRead (const xercesc::DOMElement *const)
 
void PositionRead (const xercesc::DOMElement *const)
 
void RotationRead (const xercesc::DOMElement *const)
 
void ScaleRead (const xercesc::DOMElement *const)
 
void VariableRead (const xercesc::DOMElement *const)
 
void QuantityRead (const xercesc::DOMElement *const)
 
void ExpressionRead (const xercesc::DOMElement *const)
 
- Protected Member Functions inherited from G4GDMLRead
 G4GDMLRead ()
 
virtual ~G4GDMLRead ()
 
G4String Transcode (const XMLCh *const)
 
G4String GenerateName (const G4String &name, G4bool strip=false)
 
G4String Strip (const G4String &) const
 
void StripName (G4String &) const
 
void GeneratePhysvolName (const G4String &, G4VPhysicalVolume *)
 
void LoopRead (const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
 

Protected Attributes

std::map< G4String, G4doublequantityMap
 
std::map< G4String, G4ThreeVectorpositionMap
 
std::map< G4String, G4ThreeVectorrotationMap
 
std::map< G4String, G4ThreeVectorscaleMap
 
std::map< G4String, G4GDMLMatrixmatrixMap
 
- Protected Attributes inherited from G4GDMLRead
G4GDMLEvaluator eval
 
G4bool validate
 
G4bool check
 

Detailed Description

Definition at line 69 of file G4GDMLReadDefine.hh.

Constructor & Destructor Documentation

◆ G4GDMLReadDefine()

G4GDMLReadDefine::G4GDMLReadDefine ( )
protected

Definition at line 123 of file G4GDMLReadDefine.cc.

123 : G4GDMLRead()
124{
125}

◆ ~G4GDMLReadDefine()

G4GDMLReadDefine::~G4GDMLReadDefine ( )
protectedvirtual

Definition at line 127 of file G4GDMLReadDefine.cc.

128{
129}

Member Function Documentation

◆ ConstantRead()

void G4GDMLReadDefine::ConstantRead ( const xercesc::DOMElement * const  constantElement)
protected

Definition at line 144 of file G4GDMLReadDefine.cc.

145{
146 G4String name = "";
147 G4double value = 0.0;
148
149 const xercesc::DOMNamedNodeMap* const attributes
150 = constantElement->getAttributes();
151 XMLSize_t attributeCount = attributes->getLength();
152
153 for (XMLSize_t attribute_index=0;
154 attribute_index<attributeCount; attribute_index++)
155 {
156 xercesc::DOMNode* node = attributes->item(attribute_index);
157
158 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
159
160 const xercesc::DOMAttr* const attribute
161 = dynamic_cast<xercesc::DOMAttr*>(node);
162 if (!attribute)
163 {
164 G4Exception("G4GDMLRead::ConstantRead()", "InvalidRead",
165 FatalException, "No attribute found!");
166 return;
167 }
168 const G4String attName = Transcode(attribute->getName());
169 const G4String attValue = Transcode(attribute->getValue());
170
171 if (attName=="name") { name = attValue; } else
172 if (attName=="value") { value = eval.Evaluate(attValue); }
173 }
174
175 eval.DefineConstant(name,value);
176}
@ FatalException
double G4double
Definition: G4Types.hh:64
G4double Evaluate(const G4String &)
void DefineConstant(const G4String &, G4double)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:144
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by DefineRead().

◆ DefineRead()

void G4GDMLReadDefine::DefineRead ( const xercesc::DOMElement * const  defineElement)
virtual

Implements G4GDMLRead.

Definition at line 457 of file G4GDMLReadDefine.cc.

458{
459 G4cout << "G4GDML: Reading definitions..." << G4endl;
460
461 for (xercesc::DOMNode* iter = defineElement->getFirstChild();
462 iter != 0;iter = iter->getNextSibling())
463 {
464 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
465
466 const xercesc::DOMElement* const child
467 = dynamic_cast<xercesc::DOMElement*>(iter);
468 if (!child)
469 {
470 G4Exception("G4GDMLRead::DefineRead()", "InvalidRead",
471 FatalException, "No child found!");
472 return;
473 }
474 const G4String tag = Transcode(child->getTagName());
475
476 if (tag=="constant") { ConstantRead(child); } else
477 if (tag=="matrix") { MatrixRead(child); } else
478 if (tag=="position") { PositionRead(child); } else
479 if (tag=="rotation") { RotationRead(child); } else
480 if (tag=="scale") { ScaleRead(child); } else
481 if (tag=="variable") { VariableRead(child); } else
482 if (tag=="quantity") { QuantityRead(child); } else
483 if (tag=="expression") { ExpressionRead(child); }
484 else
485 {
486 G4String error_msg = "Unknown tag in define: "+tag;
487 G4Exception("G4GDMLReadDefine::defineRead()", "ReadError",
488 FatalException, error_msg);
489 }
490 }
491}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void ExpressionRead(const xercesc::DOMElement *const)
void VariableRead(const xercesc::DOMElement *const)
void QuantityRead(const xercesc::DOMElement *const)
void PositionRead(const xercesc::DOMElement *const)
void MatrixRead(const xercesc::DOMElement *const)
void RotationRead(const xercesc::DOMElement *const)
void ScaleRead(const xercesc::DOMElement *const)
void ConstantRead(const xercesc::DOMElement *const)
Definition: xmlparse.cc:179

Referenced by G4GDMLReadMaterials::MaterialsRead(), and G4GDMLReadSolids::SolidsRead().

◆ ExpressionRead()

void G4GDMLReadDefine::ExpressionRead ( const xercesc::DOMElement * const  expElement)
protected

Definition at line 179 of file G4GDMLReadDefine.cc.

180{
181 G4String name = "";
182 G4double value = 0.0;
183
184 const xercesc::DOMNamedNodeMap* const attributes
185 = expElement->getAttributes();
186 XMLSize_t attributeCount = attributes->getLength();
187
188 for (XMLSize_t attribute_index=0;
189 attribute_index<attributeCount; attribute_index++)
190 {
191 xercesc::DOMNode* node = attributes->item(attribute_index);
192
193 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
194
195 const xercesc::DOMAttr* const attribute
196 = dynamic_cast<xercesc::DOMAttr*>(node);
197 if (!attribute)
198 {
199 G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead",
200 FatalException, "No attribute found!");
201 return;
202 }
203 const G4String attName = Transcode(attribute->getName());
204 const G4String attValue = Transcode(attribute->getValue());
205
206 if (attName=="name") { name = attValue; }
207 }
208
209 const G4String expValue = Transcode(expElement->getTextContent());
210 value = eval.Evaluate(expValue);
211 eval.DefineConstant(name,value);
212}

Referenced by DefineRead().

◆ GetConstant()

G4double G4GDMLReadDefine::GetConstant ( const G4String ref)

Definition at line 568 of file G4GDMLReadDefine.cc.

569{
570 return eval.GetConstant(ref);
571}
G4double GetConstant(const G4String &)

◆ GetMatrix()

G4GDMLMatrix G4GDMLReadDefine::GetMatrix ( const G4String ref)

Definition at line 622 of file G4GDMLReadDefine.cc.

623{
624 if (matrixMap.find(ref) == matrixMap.end())
625 {
626 G4String error_msg = "Matrix '"+ref+"' was not found!";
627 G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError",
628 FatalException, error_msg);
629 }
630 return matrixMap[ref];
631}
std::map< G4String, G4GDMLMatrix > matrixMap

Referenced by G4GDMLReadMaterials::PropertyRead().

◆ GetPosition()

G4ThreeVector G4GDMLReadDefine::GetPosition ( const G4String ref)

Definition at line 589 of file G4GDMLReadDefine.cc.

590{
591 if (positionMap.find(ref) == positionMap.end())
592 {
593 G4String error_msg = "Position '"+ref+"' was not found!";
594 G4Exception("G4GDMLReadDefine::getPosition()", "ReadError",
595 FatalException, error_msg);
596 }
597 return positionMap[ref];
598}
std::map< G4String, G4ThreeVector > positionMap

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadSolids::QuadrangularRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadSolids::TetRead(), and G4GDMLReadSolids::TriangularRead().

◆ GetQuantity()

G4double G4GDMLReadDefine::GetQuantity ( const G4String ref)

Definition at line 578 of file G4GDMLReadDefine.cc.

579{
580 if (quantityMap.find(ref) == quantityMap.end())
581 {
582 G4String error_msg = "Quantity '"+ref+"' was not found!";
583 G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError",
584 FatalException, error_msg);
585 }
586 return quantityMap[ref];
587}
std::map< G4String, G4double > quantityMap

Referenced by G4GDMLReadMaterials::MaterialRead().

◆ GetRotation()

G4ThreeVector G4GDMLReadDefine::GetRotation ( const G4String ref)

Definition at line 600 of file G4GDMLReadDefine.cc.

601{
602 if (rotationMap.find(ref) == rotationMap.end())
603 {
604 G4String error_msg = "Rotation '"+ref+"' was not found!";
605 G4Exception("G4GDMLReadDefine::getRotation()", "ReadError",
606 FatalException, error_msg);
607 }
608 return rotationMap[ref];
609}
std::map< G4String, G4ThreeVector > rotationMap

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadStructure::ReplicaRead().

◆ GetRotationMatrix()

G4RotationMatrix G4GDMLReadDefine::GetRotationMatrix ( const G4ThreeVector angles)
protected

Definition at line 132 of file G4GDMLReadDefine.cc.

133{
135
136 rot.rotateX(angles.x());
137 rot.rotateY(angles.y());
138 rot.rotateZ(angles.z());
139
140 return rot;
141}
double z() const
double x() const
double y() const
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadSolids::ReflectedSolidRead().

◆ GetScale()

G4ThreeVector G4GDMLReadDefine::GetScale ( const G4String ref)

Definition at line 611 of file G4GDMLReadDefine.cc.

612{
613 if (scaleMap.find(ref) == scaleMap.end())
614 {
615 G4String error_msg = "Scale '"+ref+"' was not found!";
616 G4Exception("G4GDMLReadDefine::getScale()", "ReadError",
617 FatalException, error_msg);
618 }
619 return scaleMap[ref];
620}
std::map< G4String, G4ThreeVector > scaleMap

Referenced by G4GDMLReadStructure::PhysvolRead().

◆ GetVariable()

G4double G4GDMLReadDefine::GetVariable ( const G4String ref)

Definition at line 573 of file G4GDMLReadDefine.cc.

574{
575 return eval.GetVariable(ref);
576}
G4double GetVariable(const G4String &)

◆ IsValidID()

G4bool G4GDMLReadDefine::IsValidID ( const G4String ref) const

Definition at line 563 of file G4GDMLReadDefine.cc.

564{
565 return eval.IsVariable(ref);
566}
G4bool IsVariable(const G4String &) const

◆ MatrixRead()

void G4GDMLReadDefine::MatrixRead ( const xercesc::DOMElement * const  matrixElement)
protected

Definition at line 215 of file G4GDMLReadDefine.cc.

216{
217 G4String name = "";
218 G4int coldim = 0;
219 G4String values = "";
220
221 const xercesc::DOMNamedNodeMap* const attributes
222 = matrixElement->getAttributes();
223 XMLSize_t attributeCount = attributes->getLength();
224
225 for (XMLSize_t attribute_index=0;
226 attribute_index<attributeCount; attribute_index++)
227 {
228 xercesc::DOMNode* node = attributes->item(attribute_index);
229
230 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
231
232 const xercesc::DOMAttr* const attribute
233 = dynamic_cast<xercesc::DOMAttr*>(node);
234 if (!attribute)
235 {
236 G4Exception("G4GDMLRead::MatrixRead()", "InvalidRead",
237 FatalException, "No attribute found!");
238 return;
239 }
240 const G4String attName = Transcode(attribute->getName());
241 const G4String attValue = Transcode(attribute->getValue());
242
243 if (attName=="name") { name = GenerateName(attValue); } else
244 if (attName=="coldim") { coldim = eval.EvaluateInteger(attValue); } else
245 if (attName=="values") { values = attValue; }
246 }
247
248 std::stringstream MatrixValueStream(values);
249 std::vector<G4double> valueList;
250
251 while (!MatrixValueStream.eof())
252 {
253 G4String MatrixValue;
254 MatrixValueStream >> MatrixValue;
255 valueList.push_back(eval.Evaluate(MatrixValue));
256 }
257
258 eval.DefineMatrix(name,coldim,valueList);
259
260 G4GDMLMatrix matrix(valueList.size()/coldim,coldim);
261
262 for (size_t i=0;i<valueList.size();i++)
263 {
264 matrix.Set(i/coldim,i%coldim,valueList[i]);
265 }
266
267 matrixMap[name] = matrix;
268}
int G4int
Definition: G4Types.hh:66
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
G4int EvaluateInteger(const G4String &)
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68

Referenced by DefineRead().

◆ PositionRead()

void G4GDMLReadDefine::PositionRead ( const xercesc::DOMElement * const  positionElement)
protected

Definition at line 271 of file G4GDMLReadDefine.cc.

272{
273 G4String name = "";
274 G4double unit = 1.0;
275 G4ThreeVector position(0.,0.,0.);
276
277 const xercesc::DOMNamedNodeMap* const attributes
278 = positionElement->getAttributes();
279 XMLSize_t attributeCount = attributes->getLength();
280
281 for (XMLSize_t attribute_index=0;
282 attribute_index<attributeCount; attribute_index++)
283 {
284 xercesc::DOMNode* node = attributes->item(attribute_index);
285
286 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
287
288 const xercesc::DOMAttr* const attribute
289 = dynamic_cast<xercesc::DOMAttr*>(node);
290 if (!attribute)
291 {
292 G4Exception("G4GDMLRead::PositionRead()", "InvalidRead",
293 FatalException, "No attribute found!");
294 return;
295 }
296 const G4String attName = Transcode(attribute->getName());
297 const G4String attValue = Transcode(attribute->getValue());
298
299 if (attName=="name") { name = GenerateName(attValue); } else
300 if (attName=="unit") { unit = eval.Evaluate(attValue); } else
301 if (attName=="x") { position.setX(eval.Evaluate(attValue)); } else
302 if (attName=="y") { position.setY(eval.Evaluate(attValue)); } else
303 if (attName=="z") { position.setZ(eval.Evaluate(attValue)); }
304 }
305
306 positionMap[name] = position*unit;
307}
#define position
Definition: xmlparse.cc:605

Referenced by DefineRead().

◆ QuantityRead()

void G4GDMLReadDefine::QuantityRead ( const xercesc::DOMElement * const  element)
protected

Definition at line 419 of file G4GDMLReadDefine.cc.

420{
421 G4String name = "";
422 G4double unit = 1.0;
423 G4double value = 0.0;
424
425 const xercesc::DOMNamedNodeMap* const attributes
426 = element->getAttributes();
427 XMLSize_t attributeCount = attributes->getLength();
428
429 for (XMLSize_t attribute_index=0;
430 attribute_index<attributeCount; attribute_index++)
431 {
432 xercesc::DOMNode* node = attributes->item(attribute_index);
433
434 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
435
436 const xercesc::DOMAttr* const attribute
437 = dynamic_cast<xercesc::DOMAttr*>(node);
438 if (!attribute)
439 {
440 G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead",
441 FatalException, "No attribute found!");
442 return;
443 }
444 const G4String attName = Transcode(attribute->getName());
445 const G4String attValue = Transcode(attribute->getValue());
446
447 if (attName=="name") { name = attValue; } else
448 if (attName=="value") { value = eval.Evaluate(attValue); } else
449 if (attName=="unit") { unit = eval.Evaluate(attValue); }
450 }
451
452 quantityMap[name] = value*unit;
453 eval.DefineConstant(name,value*unit);
454}

Referenced by DefineRead().

◆ RefRead()

G4String G4GDMLReadDefine::RefRead ( const xercesc::DOMElement * const  element)
protected

Definition at line 531 of file G4GDMLReadDefine.cc.

532{
533 G4String ref;
534
535 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
536 XMLSize_t attributeCount = attributes->getLength();
537
538 for (XMLSize_t attribute_index=0;
539 attribute_index<attributeCount; attribute_index++)
540 {
541 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
542
543 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
544 { continue; }
545
546 const xercesc::DOMAttr* const attribute
547 = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
548 if (!attribute)
549 {
550 G4Exception("G4GDMLRead::Read()", "InvalidRead",
551 FatalException, "No attribute found!");
552 return ref;
553 }
554 const G4String attName = Transcode(attribute->getName());
555 const G4String attValue = Transcode(attribute->getValue());
556
557 if (attName=="ref") { ref = attValue; }
558 }
559
560 return ref;
561}

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadStructure::BorderSurfaceRead(), G4GDMLReadStructure::DivisionvolRead(), G4GDMLReadMaterials::MaterialRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadParamvol::ParamvolRead(), G4GDMLReadStructure::PhysvolRead(), G4GDMLReadStructure::ReplicaRead(), G4GDMLReadStructure::ReplicavolRead(), G4GDMLReadSetup::SetupRead(), G4GDMLReadStructure::SkinSurfaceRead(), and G4GDMLReadStructure::VolumeRead().

◆ RotationRead()

void G4GDMLReadDefine::RotationRead ( const xercesc::DOMElement * const  rotationElement)
protected

Definition at line 310 of file G4GDMLReadDefine.cc.

311{
312 G4String name = "";
313 G4double unit = 1.0;
314 G4ThreeVector rotation(0.,0.,0.);
315
316 const xercesc::DOMNamedNodeMap* const attributes
317 = rotationElement->getAttributes();
318 XMLSize_t attributeCount = attributes->getLength();
319
320 for (XMLSize_t attribute_index=0;
321 attribute_index<attributeCount; attribute_index++)
322 {
323 xercesc::DOMNode* node = attributes->item(attribute_index);
324
325 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
326
327 const xercesc::DOMAttr* const attribute
328 = dynamic_cast<xercesc::DOMAttr*>(node);
329 if (!attribute)
330 {
331 G4Exception("G4GDMLRead::RotationRead()", "InvalidRead",
332 FatalException, "No attribute found!");
333 return;
334 }
335 const G4String attName = Transcode(attribute->getName());
336 const G4String attValue = Transcode(attribute->getValue());
337
338 if (attName=="name") { name = GenerateName(attValue); } else
339 if (attName=="unit") { unit = eval.Evaluate(attValue); } else
340 if (attName=="x") { rotation.setX(eval.Evaluate(attValue)); } else
341 if (attName=="y") { rotation.setY(eval.Evaluate(attValue)); } else
342 if (attName=="z") { rotation.setZ(eval.Evaluate(attValue)); }
343 }
344
345 rotationMap[name] = rotation*unit;
346}

Referenced by DefineRead().

◆ ScaleRead()

void G4GDMLReadDefine::ScaleRead ( const xercesc::DOMElement * const  scaleElement)
protected

Definition at line 348 of file G4GDMLReadDefine.cc.

349{
350 G4String name = "";
351 G4ThreeVector scale(1.0,1.0,1.0);
352
353 const xercesc::DOMNamedNodeMap* const attributes
354 = scaleElement->getAttributes();
355 XMLSize_t attributeCount = attributes->getLength();
356
357 for (XMLSize_t attribute_index=0;
358 attribute_index<attributeCount; attribute_index++)
359 {
360 xercesc::DOMNode* node = attributes->item(attribute_index);
361
362 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
363
364 const xercesc::DOMAttr* const attribute
365 = dynamic_cast<xercesc::DOMAttr*>(node);
366 if (!attribute)
367 {
368 G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead",
369 FatalException, "No attribute found!");
370 return;
371 }
372 const G4String attName = Transcode(attribute->getName());
373 const G4String attValue = Transcode(attribute->getValue());
374
375 if (attName=="name") { name = GenerateName(attValue); } else
376 if (attName=="x") { scale.setX(eval.Evaluate(attValue)); } else
377 if (attName=="y") { scale.setY(eval.Evaluate(attValue)); } else
378 if (attName=="z") { scale.setZ(eval.Evaluate(attValue)); }
379 }
380
381 scaleMap[name] = scale;
382}

Referenced by DefineRead().

◆ VariableRead()

void G4GDMLReadDefine::VariableRead ( const xercesc::DOMElement * const  variableElement)
protected

Definition at line 385 of file G4GDMLReadDefine.cc.

386{
387 G4String name = "";
388 G4double value = 0.0;
389
390 const xercesc::DOMNamedNodeMap* const attributes
391 = variableElement->getAttributes();
392 XMLSize_t attributeCount = attributes->getLength();
393
394 for (XMLSize_t attribute_index=0;
395 attribute_index<attributeCount; attribute_index++)
396 {
397 xercesc::DOMNode* node = attributes->item(attribute_index);
398
399 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
400
401 const xercesc::DOMAttr* const attribute
402 = dynamic_cast<xercesc::DOMAttr*>(node);
403 if (!attribute)
404 {
405 G4Exception("G4GDMLRead::VariableRead()", "InvalidRead",
406 FatalException, "No attribute found!");
407 return;
408 }
409 const G4String attName = Transcode(attribute->getName());
410 const G4String attValue = Transcode(attribute->getValue());
411
412 if (attName=="name") { name = attValue; } else
413 if (attName=="value") { value = eval.Evaluate(attValue); }
414 }
415
416 eval.DefineVariable(name,value);
417}
void DefineVariable(const G4String &, G4double)

Referenced by DefineRead().

◆ VectorRead()

void G4GDMLReadDefine::VectorRead ( const xercesc::DOMElement * const  vectorElement,
G4ThreeVector vec 
)
protected

Definition at line 494 of file G4GDMLReadDefine.cc.

496{
497 G4double unit = 1.0;
498
499 const xercesc::DOMNamedNodeMap* const attributes
500 = vectorElement->getAttributes();
501 XMLSize_t attributeCount = attributes->getLength();
502
503 for (XMLSize_t attribute_index=0;
504 attribute_index<attributeCount; attribute_index++)
505 {
506 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
507
508 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
509 { continue; }
510
511 const xercesc::DOMAttr* const attribute
512 = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
513 if (!attribute)
514 {
515 G4Exception("G4GDMLRead::VectorRead()", "InvalidRead",
516 FatalException, "No attribute found!");
517 return;
518 }
519 const G4String attName = Transcode(attribute->getName());
520 const G4String attValue = Transcode(attribute->getValue());
521
522 if (attName=="unit") { unit = eval.Evaluate(attValue); } else
523 if (attName=="x") { vec.setX(eval.Evaluate(attValue)); } else
524 if (attName=="y") { vec.setY(eval.Evaluate(attValue)); } else
525 if (attName=="z") { vec.setZ(eval.Evaluate(attValue)); }
526 }
527
528 vec *= unit;
529}
void setY(double)
void setZ(double)
void setX(double)

Referenced by G4GDMLReadSolids::BooleanRead(), G4GDMLReadParamvol::ParametersRead(), G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadStructure::ReplicaRead().

Member Data Documentation

◆ matrixMap

std::map<G4String,G4GDMLMatrix> G4GDMLReadDefine::matrixMap
protected

Definition at line 109 of file G4GDMLReadDefine.hh.

Referenced by GetMatrix(), and MatrixRead().

◆ positionMap

std::map<G4String,G4ThreeVector> G4GDMLReadDefine::positionMap
protected

Definition at line 106 of file G4GDMLReadDefine.hh.

Referenced by GetPosition(), and PositionRead().

◆ quantityMap

std::map<G4String,G4double> G4GDMLReadDefine::quantityMap
protected

Definition at line 105 of file G4GDMLReadDefine.hh.

Referenced by GetQuantity(), and QuantityRead().

◆ rotationMap

std::map<G4String,G4ThreeVector> G4GDMLReadDefine::rotationMap
protected

Definition at line 107 of file G4GDMLReadDefine.hh.

Referenced by GetRotation(), and RotationRead().

◆ scaleMap

std::map<G4String,G4ThreeVector> G4GDMLReadDefine::scaleMap
protected

Definition at line 108 of file G4GDMLReadDefine.hh.

Referenced by GetScale(), and ScaleRead().


The documentation for this class was generated from the following files: