|
Lines 69-74
Link Here
|
| 69 |
#include "G4OpticalSurface.hh" |
69 |
#include "G4OpticalSurface.hh" |
| 70 |
#include "G4UnitsTable.hh" |
70 |
#include "G4UnitsTable.hh" |
| 71 |
#include "G4SurfaceProperty.hh" |
71 |
#include "G4SurfaceProperty.hh" |
|
|
72 |
#include "G4MaterialPropertiesTable.hh" |
| 72 |
|
73 |
|
| 73 |
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials() |
74 |
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials() |
| 74 |
{ |
75 |
{ |
|
Lines 2467-2472
Link Here
|
| 2467 |
} |
2468 |
} |
| 2468 |
|
2469 |
|
| 2469 |
void G4GDMLReadSolids:: |
2470 |
void G4GDMLReadSolids:: |
|
|
2471 |
PropertyRead(const xercesc::DOMElement* const propertyElement, |
| 2472 |
G4OpticalSurface* opticalsurface) |
| 2473 |
{ |
| 2474 |
G4String name; |
| 2475 |
G4String ref; |
| 2476 |
G4GDMLMatrix matrix; |
| 2477 |
|
| 2478 |
const xercesc::DOMNamedNodeMap* const attributes |
| 2479 |
= propertyElement->getAttributes(); |
| 2480 |
XMLSize_t attributeCount = attributes->getLength(); |
| 2481 |
|
| 2482 |
for (XMLSize_t attribute_index=0; |
| 2483 |
attribute_index<attributeCount; attribute_index++) |
| 2484 |
{ |
| 2485 |
xercesc::DOMNode* attribute_node = attributes->item(attribute_index); |
| 2486 |
|
| 2487 |
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) |
| 2488 |
{ continue; } |
| 2489 |
|
| 2490 |
const xercesc::DOMAttr* const attribute |
| 2491 |
= dynamic_cast<xercesc::DOMAttr*>(attribute_node); |
| 2492 |
if (!attribute) |
| 2493 |
{ |
| 2494 |
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead", |
| 2495 |
FatalException, "No attribute found!"); |
| 2496 |
return; |
| 2497 |
} |
| 2498 |
const G4String attName = Transcode(attribute->getName()); |
| 2499 |
const G4String attValue = Transcode(attribute->getValue()); |
| 2500 |
|
| 2501 |
if (attName=="name") { name = GenerateName(attValue); } else |
| 2502 |
if (attName=="ref") { matrix = GetMatrix(ref=attValue); } |
| 2503 |
} |
| 2504 |
|
| 2505 |
/* |
| 2506 |
if (matrix.GetCols() != 2) |
| 2507 |
{ |
| 2508 |
G4String error_msg = "Referenced matrix '" + ref |
| 2509 |
+ "' should have \n two columns as a property table for opticalsurface: " |
| 2510 |
+ opticalsurface->GetName(); |
| 2511 |
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead", |
| 2512 |
FatalException, error_msg); |
| 2513 |
} |
| 2514 |
*/ |
| 2515 |
|
| 2516 |
if (matrix.GetRows() == 0) { return; } |
| 2517 |
|
| 2518 |
G4MaterialPropertiesTable* matprop=opticalsurface->GetMaterialPropertiesTable(); |
| 2519 |
if (!matprop) |
| 2520 |
{ |
| 2521 |
matprop = new G4MaterialPropertiesTable(); |
| 2522 |
opticalsurface->SetMaterialPropertiesTable(matprop); |
| 2523 |
} |
| 2524 |
if (matrix.GetCols() == 1) // constant property assumed |
| 2525 |
{ |
| 2526 |
matprop->AddConstProperty(Strip(name), matrix.Get(0,0)); |
| 2527 |
} |
| 2528 |
else // build the material properties vector |
| 2529 |
{ |
| 2530 |
G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector(); |
| 2531 |
for (size_t i=0; i<matrix.GetRows(); i++) |
| 2532 |
{ |
| 2533 |
propvect->InsertValues(matrix.Get(i,0),matrix.Get(i,1)); |
| 2534 |
} |
| 2535 |
matprop->AddProperty(Strip(name),propvect); |
| 2536 |
} |
| 2537 |
} |
| 2538 |
|
| 2539 |
void G4GDMLReadSolids:: |
| 2470 |
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement) |
2540 |
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement) |
| 2471 |
{ |
2541 |
{ |
| 2472 |
G4String name; |
2542 |
G4String name; |
|
Lines 2586-2592
Link Here
|
| 2586 |
{ type = firsov; } |
2656 |
{ type = firsov; } |
| 2587 |
else { type = x_ray; } |
2657 |
else { type = x_ray; } |
| 2588 |
|
2658 |
|
| 2589 |
new G4OpticalSurface(name,model,finish,type,value); |
2659 |
G4OpticalSurface* opticalsurface |
|
|
2660 |
= new G4OpticalSurface(name,model,finish,type,value); |
| 2661 |
|
| 2662 |
for (xercesc::DOMNode* iter = opticalsurfaceElement->getFirstChild(); |
| 2663 |
iter != 0;iter = iter->getNextSibling()) |
| 2664 |
{ |
| 2665 |
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } |
| 2666 |
|
| 2667 |
const xercesc::DOMElement* const child |
| 2668 |
= dynamic_cast<xercesc::DOMElement*>(iter); |
| 2669 |
if (!child) |
| 2670 |
{ |
| 2671 |
G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()", |
| 2672 |
"InvalidRead", FatalException, "No child found!"); |
| 2673 |
return; |
| 2674 |
} |
| 2675 |
const G4String tag = Transcode(child->getTagName()); |
| 2676 |
|
| 2677 |
if (tag=="property") { PropertyRead(child,opticalsurface); } |
| 2678 |
} |
| 2590 |
} |
2679 |
} |
| 2591 |
|
2680 |
|
| 2592 |
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement) |
2681 |
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement) |