00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4tgrSolidBoolean.cc 69803 2013-05-15 15:24:50Z gcosmo $ 00028 // 00029 // 00030 // class G4tgrSolidBoolean 00031 00032 // History: 00033 // - Created. P.Arce, CIEMAT (November 2007) 00034 // ------------------------------------------------------------------------- 00035 00036 #include "G4tgrSolidBoolean.hh" 00037 #include "G4tgrUtils.hh" 00038 #include "G4tgrVolume.hh" 00039 #include "G4tgrVolumeMgr.hh" 00040 #include "G4tgrMessenger.hh" 00041 #include "G4tgrFileReader.hh" 00042 00043 // ------------------------------------------------------------------------- 00044 G4tgrSolidBoolean::G4tgrSolidBoolean( const std::vector<G4String>& wl ) 00045 { 00046 // :SOLID/:VOLU VOLU UNION/SUBS/INTERS VOLU1 VOLU2 ROTM POSX POSY POSZ 00047 00048 if( wl.size() != 9 ) 00049 { 00050 G4tgrUtils::DumpVS(wl, "G4tgrSolidBoolean::G4tgrSolidBoolean()"); 00051 G4Exception("G4tgrSolidBoolean::G4tgrSolidBoolean()", "InvalidInput", 00052 FatalException, "Line read with less or more than 9 words."); 00053 } 00054 00055 //---------- Set name 00056 theName = G4tgrUtils::GetString( wl[1] ); 00057 00058 G4tgrVolumeMgr* volmgr = G4tgrVolumeMgr::GetInstance(); 00059 const G4tgrSolid* sol1 = volmgr->FindSolid( G4tgrUtils::GetString( wl[3] )); 00060 if( !sol1 ) 00061 { 00062 sol1 = volmgr->FindVolume( G4tgrUtils::GetString( wl[3] ), 1)->GetSolid(); 00063 } 00064 const G4tgrSolid* sol2 = volmgr->FindSolid( G4tgrUtils::GetString( wl[4] )); 00065 if( !sol2 ) 00066 { 00067 sol2 = volmgr->FindVolume( G4tgrUtils::GetString( wl[4] ), 1)->GetSolid(); 00068 } 00069 theSolids.push_back( sol1 ); 00070 theSolids.push_back( sol2 ); 00071 00072 //---------- Set relative placement and rotation matrix 00073 theRelativeRotMatName = G4tgrUtils::GetString( wl[5] ); 00074 theRelativePlace = G4ThreeVector( G4tgrUtils::GetDouble(wl[6]), 00075 G4tgrUtils::GetDouble(wl[7]), 00076 G4tgrUtils::GetDouble(wl[8]) ); 00077 //---------- Set solid type 00078 G4String wl2 = wl[2]; 00079 for( size_t ii = 0; ii < wl2.length(); ii++ ) 00080 { 00081 wl2[ii] = toupper( wl2[ii] ); 00082 } 00083 theType = "Boolean_" + wl2; 00084 00085 #ifdef G4VERBOSE 00086 if( G4tgrMessenger::GetVerboseLevel() >= 1 ) 00087 { 00088 G4cout << " Created " << *this << G4endl; 00089 } 00090 #endif 00091 00092 G4tgrVolumeMgr::GetInstance()->RegisterMe( this ); 00093 } 00094 00095 00096 // ------------------------------------------------------------------------- 00097 G4tgrSolidBoolean::~G4tgrSolidBoolean() 00098 { 00099 } 00100 00101 00102 // ------------------------------------------------------------------------- 00103 const G4String& G4tgrSolidBoolean::GetRelativeRotMatName() const 00104 { 00105 return theRelativeRotMatName; 00106 } 00107 00108 00109 // ------------------------------------------------------------------------- 00110 G4ThreeVector G4tgrSolidBoolean::GetRelativePlace() const 00111 { 00112 return theRelativePlace; 00113 } 00114 00115 00116 // ------------------------------------------------------------------------- 00117 std::ostream& operator<<(std::ostream& os, const G4tgrSolidBoolean& sol) 00118 { 00119 os << "G4tgrSolidBoolean= " << sol.theName << " of type " << sol.theType 00120 << " PARAMS: "; 00121 if( sol.theSolidParams.size() != 0 ) 00122 { 00123 std::vector<G4double> solpar = *(sol.theSolidParams[0]); 00124 for( size_t ii = 0; ii < solpar.size(); ii++) 00125 { 00126 os << solpar[ii] << " " ; 00127 } 00128 } 00129 os << G4endl; 00130 00131 return os; 00132 }