Geant4 11.1.1
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)
 
void SetReverseSearch (G4bool flag)
 
- 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 void UserinfoRead (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 StripName (G4String &) const
 
void OverlapCheck (G4bool)
 
const G4GDMLAuxListTypeGetAuxList () const
 

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 GeneratePhysvolName (const G4String &, G4VPhysicalVolume *)
 
void LoopRead (const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
 
G4GDMLAuxStructType AuxiliaryRead (const xercesc::DOMElement *const auxElem)
 

Protected Attributes

G4bool reverseSearch = false
 
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 = true
 
G4bool check = false
 
G4bool dostrip = true
 

Detailed Description

Definition at line 66 of file G4GDMLReadDefine.hh.

Constructor & Destructor Documentation

◆ G4GDMLReadDefine()

G4GDMLReadDefine::G4GDMLReadDefine ( )
protected

Definition at line 142 of file G4GDMLReadDefine.cc.

143 : G4GDMLRead()
144{
145}

◆ ~G4GDMLReadDefine()

G4GDMLReadDefine::~G4GDMLReadDefine ( )
protectedvirtual

Definition at line 148 of file G4GDMLReadDefine.cc.

149{
150}

Member Function Documentation

◆ ConstantRead()

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

Definition at line 167 of file G4GDMLReadDefine.cc.

169{
170 G4String name = "";
171 G4double value = 0.0;
172
173 const xercesc::DOMNamedNodeMap* const attributes =
174 constantElement->getAttributes();
175 XMLSize_t attributeCount = attributes->getLength();
176
177 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
178 ++attribute_index)
179 {
180 xercesc::DOMNode* node = attributes->item(attribute_index);
181
182 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
183 {
184 continue;
185 }
186
187 const xercesc::DOMAttr* const attribute =
188 dynamic_cast<xercesc::DOMAttr*>(node);
189 if(attribute == nullptr)
190 {
191 G4Exception("G4GDMLRead::ConstantRead()", "InvalidRead", FatalException,
192 "No attribute found!");
193 return;
194 }
195 const G4String attName = Transcode(attribute->getName());
196 const G4String attValue = Transcode(attribute->getValue());
197
198 if(attName == "name")
199 {
200 name = attValue;
201 }
202 else if(attName == "value")
203 {
204 value = eval.Evaluate(attValue);
205 }
206 }
207
208 eval.DefineConstant(name, value);
209}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
G4double Evaluate(const G4String &)
void DefineConstant(const G4String &, G4double)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:156
const char * name(G4int ptype)

Referenced by DefineRead().

◆ DefineRead()

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

Implements G4GDMLRead.

Definition at line 596 of file G4GDMLReadDefine.cc.

598{
599#ifdef G4VERBOSE
600 G4cout << "G4GDML: Reading definitions..." << G4endl;
601#endif
602 for(xercesc::DOMNode* iter = defineElement->getFirstChild(); iter != nullptr;
603 iter = iter->getNextSibling())
604 {
605 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
606 {
607 continue;
608 }
609
610 const xercesc::DOMElement* const child =
611 dynamic_cast<xercesc::DOMElement*>(iter);
612 if(child == nullptr)
613 {
614 G4Exception("G4GDMLRead::DefineRead()", "InvalidRead", FatalException,
615 "No child found!");
616 return;
617 }
618 const G4String tag = Transcode(child->getTagName());
619
620 if(tag == "constant")
621 {
622 ConstantRead(child);
623 }
624 else if(tag == "matrix")
625 {
626 MatrixRead(child);
627 }
628 else if(tag == "position")
629 {
630 PositionRead(child);
631 }
632 else if(tag == "rotation")
633 {
634 RotationRead(child);
635 }
636 else if(tag == "scale")
637 {
638 ScaleRead(child);
639 }
640 else if(tag == "variable")
641 {
642 VariableRead(child);
643 }
644 else if(tag == "quantity")
645 {
646 QuantityRead(child);
647 }
648 else if(tag == "expression")
649 {
650 ExpressionRead(child);
651 }
652 else
653 {
654 G4String error_msg = "Unknown tag in define: " + tag;
655 G4Exception("G4GDMLReadDefine::defineRead()", "ReadError", FatalException,
656 error_msg);
657 }
658 }
659}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL 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.c:284

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

◆ ExpressionRead()

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

Definition at line 212 of file G4GDMLReadDefine.cc.

214{
215 G4String name = "";
216 G4double value = 0.0;
217
218 const xercesc::DOMNamedNodeMap* const attributes =
219 expElement->getAttributes();
220 XMLSize_t attributeCount = attributes->getLength();
221
222 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
223 ++attribute_index)
224 {
225 xercesc::DOMNode* node = attributes->item(attribute_index);
226
227 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
228 {
229 continue;
230 }
231
232 const xercesc::DOMAttr* const attribute =
233 dynamic_cast<xercesc::DOMAttr*>(node);
234 if(attribute == nullptr)
235 {
236 G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead", FatalException,
237 "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")
244 {
245 name = attValue;
246 }
247 }
248
249 const G4String expValue = Transcode(expElement->getTextContent());
250 value = eval.Evaluate(expValue);
251 eval.DefineConstant(name, value);
252}

Referenced by DefineRead().

◆ GetConstant()

G4double G4GDMLReadDefine::GetConstant ( const G4String ref)

Definition at line 758 of file G4GDMLReadDefine.cc.

759{
760 return eval.GetConstant(ref);
761}
G4double GetConstant(const G4String &)

◆ GetMatrix()

G4GDMLMatrix G4GDMLReadDefine::GetMatrix ( const G4String ref)

Definition at line 818 of file G4GDMLReadDefine.cc.

819{
820 if(matrixMap.find(ref) == matrixMap.end())
821 {
822 G4String error_msg = "Matrix '" + ref + "' was not found!";
823 G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError", FatalException,
824 error_msg);
825 }
826 return matrixMap[ref];
827}
std::map< G4String, G4GDMLMatrix > matrixMap

Referenced by G4GDMLReadMaterials::PropertyRead(), and G4GDMLReadSolids::PropertyRead().

◆ GetPosition()

G4ThreeVector G4GDMLReadDefine::GetPosition ( const G4String ref)

Definition at line 782 of file G4GDMLReadDefine.cc.

783{
784 if(positionMap.find(ref) == positionMap.cend())
785 {
786 G4String error_msg = "Position '" + ref + "' was not found!";
787 G4Exception("G4GDMLReadDefine::getPosition()", "ReadError", FatalException,
788 error_msg);
789 }
790 return positionMap[ref];
791}
std::map< G4String, G4ThreeVector > positionMap

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

◆ GetQuantity()

G4double G4GDMLReadDefine::GetQuantity ( const G4String ref)

Definition at line 770 of file G4GDMLReadDefine.cc.

771{
772 if(quantityMap.find(ref) == quantityMap.cend())
773 {
774 G4String error_msg = "Quantity '" + ref + "' was not found!";
775 G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError", FatalException,
776 error_msg);
777 }
778 return quantityMap[ref];
779}
std::map< G4String, G4double > quantityMap

Referenced by G4GDMLReadMaterials::MaterialRead().

◆ GetRotation()

G4ThreeVector G4GDMLReadDefine::GetRotation ( const G4String ref)

Definition at line 794 of file G4GDMLReadDefine.cc.

795{
796 if(rotationMap.find(ref) == rotationMap.cend())
797 {
798 G4String error_msg = "Rotation '" + ref + "' was not found!";
799 G4Exception("G4GDMLReadDefine::getRotation()", "ReadError", FatalException,
800 error_msg);
801 }
802 return rotationMap[ref];
803}
std::map< G4String, G4ThreeVector > rotationMap

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

◆ GetRotationMatrix()

G4RotationMatrix G4GDMLReadDefine::GetRotationMatrix ( const G4ThreeVector angles)
protected

Definition at line 153 of file G4GDMLReadDefine.cc.

155{
157
158 rot.rotateX(angles.x());
159 rot.rotateY(angles.y());
160 rot.rotateZ(angles.z());
161 rot.rectify(); // Rectify matrix from possible roundoff errors
162
163 return rot;
164}
double z() const
double x() const
double y() const
HepRotation & rotateX(double delta)
Definition: Rotation.cc:61
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
HepRotation & rotateY(double delta)
Definition: Rotation.cc:74

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

◆ GetScale()

G4ThreeVector G4GDMLReadDefine::GetScale ( const G4String ref)

Definition at line 806 of file G4GDMLReadDefine.cc.

807{
808 if(scaleMap.find(ref) == scaleMap.end())
809 {
810 G4String error_msg = "Scale '" + ref + "' was not found!";
811 G4Exception("G4GDMLReadDefine::getScale()", "ReadError", FatalException,
812 error_msg);
813 }
814 return scaleMap[ref];
815}
std::map< G4String, G4ThreeVector > scaleMap

Referenced by G4GDMLReadStructure::PhysvolRead(), and G4GDMLReadSolids::ScaledSolidRead().

◆ GetVariable()

G4double G4GDMLReadDefine::GetVariable ( const G4String ref)

Definition at line 764 of file G4GDMLReadDefine.cc.

765{
766 return eval.GetVariable(ref);
767}
G4double GetVariable(const G4String &)

◆ IsValidID()

G4bool G4GDMLReadDefine::IsValidID ( const G4String ref) const

Definition at line 752 of file G4GDMLReadDefine.cc.

753{
754 return eval.IsVariable(ref);
755}
G4bool IsVariable(const G4String &) const

◆ MatrixRead()

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

Definition at line 255 of file G4GDMLReadDefine.cc.

257{
258 G4String name = "";
259 G4int coldim = 0;
260 G4String values = "";
261
262 const xercesc::DOMNamedNodeMap* const attributes =
263 matrixElement->getAttributes();
264 XMLSize_t attributeCount = attributes->getLength();
265
266 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
267 ++attribute_index)
268 {
269 xercesc::DOMNode* node = attributes->item(attribute_index);
270
271 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
272 {
273 continue;
274 }
275
276 const xercesc::DOMAttr* const attribute =
277 dynamic_cast<xercesc::DOMAttr*>(node);
278 if(attribute == nullptr)
279 {
280 G4Exception("G4GDMLRead::MatrixRead()", "InvalidRead", FatalException,
281 "No attribute found!");
282 return;
283 }
284 const G4String attName = Transcode(attribute->getName());
285 const G4String attValue = Transcode(attribute->getValue());
286
287 if(attName == "name")
288 {
289 name = GenerateName(attValue);
290 }
291 else if(attName == "coldim")
292 {
293 coldim = eval.EvaluateInteger(attValue);
294 }
295 else if(attName == "values")
296 {
297 values = attValue;
298 }
299 }
300
301 std::stringstream MatrixValueStream(values);
302 std::vector<G4double> valueList;
303
304 while(!MatrixValueStream.eof())
305 {
306 G4String MatrixValue;
307 MatrixValueStream >> MatrixValue;
308 valueList.push_back(eval.Evaluate(MatrixValue));
309 }
310
311 eval.DefineMatrix(name, coldim, valueList);
312
313 G4GDMLMatrix matrix(valueList.size() / coldim, coldim);
314
315 for(std::size_t i = 0; i < valueList.size(); ++i)
316 {
317 matrix.Set(i / coldim, i % coldim, valueList[i]);
318 }
319
320 matrixMap[name] = matrix;
321}
int G4int
Definition: G4Types.hh:85
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
G4int EvaluateInteger(const G4String &)
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:70

Referenced by DefineRead().

◆ PositionRead()

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

Definition at line 324 of file G4GDMLReadDefine.cc.

326{
327 G4String name = "";
328 G4double unit = 1.0;
329 G4ThreeVector position(0., 0., 0.);
330
331 const xercesc::DOMNamedNodeMap* const attributes =
332 positionElement->getAttributes();
333 XMLSize_t attributeCount = attributes->getLength();
334
335 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
336 ++attribute_index)
337 {
338 xercesc::DOMNode* node = attributes->item(attribute_index);
339
340 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
341 {
342 continue;
343 }
344
345 const xercesc::DOMAttr* const attribute =
346 dynamic_cast<xercesc::DOMAttr*>(node);
347 if(attribute == nullptr)
348 {
349 G4Exception("G4GDMLRead::PositionRead()", "InvalidRead", FatalException,
350 "No attribute found!");
351 return;
352 }
353 const G4String attName = Transcode(attribute->getName());
354 const G4String attValue = Transcode(attribute->getValue());
355
356 if(attName == "name")
357 {
358 name = GenerateName(attValue);
359 }
360 else if(attName == "unit")
361 {
362 unit = G4UnitDefinition::GetValueOf(attValue);
363 if(G4UnitDefinition::GetCategory(attValue) != "Length")
364 {
365 G4Exception("G4GDMLReadDefine::PositionRead()", "InvalidRead",
366 FatalException, "Invalid unit for length!");
367 }
368 }
369 else if(attName == "x")
370 {
371 position.setX(eval.Evaluate(attValue));
372 }
373 else if(attName == "y")
374 {
375 position.setY(eval.Evaluate(attValue));
376 }
377 else if(attName == "z")
378 {
379 position.setZ(eval.Evaluate(attValue));
380 }
381 }
382
383 positionMap[name] = position * unit;
384}
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)

Referenced by DefineRead().

◆ QuantityRead()

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

Definition at line 547 of file G4GDMLReadDefine.cc.

548{
549 G4String name = "";
550 G4double unit = 1.0;
551 G4double value = 0.0;
552
553 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
554 XMLSize_t attributeCount = attributes->getLength();
555
556 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
557 ++attribute_index)
558 {
559 xercesc::DOMNode* node = attributes->item(attribute_index);
560
561 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
562 {
563 continue;
564 }
565
566 const xercesc::DOMAttr* const attribute =
567 dynamic_cast<xercesc::DOMAttr*>(node);
568 if(attribute == nullptr)
569 {
570 G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead", FatalException,
571 "No attribute found!");
572 return;
573 }
574 const G4String attName = Transcode(attribute->getName());
575 const G4String attValue = Transcode(attribute->getValue());
576
577 if(attName == "name")
578 {
579 name = attValue;
580 }
581 else if(attName == "value")
582 {
583 value = eval.Evaluate(attValue);
584 }
585 else if(attName == "unit")
586 {
587 unit = G4UnitDefinition::GetValueOf(attValue);
588 }
589 }
590
591 quantityMap[name] = value * unit;
592 eval.DefineConstant(name, value * unit);
593}

Referenced by DefineRead().

◆ RefRead()

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

Definition at line 714 of file G4GDMLReadDefine.cc.

715{
716 G4String ref;
717
718 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
719 XMLSize_t attributeCount = attributes->getLength();
720
721 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
722 ++attribute_index)
723 {
724 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
725
726 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
727 {
728 continue;
729 }
730
731 const xercesc::DOMAttr* const attribute =
732 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
733 if(attribute == nullptr)
734 {
735 G4Exception("G4GDMLRead::Read()", "InvalidRead", FatalException,
736 "No attribute found!");
737 return ref;
738 }
739 const G4String attName = Transcode(attribute->getName());
740 const G4String attValue = Transcode(attribute->getValue());
741
742 if(attName == "ref")
743 {
744 ref = attValue;
745 }
746 }
747
748 return ref;
749}

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

◆ RotationRead()

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

Definition at line 387 of file G4GDMLReadDefine.cc.

389{
390 G4String name = "";
391 G4double unit = 1.0;
392 G4ThreeVector rotation(0., 0., 0.);
393
394 const xercesc::DOMNamedNodeMap* const attributes =
395 rotationElement->getAttributes();
396 XMLSize_t attributeCount = attributes->getLength();
397
398 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
399 ++attribute_index)
400 {
401 xercesc::DOMNode* node = attributes->item(attribute_index);
402
403 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
404 {
405 continue;
406 }
407
408 const xercesc::DOMAttr* const attribute =
409 dynamic_cast<xercesc::DOMAttr*>(node);
410 if(attribute == nullptr)
411 {
412 G4Exception("G4GDMLRead::RotationRead()", "InvalidRead", FatalException,
413 "No attribute found!");
414 return;
415 }
416 const G4String attName = Transcode(attribute->getName());
417 const G4String attValue = Transcode(attribute->getValue());
418
419 if(attName == "name")
420 {
421 name = GenerateName(attValue);
422 }
423 else if(attName == "unit")
424 {
425 unit = G4UnitDefinition::GetValueOf(attValue);
426 if(G4UnitDefinition::GetCategory(attValue) != "Angle")
427 {
428 G4Exception("G4GDMLReadDefine::RotationRead()", "InvalidRead",
429 FatalException, "Invalid unit for angle!");
430 }
431 }
432 else if(attName == "x")
433 {
434 rotation.setX(eval.Evaluate(attValue));
435 }
436 else if(attName == "y")
437 {
438 rotation.setY(eval.Evaluate(attValue));
439 }
440 else if(attName == "z")
441 {
442 rotation.setZ(eval.Evaluate(attValue));
443 }
444 }
445
446 rotationMap[name] = rotation * unit;
447}

Referenced by DefineRead().

◆ ScaleRead()

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

Definition at line 450 of file G4GDMLReadDefine.cc.

451{
452 G4String name = "";
453 G4ThreeVector scale(1.0, 1.0, 1.0);
454
455 const xercesc::DOMNamedNodeMap* const attributes =
456 scaleElement->getAttributes();
457 XMLSize_t attributeCount = attributes->getLength();
458
459 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
460 ++attribute_index)
461 {
462 xercesc::DOMNode* node = attributes->item(attribute_index);
463
464 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
465 {
466 continue;
467 }
468
469 const xercesc::DOMAttr* const attribute =
470 dynamic_cast<xercesc::DOMAttr*>(node);
471 if(attribute == nullptr)
472 {
473 G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead", FatalException,
474 "No attribute found!");
475 return;
476 }
477 const G4String attName = Transcode(attribute->getName());
478 const G4String attValue = Transcode(attribute->getValue());
479
480 if(attName == "name")
481 {
482 name = GenerateName(attValue);
483 }
484 else if(attName == "x")
485 {
486 scale.setX(eval.Evaluate(attValue));
487 }
488 else if(attName == "y")
489 {
490 scale.setY(eval.Evaluate(attValue));
491 }
492 else if(attName == "z")
493 {
494 scale.setZ(eval.Evaluate(attValue));
495 }
496 }
497
498 scaleMap[name] = scale;
499}

Referenced by DefineRead().

◆ SetReverseSearch()

void G4GDMLReadDefine::SetReverseSearch ( G4bool  flag)
inline

Definition at line 81 of file G4GDMLReadDefine.hh.

82 { reverseSearch = flag; }

◆ VariableRead()

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

Definition at line 502 of file G4GDMLReadDefine.cc.

504{
505 G4String name = "";
506 G4double value = 0.0;
507
508 const xercesc::DOMNamedNodeMap* const attributes =
509 variableElement->getAttributes();
510 XMLSize_t attributeCount = attributes->getLength();
511
512 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
513 ++attribute_index)
514 {
515 xercesc::DOMNode* node = attributes->item(attribute_index);
516
517 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
518 {
519 continue;
520 }
521
522 const xercesc::DOMAttr* const attribute =
523 dynamic_cast<xercesc::DOMAttr*>(node);
524 if(attribute == nullptr)
525 {
526 G4Exception("G4GDMLRead::VariableRead()", "InvalidRead", FatalException,
527 "No attribute found!");
528 return;
529 }
530 const G4String attName = Transcode(attribute->getName());
531 const G4String attValue = Transcode(attribute->getValue());
532
533 if(attName == "name")
534 {
535 name = attValue;
536 }
537 else if(attName == "value")
538 {
539 value = eval.Evaluate(attValue);
540 }
541 }
542
543 eval.DefineVariable(name, value);
544}
void DefineVariable(const G4String &, G4double)

Referenced by DefineRead().

◆ VectorRead()

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

Definition at line 662 of file G4GDMLReadDefine.cc.

664{
665 G4double unit = 1.0;
666
667 const xercesc::DOMNamedNodeMap* const attributes =
668 vectorElement->getAttributes();
669 XMLSize_t attributeCount = attributes->getLength();
670
671 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
672 ++attribute_index)
673 {
674 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
675
676 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
677 {
678 continue;
679 }
680
681 const xercesc::DOMAttr* const attribute =
682 dynamic_cast<xercesc::DOMAttr*>(attribute_node);
683 if(attribute == nullptr)
684 {
685 G4Exception("G4GDMLRead::VectorRead()", "InvalidRead", FatalException,
686 "No attribute found!");
687 return;
688 }
689 const G4String attName = Transcode(attribute->getName());
690 const G4String attValue = Transcode(attribute->getValue());
691
692 if(attName == "unit")
693 {
694 unit = G4UnitDefinition::GetValueOf(attValue);
695 }
696 else if(attName == "x")
697 {
698 vec.setX(eval.Evaluate(attValue));
699 }
700 else if(attName == "y")
701 {
702 vec.setY(eval.Evaluate(attValue));
703 }
704 else if(attName == "z")
705 {
706 vec.setZ(eval.Evaluate(attValue));
707 }
708 }
709
710 vec *= unit;
711}
void setY(double)
void setZ(double)
void setX(double)

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

Member Data Documentation

◆ matrixMap

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

Definition at line 108 of file G4GDMLReadDefine.hh.

Referenced by GetMatrix(), and MatrixRead().

◆ positionMap

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

Definition at line 105 of file G4GDMLReadDefine.hh.

Referenced by GetPosition(), and PositionRead().

◆ quantityMap

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

Definition at line 104 of file G4GDMLReadDefine.hh.

Referenced by GetQuantity(), and QuantityRead().

◆ reverseSearch

◆ rotationMap

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

Definition at line 106 of file G4GDMLReadDefine.hh.

Referenced by GetRotation(), and RotationRead().

◆ scaleMap

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

Definition at line 107 of file G4GDMLReadDefine.hh.

Referenced by GetScale(), and ScaleRead().


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