Import Geant4 10.6.0.beta source tree
This commit is contained in:
@@ -16,18 +16,25 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
12 April 2019 Witek Pokorski (gdml-V10-04-06)
|
||||
17 May 2019 Witek Pokorski (gdml-V10-05-05)
|
||||
- Adding support for writing out assemblies.
|
||||
|
||||
2 May 2019 Witek Pokorski (gdml-V10-05-04)
|
||||
- Improvement in the optical properties reader allowing to reuse the same
|
||||
G4MaterialPropertyVector object for identical properties.
|
||||
|
||||
12 April 2019 Witek Pokorski (gdml-V10-05-03)
|
||||
- Fixes to BorderSurface and OpticalSurface writer provided by Binbin Qi.
|
||||
Addressing problem reports #2143 and #2142.
|
||||
|
||||
2 April 2019 Gabriele Cosmo (gdml-V10-04-05)
|
||||
2 April 2019 Gabriele Cosmo (gdml-V10-05-02)
|
||||
- Added more protections for workers also for writing modules and read.
|
||||
|
||||
1 April 2019 Gabriele Cosmo
|
||||
1 April 2019 Gabriele Cosmo (gdml-V10-05-01)
|
||||
- Added protection to G4GDMLParser::Write() to dump geometry only through
|
||||
the master thread. Addressing problem report #2156.
|
||||
|
||||
4 March 2019 Gabriele Cosmo
|
||||
4 March 2019 Gabriele Cosmo (gdml-V10-05-00)
|
||||
- Fix in G4GDMLReadStructure::PhysvolRead() to allow correct import of
|
||||
recursive assembly structures. Thanks to B.Qi for the suggested fix.
|
||||
Addressing problem report #2141.
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "G4GDMLReadMaterials.hh"
|
||||
#include "G4ExtrudedSolid.hh"
|
||||
#include "G4MultiUnion.hh"
|
||||
#include "G4MaterialPropertiesTable.hh"
|
||||
|
||||
class G4VSolid;
|
||||
class G4QuadrangularFacet;
|
||||
@@ -108,6 +109,9 @@ class G4GDMLReadSolids : public G4GDMLReadMaterials
|
||||
rzPointType RZPointRead(const xercesc::DOMElement* const);
|
||||
void OpticalSurfaceRead(const xercesc::DOMElement* const);
|
||||
void PropertyRead(const xercesc::DOMElement* const,G4OpticalSurface*);
|
||||
|
||||
private:
|
||||
std::map<G4String, G4MaterialPropertyVector*> mapOfMatPropVects;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class G4LogicalSkinSurface;
|
||||
class G4OpticalSurface;
|
||||
class G4SurfaceProperty;
|
||||
class G4ReflectionFactory;
|
||||
class G4AssemblyTriplet;
|
||||
|
||||
class G4GDMLWriteStructure : public G4GDMLWriteParamvol
|
||||
{
|
||||
@@ -75,6 +76,7 @@ class G4GDMLWriteStructure : public G4GDMLWriteParamvol
|
||||
void PhysvolWrite(xercesc::DOMElement*,const G4VPhysicalVolume* const topVol,
|
||||
const G4Transform3D& transform, const G4String& moduleName);
|
||||
void ReplicavolWrite(xercesc::DOMElement*, const G4VPhysicalVolume* const);
|
||||
void AssemblyWrite(xercesc::DOMElement*, const int assemblyID);
|
||||
G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const topVol,
|
||||
const G4int depth);
|
||||
void SurfacesWrite();
|
||||
@@ -101,6 +103,10 @@ class G4GDMLWriteStructure : public G4GDMLWriteParamvol
|
||||
G4bool sdexport; // Flag for optional export of SD per volume
|
||||
G4int maxLevel; // Maximum number of levels to export
|
||||
static G4int levelNo; // Counter for level being exported
|
||||
std::map<const G4VPhysicalVolume*, G4int> assemblyVolMap; // Map of phys volumes to assembly IDs
|
||||
std::map<const G4VPhysicalVolume*, G4int> imprintsMap; // Map of phys volumes to imprints IDs
|
||||
std::vector<int> addedAssemblies; // vector of assemblies IDs already added to the structure
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
#include "G4OpticalSurface.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SurfaceProperty.hh"
|
||||
#include "G4MaterialPropertiesTable.hh"
|
||||
|
||||
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
|
||||
{
|
||||
@@ -2535,11 +2534,24 @@ PropertyRead(const xercesc::DOMElement* const propertyElement,
|
||||
}
|
||||
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));
|
||||
}
|
||||
G4MaterialPropertyVector* propvect;
|
||||
// first check if it was already built
|
||||
if ( mapOfMatPropVects.find(Strip(name)) == mapOfMatPropVects.end())
|
||||
{
|
||||
// if not create a new one
|
||||
propvect = new G4MaterialPropertyVector();
|
||||
for (size_t i=0; i<matrix.GetRows(); i++)
|
||||
{
|
||||
propvect->InsertValues(matrix.Get(i,0),matrix.Get(i,1));
|
||||
}
|
||||
// and add it to the list for potential future reuse
|
||||
mapOfMatPropVects[Strip(name)] = propvect;
|
||||
}
|
||||
else
|
||||
{
|
||||
propvect = mapOfMatPropVects[Strip(name)];
|
||||
}
|
||||
|
||||
matprop->AddProperty(Strip(name),propvect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
#include "G4Proton.hh"
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4AssemblyStore.hh"
|
||||
#include "G4AssemblyVolume.hh"
|
||||
|
||||
G4int G4GDMLWriteStructure::levelNo = 0; // Counter for level being exported
|
||||
|
||||
@@ -229,6 +231,63 @@ void G4GDMLWriteStructure::ReplicavolWrite(xercesc::DOMElement* volumeElement,
|
||||
volumeElement->appendChild(replicavolElement);
|
||||
}
|
||||
|
||||
|
||||
void G4GDMLWriteStructure::AssemblyWrite(xercesc::DOMElement* volumeElement,
|
||||
const int assemblyID)
|
||||
{
|
||||
|
||||
G4AssemblyStore* assemblies = G4AssemblyStore::GetInstance();
|
||||
G4AssemblyVolume* myassembly = assemblies->GetAssembly(assemblyID);
|
||||
|
||||
xercesc::DOMElement* assemblyElement = NewElement("assembly");
|
||||
G4String name = "Assembly_" + std::to_string(assemblyID);
|
||||
|
||||
assemblyElement->setAttributeNode(NewAttribute("name",name));
|
||||
|
||||
std::vector<G4AssemblyTriplet>::iterator vit = myassembly->GetTripletsIterator();
|
||||
|
||||
int depth = 0;
|
||||
const G4String ModuleName;
|
||||
|
||||
for (size_t i5=0; i5<myassembly->TotalTriplets(); i5++)
|
||||
{
|
||||
TraverseVolumeTree((*vit).GetVolume(),depth+1);
|
||||
|
||||
const G4ThreeVector rot = GetAngles((*vit).GetRotation()->inverse());
|
||||
const G4ThreeVector pos = (*vit).GetTranslation();
|
||||
|
||||
const G4String pname = GenerateName((*vit).GetVolume()->GetName()+"_pv", &(*vit));
|
||||
|
||||
xercesc::DOMElement* physvolElement = NewElement("physvol");
|
||||
physvolElement->setAttributeNode(NewAttribute("name",pname));
|
||||
|
||||
assemblyElement->appendChild(physvolElement);
|
||||
|
||||
const G4String volumeref = GenerateName((*vit).GetVolume()->GetName(), (*vit).GetVolume());
|
||||
|
||||
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
|
||||
volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
|
||||
physvolElement->appendChild(volumerefElement);
|
||||
|
||||
if (std::fabs(pos.x()) > kLinearPrecision
|
||||
|| std::fabs(pos.y()) > kLinearPrecision
|
||||
|| std::fabs(pos.z()) > kLinearPrecision)
|
||||
{
|
||||
PositionWrite(physvolElement,"Position_" + std::to_string(i5), pos);
|
||||
}
|
||||
if (std::fabs(rot.x()) > kAngularPrecision
|
||||
|| std::fabs(rot.y()) > kAngularPrecision
|
||||
|| std::fabs(rot.z()) > kAngularPrecision)
|
||||
{
|
||||
RotationWrite(physvolElement,"Rotation_" + std::to_string(i5), rot);
|
||||
}
|
||||
vit++;
|
||||
}
|
||||
|
||||
volumeElement->appendChild(assemblyElement);
|
||||
}
|
||||
|
||||
|
||||
void G4GDMLWriteStructure::
|
||||
BorderSurfaceCache(const G4LogicalBorderSurface* const bsurf)
|
||||
{
|
||||
@@ -383,6 +442,31 @@ void G4GDMLWriteStructure::StructureWrite(xercesc::DOMElement* gdmlElement)
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "G4GDML: Writing structure..." << G4endl;
|
||||
#endif
|
||||
|
||||
// filling the list of phys volumes that are parts of assemblies
|
||||
|
||||
G4AssemblyStore* assemblies = G4AssemblyStore::GetInstance();
|
||||
|
||||
for(G4AssemblyStore::iterator it=assemblies->begin(); it!=assemblies->end(); it++)
|
||||
{
|
||||
|
||||
std::vector<G4VPhysicalVolume*>::iterator vit = (*it)->GetVolumesIterator();
|
||||
|
||||
for (size_t i5=0; i5<(*it)->TotalImprintedVolumes(); i5++)
|
||||
{
|
||||
G4String pvname = (*vit)->GetName();
|
||||
std::size_t pos = pvname.find("_impr_") + 6;
|
||||
G4String impID = pvname.substr(pos);
|
||||
|
||||
pos = impID.find("_");
|
||||
impID = impID.substr(0, pos);
|
||||
|
||||
assemblyVolMap[*vit] = (*it)->GetAssemblyID();
|
||||
imprintsMap[*vit] = std::atoi(impID.c_str());
|
||||
vit++;
|
||||
}
|
||||
}
|
||||
|
||||
structureElement = NewElement("structure");
|
||||
gdmlElement->appendChild(structureElement);
|
||||
}
|
||||
@@ -480,6 +564,8 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
|
||||
daughterCount = 0;
|
||||
}
|
||||
|
||||
std::vector<int> addedImprints;
|
||||
|
||||
for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
|
||||
{
|
||||
const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
|
||||
@@ -532,16 +618,100 @@ TraverseVolumeTree(const G4LogicalVolume* const volumePtr, const G4int depth)
|
||||
}
|
||||
ReplicavolWrite(volumeElement,physvol);
|
||||
}
|
||||
else // Is it a physvol?
|
||||
else // Is it a physvol or an assembly?
|
||||
{
|
||||
G4RotationMatrix rot;
|
||||
if (physvol->GetFrameRotation() != 0)
|
||||
if(assemblyVolMap.find(physvol) != assemblyVolMap.end())
|
||||
{
|
||||
rot = *(physvol->GetFrameRotation());
|
||||
int assemblyID = assemblyVolMap[physvol];
|
||||
|
||||
G4String assemblyref = "Assembly_" + std::to_string(assemblyID);
|
||||
|
||||
// here I need to retrieve the imprint ID
|
||||
|
||||
G4int imprintID = imprintsMap[physvol];
|
||||
|
||||
// there are 2 steps:
|
||||
//
|
||||
// 1) add assembly to the structure if that has not yet been done
|
||||
// (but after the constituents volumes have been added)
|
||||
//
|
||||
|
||||
if(std::find(addedAssemblies.begin(), addedAssemblies.end(), assemblyID) == addedAssemblies.end())
|
||||
{
|
||||
AssemblyWrite(structureElement, assemblyID);
|
||||
addedAssemblies.push_back(assemblyID);
|
||||
}
|
||||
|
||||
// 2) add the assembly (as physical volume) to the mother volume (but only once),
|
||||
// using it's original position and rotation.
|
||||
//
|
||||
|
||||
// here I need a check if assembly has been already added to the mother volume
|
||||
if(std::find(addedImprints.begin(), addedImprints.end(), imprintID) == addedImprints.end())
|
||||
{
|
||||
G4String imprintname = "Imprint_" + std::to_string(imprintID);
|
||||
imprintname = GenerateName(imprintname, physvol);
|
||||
|
||||
// I need to get those two from the container of imprints from the assembly
|
||||
// I have the imprint ID, I need to get pos and rot
|
||||
//
|
||||
G4Transform3D& transf =
|
||||
G4AssemblyStore::GetInstance()->GetAssembly(assemblyID)->GetImprintTransformation(imprintID);
|
||||
|
||||
HepGeom::Scale3D scale;
|
||||
HepGeom::Rotate3D rotate;
|
||||
HepGeom::Translate3D translate;
|
||||
|
||||
transf.getDecomposition(scale,rotate,translate);
|
||||
|
||||
const G4ThreeVector scl(scale(0,0),scale(1,1),scale(2,2));
|
||||
const G4ThreeVector rot = GetAngles(rotate.getRotation().inverse());
|
||||
const G4ThreeVector pos = transf.getTranslation();
|
||||
|
||||
// here I need a normal physvol referencing to my assemblyref
|
||||
|
||||
xercesc::DOMElement* physvolElement = NewElement("physvol");
|
||||
physvolElement->setAttributeNode(NewAttribute("name",imprintname));
|
||||
|
||||
xercesc::DOMElement* volumerefElement = NewElement("volumeref");
|
||||
volumerefElement->setAttributeNode(NewAttribute("ref",assemblyref));
|
||||
physvolElement->appendChild(volumerefElement);
|
||||
|
||||
if (std::fabs(pos.x()) > kLinearPrecision
|
||||
|| std::fabs(pos.y()) > kLinearPrecision
|
||||
|| std::fabs(pos.z()) > kLinearPrecision)
|
||||
{
|
||||
PositionWrite(physvolElement,imprintname+"_pos",pos);
|
||||
}
|
||||
if (std::fabs(rot.x()) > kAngularPrecision
|
||||
|| std::fabs(rot.y()) > kAngularPrecision
|
||||
|| std::fabs(rot.z()) > kAngularPrecision)
|
||||
{
|
||||
RotationWrite(physvolElement,imprintname+"_rot",rot);
|
||||
}
|
||||
if (std::fabs(scl.x()-1.0) > kRelativePrecision
|
||||
|| std::fabs(scl.y()-1.0) > kRelativePrecision
|
||||
|| std::fabs(scl.z()-1.0) > kRelativePrecision)
|
||||
{
|
||||
ScaleWrite(physvolElement,name+"_scl",scl);
|
||||
}
|
||||
|
||||
volumeElement->appendChild(physvolElement);
|
||||
//
|
||||
addedImprints.push_back(imprintID);
|
||||
}
|
||||
}
|
||||
G4Transform3D P(rot,physvol->GetObjectTranslation());
|
||||
else // not part of assembly, so a normal physical volume
|
||||
{
|
||||
G4RotationMatrix rot;
|
||||
if (physvol->GetFrameRotation() != 0)
|
||||
{
|
||||
rot = *(physvol->GetFrameRotation());
|
||||
}
|
||||
G4Transform3D P(rot,physvol->GetObjectTranslation());
|
||||
|
||||
PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
|
||||
PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
|
||||
}
|
||||
}
|
||||
// BorderSurfaceCache(GetBorderSurface(physvol));
|
||||
GetBorderSurface(physvol);
|
||||
|
||||
Reference in New Issue
Block a user