Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4GDMLReadStructure.cc,v 1.62 2009/09/24 15:04:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4GDMLReadStructure.cc,v 1.67 2010/11/02 10:39:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// class G4GDMLReadStructure Implementation
//
@@ -46,7 +46,8 @@
#include "G4LogicalSkinSurface.hh"
#include "G4VisAttributes.hh"
G4GDMLReadStructure::G4GDMLReadStructure() : G4GDMLReadParamvol()
G4GDMLReadStructure::G4GDMLReadStructure()
: G4GDMLReadParamvol(), pMotherLogical(0)
{
}
@@ -57,7 +58,7 @@ G4GDMLReadStructure::~G4GDMLReadStructure()
G4GDMLAuxPairType G4GDMLReadStructure::
AuxiliaryRead(const xercesc::DOMElement* const auxiliaryElement)
{
G4GDMLAuxPairType auxpair;
G4GDMLAuxPairType auxpair = {"",""};
const xercesc::DOMNamedNodeMap* const attributes
= auxiliaryElement->getAttributes();
@@ -73,11 +74,18 @@ AuxiliaryRead(const xercesc::DOMElement* const auxiliaryElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::AuxiliaryRead()",
"InvalidRead", FatalException, "No attribute found!");
return auxpair;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="auxtype") { auxpair.type = attValue; } else
if (attName=="auxvalue") { auxpair.value = eval.Evaluate(attValue); }
// if (attName=="auxvalue") { auxpair.value = eval.Evaluate(attValue); }
if (attName=="auxvalue") { auxpair.value = attValue; }
}
return auxpair;
@@ -106,6 +114,12 @@ BorderSurfaceRead(const xercesc::DOMElement* const bordersurfaceElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::BorderSurfaceRead()",
"InvalidRead", FatalException, "No attribute found!");
return;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -122,6 +136,12 @@ BorderSurfaceRead(const xercesc::DOMElement* const bordersurfaceElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::BorderSurfaceRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag != "physvolref") { continue; }
@@ -161,6 +181,12 @@ DivisionvolRead(const xercesc::DOMElement* const divisionvolElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead", FatalException, "No attribute found!");
return;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -189,11 +215,19 @@ DivisionvolRead(const xercesc::DOMElement* const divisionvolElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref") { logvol = GetVolume(GenerateName(RefRead(child))); }
}
if (!logvol) { return; }
G4PVDivisionFactory::GetInstance();
G4PhysicalVolumesPair pair;
@@ -238,6 +272,12 @@ FileRead(const xercesc::DOMElement* const fileElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::FileRead()",
"InvalidRead", FatalException, "No attribute found!");
return 0;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -298,6 +338,12 @@ PhysvolRead(const xercesc::DOMElement* const physvolElement,
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::PhysvolRead()",
"InvalidRead", FatalException, "No attribute found!");
return;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -311,6 +357,12 @@ PhysvolRead(const xercesc::DOMElement* const physvolElement,
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::PhysvolRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref")
@@ -338,6 +390,7 @@ PhysvolRead(const xercesc::DOMElement* const physvolElement,
G4String error_msg = "Unknown tag in physvol: " + tag;
G4Exception("G4GDMLReadStructure::PhysvolRead()", "ReadError",
FatalException, error_msg);
return;
}
}
@@ -346,6 +399,7 @@ PhysvolRead(const xercesc::DOMElement* const physvolElement,
if (pAssembly) // Fill assembly structure
{
if (!logvol) { return; }
pAssembly->AddPlacedVolume(logvol, transform);
}
else // Generate physical volume tree or do assembly imprint
@@ -356,6 +410,7 @@ PhysvolRead(const xercesc::DOMElement* const physvolElement,
}
else
{
if (!logvol) { return; }
G4String pv_name = logvol->GetName() + "_PV";
G4PhysicalVolumesPair pair = G4ReflectionFactory::Instance()
->Place(transform,pv_name,logvol,pMotherLogical,false,0,check);
@@ -377,6 +432,12 @@ ReplicavolRead(const xercesc::DOMElement* const replicavolElement, G4int number)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::ReplicavolRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref")
@@ -385,7 +446,7 @@ ReplicavolRead(const xercesc::DOMElement* const replicavolElement, G4int number)
}
else if (tag=="replicate_along_axis")
{
ReplicaRead(child,logvol,number);
if (logvol) { ReplicaRead(child,logvol,number); }
}
else
{
@@ -414,6 +475,12 @@ ReplicaRead(const xercesc::DOMElement* const replicaElement,
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::ReplicaRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="position")
@@ -450,7 +517,6 @@ ReplicaRead(const xercesc::DOMElement* const replicaElement,
EAxis G4GDMLReadStructure::
AxisRead(const xercesc::DOMElement* const axisElement)
{
EAxis axis = kUndefined;
const xercesc::DOMNamedNodeMap* const attributes
@@ -467,6 +533,12 @@ AxisRead(const xercesc::DOMElement* const axisElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::AxisRead()",
"InvalidRead", FatalException, "No attribute found!");
return axis;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="x")
@@ -502,6 +574,12 @@ QuantityRead(const xercesc::DOMElement* const readElement)
{ continue; }
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::QuantityRead()",
"InvalidRead", FatalException, "No attribute found!");
return value;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -530,6 +608,12 @@ VolumeRead(const xercesc::DOMElement* const volumeElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::VolumeRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="auxiliary")
@@ -564,6 +648,12 @@ AssemblyRead(const xercesc::DOMElement* const assemblyElement)
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::AssemblyRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="physvol")
@@ -599,6 +689,12 @@ SkinSurfaceRead(const xercesc::DOMElement* const skinsurfaceElement)
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::SkinsurfaceRead()",
"InvalidRead", FatalException, "No attribute found!");
return;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
@@ -615,6 +711,12 @@ SkinSurfaceRead(const xercesc::DOMElement* const skinsurfaceElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::SkinsurfaceRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="volumeref")
@@ -642,6 +744,12 @@ Volume_contentRead(const xercesc::DOMElement* const volumeElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::Volume_contentRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if ((tag=="auxiliary") || (tag=="materialref") || (tag=="solidref"))
@@ -673,6 +781,12 @@ Volume_contentRead(const xercesc::DOMElement* const volumeElement)
}
const xercesc::DOMAttr* const attribute
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
if (!attribute)
{
G4Exception("G4GDMLReadStructure::Volume_contentRead()",
"InvalidRead", FatalException, "No attribute found!");
return;
}
const G4String attName = Transcode(attribute->getName());
const G4String attValue = Transcode(attribute->getValue());
if (attName=="number")
@@ -710,6 +824,12 @@ StructureRead(const xercesc::DOMElement* const structureElement)
const xercesc::DOMElement* const child
= dynamic_cast<xercesc::DOMElement*>(iter);
if (!child)
{
G4Exception("G4GDMLReadStructure::StructureRead()",
"InvalidRead", FatalException, "No child found!");
return;
}
const G4String tag = Transcode(child->getTagName());
if (tag=="bordersurface") { BorderSurfaceRead(child); } else
@@ -767,7 +887,7 @@ GetAssembly(const G4String& ref) const
}
G4GDMLAuxListType G4GDMLReadStructure::
GetVolumeAuxiliaryInformation(const G4LogicalVolume* const logvol)
GetVolumeAuxiliaryInformation(G4LogicalVolume* logvol) const
{
G4GDMLAuxMapType::const_iterator pos = auxMap.find(logvol);
if (pos != auxMap.end()) { return pos->second; }
@@ -785,7 +905,24 @@ GetWorldVolume(const G4String& setupName)
{
G4LogicalVolume* volume = GetVolume(Strip(GetSetup(setupName)));
volume->SetVisAttributes(G4VisAttributes::Invisible);
G4VPhysicalVolume* pvWorld =
new G4PVPlacement(0,G4ThreeVector(0,0,0),volume,setupName,0,0,0);
G4VPhysicalVolume* pvWorld = 0;
if(setuptoPV[setupName])
{
pvWorld = setuptoPV[setupName];
}
else
{
pvWorld = new G4PVPlacement(0,G4ThreeVector(0,0,0),volume,
volume->GetName()+"_PV",0,0,0);
setuptoPV[setupName] = pvWorld;
}
return pvWorld;
}
void G4GDMLReadStructure::Clear()
{
eval.Clear();
setuptoPV.clear();
}