G4tgrVolumeDivision.cc

Go to the documentation of this file.
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: G4tgrVolumeDivision.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgrVolumeDivision
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
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   // wl: NAME PARENT  MATERIAL AXIS STEP/NDIV OFFSET
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   // :DIV  NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET
00065 
00066   //---------- set name 
00067   theName = G4tgrUtils::GetString( wl[1] ); 
00068   
00069   //---------- set the pointer to the parent DU
00070   G4String parentName = G4tgrUtils::GetString(wl[2]);
00071   G4tgrVolumeMgr::GetInstance()->FindVolume( parentName, 1); // check existance
00072 
00073   //---------- initialize G4tgrPlace
00074   thePlaceDiv = new G4tgrPlaceDivRep();
00075   thePlaceDiv->SetParentName( parentName );
00076   thePlaceDiv->SetType("PlaceDivision");
00077   thePlaceDiv->SetVolume( this ); 
00078 
00079   //---------- set material name
00080   theMaterialName = G4tgrUtils::GetString( wl[3] );
00081  
00082   //----- set axis of replica
00083   thePlaceDiv->SetAxis( thePlaceDiv->BuildAxis(G4tgrUtils::GetString(wl[4])) ); 
00084 
00085   //------ register parent - child 
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   //---------- set if division is given by number of divisions of by width
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 }

Generated on Mon May 27 17:50:00 2013 for Geant4 by  doxygen 1.4.7