Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4tgrVolume.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// G4tgrVolume implementation
27//
28// Author: P.Arce, CIEMAT (November 2007)
29// --------------------------------------------------------------------
30
31#include "G4tgrVolume.hh"
32#include "G4tgrUtils.hh"
33#include "G4tgrSolid.hh"
34#include "G4tgrVolumeMgr.hh"
35#include "G4tgrPlace.hh"
36#include "G4tgrPlaceSimple.hh"
37#include "G4tgrPlaceDivRep.hh"
39#include "G4tgrFileReader.hh"
40#include "G4tgrMessenger.hh"
41#include "G4UIcommand.hh"
42
43// --------------------------------------------------------------------
47
48// --------------------------------------------------------------------
53
54// --------------------------------------------------------------------
55G4tgrVolume::G4tgrVolume(const std::vector<G4String>& wl)
56{
57 theType = "VOLSimple";
58
59 //---------- set name
61
62 theVisibility = true;
63 theRGBColour = new G4double[4];
64 for(std::size_t ii = 0; ii < 4; ++ii)
65 {
66 theRGBColour[ii] = -1.;
67 }
68 theCheckOverlaps = false;
69
70 if(wl.size() != 4)
71 {
72 //:VOLU tag to build a volume creating solid and material
73 //---------- set material name
74 theMaterialName = G4tgrUtils::GetString(wl[wl.size() - 1]);
75
76 //---------- create only vector<double> of theSolidParams
78
79#ifdef G4VERBOSE
81 {
82 G4cout << "Created from new solid: " << *this << G4endl;
83 }
84#endif
85 }
86 else
87 {
88 //:VOLU tag to build a volume assigning material to solid
89 //---------- set material name
92
93#ifdef G4VERBOSE
95 {
96 G4cout << "Created from existing solid: " << *this << G4endl;
97 }
98#endif
99 }
100}
101
102// --------------------------------------------------------------------
114
115// --------------------------------------------------------------------
117{
118 G4String ErrMessage = "Should only be called for composite solids... " +
120 G4Exception("G4tgrVolume::GetVolume()", "InvalidCall", FatalException,
121 ErrMessage);
122 return nullptr;
123}
124
125// --------------------------------------------------------------------
126G4tgrPlace* G4tgrVolume::AddPlace(const std::vector<G4String>& wl)
127{
128 //---------- Check for exact number of words read
129 G4tgrUtils::CheckWLsize(wl, 8, WLSIZE_EQ, " G4tgrVolume::AddPlace");
130 //---------- set G4tgrPlace
132 //---------- check that there is no previous placement in
133 // the same parent with the same copyNo
134 for(auto ite = thePlacements.cbegin(); ite != thePlacements.cend(); ++ite)
135 {
136 if(((*ite)->GetCopyNo() == pl->GetCopyNo()) &&
137 ((*ite)->GetParentName() == pl->GetParentName()))
138 {
139 G4String ErrMessage =
140 "Repeated placement. Volume " + theName + " in " + pl->GetParentName();
141 G4Exception("G4tgrVolume::AddPlace()", "InvalidArgument",
142 FatalErrorInArgument, ErrMessage);
143 }
144 }
145
146 pl->SetVolume(this);
147 thePlacements.push_back(pl);
148
149#ifdef G4VERBOSE
151 {
152 G4cout << " G4tgrVolume: New placement: " << thePlacements.size()
153 << " added for Volume " << theName << " inside "
154 << pl->GetParentName() << " type " << pl->GetType() << G4endl;
155 }
156#endif
157 //---------- register parent - child
159
160 return pl;
161}
162
163// --------------------------------------------------------------------
164G4tgrPlaceDivRep* G4tgrVolume::AddPlaceReplica(const std::vector<G4String>& wl)
165{
166 //---------- Check for exact number of words read
167 G4tgrUtils::CheckWLsize(wl, 6, WLSIZE_GE, " G4tgrVolume::AddPlaceReplica");
168 G4tgrUtils::CheckWLsize(wl, 7, WLSIZE_LE, " G4tgrVolume::AddPlaceReplica");
169
170 if((wl.size() == 7) && (G4tgrUtils::GetDouble(wl[6]) != 0.) &&
171 (wl[3] != "PHI"))
172 {
173 G4Exception("G4tgrVolume::AddPlaceReplica",
174 "Offset set for replica not along PHI, it will not be used",
176 G4String("Volume " + wl[1] + " in volume " + wl[2]).c_str());
177 }
178
179 //---------- set G4tgrPlace
181 pl->SetType("PlaceReplica");
182 pl->SetVolume(this);
183 thePlacements.push_back(pl);
184
185#ifdef G4VERBOSE
187 {
188 G4cout << " G4tgrVolume: New placement replica: " << thePlacements.size()
189 << " added for Volume " << theName << " inside "
190 << pl->GetParentName() << G4endl;
191 }
192#endif
193 //---------- register parent - child
195
196 return pl;
197}
198
199// --------------------------------------------------------------------
201G4tgrVolume::AddPlaceParam(const std::vector<G4String>& wl)
202{
203 //---------- set G4tgrPlaceParameterisation
205
206 pl->SetVolume(this);
207 thePlacements.push_back(pl);
208
209#ifdef G4VERBOSE
211 {
212 G4cout << " G4tgrVolume: New placement Param: " << thePlacements.size()
213 << " added for Volume " << theName << " inside "
214 << pl->GetParentName() << G4endl;
215 }
216#endif
217 //---------- register parent - child
219
220 return pl;
221}
222
223// --------------------------------------------------------------------
224void G4tgrVolume::AddVisibility(const std::vector<G4String>& wl)
225{
226 //---------- Check for exact number of words read
227 G4tgrUtils::CheckWLsize(wl, 3, WLSIZE_EQ, " G4tgrVolume::AddVisibility");
228
229 //---------- Set visibility
231}
232
233// --------------------------------------------------------------------
234void G4tgrVolume::AddRGBColour(const std::vector<G4String>& wl)
235{
236 //---------- Check for exact number of words read
237 G4tgrUtils::CheckWLsize(wl, 5, WLSIZE_GE, " G4tgrVolume::AddRGBColour");
238
239 //---------- Set RGB colour
243 ///--------- Set transparency
244 if(wl.size() == 6)
245 {
247 }
248}
249
250// --------------------------------------------------------------------
251void G4tgrVolume::AddCheckOverlaps(const std::vector<G4String>& wl)
252{
253 //---------- Check for exact number of words read
254 G4tgrUtils::CheckWLsize(wl, 3, WLSIZE_GE, " G4tgrVolume::AddCheckOverlaps");
255
256 ///--------- Set check overlaps
258}
259
260// --------------------------------------------------------------------
261std::ostream& operator<<(std::ostream& os, const G4tgrVolume& obj)
262{
263 os << "G4tgrVolume= " << obj.theName << " Type= " << obj.theType
264 << " Material= " << obj.theMaterialName << " Visibility "
265 << obj.theVisibility << " Colour " << (obj.theRGBColour)[0] << " "
266 << (obj.theRGBColour)[1] << " " << (obj.theRGBColour)[2] << " "
267 << (obj.theRGBColour)[3] << " "
268 << " CheckOverlaps " << obj.theCheckOverlaps << " N placements "
269 << obj.thePlacements.size() << G4endl;
270
271 return os;
272}
@ JustWarning
@ FatalException
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
@ WLSIZE_EQ
Definition G4tgrUtils.hh:47
@ WLSIZE_GE
Definition G4tgrUtils.hh:51
@ WLSIZE_LE
Definition G4tgrUtils.hh:49
std::ostream & operator<<(std::ostream &os, const G4tgrVolume &obj)
static G4String ConvertToString(G4bool boolVal)
static G4int GetVerboseLevel()
void SetType(const G4String &typ)
Definition G4tgrPlace.hh:57
const G4String & GetParentName() const
Definition G4tgrPlace.hh:52
const G4String & GetType() const
Definition G4tgrPlace.hh:55
unsigned int GetCopyNo() const
Definition G4tgrPlace.hh:54
void SetVolume(G4tgrVolume *vol)
Definition G4tgrPlace.hh:56
static G4String GetString(const G4String &str)
static void CheckWLsize(const std::vector< G4String > &wl, unsigned int nWCheck, WLSIZEtype st, const G4String &methodName)
static G4bool GetBool(const G4String &str)
static G4double GetDouble(const G4String &str, G4double unitval=1.)
G4tgrSolid * FindSolid(const G4String &name, G4bool exists=false)
void RegisterParentChild(const G4String &parentName, const G4tgrPlace *pl)
G4tgrSolid * CreateSolid(const std::vector< G4String > &wl, G4bool bVOLUtag)
static G4tgrVolumeMgr * GetInstance()
G4String theMaterialName
G4bool GetVisibility() const
G4bool GetCheckOverlaps() const
void AddRGBColour(const std::vector< G4String > &wl)
G4bool theCheckOverlaps
G4String theType
G4String theName
virtual G4tgrVolume * GetVolume(G4int ii) const
G4tgrSolid * theSolid
const G4String & GetName() const
virtual G4tgrPlace * AddPlace(const std::vector< G4String > &wl)
G4double * GetRGBColour() const
G4tgrPlaceParameterisation * AddPlaceParam(const std::vector< G4String > &wl)
G4tgrPlaceDivRep * AddPlaceReplica(const std::vector< G4String > &wl)
G4bool theVisibility
G4double * theRGBColour
void AddVisibility(const std::vector< G4String > &wl)
virtual ~G4tgrVolume()
G4tgrSolid * GetSolid() const
const G4String & GetType() const
const G4String & GetMaterialName() const
void AddCheckOverlaps(const std::vector< G4String > &wl)
std::vector< G4tgrPlace * > thePlacements
const std::vector< G4tgrPlace * > GetPlacements() const