Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4tgrVolumeDivision.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4tgrVolumeDivision.cc 68052 2013-03-13 14:38:53Z gcosmo $
28 //
29 //
30 // class G4tgrVolumeDivision
31 
32 // History:
33 // - Created. P.Arce, CIEMAT (November 2007)
34 // -------------------------------------------------------------------------
35 
36 #include "G4tgrVolumeDivision.hh"
37 
38 #include "G4SystemOfUnits.hh"
39 #include "G4tgrUtils.hh"
40 #include "G4tgrVolumeMgr.hh"
41 #include "G4tgrPlace.hh"
42 #include "G4tgrFileReader.hh"
43 #include "G4tgrPlaceDivRep.hh"
44 #include "G4tgrMessenger.hh"
45 
46 
47 //-------------------------------------------------------------
49 {
50 }
51 
52 //-------------------------------------------------------------
53 G4tgrVolumeDivision::G4tgrVolumeDivision( const std::vector<G4String>& wl )
54 {
55  // wl: NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET
56 
58  "G4tgrVolumeDivision::G4tgrVolumeDivision" );
60  "G4tgrVolumeDivision::G4tgrVolumeDivision" );
61 
62  theType = "VOLDivision";
63 
64  // :DIV NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET
65 
66  //---------- set name
67  theName = G4tgrUtils::GetString( wl[1] );
68 
69  //---------- set the pointer to the parent DU
70  G4String parentName = G4tgrUtils::GetString(wl[2]);
71  G4tgrVolumeMgr::GetInstance()->FindVolume( parentName, 1); // check existance
72 
73  //---------- initialize G4tgrPlace
74  thePlaceDiv = new G4tgrPlaceDivRep();
75  thePlaceDiv->SetParentName( parentName );
76  thePlaceDiv->SetType("PlaceDivision");
77  thePlaceDiv->SetVolume( this );
78 
79  //---------- set material name
81 
82  //----- set axis of replica
83  thePlaceDiv->SetAxis( thePlaceDiv->BuildAxis(G4tgrUtils::GetString(wl[4])) );
84 
85  //------ register parent - child
86  G4tgrVolumeMgr::GetInstance()->RegisterParentChild( parentName, thePlaceDiv );
87 #ifdef G4VERBOSE
89  {
90  G4cout << " G4tgrVolumeDivision::G4tgrVolumeDivision() -"
91  << " Replica register parent - child " << G4endl;
92  }
93 #endif
94 
95  //---------- set if division is given by number of divisions of by width
96  G4String wl0 = wl[0];
97  for( size_t ii = 0; ii < wl0.length(); ii++ )
98  {
99  wl0[ii] = toupper( wl0[ii] );
100  }
101 
102  if( wl0 == ":DIV_NDIV" )
103  {
104  thePlaceDiv->SetDivType( DivByNdiv );
105  thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
106  if( wl.size() == 7 )
107  {
108  thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
109  }
110  }
111  else if( wl0 == ":DIV_WIDTH" )
112  {
113  thePlaceDiv->SetDivType( DivByWidth );
114  thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[5] )*mm );
115  if( wl.size() == 7 )
116  {
117  thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
118  }
119  }
120  else if( wl0 == ":DIV_NDIV_WIDTH" )
121  {
122  thePlaceDiv->SetDivType( DivByNdivAndWidth );
123  thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
124  thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[6] )*mm );
125  if( wl.size() == 8 )
126  {
127  thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[7] )*mm );
128  }
129  }
130  else
131  {
132  G4String ErrMessage = "Division type not supported, sorry... " + wl[0];
133  G4Exception("G4tgrVolumeDivision::G4tgrVolumeDivision()",
134  "NotImplemented", FatalException, ErrMessage);
135  }
136 
137  theVisibility = 1;
138  theRGBColour = new G4double[3];
139  for(size_t ii=0; ii<3; ii++) { theRGBColour[ii] = -1.; }
140 
141 #ifdef G4VERBOSE
143  {
144  G4cout << " Created " << *this << G4endl;
145  }
146 #endif
147 
148  theSolid = 0;
149 }
150 
151 
152 // -------------------------------------------------------------------------
153 std::ostream& operator<<(std::ostream& os, const G4tgrVolumeDivision& obj)
154 {
155  os << "G4tgrVolumeDivision= " << obj.theName
156  << " Placement= " << *(obj.thePlaceDiv) << G4endl;
157 
158  return os;
159 }
EAxis BuildAxis(const G4String &axisName)
G4tgrVolumeDivision(const std::vector< G4String > &wl)
static constexpr double mm
Definition: G4SIunits.hh:115
G4String theMaterialName
Definition: G4tgrVolume.hh:112
G4bool theVisibility
Definition: G4tgrVolume.hh:119
static void CheckWLsize(const std::vector< G4String > &wl, unsigned int nWCheck, WLSIZEtype st, const G4String &methodName)
Definition: G4tgrUtils.cc:475
void SetOffset(G4double offset)
void SetNDiv(G4int ndiv)
G4String theType
Definition: G4tgrVolume.hh:110
void SetType(const G4String &typ)
Definition: G4tgrPlace.hh:63
G4GLOB_DLL std::ostream G4cout
void SetVolume(G4tgrVolume *vol)
Definition: G4tgrPlace.hh:62
static G4int GetVerboseLevel()
void SetAxis(EAxis axis)
static G4tgrVolumeMgr * GetInstance()
G4tgrSolid * theSolid
Definition: G4tgrVolume.hh:114
G4String theName
Definition: G4tgrVolume.hh:108
void SetDivType(G4DivType typ)
G4tgrVolume * FindVolume(const G4String &volname, G4bool exists=false)
static G4int GetInt(const G4String &str)
Definition: G4tgrUtils.cc:430
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4double GetDouble(const G4String &str, G4double unitval=1.)
Definition: G4tgrUtils.cc:205
void SetWidth(G4double width)
static G4String GetString(const G4String &str)
Definition: G4tgrUtils.cc:180
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
void RegisterParentChild(const G4String &parentName, const G4tgrPlace *pl)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double * theRGBColour
Definition: G4tgrVolume.hh:120
void SetParentName(const G4String &parentName)