00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4tgrVolumeDivision.hh"
00037
00038 #include "G4SystemOfUnits.hh"
00039 #include "G4tgrUtils.hh"
00040 #include "G4tgrVolumeMgr.hh"
00041 #include "G4tgrPlace.hh"
00042 #include "G4tgrFileReader.hh"
00043 #include "G4tgrPlaceDivRep.hh"
00044 #include "G4tgrMessenger.hh"
00045
00046
00047
00048 G4tgrVolumeDivision::~G4tgrVolumeDivision()
00049 {
00050 }
00051
00052
00053 G4tgrVolumeDivision::G4tgrVolumeDivision( const std::vector<G4String>& wl )
00054 {
00055
00056
00057 G4tgrUtils::CheckWLsize( wl, 6, WLSIZE_GE,
00058 "G4tgrVolumeDivision::G4tgrVolumeDivision" );
00059 G4tgrUtils::CheckWLsize( wl, 8, WLSIZE_LE,
00060 "G4tgrVolumeDivision::G4tgrVolumeDivision" );
00061
00062 theType = "VOLDivision";
00063
00064
00065
00066
00067 theName = G4tgrUtils::GetString( wl[1] );
00068
00069
00070 G4String parentName = G4tgrUtils::GetString(wl[2]);
00071 G4tgrVolumeMgr::GetInstance()->FindVolume( parentName, 1);
00072
00073
00074 thePlaceDiv = new G4tgrPlaceDivRep();
00075 thePlaceDiv->SetParentName( parentName );
00076 thePlaceDiv->SetType("PlaceDivision");
00077 thePlaceDiv->SetVolume( this );
00078
00079
00080 theMaterialName = G4tgrUtils::GetString( wl[3] );
00081
00082
00083 thePlaceDiv->SetAxis( thePlaceDiv->BuildAxis(G4tgrUtils::GetString(wl[4])) );
00084
00085
00086 G4tgrVolumeMgr::GetInstance()->RegisterParentChild( parentName, thePlaceDiv );
00087 #ifdef G4VERBOSE
00088 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00089 {
00090 G4cout << " G4tgrVolumeDivision::G4tgrVolumeDivision() -"
00091 << " Replica register parent - child " << G4endl;
00092 }
00093 #endif
00094
00095
00096 G4String wl0 = wl[0];
00097 for( size_t ii = 0; ii < wl0.length(); ii++ )
00098 {
00099 wl0[ii] = toupper( wl0[ii] );
00100 }
00101
00102 if( wl0 == ":DIV_NDIV" )
00103 {
00104 thePlaceDiv->SetDivType( DivByNdiv );
00105 thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
00106 if( wl.size() == 7 )
00107 {
00108 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
00109 }
00110 }
00111 else if( wl0 == ":DIV_WIDTH" )
00112 {
00113 thePlaceDiv->SetDivType( DivByWidth );
00114 thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[5] )*mm );
00115 if( wl.size() == 7 )
00116 {
00117 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
00118 }
00119 }
00120 else if( wl0 == ":DIV_NDIV_WIDTH" )
00121 {
00122 thePlaceDiv->SetDivType( DivByNdivAndWidth );
00123 thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
00124 thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[6] )*mm );
00125 if( wl.size() == 8 )
00126 {
00127 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[7] )*mm );
00128 }
00129 }
00130 else
00131 {
00132 G4String ErrMessage = "Division type not supported, sorry... " + wl[0];
00133 G4Exception("G4tgrVolumeDivision::G4tgrVolumeDivision()",
00134 "NotImplemented", FatalException, ErrMessage);
00135 }
00136
00137 theVisibility = 1;
00138 theRGBColour = new G4double[3];
00139 for(size_t ii=0; ii<3; ii++) { theRGBColour[ii] = -1.; }
00140
00141 #ifdef G4VERBOSE
00142 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00143 {
00144 G4cout << " Created " << *this << G4endl;
00145 }
00146 #endif
00147
00148 theSolid = 0;
00149 }
00150
00151
00152
00153 std::ostream& operator<<(std::ostream& os, const G4tgrVolumeDivision& obj)
00154 {
00155 os << "G4tgrVolumeDivision= " << obj.theName
00156 << " Placement= " << *(obj.thePlaceDiv) << G4endl;
00157
00158 return os;
00159 }