BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTunnelFactory.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSDebug.hh"
19#include "BDSGeometryComponent.hh"
20#include "BDSTunnelFactory.hh"
21#include "BDSTunnelFactoryBase.hh"
22#include "BDSTunnelFactoryCircular.hh"
23#include "BDSTunnelFactoryElliptical.hh"
24#include "BDSTunnelFactoryRectangular.hh"
25#include "BDSTunnelFactoryRectAboveGround.hh"
26#include "BDSTunnelFactorySquare.hh"
27#include "BDSTunnelSection.hh"
28#include "BDSTunnelType.hh"
29
30#include "globals.hh" // geant4 globals / types
31
33
40
49
50BDSTunnelFactory::~BDSTunnelFactory()
51{
52 delete circular;
53 delete elliptical;
54 delete rectangular;
55 delete square;
56 delete rectaboveground;
57 instance = nullptr;
58}
59
61{
62 switch (tunnelType.underlying())
63 {
64 case BDSTunnelType::circular:
65 {return circular; break;}
66 case BDSTunnelType::elliptical:
67 {return elliptical; break;}
68 case BDSTunnelType::rectangular:
69 {return rectangular; break;}
70 case BDSTunnelType::square:
71 {return square; break;}
72 case BDSTunnelType::rectaboveground:
73 {return rectaboveground; break;}
74 default:
75 {
76#ifdef BDSDEBUG
77 G4cout << __METHOD_NAME__ << "unknown tunnel type \"" << tunnelType
78 << "\" - using circular tunnel factory by default" << G4endl;
79#endif
80 return circular;
81 break;
82 }
83 }
84}
85
87 G4String name,
88 G4double length,
89 G4double tunnelThickness,
90 G4double tunnelSoilThickness,
91 G4Material* tunnelMaterial,
92 G4Material* tunnelSoilMaterial,
93 G4bool tunnelFloor,
94 G4double tunnelFloorOffset,
95 G4double tunnel1,
96 G4double tunnel2,
97 G4bool visible)
98{
99 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
100 return factory->CreateTunnelSection(name, length, tunnelThickness,
101 tunnelSoilThickness, tunnelMaterial,
102 tunnelSoilMaterial, tunnelFloor,
103 tunnelFloorOffset, tunnel1, tunnel2, visible);
104}
105
107 G4String name,
108 G4double length,
109 G4double angleIn,
110 G4double tunnelThickness,
111 G4double tunnelSoilThickness,
112 G4Material* tunnelMaterial,
113 G4Material* tunnelSoilMaterial,
114 G4bool tunnelFloor,
115 G4double tunnelFloorOffset,
116 G4double tunnel1,
117 G4double tunnel2,
118 G4bool visible)
119{
120 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
121 return factory->CreateTunnelSectionAngledIn(name, length, angleIn, tunnelThickness,
122 tunnelSoilThickness, tunnelMaterial,
123 tunnelSoilMaterial, tunnelFloor,
124 tunnelFloorOffset, tunnel1, tunnel2, visible);
125}
126
128 G4String name,
129 G4double length,
130 G4double angleOut,
131 G4double tunnelThickness,
132 G4double tunnelSoilThickness,
133 G4Material* tunnelMaterial,
134 G4Material* tunnelSoilMaterial,
135 G4bool tunnelFloor,
136 G4double tunnelFloorOffset,
137 G4double tunnel1,
138 G4double tunnel2,
139 G4bool visible)
140{
141 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
142 return factory->CreateTunnelSectionAngledOut(name, length, angleOut, tunnelThickness,
143 tunnelSoilThickness, tunnelMaterial,
144 tunnelSoilMaterial, tunnelFloor,
145 tunnelFloorOffset, tunnel1, tunnel2, visible);
146}
147
149 G4String name,
150 G4double length,
151 G4double angleIn,
152 G4double angleOut,
153 G4double tunnelThickness,
154 G4double tunnelSoilThickness,
155 G4Material* tunnelMaterial,
156 G4Material* tunnelSoilMaterial,
157 G4bool tunnelFloor,
158 G4double tunnelFloorOffset,
159 G4double tunnel1,
160 G4double tunnel2,
161 G4bool visible)
162{
163 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
164 return factory->CreateTunnelSectionAngledInOut(name, length, angleIn, angleOut,
165 tunnelThickness, tunnelSoilThickness, tunnelMaterial,
166 tunnelSoilMaterial, tunnelFloor,
167 tunnelFloorOffset, tunnel1, tunnel2, visible);
168}
169
171 G4String name,
172 G4double length,
173 G4ThreeVector inputFace,
174 G4ThreeVector outputFace,
175 G4double tunnelThickness,
176 G4double tunnelSoilThickness,
177 G4Material* tunnelMaterial,
178 G4Material* tunnelSoilMaterial,
179 G4bool tunnelFloor,
180 G4double tunnelFloorOffset,
181 G4double tunnel1,
182 G4double tunnel2,
183 G4bool visible)
184{
185 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
186 return factory->CreateTunnelSectionAngled(name, length, inputFace, outputFace,
187 tunnelThickness, tunnelSoilThickness, tunnelMaterial,
188 tunnelSoilMaterial, tunnelFloor,
189 tunnelFloorOffset, tunnel1, tunnel2, visible);
190}
Abstract base class for tunnel factory classes.
virtual BDSTunnelSection * CreateTunnelSectionAngledInOut(G4String name, G4double length, G4double angleIn, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSectionAngled(G4String name, G4double length, G4ThreeVector inputFaceIn, G4ThreeVector outputFaceIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)=0
Create a tunnel section with an angled input and output face. Pure virtual.
virtual BDSTunnelSection * CreateTunnelSectionAngledIn(G4String name, G4double length, G4double angleIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSectionAngledOut(G4String name, G4double length, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSection(G4String name, G4double length, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)=0
Create a tunnel section with flat input and output faces. Pure virtual.
Factory for circular tunnel segments. Builds floor, tunnel and soil.
Factory for elliptical tunnel segments. Builds floor, tunnel and soil.
Factory for rectangular tunnel segments above ground.
Factory for rectangular tunnel segments. Builds floor, tunnel and soil.
Factory for square tunnel segments. Builds floor, tunnel and soil.
A singleton class that provides an interface to all tunnel factories.
static BDSTunnelFactory * instance
Singleton instance.
BDSTunnelSection * CreateTunnelSectionAngledIn(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelSection * CreateTunnelSectionAngled(BDSTunnelType tunnelType, G4String name, G4double length, G4ThreeVector inputFaceIn, G4ThreeVector outputFaceIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelFactory()
Private constructor as a singleton.
BDSTunnelFactoryBase * rectangular
Factory instance.
BDSTunnelFactoryBase * GetAppropriateFactory(BDSTunnelType tunnelType)
Accessor method to dispatch to appropriate derived factory.
BDSTunnelSection * CreateTunnelSectionAngledOut(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelFactoryBase * circular
Factory instance.
BDSTunnelFactoryBase * square
Factory instance.
BDSTunnelSection * CreateTunnelSection(BDSTunnelType tunnelType, G4String name, G4double length, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
Create a tunnel section with straight input and output face.
static BDSTunnelFactory * Instance()
singleton pattern
BDSTunnelFactoryBase * elliptical
Factory instance.
BDSTunnelSection * CreateTunnelSectionAngledInOut(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleIn, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
Create a tunnel section with an angled input and output face.
BDSTunnelFactoryBase * rectaboveground
Factory instance.
Class that represents a section of tunnel.
type underlying() const
return underlying value (can be used in switch statement)