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]; }
137 rot.rotateX(angles.x());
138 rot.rotateY(angles.y());
139 rot.rotateZ(angles.z());
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
303 if (attName==
"x") { position.setX(
eval.
Evaluate(attValue)); }
else
304 if (attName==
"y") { position.setY(
eval.
Evaluate(attValue)); }
else
305 if (attName==
"z") { position.setZ(
eval.
Evaluate(attValue)); }
318 const xercesc::DOMNamedNodeMap*
const attributes
319 = rotationElement->getAttributes();
320 XMLSize_t attributeCount = attributes->getLength();
322 for (XMLSize_t attribute_index=0;
323 attribute_index<attributeCount; attribute_index++)
325 xercesc::DOMNode* node = attributes->item(attribute_index);
327 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
329 const xercesc::DOMAttr*
const attribute
330 =
dynamic_cast<xercesc::DOMAttr*
>(node);
333 G4Exception(
"G4GDMLRead::RotationRead()",
"InvalidRead",
340 if (attName==
"name") { name =
GenerateName(attValue); }
else
342 if (attName==
"x") { rotation.setX(
eval.
Evaluate(attValue)); }
else
343 if (attName==
"y") { rotation.setY(
eval.
Evaluate(attValue)); }
else
344 if (attName==
"z") { rotation.setZ(
eval.
Evaluate(attValue)); }
355 const xercesc::DOMNamedNodeMap*
const attributes
356 = scaleElement->getAttributes();
357 XMLSize_t attributeCount = attributes->getLength();
359 for (XMLSize_t attribute_index=0;
360 attribute_index<attributeCount; attribute_index++)
362 xercesc::DOMNode* node = attributes->item(attribute_index);
364 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
366 const xercesc::DOMAttr*
const attribute
367 =
dynamic_cast<xercesc::DOMAttr*
>(node);
370 G4Exception(
"G4GDMLRead::ScaleRead()",
"InvalidRead",
377 if (attName==
"name") { name =
GenerateName(attValue); }
else
378 if (attName==
"x") { scale.setX(
eval.
Evaluate(attValue)); }
else
379 if (attName==
"y") { scale.setY(
eval.
Evaluate(attValue)); }
else
380 if (attName==
"z") { scale.setZ(
eval.
Evaluate(attValue)); }
392 const xercesc::DOMNamedNodeMap*
const attributes
393 = variableElement->getAttributes();
394 XMLSize_t attributeCount = attributes->getLength();
396 for (XMLSize_t attribute_index=0;
397 attribute_index<attributeCount; attribute_index++)
399 xercesc::DOMNode* node = attributes->item(attribute_index);
401 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
403 const xercesc::DOMAttr*
const attribute
404 =
dynamic_cast<xercesc::DOMAttr*
>(node);
407 G4Exception(
"G4GDMLRead::VariableRead()",
"InvalidRead",
414 if (attName==
"name") { name = attValue; }
else
415 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
427 const xercesc::DOMNamedNodeMap*
const attributes
428 = element->getAttributes();
429 XMLSize_t attributeCount = attributes->getLength();
431 for (XMLSize_t attribute_index=0;
432 attribute_index<attributeCount; attribute_index++)
434 xercesc::DOMNode* node = attributes->item(attribute_index);
436 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
438 const xercesc::DOMAttr*
const attribute
439 =
dynamic_cast<xercesc::DOMAttr*
>(node);
442 G4Exception(
"G4GDMLRead::QuantityRead()",
"InvalidRead",
449 if (attName==
"name") { name = attValue; }
else
450 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
463 for (xercesc::DOMNode* iter = defineElement->getFirstChild();
464 iter != 0;iter = iter->getNextSibling())
466 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
468 const xercesc::DOMElement*
const child
469 =
dynamic_cast<xercesc::DOMElement*
>(iter);
472 G4Exception(
"G4GDMLRead::DefineRead()",
"InvalidRead",
479 if (tag==
"matrix") {
MatrixRead(child); }
else
482 if (tag==
"scale") {
ScaleRead(child); }
else
488 G4String error_msg =
"Unknown tag in define: "+tag;
489 G4Exception(
"G4GDMLReadDefine::defineRead()",
"ReadError",
501 const xercesc::DOMNamedNodeMap*
const attributes
502 = vectorElement->getAttributes();
503 XMLSize_t attributeCount = attributes->getLength();
505 for (XMLSize_t attribute_index=0;
506 attribute_index<attributeCount; attribute_index++)
508 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
510 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
513 const xercesc::DOMAttr*
const attribute
514 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
517 G4Exception(
"G4GDMLRead::VectorRead()",
"InvalidRead",
525 if (attName==
"x") { vec.setX(
eval.
Evaluate(attValue)); }
else
526 if (attName==
"y") { vec.setY(
eval.
Evaluate(attValue)); }
else
527 if (attName==
"z") { vec.setZ(
eval.
Evaluate(attValue)); }
537 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
538 XMLSize_t attributeCount = attributes->getLength();
540 for (XMLSize_t attribute_index=0;
541 attribute_index<attributeCount; attribute_index++)
543 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
545 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
548 const xercesc::DOMAttr*
const attribute
549 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
559 if (attName==
"ref") { ref = attValue; }
584 G4String error_msg =
"Quantity '"+ref+
"' was not found!";
585 G4Exception(
"G4GDMLReadDefine::getQuantity()",
"ReadError",
595 G4String error_msg =
"Position '"+ref+
"' was not found!";
596 G4Exception(
"G4GDMLReadDefine::getPosition()",
"ReadError",
606 G4String error_msg =
"Rotation '"+ref+
"' was not found!";
607 G4Exception(
"G4GDMLReadDefine::getRotation()",
"ReadError",
617 G4String error_msg =
"Scale '"+ref+
"' was not found!";
618 G4Exception(
"G4GDMLReadDefine::getScale()",
"ReadError",
628 G4String error_msg =
"Matrix '"+ref+
"' was not found!";
629 G4Exception(
"G4GDMLReadDefine::getMatrix()",
"ReadError",
G4int EvaluateInteger(const G4String &)
G4double GetQuantity(const G4String &)
std::map< G4String, G4ThreeVector > rotationMap
void PositionRead(const xercesc::DOMElement *const)
CLHEP::Hep3Vector G4ThreeVector
G4double GetConstant(const G4String &)
CLHEP::HepRotation G4RotationMatrix
void DefineConstant(const G4String &, G4double)
virtual void DefineRead(const xercesc::DOMElement *const)
G4String Transcode(const XMLCh *const)
G4ThreeVector GetScale(const G4String &)
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
void MatrixRead(const xercesc::DOMElement *const)
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)
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 &)
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 &)