38 :
m(0), rows(0), cols(0)
44 if ((rows0==0) || (cols0==0))
46 G4Exception(
"G4GDMLMatrix::G4GDMLMatrix(r,c)",
"InvalidSetup",
55 :
m(0), rows(0), cols(0)
62 for (
size_t i=0; i<rows*cols; i++) { m[i] = rhs.m[i]; }
70 if (
this == &rhs) {
return *
this; }
79 for (
size_t i=0; i<rows*cols; i++) { m[i] = rhs.m[i]; }
96 if (r>=rows || c>=cols)
106 if (r>=rows || c>=cols)
151 const xercesc::DOMNamedNodeMap*
const attributes
152 = constantElement->getAttributes();
153 XMLSize_t attributeCount = attributes->getLength();
155 for (XMLSize_t attribute_index=0;
156 attribute_index<attributeCount; attribute_index++)
158 xercesc::DOMNode* node = attributes->item(attribute_index);
160 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
162 const xercesc::DOMAttr*
const attribute
163 =
dynamic_cast<xercesc::DOMAttr*
>(node);
166 G4Exception(
"G4GDMLRead::ConstantRead()",
"InvalidRead",
173 if (attName==
"name") { name = attValue; }
else
174 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
186 const xercesc::DOMNamedNodeMap*
const attributes
187 = expElement->getAttributes();
188 XMLSize_t attributeCount = attributes->getLength();
190 for (XMLSize_t attribute_index=0;
191 attribute_index<attributeCount; attribute_index++)
193 xercesc::DOMNode* node = attributes->item(attribute_index);
195 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
197 const xercesc::DOMAttr*
const attribute
198 =
dynamic_cast<xercesc::DOMAttr*
>(node);
201 G4Exception(
"G4GDMLRead::ExpressionRead()",
"InvalidRead",
208 if (attName==
"name") { name = attValue; }
223 const xercesc::DOMNamedNodeMap*
const attributes
224 = matrixElement->getAttributes();
225 XMLSize_t attributeCount = attributes->getLength();
227 for (XMLSize_t attribute_index=0;
228 attribute_index<attributeCount; attribute_index++)
230 xercesc::DOMNode* node = attributes->item(attribute_index);
232 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
234 const xercesc::DOMAttr*
const attribute
235 =
dynamic_cast<xercesc::DOMAttr*
>(node);
238 G4Exception(
"G4GDMLRead::MatrixRead()",
"InvalidRead",
245 if (attName==
"name") { name =
GenerateName(attValue); }
else
247 if (attName==
"values") { values = attValue; }
250 std::stringstream MatrixValueStream(values);
251 std::vector<G4double> valueList;
253 while (!MatrixValueStream.eof())
256 MatrixValueStream >> MatrixValue;
264 for (
size_t i=0;i<valueList.size();i++)
266 matrix.
Set(i/coldim,i%coldim,valueList[i]);
279 const xercesc::DOMNamedNodeMap*
const attributes
280 = positionElement->getAttributes();
281 XMLSize_t attributeCount = attributes->getLength();
283 for (XMLSize_t attribute_index=0;
284 attribute_index<attributeCount; attribute_index++)
286 xercesc::DOMNode* node = attributes->item(attribute_index);
288 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
290 const xercesc::DOMAttr*
const attribute
291 =
dynamic_cast<xercesc::DOMAttr*
>(node);
294 G4Exception(
"G4GDMLRead::PositionRead()",
"InvalidRead",
301 if (attName==
"name") { name =
GenerateName(attValue); }
else
304 G4Exception(
"G4GDMLReadDefine::PositionRead()",
"InvalidRead",
322 const xercesc::DOMNamedNodeMap*
const attributes
323 = rotationElement->getAttributes();
324 XMLSize_t attributeCount = attributes->getLength();
326 for (XMLSize_t attribute_index=0;
327 attribute_index<attributeCount; attribute_index++)
329 xercesc::DOMNode* node = attributes->item(attribute_index);
331 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
333 const xercesc::DOMAttr*
const attribute
334 =
dynamic_cast<xercesc::DOMAttr*
>(node);
337 G4Exception(
"G4GDMLRead::RotationRead()",
"InvalidRead",
344 if (attName==
"name") { name =
GenerateName(attValue); }
else
347 G4Exception(
"G4GDMLReadDefine::RotationRead()",
"InvalidRead",
363 const xercesc::DOMNamedNodeMap*
const attributes
364 = scaleElement->getAttributes();
365 XMLSize_t attributeCount = attributes->getLength();
367 for (XMLSize_t attribute_index=0;
368 attribute_index<attributeCount; attribute_index++)
370 xercesc::DOMNode* node = attributes->item(attribute_index);
372 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
374 const xercesc::DOMAttr*
const attribute
375 =
dynamic_cast<xercesc::DOMAttr*
>(node);
378 G4Exception(
"G4GDMLRead::ScaleRead()",
"InvalidRead",
385 if (attName==
"name") { name =
GenerateName(attValue); }
else
400 const xercesc::DOMNamedNodeMap*
const attributes
401 = variableElement->getAttributes();
402 XMLSize_t attributeCount = attributes->getLength();
404 for (XMLSize_t attribute_index=0;
405 attribute_index<attributeCount; attribute_index++)
407 xercesc::DOMNode* node = attributes->item(attribute_index);
409 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
411 const xercesc::DOMAttr*
const attribute
412 =
dynamic_cast<xercesc::DOMAttr*
>(node);
415 G4Exception(
"G4GDMLRead::VariableRead()",
"InvalidRead",
422 if (attName==
"name") { name = attValue; }
else
423 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
435 const xercesc::DOMNamedNodeMap*
const attributes
436 = element->getAttributes();
437 XMLSize_t attributeCount = attributes->getLength();
439 for (XMLSize_t attribute_index=0;
440 attribute_index<attributeCount; attribute_index++)
442 xercesc::DOMNode* node = attributes->item(attribute_index);
444 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
446 const xercesc::DOMAttr*
const attribute
447 =
dynamic_cast<xercesc::DOMAttr*
>(node);
450 G4Exception(
"G4GDMLRead::QuantityRead()",
"InvalidRead",
457 if (attName==
"name") { name = attValue; }
else
458 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
471 for (xercesc::DOMNode* iter = defineElement->getFirstChild();
472 iter != 0;iter = iter->getNextSibling())
474 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
476 const xercesc::DOMElement*
const child
477 =
dynamic_cast<xercesc::DOMElement*
>(iter);
480 G4Exception(
"G4GDMLRead::DefineRead()",
"InvalidRead",
487 if (tag==
"matrix") {
MatrixRead(child); }
else
490 if (tag==
"scale") {
ScaleRead(child); }
else
496 G4String error_msg =
"Unknown tag in define: "+tag;
497 G4Exception(
"G4GDMLReadDefine::defineRead()",
"ReadError",
509 const xercesc::DOMNamedNodeMap*
const attributes
510 = vectorElement->getAttributes();
511 XMLSize_t attributeCount = attributes->getLength();
513 for (XMLSize_t attribute_index=0;
514 attribute_index<attributeCount; attribute_index++)
516 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
518 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
521 const xercesc::DOMAttr*
const attribute
522 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
525 G4Exception(
"G4GDMLRead::VectorRead()",
"InvalidRead",
545 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
546 XMLSize_t attributeCount = attributes->getLength();
548 for (XMLSize_t attribute_index=0;
549 attribute_index<attributeCount; attribute_index++)
551 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
553 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
556 const xercesc::DOMAttr*
const attribute
557 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
567 if (attName==
"ref") { ref = attValue; }
592 G4String error_msg =
"Quantity '"+ref+
"' was not found!";
593 G4Exception(
"G4GDMLReadDefine::getQuantity()",
"ReadError",
603 G4String error_msg =
"Position '"+ref+
"' was not found!";
604 G4Exception(
"G4GDMLReadDefine::getPosition()",
"ReadError",
614 G4String error_msg =
"Rotation '"+ref+
"' was not found!";
615 G4Exception(
"G4GDMLReadDefine::getRotation()",
"ReadError",
625 G4String error_msg =
"Scale '"+ref+
"' was not found!";
626 G4Exception(
"G4GDMLReadDefine::getScale()",
"ReadError",
636 G4String error_msg =
"Matrix '"+ref+
"' was not found!";
637 G4Exception(
"G4GDMLReadDefine::getMatrix()",
"ReadError",
G4int EvaluateInteger(const G4String &)
G4double GetQuantity(const G4String &)
std::map< G4String, G4ThreeVector > rotationMap
void PositionRead(const xercesc::DOMElement *const)
G4double GetConstant(const G4String &)
HepRotation & rotateX(double delta)
void DefineConstant(const G4String &, G4double)
virtual void DefineRead(const xercesc::DOMElement *const)
G4String Transcode(const XMLCh *const)
G4ThreeVector GetScale(const G4String &)
HepRotation & rotateY(double delta)
G4double Get(size_t r, size_t c) const
void ConstantRead(const xercesc::DOMElement *const)
void ExpressionRead(const xercesc::DOMElement *const)
G4String RefRead(const xercesc::DOMElement *const)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
void MatrixRead(const xercesc::DOMElement *const)
const XML_Char int const XML_Char * value
G4bool IsValidID(const G4String &) const
void RotationRead(const xercesc::DOMElement *const)
std::map< G4String, G4ThreeVector > positionMap
std::map< G4String, G4GDMLMatrix > matrixMap
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
G4bool IsVariable(const G4String &) const
G4double GetConstant(const G4String &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4String GetCategory(const G4String &)
void VariableRead(const xercesc::DOMElement *const)
G4String GenerateName(const G4String &name, G4bool strip=false)
virtual ~G4GDMLReadDefine()
std::map< G4String, G4ThreeVector > scaleMap
G4GDMLMatrix & operator=(const G4GDMLMatrix &rhs)
void QuantityRead(const xercesc::DOMElement *const)
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
HepRotation & rotateZ(double delta)
void ScaleRead(const xercesc::DOMElement *const)
G4ThreeVector GetRotation(const G4String &)
G4double GetVariable(const G4String &)
void Set(size_t r, size_t c, G4double a)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
void DefineVariable(const G4String &, G4double)
std::map< G4String, G4double > quantityMap
G4double Evaluate(const G4String &)
G4GDMLMatrix GetMatrix(const G4String &)
G4double GetVariable(const G4String &)
G4ThreeVector GetPosition(const G4String &)