Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GDMLReadDefine Class Reference

#include <G4GDMLReadDefine.hh>

Inheritance diagram for G4GDMLReadDefine:
Collaboration 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 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

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
 
G4bool dostrip
 

Detailed Description

Definition at line 69 of file G4GDMLReadDefine.hh.

Constructor & Destructor Documentation

G4GDMLReadDefine::G4GDMLReadDefine ( )
protected

Definition at line 124 of file G4GDMLReadDefine.cc.

124  : G4GDMLRead()
125 {
126 }
G4GDMLReadDefine::~G4GDMLReadDefine ( )
protectedvirtual

Definition at line 128 of file G4GDMLReadDefine.cc.

129 {
130 }

Member Function Documentation

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

Definition at line 146 of file G4GDMLReadDefine.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements G4GDMLRead.

Definition at line 467 of file G4GDMLReadDefine.cc.

468 {
469  G4cout << "G4GDML: Reading definitions..." << G4endl;
470 
471  for (xercesc::DOMNode* iter = defineElement->getFirstChild();
472  iter != 0;iter = iter->getNextSibling())
473  {
474  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
475 
476  const xercesc::DOMElement* const child
477  = dynamic_cast<xercesc::DOMElement*>(iter);
478  if (!child)
479  {
480  G4Exception("G4GDMLRead::DefineRead()", "InvalidRead",
481  FatalException, "No child found!");
482  return;
483  }
484  const G4String tag = Transcode(child->getTagName());
485 
486  if (tag=="constant") { ConstantRead(child); } else
487  if (tag=="matrix") { MatrixRead(child); } else
488  if (tag=="position") { PositionRead(child); } else
489  if (tag=="rotation") { RotationRead(child); } else
490  if (tag=="scale") { ScaleRead(child); } else
491  if (tag=="variable") { VariableRead(child); } else
492  if (tag=="quantity") { QuantityRead(child); } else
493  if (tag=="expression") { ExpressionRead(child); }
494  else
495  {
496  G4String error_msg = "Unknown tag in define: "+tag;
497  G4Exception("G4GDMLReadDefine::defineRead()", "ReadError",
498  FatalException, error_msg);
499  }
500  }
501 }
void PositionRead(const xercesc::DOMElement *const)
Definition: xmlparse.cc:187
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void ConstantRead(const xercesc::DOMElement *const)
void ExpressionRead(const xercesc::DOMElement *const)
G4GLOB_DLL std::ostream G4cout
void MatrixRead(const xercesc::DOMElement *const)
void RotationRead(const xercesc::DOMElement *const)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void VariableRead(const xercesc::DOMElement *const)
void QuantityRead(const xercesc::DOMElement *const)
#define G4endl
Definition: G4ios.hh:61
void ScaleRead(const xercesc::DOMElement *const)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 181 of file G4GDMLReadDefine.cc.

182 {
183  G4String name = "";
184  G4double value = 0.0;
185 
186  const xercesc::DOMNamedNodeMap* const attributes
187  = expElement->getAttributes();
188  XMLSize_t attributeCount = attributes->getLength();
189 
190  for (XMLSize_t attribute_index=0;
191  attribute_index<attributeCount; attribute_index++)
192  {
193  xercesc::DOMNode* node = attributes->item(attribute_index);
194 
195  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
196 
197  const xercesc::DOMAttr* const attribute
198  = dynamic_cast<xercesc::DOMAttr*>(node);
199  if (!attribute)
200  {
201  G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead",
202  FatalException, "No attribute found!");
203  return;
204  }
205  const G4String attName = Transcode(attribute->getName());
206  const G4String attValue = Transcode(attribute->getValue());
207 
208  if (attName=="name") { name = attValue; }
209  }
210 
211  const G4String expValue = Transcode(expElement->getTextContent());
212  value = eval.Evaluate(expValue);
213  eval.DefineConstant(name,value);
214 }
const XML_Char * name
Definition: expat.h:151
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
void DefineConstant(const G4String &, G4double)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4GDMLReadDefine::GetConstant ( const G4String ref)

Definition at line 578 of file G4GDMLReadDefine.cc.

579 {
580  return eval.GetConstant(ref);
581 }
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4double GetConstant(const G4String &)

Here is the call graph for this function:

G4GDMLMatrix G4GDMLReadDefine::GetMatrix ( const G4String ref)

Definition at line 632 of file G4GDMLReadDefine.cc.

633 {
634  if (matrixMap.find(ref) == matrixMap.end())
635  {
636  G4String error_msg = "Matrix '"+ref+"' was not found!";
637  G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError",
638  FatalException, error_msg);
639  }
640  return matrixMap[ref];
641 }
std::map< G4String, G4GDMLMatrix > matrixMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4ThreeVector G4GDMLReadDefine::GetPosition ( const G4String ref)

Definition at line 599 of file G4GDMLReadDefine.cc.

600 {
601  if (positionMap.find(ref) == positionMap.end())
602  {
603  G4String error_msg = "Position '"+ref+"' was not found!";
604  G4Exception("G4GDMLReadDefine::getPosition()", "ReadError",
605  FatalException, error_msg);
606  }
607  return positionMap[ref];
608 }
std::map< G4String, G4ThreeVector > positionMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4GDMLReadDefine::GetQuantity ( const G4String ref)

Definition at line 588 of file G4GDMLReadDefine.cc.

589 {
590  if (quantityMap.find(ref) == quantityMap.end())
591  {
592  G4String error_msg = "Quantity '"+ref+"' was not found!";
593  G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError",
594  FatalException, error_msg);
595  }
596  return quantityMap[ref];
597 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::map< G4String, G4double > quantityMap

Here is the call graph for this function:

Here is the caller graph for this function:

G4ThreeVector G4GDMLReadDefine::GetRotation ( const G4String ref)

Definition at line 610 of file G4GDMLReadDefine.cc.

611 {
612  if (rotationMap.find(ref) == rotationMap.end())
613  {
614  G4String error_msg = "Rotation '"+ref+"' was not found!";
615  G4Exception("G4GDMLReadDefine::getRotation()", "ReadError",
616  FatalException, error_msg);
617  }
618  return rotationMap[ref];
619 }
std::map< G4String, G4ThreeVector > rotationMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4RotationMatrix G4GDMLReadDefine::GetRotationMatrix ( const G4ThreeVector angles)
protected

Definition at line 133 of file G4GDMLReadDefine.cc.

134 {
135  G4RotationMatrix rot;
136 
137  rot.rotateX(angles.x());
138  rot.rotateY(angles.y());
139  rot.rotateZ(angles.z());
140  rot.rectify(); // Rectify matrix from possible roundoff errors
141 
142  return rot;
143 }
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
double x() const
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79
double z() const
double y() const
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92

Here is the call graph for this function:

Here is the caller graph for this function:

G4ThreeVector G4GDMLReadDefine::GetScale ( const G4String ref)

Definition at line 621 of file G4GDMLReadDefine.cc.

622 {
623  if (scaleMap.find(ref) == scaleMap.end())
624  {
625  G4String error_msg = "Scale '"+ref+"' was not found!";
626  G4Exception("G4GDMLReadDefine::getScale()", "ReadError",
627  FatalException, error_msg);
628  }
629  return scaleMap[ref];
630 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::map< G4String, G4ThreeVector > scaleMap

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4GDMLReadDefine::GetVariable ( const G4String ref)

Definition at line 583 of file G4GDMLReadDefine.cc.

584 {
585  return eval.GetVariable(ref);
586 }
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4double GetVariable(const G4String &)

Here is the call graph for this function:

G4bool G4GDMLReadDefine::IsValidID ( const G4String ref) const

Definition at line 573 of file G4GDMLReadDefine.cc.

574 {
575  return eval.IsVariable(ref);
576 }
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4bool IsVariable(const G4String &) const

Here is the call graph for this function:

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

Definition at line 217 of file G4GDMLReadDefine.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 273 of file G4GDMLReadDefine.cc.

274 {
275  G4String name = "";
276  G4double unit = 1.0;
277  G4ThreeVector position(0.,0.,0.);
278 
279  const xercesc::DOMNamedNodeMap* const attributes
280  = positionElement->getAttributes();
281  XMLSize_t attributeCount = attributes->getLength();
282 
283  for (XMLSize_t attribute_index=0;
284  attribute_index<attributeCount; attribute_index++)
285  {
286  xercesc::DOMNode* node = attributes->item(attribute_index);
287 
288  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
289 
290  const xercesc::DOMAttr* const attribute
291  = dynamic_cast<xercesc::DOMAttr*>(node);
292  if (!attribute)
293  {
294  G4Exception("G4GDMLRead::PositionRead()", "InvalidRead",
295  FatalException, "No attribute found!");
296  return;
297  }
298  const G4String attName = Transcode(attribute->getName());
299  const G4String attValue = Transcode(attribute->getValue());
300 
301  if (attName=="name") { name = GenerateName(attValue); } else
302  if (attName=="unit") { unit = G4UnitDefinition::GetValueOf(attValue);
303  if (G4UnitDefinition::GetCategory(attValue)!="Length") {
304  G4Exception("G4GDMLReadDefine::PositionRead()", "InvalidRead",
305  FatalException, "Invalid unit for length!"); }
306  } else
307  if (attName=="x") { position.setX(eval.Evaluate(attValue)); } else
308  if (attName=="y") { position.setY(eval.Evaluate(attValue)); } else
309  if (attName=="z") { position.setZ(eval.Evaluate(attValue)); }
310  }
311 
312  positionMap[name] = position*unit;
313 }
const XML_Char * name
Definition: expat.h:151
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
static G4double GetValueOf(const G4String &)
#define position
Definition: xmlparse.cc:622
std::map< G4String, G4ThreeVector > positionMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4String GetCategory(const G4String &)
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68
double G4double
Definition: G4Types.hh:76
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 429 of file G4GDMLReadDefine.cc.

430 {
431  G4String name = "";
432  G4double unit = 1.0;
433  G4double value = 0.0;
434 
435  const xercesc::DOMNamedNodeMap* const attributes
436  = element->getAttributes();
437  XMLSize_t attributeCount = attributes->getLength();
438 
439  for (XMLSize_t attribute_index=0;
440  attribute_index<attributeCount; attribute_index++)
441  {
442  xercesc::DOMNode* node = attributes->item(attribute_index);
443 
444  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
445 
446  const xercesc::DOMAttr* const attribute
447  = dynamic_cast<xercesc::DOMAttr*>(node);
448  if (!attribute)
449  {
450  G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead",
451  FatalException, "No attribute found!");
452  return;
453  }
454  const G4String attName = Transcode(attribute->getName());
455  const G4String attValue = Transcode(attribute->getValue());
456 
457  if (attName=="name") { name = attValue; } else
458  if (attName=="value") { value = eval.Evaluate(attValue); } else
459  if (attName=="unit") { unit = G4UnitDefinition::GetValueOf(attValue); }
460  }
461 
462  quantityMap[name] = value*unit;
463  eval.DefineConstant(name,value*unit);
464 }
const XML_Char * name
Definition: expat.h:151
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
void DefineConstant(const G4String &, G4double)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
static G4double GetValueOf(const G4String &)
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
std::map< G4String, G4double > quantityMap
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 541 of file G4GDMLReadDefine.cc.

542 {
543  G4String ref;
544 
545  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
546  XMLSize_t attributeCount = attributes->getLength();
547 
548  for (XMLSize_t attribute_index=0;
549  attribute_index<attributeCount; attribute_index++)
550  {
551  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
552 
553  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
554  { continue; }
555 
556  const xercesc::DOMAttr* const attribute
557  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
558  if (!attribute)
559  {
560  G4Exception("G4GDMLRead::Read()", "InvalidRead",
561  FatalException, "No attribute found!");
562  return ref;
563  }
564  const G4String attName = Transcode(attribute->getName());
565  const G4String attValue = Transcode(attribute->getValue());
566 
567  if (attName=="ref") { ref = attValue; }
568  }
569 
570  return ref;
571 }
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 316 of file G4GDMLReadDefine.cc.

317 {
318  G4String name = "";
319  G4double unit = 1.0;
320  G4ThreeVector rotation(0.,0.,0.);
321 
322  const xercesc::DOMNamedNodeMap* const attributes
323  = rotationElement->getAttributes();
324  XMLSize_t attributeCount = attributes->getLength();
325 
326  for (XMLSize_t attribute_index=0;
327  attribute_index<attributeCount; attribute_index++)
328  {
329  xercesc::DOMNode* node = attributes->item(attribute_index);
330 
331  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
332 
333  const xercesc::DOMAttr* const attribute
334  = dynamic_cast<xercesc::DOMAttr*>(node);
335  if (!attribute)
336  {
337  G4Exception("G4GDMLRead::RotationRead()", "InvalidRead",
338  FatalException, "No attribute found!");
339  return;
340  }
341  const G4String attName = Transcode(attribute->getName());
342  const G4String attValue = Transcode(attribute->getValue());
343 
344  if (attName=="name") { name = GenerateName(attValue); } else
345  if (attName=="unit") { unit = G4UnitDefinition::GetValueOf(attValue);
346  if (G4UnitDefinition::GetCategory(attValue)!="Angle") {
347  G4Exception("G4GDMLReadDefine::RotationRead()", "InvalidRead",
348  FatalException, "Invalid unit for angle!"); }
349  } else
350  if (attName=="x") { rotation.setX(eval.Evaluate(attValue)); } else
351  if (attName=="y") { rotation.setY(eval.Evaluate(attValue)); } else
352  if (attName=="z") { rotation.setZ(eval.Evaluate(attValue)); }
353  }
354 
355  rotationMap[name] = rotation*unit;
356 }
const XML_Char * name
Definition: expat.h:151
std::map< G4String, G4ThreeVector > rotationMap
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
static G4double GetValueOf(const G4String &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4String GetCategory(const G4String &)
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68
double G4double
Definition: G4Types.hh:76
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 358 of file G4GDMLReadDefine.cc.

359 {
360  G4String name = "";
361  G4ThreeVector scale(1.0,1.0,1.0);
362 
363  const xercesc::DOMNamedNodeMap* const attributes
364  = scaleElement->getAttributes();
365  XMLSize_t attributeCount = attributes->getLength();
366 
367  for (XMLSize_t attribute_index=0;
368  attribute_index<attributeCount; attribute_index++)
369  {
370  xercesc::DOMNode* node = attributes->item(attribute_index);
371 
372  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
373 
374  const xercesc::DOMAttr* const attribute
375  = dynamic_cast<xercesc::DOMAttr*>(node);
376  if (!attribute)
377  {
378  G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead",
379  FatalException, "No attribute found!");
380  return;
381  }
382  const G4String attName = Transcode(attribute->getName());
383  const G4String attValue = Transcode(attribute->getValue());
384 
385  if (attName=="name") { name = GenerateName(attValue); } else
386  if (attName=="x") { scale.setX(eval.Evaluate(attValue)); } else
387  if (attName=="y") { scale.setY(eval.Evaluate(attValue)); } else
388  if (attName=="z") { scale.setZ(eval.Evaluate(attValue)); }
389  }
390 
391  scaleMap[name] = scale;
392 }
const XML_Char * name
Definition: expat.h:151
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68
std::map< G4String, G4ThreeVector > scaleMap
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 395 of file G4GDMLReadDefine.cc.

396 {
397  G4String name = "";
398  G4double value = 0.0;
399 
400  const xercesc::DOMNamedNodeMap* const attributes
401  = variableElement->getAttributes();
402  XMLSize_t attributeCount = attributes->getLength();
403 
404  for (XMLSize_t attribute_index=0;
405  attribute_index<attributeCount; attribute_index++)
406  {
407  xercesc::DOMNode* node = attributes->item(attribute_index);
408 
409  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
410 
411  const xercesc::DOMAttr* const attribute
412  = dynamic_cast<xercesc::DOMAttr*>(node);
413  if (!attribute)
414  {
415  G4Exception("G4GDMLRead::VariableRead()", "InvalidRead",
416  FatalException, "No attribute found!");
417  return;
418  }
419  const G4String attName = Transcode(attribute->getName());
420  const G4String attValue = Transcode(attribute->getValue());
421 
422  if (attName=="name") { name = attValue; } else
423  if (attName=="value") { value = eval.Evaluate(attValue); }
424  }
425 
426  eval.DefineVariable(name,value);
427 }
const XML_Char * name
Definition: expat.h:151
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
void DefineVariable(const G4String &, G4double)
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 504 of file G4GDMLReadDefine.cc.

506 {
507  G4double unit = 1.0;
508 
509  const xercesc::DOMNamedNodeMap* const attributes
510  = vectorElement->getAttributes();
511  XMLSize_t attributeCount = attributes->getLength();
512 
513  for (XMLSize_t attribute_index=0;
514  attribute_index<attributeCount; attribute_index++)
515  {
516  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
517 
518  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
519  { continue; }
520 
521  const xercesc::DOMAttr* const attribute
522  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
523  if (!attribute)
524  {
525  G4Exception("G4GDMLRead::VectorRead()", "InvalidRead",
526  FatalException, "No attribute found!");
527  return;
528  }
529  const G4String attName = Transcode(attribute->getName());
530  const G4String attValue = Transcode(attribute->getValue());
531 
532  if (attName=="unit") { unit = G4UnitDefinition::GetValueOf(attValue); } else
533  if (attName=="x") { vec.setX(eval.Evaluate(attValue)); } else
534  if (attName=="y") { vec.setY(eval.Evaluate(attValue)); } else
535  if (attName=="z") { vec.setZ(eval.Evaluate(attValue)); }
536  }
537 
538  vec *= unit;
539 }
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:155
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void setY(double)
void setZ(double)
void setX(double)
static G4double GetValueOf(const G4String &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4double Evaluate(const G4String &)

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 109 of file G4GDMLReadDefine.hh.

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

Definition at line 106 of file G4GDMLReadDefine.hh.

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

Definition at line 105 of file G4GDMLReadDefine.hh.

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

Definition at line 107 of file G4GDMLReadDefine.hh.

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

Definition at line 108 of file G4GDMLReadDefine.hh.


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