G4tgrVolumeAssembly.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: G4tgrVolumeAssembly.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgrVolumeAssembly
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgrVolumeAssembly.hh"
00037 #include "G4tgrUtils.hh"
00038 #include "G4tgrVolumeMgr.hh"
00039 #include "G4tgrPlaceSimple.hh"
00040 #include "G4tgrPlaceDivRep.hh"
00041 #include "G4tgrPlaceParameterisation.hh"
00042 #include "G4tgrFileReader.hh"
00043 #include "G4tgrMessenger.hh"
00044 
00045 //-------------------------------------------------------------
00046 G4tgrVolumeAssembly::G4tgrVolumeAssembly()
00047 {
00048 }
00049 
00050 
00051 //-------------------------------------------------------------
00052 G4tgrVolumeAssembly::~G4tgrVolumeAssembly()
00053 {
00054 }
00055 
00056 
00057 //-------------------------------------------------------------
00058 G4tgrVolumeAssembly::G4tgrVolumeAssembly( const std::vector<G4String>& wl ) 
00059 {
00060   theType = "VOLAssembly";
00061 
00062   //---------- set name 
00063   theName = G4tgrUtils::GetString( wl[1] ); 
00064 
00065   G4int nVol = G4tgrUtils::GetInt( wl[2] ); 
00066 
00067   G4tgrUtils::CheckWLsize( wl, 3+nVol*5, WLSIZE_GE,
00068                            "G4tgrVolumeAssembly::G4tgrVolumeAssembly" );
00069 
00070 
00071   for(G4int ii=0; ii<nVol*5; ii+=5)
00072   {
00073 #ifdef G4VERBOSE
00074     if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00075     {
00076          G4cout << " G4tgrVolumeAssembly::G4tgrVolumeAssembly() -"
00077                 << " Adding component: " << ii << " - " << wl[ii+3] << G4endl;
00078     }
00079 #endif
00080     theComponentNames.push_back(G4tgrUtils::GetString( wl[3+ii+0]));
00081     theComponentRMs.push_back(G4tgrUtils::GetString( wl[3+ii+1]));
00082     theComponentPos.push_back(G4ThreeVector(G4tgrUtils::GetDouble(wl[3+ii+2]),
00083                                             G4tgrUtils::GetDouble(wl[3+ii+3]),
00084                                             G4tgrUtils::GetDouble(wl[3+ii+4])));
00085   }
00086   theVisibility = 1;
00087   theRGBColour = new G4double[4];
00088   for (size_t ii=0; ii<4; ii++)  { theRGBColour[ii] = -1.; }
00089 
00090   theSolid = 0;
00091 
00092 #ifdef G4VERBOSE
00093   if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00094   {
00095      G4cout << " Created " << *this << G4endl;
00096   }
00097 #endif
00098 
00099 }
00100 
00101 
00102 //-------------------------------------------------------------------------
00103 G4tgrPlace* G4tgrVolumeAssembly::AddPlace( const std::vector<G4String>& wl )
00104 {
00105   //---------- Check for exact number of words read 
00106   G4tgrUtils::CheckWLsize( wl, 7, WLSIZE_EQ, " G4tgrVolumeAssembly::AddPlace");
00107 
00108   //---------- set G4tgrPlace 
00109   G4tgrPlaceSimple* pl = new G4tgrPlaceSimple( wl );
00110 
00111   pl->SetVolume( this );
00112   thePlacements.push_back( pl ); 
00113 
00114 #ifdef G4VERBOSE
00115   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00116   {
00117     G4cout << "   New placement: " << thePlacements.size()
00118            << " added for Volume " << theName
00119            << " inside " << pl->GetParentName()
00120            << " type " << pl->GetType() << G4endl;
00121   }
00122 #endif
00123   //---------- register parent - child 
00124   G4tgrVolumeMgr::GetInstance()->RegisterParentChild( pl->GetParentName(), pl );
00125 
00126   return pl;
00127 }
00128 
00129 
00130 // -------------------------------------------------------------------------
00131 std::ostream& operator<<(std::ostream& os, const G4tgrVolumeAssembly& obj)
00132 {
00133   os << "G4tgrVolumeAssembly= " << obj.theName;
00134 
00135   for( size_t ii = 0; ii < obj.theComponentNames.size(); ii++ )
00136   {
00137     os << obj.theComponentNames[ii] << " RotMatName= "
00138        << obj.theComponentRMs[ii] << " Position= "
00139        << obj.theComponentPos[ii].x() << " "
00140        << obj.theComponentPos[ii].y() << " "
00141        << obj.theComponentPos[ii].z();
00142   }
00143   os << G4endl;
00144 
00145   return os;
00146 }

Generated on Mon May 27 17:49:59 2013 for Geant4 by  doxygen 1.4.7