86{
91 G4double ourStep=currentProposedStepLength, ourSafety;
93 G4int localNoDaughters, sampleNo;
94
95 G4bool initialNode, noStep;
97 G4int curNoVolumes, contentNo;
99
102 motherSolid = motherLogical->
GetSolid();
103
104
105
106
107
109 ourSafety = motherSafety;
110
111#ifdef G4VERBOSE
113 {
115 }
116#endif
117
118
119
120
121
122
123
124 if ( exiting && validExitNormal )
125 {
126 if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine )
127 {
128
129
130 blockedExitedVol = *pBlockedPhysical;
131 ourSafety = 0;
132 }
133 }
134 exiting = false;
135 entering = false;
136
137
138 G4bool motherValidExitNormal =
false;
140
141#ifdef G4VERBOSE
143 {
144
145
147 localDirection,
148 true,
149 &motherValidExitNormal,
150 &motherExitNormal);
151
153 motherStep, motherSafety);
154
155 if( (motherStep >= kInfinity) || (motherStep < 0.0) )
156 {
157
158
160
161 ourStep = 0.0;
162
163 exiting = true;
164 entering = false;
165
166
167
168
169
170
171 validExitNormal = false;
172
173 *pBlockedPhysical = nullptr;
174 blockedReplicaNo = 0;
175
176 newSafety = 0.0;
177 return ourStep;
178 }
179 }
180#endif
181
183
186
187 initialNode = true;
188 noStep = true;
189
190 while (noStep)
191 {
194 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
195 {
196 sampleNo = curVoxelNode->
GetVolume(contentNo);
198 {
200 samplePhysical = motherLogical->
GetDaughter(sampleNo);
201 if ( samplePhysical!=blockedExitedVol )
202 {
205 sampleTf.Invert();
207 sampleTf.TransformPoint(localPoint);
212
213 if ( sampleSafety<ourSafety )
214 {
215 ourSafety = sampleSafety;
216 }
217 if ( sampleSafety<=ourStep )
218 {
219 sampleDirection = sampleTf.TransformAxis(localDirection);
221 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
222#ifdef G4VERBOSE
224 {
226 sampleSafety, true,
227 sampleDirection, sampleStep);
228 }
229#endif
230 if ( sampleStep<=ourStep )
231 {
232 ourStep = sampleStep;
233 entering = true;
234 exiting = false;
235 *pBlockedPhysical = samplePhysical;
236 blockedReplicaNo = -1;
237#ifdef G4VERBOSE
238
239
241 {
243 sampleDirection, localDirection, sampleSafety, sampleStep);
244 }
245#endif
246 }
247#ifdef G4VERBOSE
248 if (
fCheck && ( sampleStep < kInfinity )
249 && ( sampleStep >= motherStep ) )
250 {
251
252
254 samplePoint, sampleDirection,
255 motherSolid,
256 localPoint, localDirection,
257 motherStep, sampleStep);
258 }
259#endif
260 }
261#ifdef G4VERBOSE
262 else
263 {
265 {
267 sampleSafety, false,
269 }
270 }
271#endif
272 }
273 }
274 }
275 if (initialNode)
276 {
277 initialNode = false;
279 if ( voxelSafety<ourSafety )
280 {
281 ourSafety = voxelSafety;
282 }
283 if ( currentProposedStepLength<ourSafety )
284 {
285
286
287 noStep = false;
288 entering = false;
289 exiting = false;
290 *pBlockedPhysical = nullptr;
291 ourStep = kInfinity;
292 }
293 else
294 {
295
296
297
298 if ( motherSafety<=ourStep )
299 {
301 {
302 motherStep = motherSolid->
DistanceToOut(localPoint, localDirection,
303 true, &motherValidExitNormal, &motherExitNormal);
304 }
305
306
307
308#ifdef G4VERBOSE
309 else
310 {
312 motherStep, motherSafety);
313 if( motherValidExitNormal )
314 {
316 localPoint, localDirection,
317 motherStep, motherSolid,
318 "From motherSolid::DistanceToOut" );
319 }
320 }
321#endif
322 if( (motherStep >= kInfinity) || (motherStep < 0.0) )
323 {
324#ifdef G4VERBOSE
326 {
328 motherPhysical);
329 }
330#endif
331 motherStep = 0.0;
332 ourStep = 0.0;
333 exiting = true;
334 entering = false;
335
336
337
338
339
340 validExitNormal= false;
341
342 *pBlockedPhysical = nullptr;
343 blockedReplicaNo = 0;
344
345 newSafety = 0.0;
346 return ourStep;
347 }
348
349 if ( motherStep<=ourStep )
350 {
351 ourStep = motherStep;
352 exiting = true;
353 entering = false;
354
355
356
357 validExitNormal = motherValidExitNormal;
358 exitNormal = motherExitNormal;
359
360 if ( validExitNormal )
361 {
363 if (rot)
364 {
366#ifdef G4VERBOSE
369 motherExitNormal,
370 *rot,
371 "From RotationMatrix" );
372#endif
373 }
374 }
375 }
376 else
377 {
378 validExitNormal = false;
379 }
380 }
381 }
382 newSafety = ourSafety;
383 }
384 if (noStep)
385 {
387 }
388 }
389
390 return ourStep;
391}
CLHEP::Hep3Vector G4ThreeVector
HepRotation inverse() const
void BlockVolume(const G4int v)
void Enlarge(const G4int nv)
G4bool IsBlocked(const G4int v) const
size_t GetNoDaughters() const
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
void CheckDaughterEntryPoint(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double sampleStep) const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4bool onlySafety, const G4ThreeVector &sampleDirection, G4double sampleStep) const
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) const
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)