Geant4  10.02.p03
G4GDMLWriteStructure Class Reference

#include <G4GDMLWriteStructure.hh>

Inheritance diagram for G4GDMLWriteStructure:
Collaboration diagram for G4GDMLWriteStructure:

Public Member Functions

 G4GDMLWriteStructure ()
 
virtual ~G4GDMLWriteStructure ()
 
virtual void StructureWrite (xercesc::DOMElement *)
 
void AddVolumeAuxiliary (G4GDMLAuxStructType myaux, const G4LogicalVolume *const)
 
void SetEnergyCutsExport (G4bool)
 
- Public Member Functions inherited from G4GDMLWriteParamvol
virtual void ParamvolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const)
 
virtual void ParamvolAlgorithmWrite (xercesc::DOMElement *paramvolElement, const G4VPhysicalVolume *const paramvol)
 
- Public Member Functions inherited from G4GDMLWriteSetup
virtual void SetupWrite (xercesc::DOMElement *, const G4LogicalVolume *const)
 
- Public Member Functions inherited from G4GDMLWriteSolids
virtual void AddSolid (const G4VSolid *const)
 
virtual void SolidsWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWriteMaterials
void AddIsotope (const G4Isotope *const)
 
void AddElement (const G4Element *const)
 
void AddMaterial (const G4Material *const)
 
virtual void MaterialsWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWriteDefine
G4ThreeVector GetAngles (const G4RotationMatrix &)
 
void ScaleWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &scl)
 
void RotationWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
 
void PositionWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
 
void FirstrotationWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
 
void FirstpositionWrite (xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
 
void AddPosition (const G4String &name, const G4ThreeVector &pos)
 
virtual void DefineWrite (xercesc::DOMElement *)
 
- Public Member Functions inherited from G4GDMLWrite
G4Transform3D Write (const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
 
void AddModule (const G4VPhysicalVolume *const topVol)
 
void AddModule (const G4int depth)
 
void AddAuxiliary (G4GDMLAuxStructType myaux)
 
virtual void ExtensionWrite (xercesc::DOMElement *)
 
virtual void UserinfoWrite (xercesc::DOMElement *)
 
virtual void AddExtension (xercesc::DOMElement *, const G4LogicalVolume *const)
 
G4String GenerateName (const G4String &, const void *const)
 

Protected Member Functions

void DivisionvolWrite (xercesc::DOMElement *, const G4PVDivision *const)
 
void PhysvolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const topVol, const G4Transform3D &transform, const G4String &moduleName)
 
void ReplicavolWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const)
 
G4Transform3D TraverseVolumeTree (const G4LogicalVolume *const topVol, const G4int depth)
 
void SurfacesWrite ()
 
void BorderSurfaceCache (const G4LogicalBorderSurface *const)
 
void SkinSurfaceCache (const G4LogicalSkinSurface *const)
 
const G4LogicalBorderSurfaceGetBorderSurface (const G4VPhysicalVolume *const)
 
const G4LogicalSkinSurfaceGetSkinSurface (const G4LogicalVolume *const)
 
G4bool FindOpticalSurface (const G4SurfaceProperty *)
 
void ExportEnergyCuts (const G4LogicalVolume *const)
 
- Protected Member Functions inherited from G4GDMLWriteParamvol
 G4GDMLWriteParamvol ()
 
virtual ~G4GDMLWriteParamvol ()
 
void Box_dimensionsWrite (xercesc::DOMElement *, const G4Box *const)
 
void Trd_dimensionsWrite (xercesc::DOMElement *, const G4Trd *const)
 
void Trap_dimensionsWrite (xercesc::DOMElement *, const G4Trap *const)
 
void Tube_dimensionsWrite (xercesc::DOMElement *, const G4Tubs *const)
 
void Cone_dimensionsWrite (xercesc::DOMElement *, const G4Cons *const)
 
void Sphere_dimensionsWrite (xercesc::DOMElement *, const G4Sphere *const)
 
void Orb_dimensionsWrite (xercesc::DOMElement *, const G4Orb *const)
 
void Torus_dimensionsWrite (xercesc::DOMElement *, const G4Torus *const)
 
void Ellipsoid_dimensionsWrite (xercesc::DOMElement *, const G4Ellipsoid *const)
 
void Para_dimensionsWrite (xercesc::DOMElement *, const G4Para *const)
 
void Hype_dimensionsWrite (xercesc::DOMElement *, const G4Hype *const)
 
void Polycone_dimensionsWrite (xercesc::DOMElement *, const G4Polycone *const)
 
void Polyhedra_dimensionsWrite (xercesc::DOMElement *, const G4Polyhedra *const)
 
void ParametersWrite (xercesc::DOMElement *, const G4VPhysicalVolume *const, const G4int &)
 
- Protected Member Functions inherited from G4GDMLWriteSetup
 G4GDMLWriteSetup ()
 
virtual ~G4GDMLWriteSetup ()
 
- Protected Member Functions inherited from G4GDMLWriteSolids
 G4GDMLWriteSolids ()
 
virtual ~G4GDMLWriteSolids ()
 
void MultiUnionWrite (xercesc::DOMElement *solElement, const G4MultiUnion *const)
 
void BooleanWrite (xercesc::DOMElement *, const G4BooleanSolid *const)
 
void BoxWrite (xercesc::DOMElement *, const G4Box *const)
 
void ConeWrite (xercesc::DOMElement *, const G4Cons *const)
 
void ElconeWrite (xercesc::DOMElement *, const G4EllipticalCone *const)
 
void EllipsoidWrite (xercesc::DOMElement *, const G4Ellipsoid *const)
 
void EltubeWrite (xercesc::DOMElement *, const G4EllipticalTube *const)
 
void XtruWrite (xercesc::DOMElement *, const G4ExtrudedSolid *const)
 
void HypeWrite (xercesc::DOMElement *, const G4Hype *const)
 
void OrbWrite (xercesc::DOMElement *, const G4Orb *const)
 
void ParaWrite (xercesc::DOMElement *, const G4Para *const)
 
void ParaboloidWrite (xercesc::DOMElement *, const G4Paraboloid *const)
 
void PolyconeWrite (xercesc::DOMElement *, const G4Polycone *const)
 
void GenericPolyconeWrite (xercesc::DOMElement *, const G4GenericPolycone *const)
 
void PolyhedraWrite (xercesc::DOMElement *, const G4Polyhedra *const)
 
void SphereWrite (xercesc::DOMElement *, const G4Sphere *const)
 
void TessellatedWrite (xercesc::DOMElement *, const G4TessellatedSolid *const)
 
void TetWrite (xercesc::DOMElement *, const G4Tet *const)
 
void TorusWrite (xercesc::DOMElement *, const G4Torus *const)
 
void GenTrapWrite (xercesc::DOMElement *, const G4GenericTrap *const)
 
void TrapWrite (xercesc::DOMElement *, const G4Trap *const)
 
void TrdWrite (xercesc::DOMElement *, const G4Trd *const)
 
void TubeWrite (xercesc::DOMElement *, const G4Tubs *const)
 
void CutTubeWrite (xercesc::DOMElement *, const G4CutTubs *const)
 
void TwistedboxWrite (xercesc::DOMElement *, const G4TwistedBox *const)
 
void TwistedtrapWrite (xercesc::DOMElement *, const G4TwistedTrap *const)
 
void TwistedtrdWrite (xercesc::DOMElement *, const G4TwistedTrd *const)
 
void TwistedtubsWrite (xercesc::DOMElement *, const G4TwistedTubs *const)
 
void ZplaneWrite (xercesc::DOMElement *, const G4double &, const G4double &, const G4double &)
 
void RZPointWrite (xercesc::DOMElement *, const G4double &, const G4double &)
 
void OpticalSurfaceWrite (xercesc::DOMElement *, const G4OpticalSurface *const)
 
- Protected Member Functions inherited from G4GDMLWriteMaterials
 G4GDMLWriteMaterials ()
 
virtual ~G4GDMLWriteMaterials ()
 
void AtomWrite (xercesc::DOMElement *, const G4double &)
 
void DWrite (xercesc::DOMElement *, const G4double &)
 
void PWrite (xercesc::DOMElement *, const G4double &)
 
void TWrite (xercesc::DOMElement *, const G4double &)
 
void MEEWrite (xercesc::DOMElement *, const G4double &)
 
void IsotopeWrite (const G4Isotope *const)
 
void ElementWrite (const G4Element *const)
 
void MaterialWrite (const G4Material *const)
 
void PropertyWrite (xercesc::DOMElement *, const G4Material *const)
 
void PropertyVectorWrite (const G4String &, const G4PhysicsOrderedFreeVector *const)
 
- Protected Member Functions inherited from G4GDMLWriteDefine
 G4GDMLWriteDefine ()
 
virtual ~G4GDMLWriteDefine ()
 
void Scale_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
void Rotation_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
void Position_vectorWrite (xercesc::DOMElement *, const G4String &, const G4String &, const G4ThreeVector &)
 
- Protected Member Functions inherited from G4GDMLWrite
 G4GDMLWrite ()
 
virtual ~G4GDMLWrite ()
 
VolumeMapTypeVolumeMap ()
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4String &)
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4double &)
 
xercesc::DOMElement * NewElement (const G4String &)
 
G4String Modularize (const G4VPhysicalVolume *const topvol, const G4int depth)
 
void AddAuxInfo (G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
 
G4bool FileExists (const G4String &) const
 
PhysVolumeMapTypePvolumeMap ()
 
DepthMapTypeDepthMap ()
 

Protected Attributes

xercesc::DOMElement * structureElement
 
std::vector< xercesc::DOMElement * > borderElementVec
 
std::vector< xercesc::DOMElement * > skinElementVec
 
std::map< const G4LogicalVolume *, G4GDMLAuxListTypeauxmap
 
- Protected Attributes inherited from G4GDMLWriteSolids
std::vector< const G4VSolid * > solidList
 
xercesc::DOMElement * solidsElement
 
- Protected Attributes inherited from G4GDMLWriteMaterials
std::vector< const G4Isotope * > isotopeList
 
std::vector< const G4Element * > elementList
 
std::vector< const G4Material * > materialList
 
xercesc::DOMElement * materialsElement
 
- Protected Attributes inherited from G4GDMLWriteDefine
xercesc::DOMElement * defineElement
 
- Protected Attributes inherited from G4GDMLWrite
G4String SchemaLocation
 
xercesc::DOMDocument * doc
 
xercesc::DOMElement * extElement
 
xercesc::DOMElement * userinfoElement
 
XMLCh tempStr [10000]
 
G4GDMLAuxListType auxList
 

Private Attributes

std::vector< const G4OpticalSurface * > opt_vec
 
G4ReflectionFactoryreflFactory
 
G4bool cexport
 

Additional Inherited Members

- Static Public Member Functions inherited from G4GDMLWrite
static void SetAddPointerToName (G4bool)
 
- Static Protected Attributes inherited from G4GDMLWriteSolids
static const G4int maxTransforms = 8
 
- Static Protected Attributes inherited from G4GDMLWriteDefine
static const G4double kRelativePrecision = DBL_EPSILON
 
static const G4double kAngularPrecision = DBL_EPSILON
 
static const G4double kLinearPrecision = DBL_EPSILON
 
- Static Protected Attributes inherited from G4GDMLWrite
static G4bool addPointerToName = true
 

Detailed Description

Definition at line 56 of file G4GDMLWriteStructure.hh.

Constructor & Destructor Documentation

◆ G4GDMLWriteStructure()

G4GDMLWriteStructure::G4GDMLWriteStructure ( )

Definition at line 58 of file G4GDMLWriteStructure.cc.

59  : G4GDMLWriteParamvol(), cexport(false)
60 {
62 }
G4ReflectionFactory * reflFactory
static G4ReflectionFactory * Instance()
Here is the call graph for this function:

◆ ~G4GDMLWriteStructure()

G4GDMLWriteStructure::~G4GDMLWriteStructure ( )
virtual

Definition at line 64 of file G4GDMLWriteStructure.cc.

65 {
66 }

Member Function Documentation

◆ AddVolumeAuxiliary()

void G4GDMLWriteStructure::AddVolumeAuxiliary ( G4GDMLAuxStructType  myaux,
const G4LogicalVolume * const  lvol 
)

Definition at line 559 of file G4GDMLWriteStructure.cc.

561 {
562  std::map<const G4LogicalVolume*,
563  G4GDMLAuxListType>::iterator pos = auxmap.find(lvol);
564 
565  if (pos == auxmap.end()) { auxmap[lvol] = G4GDMLAuxListType(); }
566 
567  auxmap[lvol].push_back(myaux);
568 }
std::map< const G4LogicalVolume *, G4GDMLAuxListType > auxmap
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
static const G4double pos
Here is the caller graph for this function:

◆ BorderSurfaceCache()

void G4GDMLWriteStructure::BorderSurfaceCache ( const G4LogicalBorderSurface * const  bsurf)
protected

Definition at line 230 of file G4GDMLWriteStructure.cc.

231 {
232  if (!bsurf) { return; }
233 
234  const G4SurfaceProperty* psurf = bsurf->GetSurfaceProperty();
235 
236  // Generate the new element for border-surface
237  //
238  xercesc::DOMElement* borderElement = NewElement("bordersurface");
239  borderElement->setAttributeNode(NewAttribute("name", bsurf->GetName()));
240  borderElement->setAttributeNode(NewAttribute("surfaceproperty",
241  psurf->GetName()));
242 
243  const G4String volumeref1 = GenerateName(bsurf->GetVolume1()->GetName(),
244  bsurf->GetVolume1());
245  const G4String volumeref2 = GenerateName(bsurf->GetVolume2()->GetName(),
246  bsurf->GetVolume2());
247  xercesc::DOMElement* volumerefElement1 = NewElement("physvolref");
248  xercesc::DOMElement* volumerefElement2 = NewElement("physvolref");
249  volumerefElement1->setAttributeNode(NewAttribute("ref",volumeref1));
250  volumerefElement2->setAttributeNode(NewAttribute("ref",volumeref2));
251  borderElement->appendChild(volumerefElement1);
252  borderElement->appendChild(volumerefElement2);
253 
254  if (FindOpticalSurface(psurf))
255  {
256  const G4OpticalSurface* opsurf =
257  dynamic_cast<const G4OpticalSurface*>(psurf);
258  if (!opsurf)
259  {
260  G4Exception("G4GDMLWriteStructure::BorderSurfaceCache()",
261  "InvalidSetup", FatalException, "No optical surface found!");
262  return;
263  }
265  }
266 
267  borderElementVec.push_back(borderElement);
268 }
const G4String & GetName() const
const G4String & GetName() const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
const G4VPhysicalVolume * GetVolume1() const
void OpticalSurfaceWrite(xercesc::DOMElement *, const G4OpticalSurface *const)
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4String & GetName() const
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4SurfaceProperty * GetSurfaceProperty() const
xercesc::DOMElement * solidsElement
std::vector< xercesc::DOMElement * > borderElementVec
G4bool FindOpticalSurface(const G4SurfaceProperty *)
const G4VPhysicalVolume * GetVolume2() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DivisionvolWrite()

void G4GDMLWriteStructure::DivisionvolWrite ( xercesc::DOMElement *  volumeElement,
const G4PVDivision * const  divisionvol 
)
protected

Definition at line 69 of file G4GDMLWriteStructure.cc.

71 {
72  EAxis axis = kUndefined;
73  G4int number = 0;
74  G4double width = 0.0;
75  G4double offset = 0.0;
76  G4bool consuming = false;
77 
78  divisionvol->GetReplicationData(axis,number,width,offset,consuming);
79  axis = divisionvol->GetDivisionAxis();
80 
81  G4String unitString("mm");
82  G4String axisString("kUndefined");
83  if (axis==kXAxis) { axisString = "kXAxis"; }
84  else if (axis==kYAxis) { axisString = "kYAxis"; }
85  else if (axis==kZAxis) { axisString = "kZAxis"; }
86  else if (axis==kRho) { axisString = "kRho"; }
87  else if (axis==kPhi) { axisString = "kPhi"; unitString = "rad"; }
88 
89  const G4String name
90  = GenerateName(divisionvol->GetName(),divisionvol);
91  const G4String volumeref
92  = GenerateName(divisionvol->GetLogicalVolume()->GetName(),
93  divisionvol->GetLogicalVolume());
94 
95  xercesc::DOMElement* divisionvolElement = NewElement("divisionvol");
96  divisionvolElement->setAttributeNode(NewAttribute("axis",axisString));
97  divisionvolElement->setAttributeNode(NewAttribute("number",number));
98  divisionvolElement->setAttributeNode(NewAttribute("width",width));
99  divisionvolElement->setAttributeNode(NewAttribute("offset",offset));
100  divisionvolElement->setAttributeNode(NewAttribute("unit",unitString));
101  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
102  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
103  divisionvolElement->appendChild(volumerefElement);
104  volumeElement->appendChild(divisionvolElement);
105 }
Definition: geomdefs.hh:54
G4String name
Definition: TRTMaterials.hh:40
#define width
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
const G4String & GetName() const
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
EAxis
Definition: geomdefs.hh:54
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54
G4LogicalVolume * GetLogicalVolume() const
EAxis GetDivisionAxis() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExportEnergyCuts()

void G4GDMLWriteStructure::ExportEnergyCuts ( const G4LogicalVolume * const  lvol)
protected

Definition at line 577 of file G4GDMLWriteStructure.cc.

578 {
579  G4GDMLEvaluator eval;
580  G4ProductionCuts* pcuts = lvol->GetRegion()->GetProductionCuts();
582  G4Gamma* gamma = G4Gamma::Gamma();
583  G4Electron* eminus = G4Electron::Electron();
586 
587  G4double gamma_cut = ctab->ConvertRangeToEnergy(gamma, lvol->GetMaterial(),
588  pcuts->GetProductionCut("gamma"));
589  G4double eminus_cut = ctab->ConvertRangeToEnergy(eminus, lvol->GetMaterial(),
590  pcuts->GetProductionCut("e-"));
591  G4double eplus_cut = ctab->ConvertRangeToEnergy(eplus, lvol->GetMaterial(),
592  pcuts->GetProductionCut("e+"));
593  G4double proton_cut = ctab->ConvertRangeToEnergy(proton, lvol->GetMaterial(),
594  pcuts->GetProductionCut("proton"));
595 
596  G4GDMLAuxStructType gammainfo = {"gammaECut",
597  eval.ConvertToString(gamma_cut), "MeV", 0};
598  G4GDMLAuxStructType eminusinfo = {"electronECut",
599  eval.ConvertToString(eminus_cut), "MeV", 0};
600  G4GDMLAuxStructType eplusinfo = {"positronECut",
601  eval.ConvertToString(eplus_cut), "MeV", 0};
602  G4GDMLAuxStructType protinfo = {"protonECut",
603  eval.ConvertToString(proton_cut), "MeV", 0};
604 
605  AddVolumeAuxiliary(gammainfo, lvol);
606  AddVolumeAuxiliary(eminusinfo, lvol);
607  AddVolumeAuxiliary(eplusinfo, lvol);
608  AddVolumeAuxiliary(protinfo, lvol);
609 }
G4Material * GetMaterial() const
G4double GetProductionCut(G4int index) const
G4String ConvertToString(G4int ival)
static G4Proton * Proton()
Definition: G4Proton.cc:93
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
static G4ProductionCutsTable * GetProductionCutsTable()
static G4Positron * Positron()
Definition: G4Positron.cc:94
void AddVolumeAuxiliary(G4GDMLAuxStructType myaux, const G4LogicalVolume *const)
G4Region * GetRegion() const
static G4Electron * Electron()
Definition: G4Electron.cc:94
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
G4ProductionCuts * GetProductionCuts() const
double G4double
Definition: G4Types.hh:76
static const double eplus
Definition: G4SIunits.hh:196
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindOpticalSurface()

G4bool G4GDMLWriteStructure::FindOpticalSurface ( const G4SurfaceProperty psurf)
protected

Definition at line 306 of file G4GDMLWriteStructure.cc.

307 {
308  const G4OpticalSurface* osurf = dynamic_cast<const G4OpticalSurface*>(psurf);
309  std::vector<const G4OpticalSurface*>::const_iterator pos;
310  pos = std::find(opt_vec.begin(), opt_vec.end(), osurf);
311  if (pos != opt_vec.end()) { return false; } // item already created!
312 
313  opt_vec.push_back(osurf); // cache it for future reference
314  return true;
315 }
std::vector< const G4OpticalSurface * > opt_vec
static const G4double pos
Here is the caller graph for this function:

◆ GetBorderSurface()

const G4LogicalBorderSurface * G4GDMLWriteStructure::GetBorderSurface ( const G4VPhysicalVolume * const  pvol)
protected

Definition at line 339 of file G4GDMLWriteStructure.cc.

340 {
341  G4LogicalBorderSurface* surf = 0;
343  if (nsurf)
344  {
345  const G4LogicalBorderSurfaceTable* btable =
347  std::vector<G4LogicalBorderSurface*>::const_iterator pos;
348  for (pos = btable->begin(); pos != btable->end(); pos++)
349  {
350  if (pvol == (*pos)->GetVolume1()) // just the first in the couple
351  { // is enough
352  surf = *pos; break;
353  }
354  }
355  }
356  return surf;
357 }
std::vector< G4LogicalBorderSurface * > G4LogicalBorderSurfaceTable
int G4int
Definition: G4Types.hh:78
static size_t GetNumberOfBorderSurfaces()
static const G4LogicalBorderSurfaceTable * GetSurfaceTable()
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSkinSurface()

const G4LogicalSkinSurface * G4GDMLWriteStructure::GetSkinSurface ( const G4LogicalVolume * const  lvol)
protected

Definition at line 318 of file G4GDMLWriteStructure.cc.

319 {
320  G4LogicalSkinSurface* surf = 0;
322  if (nsurf)
323  {
324  const G4LogicalSkinSurfaceTable* stable =
326  std::vector<G4LogicalSkinSurface*>::const_iterator pos;
327  for (pos = stable->begin(); pos != stable->end(); pos++)
328  {
329  if (lvol == (*pos)->GetLogicalVolume())
330  {
331  surf = *pos; break;
332  }
333  }
334  }
335  return surf;
336 }
int G4int
Definition: G4Types.hh:78
static size_t GetNumberOfSkinSurfaces()
static const G4LogicalSkinSurfaceTable * GetSurfaceTable()
std::vector< G4LogicalSkinSurface * > G4LogicalSkinSurfaceTable
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PhysvolWrite()

void G4GDMLWriteStructure::PhysvolWrite ( xercesc::DOMElement *  volumeElement,
const G4VPhysicalVolume *const  topVol,
const G4Transform3D transform,
const G4String moduleName 
)
protected

Definition at line 107 of file G4GDMLWriteStructure.cc.

111 {
113  HepGeom::Rotate3D rotate;
114  HepGeom::Translate3D translate;
115 
116  T.getDecomposition(scale,rotate,translate);
117 
118  const G4ThreeVector scl(scale(0,0),scale(1,1),scale(2,2));
119  const G4ThreeVector rot = GetAngles(rotate.getRotation());
120  const G4ThreeVector pos = T.getTranslation();
121 
122  const G4String name = GenerateName(physvol->GetName(),physvol);
123  const G4int copynumber = physvol->GetCopyNo();
124 
125  xercesc::DOMElement* physvolElement = NewElement("physvol");
126  physvolElement->setAttributeNode(NewAttribute("name",name));
127  if (copynumber) physvolElement->setAttributeNode(NewAttribute("copynumber", copynumber));
128 
129  volumeElement->appendChild(physvolElement);
130 
131  G4LogicalVolume* lv;
132  // Is it reflected?
133  if (reflFactory->IsReflected(physvol->GetLogicalVolume()))
134  {
135  lv = reflFactory->GetConstituentLV(physvol->GetLogicalVolume());
136  }
137  else
138  {
139  lv = physvol->GetLogicalVolume();
140  }
141 
142  const G4String volumeref = GenerateName(lv->GetName(), lv);
143 
144  if (ModuleName.empty())
145  {
146  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
147  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
148  physvolElement->appendChild(volumerefElement);
149  }
150  else
151  {
152  xercesc::DOMElement* fileElement = NewElement("file");
153  fileElement->setAttributeNode(NewAttribute("name",ModuleName));
154  fileElement->setAttributeNode(NewAttribute("volname",volumeref));
155  physvolElement->appendChild(fileElement);
156  }
157 
158  if (std::fabs(pos.x()) > kLinearPrecision
159  || std::fabs(pos.y()) > kLinearPrecision
160  || std::fabs(pos.z()) > kLinearPrecision)
161  {
162  PositionWrite(physvolElement,name+"_pos",pos);
163  }
164  if (std::fabs(rot.x()) > kAngularPrecision
165  || std::fabs(rot.y()) > kAngularPrecision
166  || std::fabs(rot.z()) > kAngularPrecision)
167  {
168  RotationWrite(physvolElement,name+"_rot",rot);
169  }
170  if (std::fabs(scl.x()-1.0) > kRelativePrecision
171  || std::fabs(scl.y()-1.0) > kRelativePrecision
172  || std::fabs(scl.z()-1.0) > kRelativePrecision)
173  {
174  ScaleWrite(physvolElement,name+"_scl",scl);
175  }
176 }
static const G4double kAngularPrecision
G4ReflectionFactory * reflFactory
G4String name
Definition: TRTMaterials.hh:40
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Definition: Transform3D.cc:174
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
G4bool IsReflected(G4LogicalVolume *lv) const
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
static const G4double kRelativePrecision
Double_t scale
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void RotationWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &rot)
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
double x() const
void ScaleWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &scl)
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
static const G4double kLinearPrecision
double y() const
G4ThreeVector GetAngles(const G4RotationMatrix &)
double z() const
void PositionWrite(xercesc::DOMElement *element, const G4String &name, const G4ThreeVector &pos)
CLHEP::HepRotation getRotation() const
static const G4double pos
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReplicavolWrite()

void G4GDMLWriteStructure::ReplicavolWrite ( xercesc::DOMElement *  volumeElement,
const G4VPhysicalVolume * const  replicavol 
)
protected

Definition at line 178 of file G4GDMLWriteStructure.cc.

180 {
181  EAxis axis = kUndefined;
182  G4int number = 0;
183  G4double width = 0.0;
184  G4double offset = 0.0;
185  G4bool consuming = false;
186  G4String unitString("mm");
187 
188  replicavol->GetReplicationData(axis,number,width,offset,consuming);
189 
190  const G4String volumeref
191  = GenerateName(replicavol->GetLogicalVolume()->GetName(),
192  replicavol->GetLogicalVolume());
193 
194  xercesc::DOMElement* replicavolElement = NewElement("replicavol");
195  replicavolElement->setAttributeNode(NewAttribute("number",number));
196  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
197  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
198  replicavolElement->appendChild(volumerefElement);
199  xercesc::DOMElement* replicateElement = NewElement("replicate_along_axis");
200  replicavolElement->appendChild(replicateElement);
201 
202  xercesc::DOMElement* dirElement = NewElement("direction");
203  if(axis==kXAxis)
204  { dirElement->setAttributeNode(NewAttribute("x","1")); }
205  else if(axis==kYAxis)
206  { dirElement->setAttributeNode(NewAttribute("y","1")); }
207  else if(axis==kZAxis)
208  { dirElement->setAttributeNode(NewAttribute("z","1")); }
209  else if(axis==kRho)
210  { dirElement->setAttributeNode(NewAttribute("rho","1")); }
211  else if(axis==kPhi)
212  { dirElement->setAttributeNode(NewAttribute("phi","1"));
213  unitString="rad"; }
214  replicateElement->appendChild(dirElement);
215 
216  xercesc::DOMElement* widthElement = NewElement("width");
217  widthElement->setAttributeNode(NewAttribute("value",width));
218  widthElement->setAttributeNode(NewAttribute("unit",unitString));
219  replicateElement->appendChild(widthElement);
220 
221  xercesc::DOMElement* offsetElement = NewElement("offset");
222  offsetElement->setAttributeNode(NewAttribute("value",offset));
223  offsetElement->setAttributeNode(NewAttribute("unit",unitString));
224  replicateElement->appendChild(offsetElement);
225 
226  volumeElement->appendChild(replicavolElement);
227 }
Definition: geomdefs.hh:54
#define width
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
EAxis
Definition: geomdefs.hh:54
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54
G4LogicalVolume * GetLogicalVolume() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEnergyCutsExport()

void G4GDMLWriteStructure::SetEnergyCutsExport ( G4bool  fcuts)

Definition at line 571 of file G4GDMLWriteStructure.cc.

572 {
573  cexport = fcuts;
574 }

◆ SkinSurfaceCache()

void G4GDMLWriteStructure::SkinSurfaceCache ( const G4LogicalSkinSurface * const  ssurf)
protected

Definition at line 271 of file G4GDMLWriteStructure.cc.

272 {
273  if (!ssurf) { return; }
274 
275  const G4SurfaceProperty* psurf = ssurf->GetSurfaceProperty();
276 
277  // Generate the new element for border-surface
278  //
279  xercesc::DOMElement* skinElement = NewElement("skinsurface");
280  skinElement->setAttributeNode(NewAttribute("name", ssurf->GetName()));
281  skinElement->setAttributeNode(NewAttribute("surfaceproperty",
282  psurf->GetName()));
283 
284  const G4String volumeref = GenerateName(ssurf->GetLogicalVolume()->GetName(),
285  ssurf->GetLogicalVolume());
286  xercesc::DOMElement* volumerefElement = NewElement("volumeref");
287  volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
288  skinElement->appendChild(volumerefElement);
289 
290  if (FindOpticalSurface(psurf))
291  {
292  const G4OpticalSurface* opsurf =
293  dynamic_cast<const G4OpticalSurface*>(psurf);
294  if (!opsurf)
295  {
296  G4Exception("G4GDMLWriteStructure::SkinSurfaceCache()",
297  "InvalidSetup", FatalException, "No optical surface found!");
298  return;
299  }
301  }
302 
303  skinElementVec.push_back(skinElement);
304 }
const G4String & GetName() const
const G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
const G4String & GetName() const
void OpticalSurfaceWrite(xercesc::DOMElement *, const G4OpticalSurface *const)
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
G4SurfaceProperty * GetSurfaceProperty() const
std::vector< xercesc::DOMElement * > skinElementVec
xercesc::DOMElement * solidsElement
G4bool FindOpticalSurface(const G4SurfaceProperty *)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StructureWrite()

void G4GDMLWriteStructure::StructureWrite ( xercesc::DOMElement *  gdmlElement)
virtual

Implements G4GDMLWrite.

Definition at line 374 of file G4GDMLWriteStructure.cc.

375 {
376  G4cout << "G4GDML: Writing structure..." << G4endl;
377 
378  structureElement = NewElement("structure");
379  gdmlElement->appendChild(structureElement);
380 }
xercesc::DOMElement * structureElement
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

◆ SurfacesWrite()

void G4GDMLWriteStructure::SurfacesWrite ( )
protectedvirtual

Implements G4GDMLWrite.

Definition at line 359 of file G4GDMLWriteStructure.cc.

360 {
361  G4cout << "G4GDML: Writing surfaces..." << G4endl;
362 
363  std::vector<xercesc::DOMElement*>::const_iterator pos;
364  for (pos = skinElementVec.begin(); pos != skinElementVec.end(); pos++)
365  {
366  structureElement->appendChild(*pos);
367  }
368  for (pos = borderElementVec.begin(); pos != borderElementVec.end(); pos++)
369  {
370  structureElement->appendChild(*pos);
371  }
372 }
xercesc::DOMElement * structureElement
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
std::vector< xercesc::DOMElement * > skinElementVec
static const G4double pos
std::vector< xercesc::DOMElement * > borderElementVec

◆ TraverseVolumeTree()

G4Transform3D G4GDMLWriteStructure::TraverseVolumeTree ( const G4LogicalVolume *const  topVol,
const G4int  depth 
)
protectedvirtual

Implements G4GDMLWrite.

Definition at line 383 of file G4GDMLWriteStructure.cc.

384 {
385  if (VolumeMap().find(volumePtr) != VolumeMap().end())
386  {
387  return VolumeMap()[volumePtr]; // Volume is already processed
388  }
389 
390  G4VSolid* solidPtr = volumePtr->GetSolid();
391  G4Transform3D R,invR;
392  G4int trans=0;
393 
394  std::map<const G4LogicalVolume*, G4GDMLAuxListType>::iterator auxiter;
395 
396  while (true) // Solve possible displacement/reflection
397  { // of the referenced solid!
398  if (trans>maxTransforms)
399  {
400  G4String ErrorMessage = "Referenced solid in volume '"
401  + volumePtr->GetName()
402  + "' was displaced/reflected too many times!";
403  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
404  "InvalidSetup", FatalException, ErrorMessage);
405  }
406 
407  if (G4ReflectedSolid* refl = dynamic_cast<G4ReflectedSolid*>(solidPtr))
408  {
409  R = R*refl->GetTransform3D();
410  solidPtr = refl->GetConstituentMovedSolid();
411  trans++;
412  continue;
413  }
414 
415  if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(solidPtr))
416  {
417  R = R*G4Transform3D(disp->GetObjectRotation(),
418  disp->GetObjectTranslation());
419  solidPtr = disp->GetConstituentMovedSolid();
420  trans++;
421  continue;
422  }
423 
424  break;
425  }
426 
427  //check if it is a reflected volume
428  G4LogicalVolume* tmplv = const_cast<G4LogicalVolume*>(volumePtr);
429 
430  if (reflFactory->IsReflected(tmplv))
431  {
432  tmplv = reflFactory->GetConstituentLV(tmplv);
433  if (VolumeMap().find(tmplv) != VolumeMap().end())
434  {
435  return R; // Volume is already processed
436  }
437  }
438 
439  // Only compute the inverse when necessary!
440  //
441  if (trans>0) { invR = R.inverse(); }
442 
443  const G4String name
444  = GenerateName(tmplv->GetName(), tmplv);
445  const G4String materialref
446  = GenerateName(volumePtr->GetMaterial()->GetName(),
447  volumePtr->GetMaterial());
448  const G4String solidref
449  = GenerateName(solidPtr->GetName(),solidPtr);
450 
451  xercesc::DOMElement* volumeElement = NewElement("volume");
452  volumeElement->setAttributeNode(NewAttribute("name",name));
453  xercesc::DOMElement* materialrefElement = NewElement("materialref");
454  materialrefElement->setAttributeNode(NewAttribute("ref",materialref));
455  volumeElement->appendChild(materialrefElement);
456  xercesc::DOMElement* solidrefElement = NewElement("solidref");
457  solidrefElement->setAttributeNode(NewAttribute("ref",solidref));
458  volumeElement->appendChild(solidrefElement);
459 
460  const G4int daughterCount = volumePtr->GetNoDaughters();
461 
462  for (G4int i=0;i<daughterCount;i++) // Traverse all the children!
463  {
464  const G4VPhysicalVolume* const physvol = volumePtr->GetDaughter(i);
465  const G4String ModuleName = Modularize(physvol,depth);
466 
467  G4Transform3D daughterR;
468 
469  if (ModuleName.empty()) // Check if subtree requested to be
470  { // a separate module!
471  daughterR = TraverseVolumeTree(physvol->GetLogicalVolume(),depth+1);
472  }
473  else
474  {
475  G4GDMLWriteStructure writer;
476  daughterR = writer.Write(ModuleName,physvol->GetLogicalVolume(),
477  SchemaLocation,depth+1);
478  }
479 
480  if (const G4PVDivision* const divisionvol
481  = dynamic_cast<const G4PVDivision*>(physvol)) // Is it division?
482  {
483  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
484  {
485  G4String ErrorMessage = "Division volume in '" + name
486  + "' can not be related to reflected solid!";
487  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
488  "InvalidSetup", FatalException, ErrorMessage);
489  }
490  DivisionvolWrite(volumeElement,divisionvol);
491  } else
492  if (physvol->IsParameterised()) // Is it a paramvol?
493  {
494  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
495  {
496  G4String ErrorMessage = "Parameterised volume in '" + name
497  + "' can not be related to reflected solid!";
498  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
499  "InvalidSetup", FatalException, ErrorMessage);
500  }
501  ParamvolWrite(volumeElement,physvol);
502  } else
503  if (physvol->IsReplicated()) // Is it a replicavol?
504  {
505  if (!G4Transform3D::Identity.isNear(invR*daughterR,kRelativePrecision))
506  {
507  G4String ErrorMessage = "Replica volume in '" + name
508  + "' can not be related to reflected solid!";
509  G4Exception("G4GDMLWriteStructure::TraverseVolumeTree()",
510  "InvalidSetup", FatalException, ErrorMessage);
511  }
512  ReplicavolWrite(volumeElement,physvol);
513  }
514  else // Is it a physvol?
515  {
516  G4RotationMatrix rot;
517  if (physvol->GetFrameRotation() != 0)
518  {
519  rot = *(physvol->GetFrameRotation());
520  }
521  G4Transform3D P(rot,physvol->GetObjectTranslation());
522 
523  PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
524  }
526  }
527 
528  if (cexport) { ExportEnergyCuts(volumePtr); }
529  // Add optional energy cuts
530 
531  // Here write the auxiliary info
532  //
533  auxiter = auxmap.find(volumePtr);
534  if (auxiter != auxmap.end())
535  {
536  AddAuxInfo(&(auxiter->second), volumeElement);
537  }
538 
539  structureElement->appendChild(volumeElement);
540  // Append the volume AFTER traversing the children so that
541  // the order of volumes will be correct!
542 
543  VolumeMap()[tmplv] = R;
544 
545  AddExtension(volumeElement, volumePtr);
546  // Add any possible user defined extension attached to a volume
547 
548  AddMaterial(volumePtr->GetMaterial());
549  // Add the involved materials and solids!
550 
551  AddSolid(solidPtr);
552 
553  SkinSurfaceCache(GetSkinSurface(volumePtr));
554 
555  return R;
556 }
const G4RotationMatrix * GetFrameRotation() const
G4ReflectionFactory * reflFactory
void AddAuxInfo(G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
Definition: G4GDMLWrite.cc:90
G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const topVol, const G4int depth)
xercesc::DOMElement * structureElement
G4String SchemaLocation
Definition: G4GDMLWrite.hh:131
virtual G4bool IsReplicated() const =0
const G4LogicalSkinSurface * GetSkinSurface(const G4LogicalVolume *const)
G4String name
Definition: TRTMaterials.hh:40
void AddMaterial(const G4Material *const)
virtual void ParamvolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const)
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
G4bool IsReflected(G4LogicalVolume *lv) const
int G4int
Definition: G4Types.hh:78
G4String GetName() const
static double P[]
static const G4int maxTransforms
G4String Modularize(const G4VPhysicalVolume *const topvol, const G4int depth)
Definition: G4GDMLWrite.cc:329
G4Transform3D Write(const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
Definition: G4GDMLWrite.cc:166
const G4String & GetName() const
static const G4double kRelativePrecision
HepGeom::Transform3D G4Transform3D
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
G4LogicalVolume * GetConstituentLV(G4LogicalVolume *reflLV) const
void BorderSurfaceCache(const G4LogicalBorderSurface *const)
G4ThreeVector GetObjectTranslation() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4bool IsParameterised() const =0
void ReplicavolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const)
void PhysvolWrite(xercesc::DOMElement *, const G4VPhysicalVolume *const topVol, const G4Transform3D &transform, const G4String &moduleName)
std::map< const G4LogicalVolume *, G4GDMLAuxListType > auxmap
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
void SkinSurfaceCache(const G4LogicalSkinSurface *const)
const G4LogicalBorderSurface * GetBorderSurface(const G4VPhysicalVolume *const)
virtual void AddExtension(xercesc::DOMElement *, const G4LogicalVolume *const)
Definition: G4GDMLWrite.cc:78
G4LogicalVolume * GetLogicalVolume() const
void DivisionvolWrite(xercesc::DOMElement *, const G4PVDivision *const)
void ExportEnergyCuts(const G4LogicalVolume *const)
VolumeMapType & VolumeMap()
Definition: G4GDMLWrite.cc:60
static const Transform3D Identity
Definition: Transform3D.h:197
virtual void AddSolid(const G4VSolid *const)
Transform3D inverse() const
Definition: Transform3D.cc:142
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ auxmap

std::map<const G4LogicalVolume*, G4GDMLAuxListType> G4GDMLWriteStructure::auxmap
protected

Definition at line 90 of file G4GDMLWriteStructure.hh.

◆ borderElementVec

std::vector<xercesc::DOMElement*> G4GDMLWriteStructure::borderElementVec
protected

Definition at line 88 of file G4GDMLWriteStructure.hh.

◆ cexport

G4bool G4GDMLWriteStructure::cexport
private

Definition at line 96 of file G4GDMLWriteStructure.hh.

◆ opt_vec

std::vector<const G4OpticalSurface*> G4GDMLWriteStructure::opt_vec
private

Definition at line 94 of file G4GDMLWriteStructure.hh.

◆ reflFactory

G4ReflectionFactory* G4GDMLWriteStructure::reflFactory
private

Definition at line 95 of file G4GDMLWriteStructure.hh.

◆ skinElementVec

std::vector<xercesc::DOMElement*> G4GDMLWriteStructure::skinElementVec
protected

Definition at line 89 of file G4GDMLWriteStructure.hh.

◆ structureElement

xercesc::DOMElement* G4GDMLWriteStructure::structureElement
protected

Definition at line 87 of file G4GDMLWriteStructure.hh.


The documentation for this class was generated from the following files: