44 if((rows0 == 0) || (cols0 == 0))
46 G4Exception(
"G4GDMLMatrix::G4GDMLMatrix(r,c)",
"InvalidSetup",
62 for(std::size_t i = 0; i < rows * cols; ++i)
86 for(std::size_t i = 0; i < rows * cols; ++i)
108 if(r >= rows || c >= cols)
111 "Index out of range!");
119 if(r >= rows || c >= cols)
122 "Index out of range!");
124 return m[cols * r + c];
168 const xercesc::DOMElement*
const constantElement)
173 const xercesc::DOMNamedNodeMap*
const attributes =
174 constantElement->getAttributes();
175 XMLSize_t attributeCount = attributes->getLength();
177 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
180 xercesc::DOMNode* node = attributes->item(attribute_index);
182 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
187 const xercesc::DOMAttr*
const attribute =
188 dynamic_cast<xercesc::DOMAttr*
>(node);
189 if(attribute ==
nullptr)
192 "No attribute found!");
198 if(attName ==
"name")
202 else if(attName ==
"value")
213 const xercesc::DOMElement*
const expElement)
218 const xercesc::DOMNamedNodeMap*
const attributes =
219 expElement->getAttributes();
220 XMLSize_t attributeCount = attributes->getLength();
222 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
225 xercesc::DOMNode* node = attributes->item(attribute_index);
227 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
232 const xercesc::DOMAttr*
const attribute =
233 dynamic_cast<xercesc::DOMAttr*
>(node);
234 if(attribute ==
nullptr)
237 "No attribute found!");
243 if(attName ==
"name")
256 const xercesc::DOMElement*
const matrixElement)
262 const xercesc::DOMNamedNodeMap*
const attributes =
263 matrixElement->getAttributes();
264 XMLSize_t attributeCount = attributes->getLength();
266 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
269 xercesc::DOMNode* node = attributes->item(attribute_index);
271 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
276 const xercesc::DOMAttr*
const attribute =
277 dynamic_cast<xercesc::DOMAttr*
>(node);
278 if(attribute ==
nullptr)
281 "No attribute found!");
287 if(attName ==
"name")
291 else if(attName ==
"coldim")
295 else if(attName ==
"values")
301 std::stringstream MatrixValueStream(values);
302 std::vector<G4double> valueList;
304 while(!MatrixValueStream.eof())
307 MatrixValueStream >> MatrixValue;
315 for(std::size_t i = 0; i < valueList.size(); ++i)
317 matrix.
Set(i / coldim, i % coldim, valueList[i]);
325 const xercesc::DOMElement*
const positionElement)
331 const xercesc::DOMNamedNodeMap*
const attributes =
332 positionElement->getAttributes();
333 XMLSize_t attributeCount = attributes->getLength();
335 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
338 xercesc::DOMNode* node = attributes->item(attribute_index);
340 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
345 const xercesc::DOMAttr*
const attribute =
346 dynamic_cast<xercesc::DOMAttr*
>(node);
347 if(attribute ==
nullptr)
350 "No attribute found!");
356 if(attName ==
"name")
360 else if(attName ==
"unit")
365 G4Exception(
"G4GDMLReadDefine::PositionRead()",
"InvalidRead",
369 else if(attName ==
"x")
373 else if(attName ==
"y")
377 else if(attName ==
"z")
388 const xercesc::DOMElement*
const rotationElement)
394 const xercesc::DOMNamedNodeMap*
const attributes =
395 rotationElement->getAttributes();
396 XMLSize_t attributeCount = attributes->getLength();
398 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
401 xercesc::DOMNode* node = attributes->item(attribute_index);
403 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
408 const xercesc::DOMAttr*
const attribute =
409 dynamic_cast<xercesc::DOMAttr*
>(node);
410 if(attribute ==
nullptr)
413 "No attribute found!");
419 if(attName ==
"name")
423 else if(attName ==
"unit")
428 G4Exception(
"G4GDMLReadDefine::RotationRead()",
"InvalidRead",
432 else if(attName ==
"x")
436 else if(attName ==
"y")
440 else if(attName ==
"z")
455 const xercesc::DOMNamedNodeMap*
const attributes =
456 scaleElement->getAttributes();
457 XMLSize_t attributeCount = attributes->getLength();
459 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
462 xercesc::DOMNode* node = attributes->item(attribute_index);
464 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
469 const xercesc::DOMAttr*
const attribute =
470 dynamic_cast<xercesc::DOMAttr*
>(node);
471 if(attribute ==
nullptr)
474 "No attribute found!");
480 if(attName ==
"name")
484 else if(attName ==
"x")
488 else if(attName ==
"y")
492 else if(attName ==
"z")
503 const xercesc::DOMElement*
const variableElement)
508 const xercesc::DOMNamedNodeMap*
const attributes =
509 variableElement->getAttributes();
510 XMLSize_t attributeCount = attributes->getLength();
512 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
515 xercesc::DOMNode* node = attributes->item(attribute_index);
517 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
522 const xercesc::DOMAttr*
const attribute =
523 dynamic_cast<xercesc::DOMAttr*
>(node);
524 if(attribute ==
nullptr)
527 "No attribute found!");
533 if(attName ==
"name")
537 else if(attName ==
"value")
553 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
554 XMLSize_t attributeCount = attributes->getLength();
556 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
559 xercesc::DOMNode* node = attributes->item(attribute_index);
561 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
566 const xercesc::DOMAttr*
const attribute =
567 dynamic_cast<xercesc::DOMAttr*
>(node);
568 if(attribute ==
nullptr)
571 "No attribute found!");
577 if(attName ==
"name")
581 else if(attName ==
"value")
585 else if(attName ==
"unit")
597 const xercesc::DOMElement*
const defineElement)
602 for(xercesc::DOMNode* iter = defineElement->getFirstChild(); iter !=
nullptr;
603 iter = iter->getNextSibling())
605 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
610 const xercesc::DOMElement*
const child =
611 dynamic_cast<xercesc::DOMElement*
>(iter);
620 if(
tag ==
"constant")
624 else if(
tag ==
"matrix")
628 else if(
tag ==
"position")
632 else if(
tag ==
"rotation")
636 else if(
tag ==
"scale")
640 else if(
tag ==
"variable")
644 else if(
tag ==
"quantity")
648 else if(
tag ==
"expression")
654 G4String error_msg =
"Unknown tag in define: " +
tag;
663 const xercesc::DOMElement*
const vectorElement,
G4ThreeVector& vec)
667 const xercesc::DOMNamedNodeMap*
const attributes =
668 vectorElement->getAttributes();
669 XMLSize_t attributeCount = attributes->getLength();
671 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
674 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
676 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
681 const xercesc::DOMAttr*
const attribute =
682 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
683 if(attribute ==
nullptr)
686 "No attribute found!");
692 if(attName ==
"unit")
696 else if(attName ==
"x")
700 else if(attName ==
"y")
704 else if(attName ==
"z")
718 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
719 XMLSize_t attributeCount = attributes->getLength();
721 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
724 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
726 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
731 const xercesc::DOMAttr*
const attribute =
732 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
733 if(attribute ==
nullptr)
736 "No attribute found!");
774 G4String error_msg =
"Quantity '" + ref +
"' was not found!";
786 G4String error_msg =
"Position '" + ref +
"' was not found!";
798 G4String error_msg =
"Rotation '" + ref +
"' was not found!";
810 G4String error_msg =
"Scale '" + ref +
"' was not found!";
822 G4String error_msg =
"Matrix '" + ref +
"' was not found!";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
HepRotation & rotateX(double delta)
HepRotation & rotateZ(double delta)
HepRotation & rotateY(double delta)
G4double Evaluate(const G4String &)
void DefineVariable(const G4String &, G4double)
void DefineConstant(const G4String &, G4double)
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
G4double GetVariable(const G4String &)
G4bool IsVariable(const G4String &) const
G4int EvaluateInteger(const G4String &)
G4double GetConstant(const G4String &)
void Set(std::size_t r, std::size_t c, G4double a)
std::size_t GetCols() const
G4GDMLMatrix & operator=(const G4GDMLMatrix &rhs)
std::size_t GetRows() const
G4double Get(std::size_t r, std::size_t c) const
void ExpressionRead(const xercesc::DOMElement *const)
void VariableRead(const xercesc::DOMElement *const)
std::map< G4String, G4ThreeVector > positionMap
void QuantityRead(const xercesc::DOMElement *const)
std::map< G4String, G4ThreeVector > rotationMap
G4ThreeVector GetScale(const G4String &)
G4bool IsValidID(const G4String &) const
G4double GetQuantity(const G4String &)
G4double GetConstant(const G4String &)
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
void PositionRead(const xercesc::DOMElement *const)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
void MatrixRead(const xercesc::DOMElement *const)
void RotationRead(const xercesc::DOMElement *const)
G4double GetVariable(const G4String &)
G4ThreeVector GetPosition(const G4String &)
std::map< G4String, G4GDMLMatrix > matrixMap
std::map< G4String, G4ThreeVector > scaleMap
G4GDMLMatrix GetMatrix(const G4String &)
G4String RefRead(const xercesc::DOMElement *const)
virtual ~G4GDMLReadDefine()
std::map< G4String, G4double > quantityMap
void ScaleRead(const xercesc::DOMElement *const)
G4ThreeVector GetRotation(const G4String &)
virtual void DefineRead(const xercesc::DOMElement *const)
void ConstantRead(const xercesc::DOMElement *const)
G4String GenerateName(const G4String &name, G4bool strip=false)
G4String Transcode(const XMLCh *const)
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)