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());
150 const xercesc::DOMNamedNodeMap*
const attributes
151 = constantElement->getAttributes();
152 XMLSize_t attributeCount = attributes->getLength();
154 for (XMLSize_t attribute_index=0;
155 attribute_index<attributeCount; attribute_index++)
157 xercesc::DOMNode* node = attributes->item(attribute_index);
159 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
161 const xercesc::DOMAttr*
const attribute
162 =
dynamic_cast<xercesc::DOMAttr*
>(node);
165 G4Exception(
"G4GDMLRead::ConstantRead()",
"InvalidRead",
172 if (attName==
"name") { name = attValue; }
else
173 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
185 const xercesc::DOMNamedNodeMap*
const attributes
186 = expElement->getAttributes();
187 XMLSize_t attributeCount = attributes->getLength();
189 for (XMLSize_t attribute_index=0;
190 attribute_index<attributeCount; attribute_index++)
192 xercesc::DOMNode* node = attributes->item(attribute_index);
194 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
196 const xercesc::DOMAttr*
const attribute
197 =
dynamic_cast<xercesc::DOMAttr*
>(node);
200 G4Exception(
"G4GDMLRead::ExpressionRead()",
"InvalidRead",
207 if (attName==
"name") { name = attValue; }
222 const xercesc::DOMNamedNodeMap*
const attributes
223 = matrixElement->getAttributes();
224 XMLSize_t attributeCount = attributes->getLength();
226 for (XMLSize_t attribute_index=0;
227 attribute_index<attributeCount; attribute_index++)
229 xercesc::DOMNode* node = attributes->item(attribute_index);
231 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
233 const xercesc::DOMAttr*
const attribute
234 =
dynamic_cast<xercesc::DOMAttr*
>(node);
237 G4Exception(
"G4GDMLRead::MatrixRead()",
"InvalidRead",
244 if (attName==
"name") { name =
GenerateName(attValue); }
else
246 if (attName==
"values") { values = attValue; }
249 std::stringstream MatrixValueStream(values);
250 std::vector<G4double> valueList;
252 while (!MatrixValueStream.eof())
255 MatrixValueStream >> MatrixValue;
263 for (
size_t i=0;i<valueList.size();i++)
265 matrix.
Set(i/coldim,i%coldim,valueList[i]);
278 const xercesc::DOMNamedNodeMap*
const attributes
279 = positionElement->getAttributes();
280 XMLSize_t attributeCount = attributes->getLength();
282 for (XMLSize_t attribute_index=0;
283 attribute_index<attributeCount; attribute_index++)
285 xercesc::DOMNode* node = attributes->item(attribute_index);
287 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
289 const xercesc::DOMAttr*
const attribute
290 =
dynamic_cast<xercesc::DOMAttr*
>(node);
293 G4Exception(
"G4GDMLRead::PositionRead()",
"InvalidRead",
300 if (attName==
"name") { name =
GenerateName(attValue); }
else
302 if (attName==
"x") { position.setX(
eval.
Evaluate(attValue)); }
else
303 if (attName==
"y") { position.setY(
eval.
Evaluate(attValue)); }
else
304 if (attName==
"z") { position.setZ(
eval.
Evaluate(attValue)); }
317 const xercesc::DOMNamedNodeMap*
const attributes
318 = rotationElement->getAttributes();
319 XMLSize_t attributeCount = attributes->getLength();
321 for (XMLSize_t attribute_index=0;
322 attribute_index<attributeCount; attribute_index++)
324 xercesc::DOMNode* node = attributes->item(attribute_index);
326 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
328 const xercesc::DOMAttr*
const attribute
329 =
dynamic_cast<xercesc::DOMAttr*
>(node);
332 G4Exception(
"G4GDMLRead::RotationRead()",
"InvalidRead",
339 if (attName==
"name") { name =
GenerateName(attValue); }
else
341 if (attName==
"x") { rotation.setX(
eval.
Evaluate(attValue)); }
else
342 if (attName==
"y") { rotation.setY(
eval.
Evaluate(attValue)); }
else
343 if (attName==
"z") { rotation.setZ(
eval.
Evaluate(attValue)); }
354 const xercesc::DOMNamedNodeMap*
const attributes
355 = scaleElement->getAttributes();
356 XMLSize_t attributeCount = attributes->getLength();
358 for (XMLSize_t attribute_index=0;
359 attribute_index<attributeCount; attribute_index++)
361 xercesc::DOMNode* node = attributes->item(attribute_index);
363 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
365 const xercesc::DOMAttr*
const attribute
366 =
dynamic_cast<xercesc::DOMAttr*
>(node);
369 G4Exception(
"G4GDMLRead::ScaleRead()",
"InvalidRead",
376 if (attName==
"name") { name =
GenerateName(attValue); }
else
377 if (attName==
"x") { scale.setX(
eval.
Evaluate(attValue)); }
else
378 if (attName==
"y") { scale.setY(
eval.
Evaluate(attValue)); }
else
379 if (attName==
"z") { scale.setZ(
eval.
Evaluate(attValue)); }
391 const xercesc::DOMNamedNodeMap*
const attributes
392 = variableElement->getAttributes();
393 XMLSize_t attributeCount = attributes->getLength();
395 for (XMLSize_t attribute_index=0;
396 attribute_index<attributeCount; attribute_index++)
398 xercesc::DOMNode* node = attributes->item(attribute_index);
400 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
402 const xercesc::DOMAttr*
const attribute
403 =
dynamic_cast<xercesc::DOMAttr*
>(node);
406 G4Exception(
"G4GDMLRead::VariableRead()",
"InvalidRead",
413 if (attName==
"name") { name = attValue; }
else
414 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
426 const xercesc::DOMNamedNodeMap*
const attributes
427 = element->getAttributes();
428 XMLSize_t attributeCount = attributes->getLength();
430 for (XMLSize_t attribute_index=0;
431 attribute_index<attributeCount; attribute_index++)
433 xercesc::DOMNode* node = attributes->item(attribute_index);
435 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) {
continue; }
437 const xercesc::DOMAttr*
const attribute
438 =
dynamic_cast<xercesc::DOMAttr*
>(node);
441 G4Exception(
"G4GDMLRead::QuantityRead()",
"InvalidRead",
448 if (attName==
"name") { name = attValue; }
else
449 if (attName==
"value") { value =
eval.
Evaluate(attValue); }
else
462 for (xercesc::DOMNode* iter = defineElement->getFirstChild();
463 iter != 0;iter = iter->getNextSibling())
465 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
467 const xercesc::DOMElement*
const child
468 =
dynamic_cast<xercesc::DOMElement*
>(iter);
471 G4Exception(
"G4GDMLRead::DefineRead()",
"InvalidRead",
478 if (tag==
"matrix") {
MatrixRead(child); }
else
481 if (tag==
"scale") {
ScaleRead(child); }
else
487 G4String error_msg =
"Unknown tag in define: "+tag;
488 G4Exception(
"G4GDMLReadDefine::defineRead()",
"ReadError",
500 const xercesc::DOMNamedNodeMap*
const attributes
501 = vectorElement->getAttributes();
502 XMLSize_t attributeCount = attributes->getLength();
504 for (XMLSize_t attribute_index=0;
505 attribute_index<attributeCount; attribute_index++)
507 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
509 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
512 const xercesc::DOMAttr*
const attribute
513 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
516 G4Exception(
"G4GDMLRead::VectorRead()",
"InvalidRead",
524 if (attName==
"x") { vec.setX(
eval.
Evaluate(attValue)); }
else
525 if (attName==
"y") { vec.setY(
eval.
Evaluate(attValue)); }
else
526 if (attName==
"z") { vec.setZ(
eval.
Evaluate(attValue)); }
536 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
537 XMLSize_t attributeCount = attributes->getLength();
539 for (XMLSize_t attribute_index=0;
540 attribute_index<attributeCount; attribute_index++)
542 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
544 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
547 const xercesc::DOMAttr*
const attribute
548 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
558 if (attName==
"ref") { ref = attValue; }
583 G4String error_msg =
"Quantity '"+ref+
"' was not found!";
584 G4Exception(
"G4GDMLReadDefine::getQuantity()",
"ReadError",
594 G4String error_msg =
"Position '"+ref+
"' was not found!";
595 G4Exception(
"G4GDMLReadDefine::getPosition()",
"ReadError",
605 G4String error_msg =
"Rotation '"+ref+
"' was not found!";
606 G4Exception(
"G4GDMLReadDefine::getRotation()",
"ReadError",
616 G4String error_msg =
"Scale '"+ref+
"' was not found!";
617 G4Exception(
"G4GDMLReadDefine::getScale()",
"ReadError",
627 G4String error_msg =
"Matrix '"+ref+
"' was not found!";
628 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 &)