83G4tgbGeometryDumper::G4tgbGeometryDumper()
84 : theFile(0), theRotationNumber(0)
91 if( theInstance == 0 ){
102 theFile =
new std::ofstream(fname);
112 G4PhysicalVolumeStore::const_iterator ite;
117 if( lv == 0 ) {
break; }
120 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
156 G4bool bVolExists = CheckIfLogVolExists( lv->
GetName(), lv );
195 std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren( lv );
196 std::vector<G4VPhysicalVolume*>::const_iterator ite;
197 for( ite = pvChildren.begin(); ite != pvChildren.end(); ite++ )
222 G4cout <<
" G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
233 colx.
y(),coly.
y(),colz.
y(),
234 colx.
z(),coly.
z(),colz.
z());
252 if( !CheckIfPhysVolExists(fullname, pv ))
256 << SubstituteRefl(AddQuotes(lvName))
257 <<
" " << copyNo <<
" "
259 <<
" " << AddQuotes(rotName) <<
" "
260 << pos.
x() <<
" " << pos.
y() <<
" " << pos.
z() <<
G4endl;
262 thePhysVols[fullname] = pv;
285 std::vector<G4double> newParams;
289 for(
G4int ii = 0; ii < nReplicas; ii++ )
376 if( ii == 0 || mate1st != newMate || params1st[0] != newParams[0] )
384 lvName =
DumpLogVol( lv, extraName, newSolid, newMate );
423 G4String ErrMessage =
"Unknown axis of replication for volume"
433 if( !CheckIfPhysVolExists(fullname, pv ))
437 << SubstituteRefl(AddQuotes(lvName))
445 <<
" " << offset <<
G4endl;
450 <<
" " << width/deg <<
"*deg"
451 <<
" " << offset/deg <<
"*deg" <<
G4endl;
454 thePhysVols[fullname] = pv;
466 if( extraName ==
"" )
468 lvName = GetObjectName(lv,theLogVols);
472 lvName = lv->
GetName()+extraName;
475 if( theLogVols.find( lvName ) != theLogVols.end() )
480 if( !solid ) { solid = lv->
GetSolid(); }
490 (*theFile) <<
":VOLU " << SubstituteRefl(AddQuotes(lvName)) <<
" "
491 << SupressRefl(AddQuotes(solidName))
492 <<
" " << AddQuotes(mateName) <<
G4endl;
494 theLogVols[lvName] = lv;
503 G4String mateName = GetObjectName(mat,theMaterials);
504 if( theMaterials.find( mateName ) != theMaterials.end() )
515 if (numElements == 1)
517 (*theFile) <<
":MATE " << AddQuotes(mateName) <<
" "
518 << mat->
GetZ() <<
" " << mat->
GetA()/(g/mole) <<
" "
525 for (
size_t ii = 0; ii < numElements; ii++)
530 (*theFile) <<
":MIXT "<< AddQuotes(mateName) <<
" "
531 << density <<
" " << numElements <<
G4endl;
533 for (
size_t ii = 0; ii < numElements; ii++)
536 << AddQuotes(GetObjectName((*elems)[ii],theElements)) <<
" "
537 << fractions[ii] <<
G4endl;
542 (*theFile) <<
":MATE_MEE " << AddQuotes(mateName) <<
" "
546 (*theFile) <<
":MATE_TEMPERATURE " << AddQuotes(mateName) <<
" "
549 (*theFile) <<
":MATE_PRESSURE " << AddQuotes(mateName) <<
" "
556 stateStr =
"Undefined";
569 (*theFile) <<
":MATE_STATE " << AddQuotes(mateName) <<
" "
572 theMaterials[mateName] = mat;
581 G4String elemName = GetObjectName(ele,theElements);
583 if( theElements.find( elemName ) != theElements.end() )
592 if( symbol ==
"" || symbol ==
" " )
599 (*theFile) <<
":ELEM " << AddQuotes(elemName) <<
" "
600 << AddQuotes(symbol) <<
" " << ele->
GetZ() <<
" "
611 (*theFile) <<
":ELEM_FROM_ISOT " << AddQuotes(elemName) <<
" "
618 << AddQuotes(GetObjectName((*isots)[ii],theIsotopes)) <<
" "
619 << fractions[ii] <<
G4endl;
622 theElements[elemName] = ele;
629 G4String isotName = GetObjectName(isot,theIsotopes);
630 if( theIsotopes.find( isotName ) != theIsotopes.end() )
635 (*theFile) <<
":ISOT " << AddQuotes(isotName) <<
" "
636 << isot->
GetZ() <<
" " << isot->
GetN() <<
" "
639 theIsotopes[isotName] = isot;
648 if( extraName ==
"" )
650 solidName = GetObjectName(solid,theSolids);
654 solidName = solid->
GetName()+extraName;
657 if( theSolids.find( solidName ) != theSolids.end() )
663 solidType = GetTGSolidType( solidType );
665 if (solidType ==
"UNIONSOLID")
669 }
else if (solidType ==
"SUBTRACTIONSOLID") {
672 }
else if (solidType ==
"INTERSECTIONSOLID") {
675 }
else if (solidType ==
"REFLECTEDSOLID") {
688 (*theFile) <<
":SOLID " << AddQuotes(solidName) <<
" ";
689 (*theFile) << AddQuotes(solidType) <<
" ";
691 theSolids[solidName] = solid;
703 if (!bso) {
return; }
722 GetTransform().NetRotation()).inverse() ) );
730 G4String bsoName = GetObjectName(so,theSolids);
731 if( theSolids.find( bsoName ) != theSolids.end() )
return;
732 G4String solid0Name = FindSolidName( solid0 );
733 G4String solid1Name = FindSolidName( solid1 );
735 (*theFile) <<
":SOLID "
736 << AddQuotes(bsoName) <<
" "
737 << AddQuotes(solidType) <<
" "
738 << AddQuotes(solid0Name) <<
" "
739 << AddQuotes(solid1Name) <<
" "
740 << AddQuotes(rotName) <<
" "
741 << approxTo0(pos.
x()) <<
" "
742 << approxTo0(pos.
y()) <<
" "
743 << approxTo0(pos.
z()) <<
" " <<
G4endl;
745 theSolids[bsoName] = bso;
753 for(
size_t ii = 0 ; ii < params.size(); ii++ )
755 (*theFile) << params[ii] <<
" " ;
764 std::vector<G4double> params;
767 solidType = GetTGSolidType( solidType );
769 if (solidType ==
"BOX") {
770 const G4Box * sb =
dynamic_cast < const G4Box*
>(so);
776 }
else if (solidType ==
"TUBS") {
777 const G4Tubs * tu =
dynamic_cast < const G4Tubs *
> (so);
785 }
else if (solidType ==
"TRAP") {
786 const G4Trap * trp =
dynamic_cast < const G4Trap *
> (so);
792 params.push_back( theta );
793 params.push_back( phi);
803 }
else if (solidType ==
"TRD") {
804 const G4Trd * tr =
dynamic_cast < const G4Trd *
> (so);
812 }
else if (solidType ==
"PARA") {
813 const G4Para * para =
dynamic_cast < const G4Para *
> (so);
821 params.push_back( std::atan(para->
GetTanAlpha())/deg);
822 params.push_back( std::acos(para->
GetSymAxis().
z())/deg);
823 params.push_back( phi/deg);
825 }
else if (solidType ==
"CONS") {
826 const G4Cons * cn =
dynamic_cast < const G4Cons *
> (so);
836 }
else if (solidType ==
"SPHERE") {
846 }
else if (solidType ==
"ORB") {
847 const G4Orb * orb =
dynamic_cast < const G4Orb *
> (so);
851 }
else if (solidType ==
"TORUS") {
854 params.push_back( torus->
GetRmin());
855 params.push_back( torus->
GetRmax());
856 params.push_back( torus->
GetRtor());
857 params.push_back( torus->
GetSPhi()/deg);
858 params.push_back( torus->
GetDPhi()/deg);
860 }
else if (solidType ==
"POLYCONE") {
866 if( angphi > 180*deg ) { angphi -= 360*deg; }
868 params.push_back( angphi );
870 params.push_back( ncor );
872 for(
G4int ii = 0; ii < ncor; ii++ )
878 }
else if (solidType ==
"POLYHEDRA") {
884 if( angphi > 180*deg ) angphi -= 360*deg;
888 params.push_back( angphi );
891 params.push_back( ncor );
893 for(
G4int ii = 0; ii < ncor; ii++ )
899 }
else if (solidType ==
"ELLIPTICALTUBE") {
903 params.push_back( eltu->
GetDx());
904 params.push_back( eltu->
GetDy());
905 params.push_back( eltu->
GetDz());
907 }
else if (solidType ==
"ELLIPSOID" ){
916 }
else if (solidType ==
"ELLIPTICAL_CONE") {
920 params.push_back( elco-> GetSemiAxisX() );
921 params.push_back( elco-> GetSemiAxisY() );
922 params.push_back( elco-> GetZMax() );
923 params.push_back( elco-> GetZTopCut() );
925 }
else if (solidType ==
"HYPE") {
926 const G4Hype* hype =
dynamic_cast < const G4Hype *
> (so);
936 }
else if( solidType ==
"TWISTEDBOX" ) {
944 }
else if( solidType ==
"TWISTEDTRAP" ) {
959 }
else if( solidType ==
"TWISTEDTRD" ) {
969 }
else if( solidType ==
"TWISTEDTUBS" ) {
975 params.push_back( ttub->
GetDPhi()/deg );
981 G4String ErrMessage =
"Solid type not supported, sorry... " + solidType;
982 G4Exception(
"G4tgbGeometryDumpe::DumpSolidParams()",
996 G4String rotName = LookForExistingRotation( rotm );
997 if( rotName !=
"" ) {
return rotName; }
1002 (*theFile) <<
":ROTM ";
1006 (*theFile) << AddQuotes(rotName) << std::setprecision(9) <<
" "
1007 << approxTo0(rotm->
xx()) <<
" "
1008 << approxTo0(rotm->
yx()) <<
" "
1009 << approxTo0(rotm->
zx()) <<
" "
1010 << approxTo0(rotm->
xy()) <<
" "
1011 << approxTo0(rotm->
yy()) <<
" "
1012 << approxTo0(rotm->
zy()) <<
" "
1013 << approxTo0(rotm->
xz()) <<
" "
1014 << approxTo0(rotm->
yz()) <<
" "
1015 << approxTo0(rotm->
zz()) <<
G4endl;
1019 (*theFile) <<
":ROTM ";
1023 (*theFile) << AddQuotes(rotName) <<
" "
1024 << approxTo0(rotm->
thetaX()/deg) <<
" "
1025 << approxTo0(rotm->
phiX()/deg) <<
" "
1026 << approxTo0(rotm->
thetaY()/deg) <<
" "
1027 << approxTo0(rotm->
phiY()/deg) <<
" "
1028 << approxTo0(rotm->
thetaZ()/deg) <<
" "
1032 theRotMats[rotName] = rotm;
1039std::vector<G4VPhysicalVolume*>
1043 G4PhysicalVolumeStore::const_iterator ite;
1044 std::vector<G4VPhysicalVolume*> children;
1045 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
1047 if( (*ite)->GetMotherLogical() == lv )
1049 children.push_back( *ite );
1053 G4cout <<
" G4tgbGeometryDumper::GetPVChildren() - adding children: "
1067 G4String newsolidType = solidType.substr(2,solidType.length() );
1068 for(
size_t ii = 0; ii < newsolidType.length(); ii++ )
1070 newsolidType[ii] = toupper(newsolidType[ii] );
1072 return newsolidType;
1092 if( std::fabs(val) < precision ) { val = 0; }
1103 size_t siz = str.length();
1104 for(
size_t ii = 0; ii < siz; ii++ )
1106 if( str.substr(ii,1) ==
" " )
1124 G4int irefl = name.rfind(
"_refl");
1127 name = name.substr( 0, irefl );
1135 G4int irefl = name.rfind(
"_refl");
1138 name = name.substr( 0, irefl ) +
"_REFL";
1151 std::map<G4String,G4Isotope*>::const_iterator ite;
1152 for( ite = theIsotopes.begin(); ite != theIsotopes.end(); ite++ )
1154 if( isot == (*ite).second ) {
return (*ite).
first; }
1160 ite = theIsotopes.find( isotName );
1161 if( ite != theIsotopes.end() )
1164 if( isot != isotold )
1166 if( !Same2G4Isotopes(isot, isotold))
1172 G4String newIsotName = isotName +
"_"
1174 std::map<G4String,G4Isotope*>::const_iterator ite2 =
1175 theIsotopes.find( newIsotName );
1176 if( ite2 == theIsotopes.end() )
1178 isotName = newIsotName;
1183 if( Same2G4Isotopes( isot, (*ite2).second ) )
1185 isotName = newIsotName;
1198template<
class TYP >
G4String G4tgbGeometryDumper::
1199GetObjectName( TYP* obj, std::map<G4String,TYP*> objectsDumped )
1206 typename std::map<G4String,TYP*>::const_iterator ite;
1207 for( ite = objectsDumped.begin(); ite != objectsDumped.end(); ite++ )
1209 if( obj == (*ite).second ) {
return (*ite).
first; }
1215 ite = objectsDumped.find( objName );
1217 if( ite != objectsDumped.end() )
1219 TYP* objold = (*ite).second;
1226 typename std::map<G4String,TYP*>::const_iterator ite2 =
1227 objectsDumped.find( newObjName );
1228 if( ite2 == objectsDumped.end() )
1230 objName = newObjName;
1241G4bool G4tgbGeometryDumper::CheckIfLogVolExists(
const G4String& name,
1244 if( theLogVols.find( name ) != theLogVols.end() )
1271G4bool G4tgbGeometryDumper::CheckIfPhysVolExists(
const G4String& name,
1277 G4cout <<
" G4tgbGeometryDumper::CheckIfPhysVolExists() - "
1281 if( thePhysVols.find( name ) != thePhysVols.end() )
1283 if( (*(thePhysVols.find(name))).second != pt )
1289 G4cerr <<
" G4tgbGeometryDumper::CheckIfPhysVolExists () -"
1290 <<
" Placement found but not same as before : " << name <<
G4endl;
1303G4tgbGeometryDumper::LookForExistingRotation(
const G4RotationMatrix* rotm )
1307 std::map<G4String,G4RotationMatrix*>::const_iterator ite;
1308 for( ite = theRotMats.begin(); ite != theRotMats.end(); ite++ )
1310 if( (*ite).second->isNear( *rotm ) )
1312 rmName = (*ite).
first;
1324 if ( (isot1->
GetZ() != isot2->
GetZ())
1325 || (isot1->
GetN() != isot2->
GetN())
1326 || (isot1->
GetA() != isot2->
GetA()) )
1340 std::map<G4String,G4VSolid*>::const_iterator ite;
1341 for( ite = theSolids.begin(); ite != theSolids.end(); ite++ )
1343 if( solid == (*ite).second ) {
return (*ite).
first; }
1346 if( ite == theSolids.end() )
1348 G4Exception(
"G4tgbGeometryDumper::FindSolidName()",
"ReadError",
1351 return (*ite).first;
std::vector< G4Element * > G4ElementVector
std::vector< G4Isotope * > G4IsotopeVector
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
HepRotation inverse() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double GetOuterRadiusPlusZ() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
G4VSolid * GetConstituentMovedSolid() const
G4ThreeVector GetObjectTranslation() const
const G4String & GetSymbol() const
G4double * GetRelativeAbundanceVector() const
size_t GetNumberOfIsotopes() const
G4IsotopeVector * GetIsotopeVector() const
G4double GetSemiAxisMax(G4int i) const
G4double GetZTopCut() const
G4double GetZBottomCut() const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetInnerStereo() const
G4double GetZHalfLength() const
G4double GetOuterStereo() const
G4double GetOuterRadius() const
G4double GetInnerRadius() const
G4double GetMeanExcitationEnergy() const
const G4String & GetName() const
G4VSolid * GetSolid() const
G4Material * GetMaterial() const
G4double GetPressure() const
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
G4double GetTemperature() const
const G4double * GetFractionVector() const
G4IonisParamMat * GetIonisation() const
size_t GetNumberOfElements() const
G4double GetRadius() const
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4VPVParameterisation * GetParameterisation() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4double GetTanAlpha() const
G4ThreeVector GetSymAxis() const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
static G4PhysicalVolumeStore * GetInstance()
G4double GetStartPhi() const
G4PolyconeHistorical * GetOriginalParameters() const
G4int GetNumRZCorner() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4int GetNumRZCorner() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
G4double GetStartPhi() const
G4VSolid * GetConstituentMovedSolid() const
G4bool IsReflected(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaThetaAngle() const
G4double GetStartThetaAngle() const
G4double GetYHalfLength1() const
G4double GetTanAlpha2() const
G4double GetXHalfLength2() const
G4ThreeVector GetSymAxis() const
G4double GetXHalfLength4() const
G4double GetZHalfLength() const
G4double GetYHalfLength2() const
G4double GetTanAlpha1() const
G4double GetXHalfLength3() const
G4double GetXHalfLength1() const
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetPhiTwist() const
G4double GetXHalfLength() const
G4double GetZHalfLength() const
G4double GetYHalfLength() const
G4double GetPolarAngleTheta() const
G4double GetAzimuthalAnglePhi() const
G4double GetTiltAngleAlpha() const
G4double GetZHalfLength() const
G4double GetX1HalfLength() const
G4double GetX2HalfLength() const
G4double GetX3HalfLength() const
G4double GetX4HalfLength() const
G4double GetY2HalfLength() const
G4double GetPhiTwist() const
G4double GetY1HalfLength() const
G4double GetX2HalfLength() const
G4double GetY2HalfLength() const
G4double GetY1HalfLength() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetX1HalfLength() const
G4double GetOuterRadius() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetInnerRadius() const
static G4String ConvertToString(G4bool boolVal)
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4LogicalVolume * GetMotherLogical() const
virtual G4bool IsReplicated() const =0
const G4RotationMatrix * GetRotation() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
const G4ThreeVector & GetTranslation() const
virtual G4bool IsParameterised() const =0
virtual G4GeometryType GetEntityType() const =0
static G4tgbGeometryDumper * GetInstance()
G4String DumpLogVol(G4LogicalVolume *lv, G4String extraName="", G4VSolid *solid=0, G4Material *mate=0)
void DumpIsotope(G4Isotope *ele)
void DumpGeometry(const G4String &fname)
void DumpPhysVol(G4VPhysicalVolume *pv)
G4String DumpRotationMatrix(G4RotationMatrix *rotm)
void DumpBooleanVolume(const G4String &solidType, G4VSolid *so)
G4String DumpMaterial(G4Material *mat)
void DumpPVReplica(G4PVReplica *pv, const G4String &lvName)
void DumpPVParameterised(G4PVParameterised *pv)
G4VPhysicalVolume * GetTopPhysVol()
G4String DumpSolid(G4VSolid *solid, const G4String &extraName="")
void DumpElement(G4Element *ele)
void DumpSolidParams(G4VSolid *so)
void DumpPVPlacement(G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)
std::vector< G4double > GetSolidParams(const G4VSolid *so)
static G4int GetVerboseLevel()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)