Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4GDMLReadSolids.cc 96190 2016-03-29 08:07:36Z gcosmo $
|
||||
// $Id: G4GDMLReadSolids.cc 103463 2017-04-11 07:22:55Z gcosmo $
|
||||
//
|
||||
// class G4GDMLReadSolids Implementation
|
||||
//
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "G4OpticalSurface.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SurfaceProperty.hh"
|
||||
#include "G4MaterialPropertiesTable.hh"
|
||||
|
||||
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
|
||||
{
|
||||
@@ -574,17 +575,6 @@ void G4GDMLReadSolids::HypeRead(const xercesc::DOMElement* const hypeElement)
|
||||
new G4Hype(name,rmin,rmax,inst,outst,z);
|
||||
}
|
||||
|
||||
#if !defined(G4GEOM_USE_USOLIDS)
|
||||
void G4GDMLReadSolids::
|
||||
MultiUnionNodeRead(const xercesc::DOMElement* const,
|
||||
G4MultiUnion* const)
|
||||
{
|
||||
G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Installation with USolids primitives required!");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
void G4GDMLReadSolids::
|
||||
MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
|
||||
G4MultiUnion* const multiUnionSolid)
|
||||
@@ -653,18 +643,7 @@ MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
|
||||
G4Transform3D transform(GetRotationMatrix(rotation),position);
|
||||
multiUnionSolid->AddNode(*solidNode, transform);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(G4GEOM_USE_USOLIDS)
|
||||
void G4GDMLReadSolids::
|
||||
MultiUnionRead(const xercesc::DOMElement* const)
|
||||
{
|
||||
G4Exception("G4GDMLReadSolids::MultiUnionRead()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Installation with USolids primitives required!");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
void G4GDMLReadSolids::
|
||||
MultiUnionRead(const xercesc::DOMElement* const unionElement)
|
||||
{
|
||||
@@ -723,7 +702,6 @@ MultiUnionRead(const xercesc::DOMElement* const unionElement)
|
||||
}
|
||||
multiUnion->Voxelize();
|
||||
}
|
||||
#endif
|
||||
|
||||
void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement)
|
||||
{
|
||||
@@ -2466,6 +2444,75 @@ RZPointRead(const xercesc::DOMElement* const zplaneElement)
|
||||
|
||||
}
|
||||
|
||||
void G4GDMLReadSolids::
|
||||
PropertyRead(const xercesc::DOMElement* const propertyElement,
|
||||
G4OpticalSurface* opticalsurface)
|
||||
{
|
||||
G4String name;
|
||||
G4String ref;
|
||||
G4GDMLMatrix matrix;
|
||||
|
||||
const xercesc::DOMNamedNodeMap* const attributes
|
||||
= propertyElement->getAttributes();
|
||||
XMLSize_t attributeCount = attributes->getLength();
|
||||
|
||||
for (XMLSize_t attribute_index=0;
|
||||
attribute_index<attributeCount; attribute_index++)
|
||||
{
|
||||
xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
|
||||
|
||||
if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
|
||||
{ continue; }
|
||||
|
||||
const xercesc::DOMAttr* const attribute
|
||||
= dynamic_cast<xercesc::DOMAttr*>(attribute_node);
|
||||
if (!attribute)
|
||||
{
|
||||
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
|
||||
FatalException, "No attribute found!");
|
||||
return;
|
||||
}
|
||||
const G4String attName = Transcode(attribute->getName());
|
||||
const G4String attValue = Transcode(attribute->getValue());
|
||||
|
||||
if (attName=="name") { name = GenerateName(attValue); } else
|
||||
if (attName=="ref") { matrix = GetMatrix(ref=attValue); }
|
||||
}
|
||||
|
||||
/*
|
||||
if (matrix.GetCols() != 2)
|
||||
{
|
||||
G4String error_msg = "Referenced matrix '" + ref
|
||||
+ "' should have \n two columns as a property table for opticalsurface: "
|
||||
+ opticalsurface->GetName();
|
||||
G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
|
||||
FatalException, error_msg);
|
||||
}
|
||||
*/
|
||||
|
||||
if (matrix.GetRows() == 0) { return; }
|
||||
|
||||
G4MaterialPropertiesTable* matprop=opticalsurface->GetMaterialPropertiesTable();
|
||||
if (!matprop)
|
||||
{
|
||||
matprop = new G4MaterialPropertiesTable();
|
||||
opticalsurface->SetMaterialPropertiesTable(matprop);
|
||||
}
|
||||
if (matrix.GetCols() == 1) // constant property assumed
|
||||
{
|
||||
matprop->AddConstProperty(Strip(name), matrix.Get(0,0));
|
||||
}
|
||||
else // build the material properties vector
|
||||
{
|
||||
G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector();
|
||||
for (size_t i=0; i<matrix.GetRows(); i++)
|
||||
{
|
||||
propvect->InsertValues(matrix.Get(i,0),matrix.Get(i,1));
|
||||
}
|
||||
matprop->AddProperty(Strip(name),propvect);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLReadSolids::
|
||||
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
|
||||
{
|
||||
@@ -2586,7 +2633,26 @@ OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
|
||||
{ type = firsov; }
|
||||
else { type = x_ray; }
|
||||
|
||||
new G4OpticalSurface(name,model,finish,type,value);
|
||||
G4OpticalSurface* opticalsurface
|
||||
= new G4OpticalSurface(name,model,finish,type,value);
|
||||
|
||||
for (xercesc::DOMNode* iter = opticalsurfaceElement->getFirstChild();
|
||||
iter != 0;iter = iter->getNextSibling())
|
||||
{
|
||||
if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
|
||||
|
||||
const xercesc::DOMElement* const child
|
||||
= dynamic_cast<xercesc::DOMElement*>(iter);
|
||||
if (!child)
|
||||
{
|
||||
G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
|
||||
"InvalidRead", FatalException, "No child found!");
|
||||
return;
|
||||
}
|
||||
const G4String tag = Transcode(child->getTagName());
|
||||
|
||||
if (tag=="property") { PropertyRead(child,opticalsurface); }
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLWriteSolids.cc 96133 2016-03-16 22:21:17Z gcosmo $
|
||||
// $Id: G4GDMLWriteSolids.cc 103463 2017-04-11 07:22:55Z gcosmo $
|
||||
//
|
||||
// class G4GDMLWriteSolids Implementation
|
||||
//
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "G4UnionSolid.hh"
|
||||
#include "G4OpticalSurface.hh"
|
||||
#include "G4SurfaceProperty.hh"
|
||||
#include "G4MaterialPropertiesTable.hh"
|
||||
|
||||
G4GDMLWriteSolids::G4GDMLWriteSolids()
|
||||
: G4GDMLWriteMaterials(), solidsElement(0)
|
||||
@@ -79,17 +80,6 @@ G4GDMLWriteSolids::~G4GDMLWriteSolids()
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(G4GEOM_USE_USOLIDS)
|
||||
void G4GDMLWriteSolids::
|
||||
MultiUnionWrite(xercesc::DOMElement*,
|
||||
const G4MultiUnion* const)
|
||||
{
|
||||
G4Exception("G4GDMLWriteSolids::MultiUnionWrite()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Installation with USolids primitives required!");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
void G4GDMLWriteSolids::
|
||||
MultiUnionWrite(xercesc::DOMElement* solElement,
|
||||
const G4MultiUnion* const munionSolid)
|
||||
@@ -98,7 +88,7 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
|
||||
G4String tag("multiUnion");
|
||||
|
||||
G4VSolid* solid;
|
||||
G4Transform3D* transform;
|
||||
G4Transform3D transform;
|
||||
|
||||
const G4String& name = GenerateName(munionSolid->GetName(),munionSolid);
|
||||
xercesc::DOMElement* multiUnionElement = NewElement(tag);
|
||||
@@ -112,7 +102,7 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
|
||||
HepGeom::Rotate3D rot3d;
|
||||
HepGeom::Translate3D transl ;
|
||||
HepGeom::Scale3D scale;
|
||||
transform->getDecomposition(scale,rot3d,transl);
|
||||
transform.getDecomposition(scale,rot3d,transl);
|
||||
|
||||
G4ThreeVector pos = transl.getTranslation();
|
||||
G4RotationMatrix
|
||||
@@ -148,7 +138,6 @@ MultiUnionWrite(xercesc::DOMElement* solElement,
|
||||
solElement->appendChild(multiUnionElement);
|
||||
// Add the multiUnion solid AFTER the constituent nodes!
|
||||
}
|
||||
#endif
|
||||
|
||||
void G4GDMLWriteSolids::
|
||||
BooleanWrite(xercesc::DOMElement* solElement,
|
||||
@@ -1050,9 +1039,62 @@ OpticalSurfaceWrite(xercesc::DOMElement* solElement,
|
||||
optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
|
||||
optElement->setAttributeNode(NewAttribute("value", sval));
|
||||
|
||||
// Write any property attached to the optical surface...
|
||||
//
|
||||
if (surf->GetMaterialPropertiesTable())
|
||||
{
|
||||
PropertyWrite(optElement, surf);
|
||||
}
|
||||
|
||||
solElement->appendChild(optElement);
|
||||
}
|
||||
|
||||
void G4GDMLWriteSolids::PropertyWrite(xercesc::DOMElement* optElement,
|
||||
const G4OpticalSurface* const surf)
|
||||
{
|
||||
xercesc::DOMElement* propElement;
|
||||
G4MaterialPropertiesTable* ptable = surf->GetMaterialPropertiesTable();
|
||||
const std::map< G4String, G4PhysicsOrderedFreeVector*,
|
||||
std::less<G4String> >* pmap = ptable->GetPropertiesMap();
|
||||
const std::map< G4String, G4double,
|
||||
std::less<G4String> >* cmap = ptable->GetPropertiesCMap();
|
||||
std::map< G4String, G4PhysicsOrderedFreeVector*,
|
||||
std::less<G4String> >::const_iterator mpos;
|
||||
std::map< G4String, G4double,
|
||||
std::less<G4String> >::const_iterator cpos;
|
||||
for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
|
||||
{
|
||||
propElement = NewElement("property");
|
||||
propElement->setAttributeNode(NewAttribute("name", mpos->first));
|
||||
propElement->setAttributeNode(NewAttribute("ref",
|
||||
GenerateName(mpos->first, mpos->second)));
|
||||
if (mpos->second)
|
||||
{
|
||||
PropertyVectorWrite(mpos->first, mpos->second);
|
||||
optElement->appendChild(propElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4String warn_message = "Null pointer for material property -"
|
||||
+ mpos->first + "- of optical surface -" + surf->GetName() + "- !";
|
||||
G4Exception("G4GDMLWriteSolids::PropertyWrite()", "NullPointer",
|
||||
JustWarning, warn_message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
|
||||
{
|
||||
propElement = NewElement("property");
|
||||
propElement->setAttributeNode(NewAttribute("name", cpos->first));
|
||||
propElement->setAttributeNode(NewAttribute("ref", cpos->first));
|
||||
xercesc::DOMElement* constElement = NewElement("constant");
|
||||
constElement->setAttributeNode(NewAttribute("name", cpos->first));
|
||||
constElement->setAttributeNode(NewAttribute("value", cpos->second));
|
||||
defineElement->appendChild(constElement);
|
||||
optElement->appendChild(propElement);
|
||||
}
|
||||
}
|
||||
|
||||
void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
|
||||
{
|
||||
G4cout << "G4GDML: Writing solids..." << G4endl;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GDMLWriteStructure.cc 96677 2016-04-29 12:20:20Z gcosmo $
|
||||
// $Id: G4GDMLWriteStructure.cc 104688 2017-06-12 12:16:28Z gcosmo $
|
||||
//
|
||||
// class G4GDMLWriteStructure Implementation
|
||||
//
|
||||
@@ -57,8 +57,10 @@
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
G4int G4GDMLWriteStructure::levelNo = 0; // Counter for level being exported
|
||||
|
||||
G4GDMLWriteStructure::G4GDMLWriteStructure()
|
||||
: G4GDMLWriteParamvol(), cexport(false)
|
||||
: G4GDMLWriteParamvol(), cexport(false), maxLevel(INT_MAX)
|
||||
{
|
||||
reflFactory = G4ReflectionFactory::Instance();
|
||||
}
|
||||
@@ -395,6 +397,8 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
|
||||
|
||||
std::map<const G4LogicalVolume*, G4GDMLAuxListType>::iterator auxiter;
|
||||
|
||||
levelNo++;
|
||||
|
||||
while (true) // Solve possible displacement/reflection
|
||||
{ // of the referenced solid!
|
||||
if (trans>maxTransforms)
|
||||
@@ -459,8 +463,13 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
|
||||
solidrefElement->setAttributeNode(NewAttribute("ref",solidref));
|
||||
volumeElement->appendChild(solidrefElement);
|
||||
|
||||
const G4int daughterCount = volumePtr->GetNoDaughters();
|
||||
|
||||
G4int daughterCount = volumePtr->GetNoDaughters();
|
||||
|
||||
if (levelNo == maxLevel) // Stop exporting if reached levels limit
|
||||
{
|
||||
daughterCount = 0;
|
||||
}
|
||||
|
||||
for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
|
||||
{
|
||||
const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
|
||||
@@ -542,9 +551,9 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
|
||||
}
|
||||
|
||||
structureElement->appendChild(volumeElement);
|
||||
// Append the volume AFTER traversing the children so that
|
||||
// the order of volumes will be correct!
|
||||
|
||||
// Append the volume AFTER traversing the children so that
|
||||
// the order of volumes will be correct!
|
||||
|
||||
VolumeMap()[tmplv] = R;
|
||||
|
||||
AddExtension(volumeElement, volumePtr);
|
||||
@@ -633,3 +642,23 @@ G4GDMLWriteStructure::ExportSD(const G4LogicalVolume* const lvol)
|
||||
AddVolumeAuxiliary(SDinfo, lvol);
|
||||
}
|
||||
}
|
||||
|
||||
G4int
|
||||
G4GDMLWriteStructure::GetMaxExportLevel() const
|
||||
{
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
void
|
||||
G4GDMLWriteStructure::SetMaxExportLevel(G4int level)
|
||||
{
|
||||
if (level <= 0)
|
||||
{
|
||||
G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
|
||||
"InvalidSetup", FatalException,
|
||||
"Levels to export must be greater than zero!");
|
||||
return;
|
||||
}
|
||||
maxLevel = level;
|
||||
levelNo = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user