84 G4tgbGeometryDumper::G4tgbGeometryDumper()
85 : theFile(0), theRotationNumber(0)
92 if( theInstance == 0 ){
103 theFile =
new std::ofstream(fname);
113 G4PhysicalVolumeStore::const_iterator ite;
118 if( lv == 0 ) {
break; }
121 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
157 G4bool bVolExists = CheckIfLogVolExists( lv->
GetName(), lv );
196 std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren( lv );
197 std::vector<G4VPhysicalVolume*>::const_iterator ite;
198 for( ite = pvChildren.begin(); ite != pvChildren.end(); ite++ )
223 G4cout <<
" G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
234 colx.
y(),coly.
y(),colz.
y(),
235 colx.
z(),coly.
z(),colz.
z());
238 *rotMat = (*rotMat).inverse();
253 if( !CheckIfPhysVolExists(fullname, pv ))
257 << SubstituteRefl(AddQuotes(lvName))
258 <<
" " << copyNo <<
" "
260 <<
" " << AddQuotes(rotName) <<
" "
261 << pos.
x() <<
" " << pos.
y() <<
" " << pos.
z() <<
G4endl;
263 thePhysVols[fullname] = pv;
286 std::vector<G4double> newParams;
290 for(
G4int ii = 0; ii < nReplicas; ii++ )
377 if( ii == 0 || mate1st != newMate || params1st[0] != newParams[0] )
385 lvName =
DumpLogVol( lv, extraName, newSolid, newMate );
424 G4String ErrMessage =
"Unknown axis of replication for volume"
434 if( !CheckIfPhysVolExists(fullname, pv ))
438 << SubstituteRefl(AddQuotes(lvName))
446 <<
" " << offset <<
G4endl;
451 <<
" " << width/
deg <<
"*deg"
452 <<
" " << offset/
deg <<
"*deg" <<
G4endl;
455 thePhysVols[fullname] = pv;
467 if( extraName ==
"" )
469 lvName = GetObjectName(lv,theLogVols);
473 lvName = lv->
GetName()+extraName;
476 if( theLogVols.find( lvName ) != theLogVols.end() )
481 if( !solid ) { solid = lv->
GetSolid(); }
491 (*theFile) <<
":VOLU " << SubstituteRefl(AddQuotes(lvName)) <<
" "
492 << SupressRefl(AddQuotes(solidName))
493 <<
" " << AddQuotes(mateName) <<
G4endl;
495 theLogVols[lvName] = lv;
504 G4String mateName = GetObjectName(mat,theMaterials);
505 if( theMaterials.find( mateName ) != theMaterials.end() )
516 if (numElements == 1)
518 (*theFile) <<
":MATE " << AddQuotes(mateName) <<
" "
526 for (
size_t ii = 0; ii < numElements; ii++)
531 (*theFile) <<
":MIXT "<< AddQuotes(mateName) <<
" "
532 << density <<
" " << numElements <<
G4endl;
534 for (
size_t ii = 0; ii < numElements; ii++)
537 << AddQuotes(GetObjectName((*elems)[ii],theElements)) <<
" "
538 << fractions[ii] <<
G4endl;
543 (*theFile) <<
":MATE_MEE " << AddQuotes(mateName) <<
" "
547 (*theFile) <<
":MATE_TEMPERATURE " << AddQuotes(mateName) <<
" "
550 (*theFile) <<
":MATE_PRESSURE " << AddQuotes(mateName) <<
" "
557 stateStr =
"Undefined";
570 (*theFile) <<
":MATE_STATE " << AddQuotes(mateName) <<
" "
573 theMaterials[mateName] =
mat;
582 G4String elemName = GetObjectName(ele,theElements);
584 if( theElements.find( elemName ) != theElements.end() )
593 if( symbol ==
"" || symbol ==
" " )
600 (*theFile) <<
":ELEM " << AddQuotes(elemName) <<
" "
601 << AddQuotes(symbol) <<
" " << ele->
GetZ() <<
" "
612 (*theFile) <<
":ELEM_FROM_ISOT " << AddQuotes(elemName) <<
" "
619 << AddQuotes(GetObjectName((*isots)[ii],theIsotopes)) <<
" "
620 << fractions[ii] <<
G4endl;
623 theElements[elemName] = ele;
630 G4String isotName = GetObjectName(isot,theIsotopes);
631 if( theIsotopes.find( isotName ) != theIsotopes.end() )
636 (*theFile) <<
":ISOT " << AddQuotes(isotName) <<
" "
637 << isot->
GetZ() <<
" " << isot->
GetN() <<
" "
640 theIsotopes[isotName] = isot;
649 if( extraName ==
"" )
651 solidName = GetObjectName(solid,theSolids);
655 solidName = solid->
GetName()+extraName;
658 if( theSolids.find( solidName ) != theSolids.end() )
664 solidType = GetTGSolidType( solidType );
666 if (solidType ==
"UNIONSOLID")
670 }
else if (solidType ==
"SUBTRACTIONSOLID") {
673 }
else if (solidType ==
"INTERSECTIONSOLID") {
676 }
else if (solidType ==
"REFLECTEDSOLID") {
689 (*theFile) <<
":SOLID " << AddQuotes(solidName) <<
" ";
690 (*theFile) << AddQuotes(solidType) <<
" ";
692 theSolids[solidName] = solid;
704 if (!bso) {
return; }
723 GetTransform().NetRotation()).inverse() ) );
731 G4String bsoName = GetObjectName(so,theSolids);
732 if( theSolids.find( bsoName ) != theSolids.end() )
return;
733 G4String solid0Name = FindSolidName( solid0 );
734 G4String solid1Name = FindSolidName( solid1 );
736 (*theFile) <<
":SOLID "
737 << AddQuotes(bsoName) <<
" "
738 << AddQuotes(solidType) <<
" "
739 << AddQuotes(solid0Name) <<
" "
740 << AddQuotes(solid1Name) <<
" "
741 << AddQuotes(rotName) <<
" "
742 << approxTo0(pos.
x()) <<
" "
743 << approxTo0(pos.
y()) <<
" "
744 << approxTo0(pos.
z()) <<
" " <<
G4endl;
746 theSolids[bsoName] = bso;
754 for(
size_t ii = 0 ; ii < params.size(); ii++ )
756 (*theFile) << params[ii] <<
" " ;
765 std::vector<G4double> params;
768 solidType = GetTGSolidType( solidType );
770 if (solidType ==
"BOX") {
771 const G4Box * sb = dynamic_cast <
const G4Box*>(so);
777 }
else if (solidType ==
"TUBS") {
778 const G4Tubs * tu = dynamic_cast <
const G4Tubs * > (so);
786 }
else if (solidType ==
"TRAP") {
787 const G4Trap * trp = dynamic_cast <
const G4Trap * > (so);
793 params.push_back( theta );
794 params.push_back( phi);
804 }
else if (solidType ==
"TRD") {
805 const G4Trd * tr = dynamic_cast <
const G4Trd * > (so);
813 }
else if (solidType ==
"PARA") {
814 const G4Para * para = dynamic_cast <
const G4Para * > (so);
824 params.push_back( phi/
deg);
826 }
else if (solidType ==
"CONS") {
827 const G4Cons * cn = dynamic_cast <
const G4Cons * > (so);
837 }
else if (solidType ==
"SPHERE") {
847 }
else if (solidType ==
"ORB") {
848 const G4Orb * orb = dynamic_cast <
const G4Orb * > (so);
852 }
else if (solidType ==
"TORUS") {
855 params.push_back( torus->
GetRmin());
856 params.push_back( torus->
GetRmax());
857 params.push_back( torus->
GetRtor());
861 }
else if (solidType ==
"POLYCONE") {
867 if( angphi > 180*
deg ) { angphi -= 360*
deg; }
869 params.push_back( angphi );
871 params.push_back( ncor );
873 for(
G4int ii = 0; ii < ncor; ii++ )
879 }
else if (solidType ==
"GENERICPOLYCONE") {
885 if( angphi > 180*
deg ) { angphi -= 360*
deg; }
887 if( endphi > 180*
deg ) { endphi -= 360*
deg; }
889 params.push_back( angphi );
890 params.push_back( endphi-angphi );
891 params.push_back( ncor );
893 for(
G4int ii = 0; ii < ncor; ii++ )
899 }
else if (solidType ==
"POLYHEDRA") {
905 if( angphi > 180*
deg ) angphi -= 360*
deg;
909 params.push_back( angphi );
912 params.push_back( ncor );
914 for(
G4int ii = 0; ii < ncor; ii++ )
920 }
else if (solidType ==
"ELLIPTICALTUBE") {
924 params.push_back( eltu->
GetDx());
925 params.push_back( eltu->
GetDy());
926 params.push_back( eltu->
GetDz());
928 }
else if (solidType ==
"ELLIPSOID" ){
937 }
else if (solidType ==
"ELLIPTICAL_CONE") {
941 params.push_back( elco-> GetSemiAxisX() );
942 params.push_back( elco-> GetSemiAxisY() );
943 params.push_back( elco-> GetZMax() );
944 params.push_back( elco-> GetZTopCut() );
946 }
else if (solidType ==
"HYPE") {
947 const G4Hype* hype = dynamic_cast <
const G4Hype * > (so);
957 }
else if( solidType ==
"TWISTEDBOX" ) {
965 }
else if( solidType ==
"TWISTEDTRAP" ) {
980 }
else if( solidType ==
"TWISTEDTRD" ) {
990 }
else if( solidType ==
"TWISTEDTUBS" ) {
1002 G4String ErrMessage =
"Solid type not supported, sorry... " + solidType;
1003 G4Exception(
"G4tgbGeometryDumpe::DumpSolidParams()",
1016 G4double de = MatDeterminant(rotm);
1017 G4String rotName = LookForExistingRotation( rotm );
1018 if( rotName !=
"" ) {
return rotName; }
1023 (*theFile) <<
":ROTM ";
1027 (*theFile) << AddQuotes(rotName) << std::setprecision(9) <<
" "
1028 << approxTo0(rotm->
xx()) <<
" "
1029 << approxTo0(rotm->
yx()) <<
" "
1030 << approxTo0(rotm->
zx()) <<
" "
1031 << approxTo0(rotm->
xy()) <<
" "
1032 << approxTo0(rotm->
yy()) <<
" "
1033 << approxTo0(rotm->
zy()) <<
" "
1034 << approxTo0(rotm->
xz()) <<
" "
1035 << approxTo0(rotm->
yz()) <<
" "
1036 << approxTo0(rotm->
zz()) <<
G4endl;
1040 (*theFile) <<
":ROTM ";
1044 (*theFile) << AddQuotes(rotName) <<
" "
1046 << approxTo0(rotm->
phiX()/
deg) <<
" "
1048 << approxTo0(rotm->
phiY()/
deg) <<
" "
1053 theRotMats[rotName] = rotm;
1060 std::vector<G4VPhysicalVolume*>
1064 G4PhysicalVolumeStore::const_iterator ite;
1065 std::vector<G4VPhysicalVolume*> children;
1066 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
1068 if( (*ite)->GetMotherLogical() == lv )
1070 children.push_back( *ite );
1074 G4cout <<
" G4tgbGeometryDumper::GetPVChildren() - adding children: "
1088 G4String newsolidType = solidType.substr(2,solidType.length() );
1089 for(
size_t ii = 0; ii < newsolidType.length(); ii++ )
1091 newsolidType[ii] = toupper(newsolidType[ii] );
1093 return newsolidType;
1113 if( std::fabs(val) < precision ) { val = 0; }
1124 size_t siz = str.length();
1125 for(
size_t ii = 0; ii < siz; ii++ )
1127 if( str.substr(ii,1) ==
" " )
1145 G4int irefl = name.rfind(
"_refl");
1148 name = name.substr( 0, irefl );
1156 G4int irefl = name.rfind(
"_refl");
1159 name = name.substr( 0, irefl ) +
"_REFL";
1172 std::map<G4String,G4Isotope*>::const_iterator ite;
1173 for( ite = theIsotopes.begin(); ite != theIsotopes.end(); ite++ )
1175 if( isot == (*ite).second ) {
return (*ite).
first; }
1181 ite = theIsotopes.find( isotName );
1182 if( ite != theIsotopes.end() )
1185 if( isot != isotold )
1187 if( !Same2G4Isotopes(isot, isotold))
1193 G4String newIsotName = isotName +
"_"
1195 std::map<G4String,G4Isotope*>::const_iterator ite2 =
1196 theIsotopes.find( newIsotName );
1197 if( ite2 == theIsotopes.end() )
1199 isotName = newIsotName;
1204 if( Same2G4Isotopes( isot, (*ite2).second ) )
1206 isotName = newIsotName;
1219 template<
class TYP >
G4String G4tgbGeometryDumper::
1220 GetObjectName( TYP* obj, std::map<G4String,TYP*> objectsDumped )
1227 typename std::map<G4String,TYP*>::const_iterator ite;
1228 for( ite = objectsDumped.begin(); ite != objectsDumped.end(); ite++ )
1230 if( obj == (*ite).second ) {
return (*ite).
first; }
1236 ite = objectsDumped.find( objName );
1238 if( ite != objectsDumped.end() )
1240 TYP* objold = (*ite).second;
1247 typename std::map<G4String,TYP*>::const_iterator ite2 =
1248 objectsDumped.find( newObjName );
1249 if( ite2 == objectsDumped.end() )
1251 objName = newObjName;
1262 G4bool G4tgbGeometryDumper::CheckIfLogVolExists(
const G4String& name,
1265 if( theLogVols.find( name ) != theLogVols.end() )
1292 G4bool G4tgbGeometryDumper::CheckIfPhysVolExists(
const G4String& name,
1298 G4cout <<
" G4tgbGeometryDumper::CheckIfPhysVolExists() - "
1302 if( thePhysVols.find( name ) != thePhysVols.end() )
1304 if( (*(thePhysVols.find(name))).second !=
pt )
1310 G4cerr <<
" G4tgbGeometryDumper::CheckIfPhysVolExists () -"
1311 <<
" Placement found but not same as before : " << name <<
G4endl;
1324 G4tgbGeometryDumper::LookForExistingRotation(
const G4RotationMatrix* rotm )
1328 std::map<G4String,G4RotationMatrix*>::const_iterator ite;
1329 for( ite = theRotMats.begin(); ite != theRotMats.end(); ite++ )
1331 if( (*ite).second->isNear( *rotm ) )
1333 rmName = (*ite).
first;
1345 if ( (isot1->
GetZ() != isot2->
GetZ())
1346 || (isot1->
GetN() != isot2->
GetN())
1347 || (isot1->
GetA() != isot2->
GetA()) )
1361 std::map<G4String,G4VSolid*>::const_iterator ite;
1362 for( ite = theSolids.begin(); ite != theSolids.end(); ite++ )
1364 if( solid == (*ite).second ) {
return (*ite).
first; }
1367 if( ite == theSolids.end() )
1369 G4Exception(
"G4tgbGeometryDumper::FindSolidName()",
"ReadError",
1372 return (*ite).first;
G4ThreeVector GetSymAxis() const
G4double GetPressure() const
size_t GetNumberOfIsotopes() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetXHalfLength4() const
G4IonisParamMat * GetIonisation() const
G4double GetXHalfLength() const
G4double GetOuterStereo() const
G4double GetX1HalfLength() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
std::vector< G4Isotope * > G4IsotopeVector
G4double GetY1HalfLength() const
G4double GetPolarAngleTheta() const
const G4String & GetName() const
G4double GetYHalfLength2() const
const G4ThreeVector & GetTranslation() const
std::vector< G4Element * > G4ElementVector
G4double GetYHalfLength1() const
G4double GetInnerStereo() const
CLHEP::Hep3Vector G4ThreeVector
G4double GetInnerRadius() const
CLHEP::HepRotation G4RotationMatrix
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
void DumpIsotope(G4Isotope *ele)
virtual G4bool IsReplicated() const =0
G4String DumpMaterial(G4Material *mat)
G4Material * GetMaterial() const
const G4String & GetSymbol() const
G4int GetNumRZCorner() const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
void DumpSolidParams(G4VSolid *so)
G4double GetZTopCut() const
G4double GetZHalfLength() const
G4double GetSurfaceTolerance() const
G4double GetZHalfLength() const
G4double GetDensity() const
static G4String ConvertToString(G4bool boolVal)
G4double GetZBottomCut() const
G4double GetOuterRadiusMinusZ() const
G4double GetX2HalfLength() const
G4double GetInnerRadius() const
virtual G4GeometryType GetEntityType() const =0
G4double GetZHalfLength() const
G4double GetDeltaPhiAngle() const
const G4ElementVector * GetElementVector() const
G4double GetZHalfLength() const
G4double GetSemiAxisMax(G4int i) const
G4bool IsReflected(G4LogicalVolume *lv) const
G4ThreeVector GetObjectTranslation() const
G4double GetXHalfLength2() const
static G4ReflectionFactory * Instance()
G4double GetZHalfLength() const
G4double GetZHalfLength() const
void DumpPVReplica(G4PVReplica *pv, const G4String &lvName)
G4double GetEndPhi() const
G4double GetTanAlpha2() const
G4int GetNumRZCorner() const
void DumpPhysVol(G4VPhysicalVolume *pv)
G4double GetPhiTwist() const
static G4PhysicalVolumeStore * GetInstance()
G4double GetY1HalfLength() const
G4double GetXHalfLength2() const
G4double GetRadius() const
void DumpGeometry(const G4String &fname)
G4VPVParameterisation * GetParameterisation() const
G4double GetXHalfLength1() const
G4GLOB_DLL std::ostream G4cout
G4double GetDeltaPhiAngle() const
G4double GetStartThetaAngle() const
const G4String & GetName() const
G4double GetXHalfLength3() const
static G4int GetVerboseLevel()
G4double GetY2HalfLength() const
G4double GetX3HalfLength() const
G4double GetPhiTwist() const
G4double * GetRelativeAbundanceVector() const
G4double GetYHalfLength() const
G4double GetStartPhiAngle() const
G4double GetYHalfLength2() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double GetStartPhi() const
G4double GetInnerRadiusPlusZ() const
G4LogicalVolume * GetMotherLogical() const
G4double GetInnerRadius() const
G4PolyconeHistorical * GetOriginalParameters() const
G4double GetStartPhi() const
G4VSolid * GetConstituentMovedSolid() const
G4double GetXHalfLength() const
G4double GetInnerRadius() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4bool IsParameterised() const =0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetX4HalfLength() const
void DumpPVPlacement(G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)
G4double GetYHalfLength() const
G4IsotopeVector * GetIsotopeVector() const
G4String DumpRotationMatrix(G4RotationMatrix *rotm)
G4double GetZHalfLength() const
G4LogicalVolume * GetLogicalVolume() const
G4double GetTanAlpha() const
void DumpBooleanVolume(const G4String &solidType, G4VSolid *so)
static G4tgbGeometryDumper * GetInstance()
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4VSolid * GetConstituentMovedSolid() const
std::vector< G4double > GetSolidParams(const G4VSolid *so)
void DumpPVParameterised(G4PVParameterised *pv)
G4VPhysicalVolume * GetTopPhysVol()
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual G4int GetCopyNo() const =0
const G4RotationMatrix * GetRotation() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4ThreeVector GetSymAxis() const
G4double GetZHalfLength() const
G4double GetMeanExcitationEnergy() const
G4double GetAzimuthalAnglePhi() const
G4double GetTemperature() const
G4double GetStartPhi() const
G4double GetXHalfLength1() const
size_t GetNumberOfElements() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
G4double GetYHalfLength1() const
G4String DumpSolid(G4VSolid *solid, const G4String &extraName="")
G4double GetPhiTwist() const
G4double GetInnerRadiusMinusZ() const
G4double GetTanAlpha1() const
const G4double * GetFractionVector() const
G4int GetNumRZCorner() const
G4double GetDeltaThetaAngle() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetX1HalfLength() const
G4double GetTiltAngleAlpha() const
G4double GetX2HalfLength() const
G4double GetOuterRadiusPlusZ() const
G4double GetZHalfLength() const
G4double GetOuterRadius() const
G4double GetXHalfLength() const
static G4GeometryTolerance * GetInstance()
G4double GetPhiTwist() const
G4VSolid * GetSolid() const
G4double GetOuterRadius() const
G4GLOB_DLL std::ostream G4cerr
G4String DumpLogVol(G4LogicalVolume *lv, G4String extraName="", G4VSolid *solid=0, G4Material *mate=0)
G4double GetY2HalfLength() const
void DumpElement(G4Element *ele)
G4double GetDeltaPhiAngle() const
G4double GetYHalfLength() const