Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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$
28//
29//
30// class G4tgrVolumeDivision
31
32// History:
33// - Created. P.Arce, CIEMAT (November 2007)
34// -------------------------------------------------------------------------
35
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
47G4mmss G4tgrVolumeDivision::theSupportedAxis;
48
49
50//-------------------------------------------------------------
52{
53}
54
55
56//-------------------------------------------------------------
57G4tgrVolumeDivision::G4tgrVolumeDivision( const std::vector<G4String>& wl )
58{
59 // wl: NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET
60
62 "G4tgrVolumeDivision::G4tgrVolumeDivision" );
64 "G4tgrVolumeDivision::G4tgrVolumeDivision" );
65
66 theType = "VOLDivision";
67
68 // :DIV NAME PARENT MATERIAL AXIS STEP/NDIV OFFSET
69
70 //---------- set name
72
73 //---------- set the pointer to the parent DU
74 G4String parentName = G4tgrUtils::GetString(wl[2]);
75 G4tgrVolumeMgr::GetInstance()->FindVolume( parentName, 1); // check existance
76
77 //---------- initialize G4tgrPlace
78 thePlaceDiv = new G4tgrPlaceDivRep();
79 thePlaceDiv->SetParentName( parentName );
80 thePlaceDiv->SetType("PlaceDivision");
81 thePlaceDiv->SetVolume( this );
82
83 //---------- set material name
85
86 //----- set axis of replica
87 thePlaceDiv->SetAxis( thePlaceDiv->BuildAxis(G4tgrUtils::GetString(wl[4])) );
88
89 //------ register parent - child
90 G4tgrVolumeMgr::GetInstance()->RegisterParentChild( parentName, thePlaceDiv );
91#ifdef G4VERBOSE
93 {
94 G4cout << " G4tgrVolumeDivision::G4tgrVolumeDivision() -"
95 << " Replica register parent - child " << G4endl;
96 }
97#endif
98
99 //---------- set if division is given by number of divisions of by width
100 G4String wl0 = wl[0];
101 for( size_t ii = 0; ii < wl0.length(); ii++ )
102 {
103 wl0[ii] = toupper( wl0[ii] );
104 }
105
106 if( wl0 == ":DIV_NDIV" )
107 {
108 thePlaceDiv->SetDivType( DivByNdiv );
109 thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
110 if( wl.size() == 7 )
111 {
112 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
113 }
114 }
115 else if( wl0 == ":DIV_WIDTH" )
116 {
117 thePlaceDiv->SetDivType( DivByWidth );
118 thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[5] )*mm );
119 if( wl.size() == 7 )
120 {
121 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[6] )*mm );
122 }
123 }
124 else if( wl0 == ":DIV_NDIV_WIDTH" )
125 {
126 thePlaceDiv->SetDivType( DivByNdivAndWidth );
127 thePlaceDiv->SetNDiv( G4tgrUtils::GetInt( wl[5] ) );
128 thePlaceDiv->SetWidth( G4tgrUtils::GetDouble( wl[6] )*mm );
129 if( wl.size() == 8 )
130 {
131 thePlaceDiv->SetOffset( G4tgrUtils::GetDouble( wl[7] )*mm );
132 }
133 }
134 else
135 {
136 G4String ErrMessage = "Division type not supported, sorry... " + wl[0];
137 G4Exception("G4tgrVolumeDivision::G4tgrVolumeDivision()",
138 "NotImplemented", FatalException, ErrMessage);
139 }
140
141 theVisibility = 1;
142 theRGBColour = new G4double[3];
143 for(size_t ii=0; ii<3; ii++) { theRGBColour[ii] = -1.; }
144
145#ifdef G4VERBOSE
147 {
148 G4cout << " Created " << *this << G4endl;
149 }
150#endif
151
152 theSolid = 0;
153}
154
155
156// -------------------------------------------------------------------------
157std::ostream& operator<<(std::ostream& os, const G4tgrVolumeDivision& obj)
158{
159 os << "G4tgrVolumeDivision= " << obj.theName
160 << " Placement= " << *(obj.thePlaceDiv) << G4endl;
161
162 return os;
163}
@ FatalException
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
@ DivByNdiv
@ DivByWidth
@ DivByNdivAndWidth
@ WLSIZE_GE
Definition: G4tgrUtils.hh:52
@ WLSIZE_LE
Definition: G4tgrUtils.hh:52
std::ostream & operator<<(std::ostream &os, const G4tgrVolumeDivision &obj)
std::multimap< G4String, G4String > G4mmss
static G4int GetVerboseLevel()
void SetDivType(G4DivType typ)
void SetParentName(const G4String &parentName)
void SetAxis(EAxis axis)
void SetNDiv(G4int ndiv)
void SetWidth(G4double width)
void SetOffset(G4double offset)
EAxis BuildAxis(const G4String &axisName)
void SetType(const G4String &typ)
Definition: G4tgrPlace.hh:63
void SetVolume(G4tgrVolume *vol)
Definition: G4tgrPlace.hh:62
static G4String GetString(const G4String &str)
Definition: G4tgrUtils.cc:178
static void CheckWLsize(const std::vector< G4String > &wl, unsigned int nWCheck, WLSIZEtype st, const G4String &methodName)
Definition: G4tgrUtils.cc:472
static G4int GetInt(const G4String &str)
Definition: G4tgrUtils.cc:427
static G4double GetDouble(const G4String &str, G4double unitval=1.)
Definition: G4tgrUtils.cc:203
G4tgrVolumeDivision(const std::vector< G4String > &wl)
G4tgrVolume * FindVolume(const G4String &volname, G4bool exists=false)
void RegisterParentChild(const G4String &parentName, const G4tgrPlace *pl)
static G4tgrVolumeMgr * GetInstance()
G4String theMaterialName
Definition: G4tgrVolume.hh:112
G4String theType
Definition: G4tgrVolume.hh:110
G4String theName
Definition: G4tgrVolume.hh:108
G4tgrSolid * theSolid
Definition: G4tgrVolume.hh:114
G4bool theVisibility
Definition: G4tgrVolume.hh:119
G4double * theRGBColour
Definition: G4tgrVolume.hh:120
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41