File indexing completed on 2025-01-18 09:58:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 inline
0043 G4ThreeVector G4ITNavigator2::GetCurrentLocalCoordinate() const
0044 {
0045 CheckNavigatorStateIsValid();
0046 return fpNavigatorState->fLastLocatedPointLocal;
0047 }
0048
0049
0050
0051
0052
0053
0054
0055 inline
0056 G4ThreeVector G4ITNavigator2::ComputeLocalAxis(const G4ThreeVector& pVec) const
0057 {
0058 CheckNavigatorStateIsValid();
0059 return (fpNavigatorState->fHistory.GetTopTransform().IsRotated())
0060 ? fpNavigatorState->fHistory.GetTopTransform().TransformAxis(pVec) : pVec ;
0061 }
0062
0063
0064
0065
0066
0067
0068
0069 inline
0070 G4ThreeVector
0071 G4ITNavigator2::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
0072 {
0073 CheckNavigatorStateIsValid();
0074 return ( fpNavigatorState->fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ;
0075 }
0076
0077
0078
0079
0080
0081
0082
0083 inline
0084 G4VPhysicalVolume* G4ITNavigator2::GetWorldVolume() const
0085 {
0086 return fTopPhysical;
0087 }
0088
0089
0090
0091
0092
0093
0094
0095 inline
0096 void G4ITNavigator2::SetWorldVolume(G4VPhysicalVolume* pWorld)
0097 {
0098 if ( !(pWorld->GetTranslation()==G4ThreeVector(0,0,0)) )
0099 {
0100 G4Exception ("G4ITNavigator2::SetWorldVolume()", "GeomNav0002",
0101 FatalException, "Volume must be centered on the origin.");
0102 }
0103 const G4RotationMatrix* rm = pWorld->GetRotation();
0104 if ( (rm != nullptr) && (!rm->isIdentity()) )
0105 {
0106 G4Exception ("G4ITNavigator2::SetWorldVolume()", "GeomNav0002",
0107 FatalException, "Volume must not be rotated.");
0108 }
0109 fTopPhysical = pWorld;
0110 if(fpNavigatorState != nullptr)
0111 fpNavigatorState->fHistory.SetFirstEntry(pWorld);
0112 }
0113
0114
0115
0116
0117
0118
0119
0120
0121 inline
0122 void G4ITNavigator2::SetGeometricallyLimitedStep()
0123 {
0124 fpNavigatorState->fWasLimitedByGeometry=true;
0125 }
0126
0127
0128
0129
0130
0131
0132
0133 inline
0134 void G4ITNavigator2::ResetStackAndState()
0135 {
0136 fpNavigatorState->fHistory.Reset();
0137 ResetState();
0138 }
0139
0140
0141
0142
0143
0144 inline
0145 EVolume G4ITNavigator2::VolumeType(const G4VPhysicalVolume *pVol) const
0146 {
0147 return pVol->VolumeType();
0148 }
0149
0150
0151
0152
0153
0154 inline
0155 EVolume G4ITNavigator2::CharacteriseDaughters(const G4LogicalVolume *pLog) const
0156 {
0157 return pLog->CharacteriseDaughters();
0158 }
0159
0160 inline std::shared_ptr<G4ITNavigatorState_Lock2> G4ITNavigator2::GetSnapshotOfState()
0161 {
0162 if(fpNavigatorState != nullptr)
0163 {
0164 std::shared_ptr<G4ITNavigatorState_Lock2>
0165 snapShot(new G4NavigatorState(*fpNavigatorState));
0166 return snapShot;
0167 }
0168
0169 return std::shared_ptr<G4ITNavigatorState_Lock2>(nullptr);
0170 }
0171
0172 inline void G4ITNavigator2::ResetFromSnapshot(std::shared_ptr<G4ITNavigatorState_Lock2> snapShot)
0173 {
0174 if((fpNavigatorState != nullptr) && snapShot)
0175 {
0176 *fpNavigatorState = *((G4NavigatorState*) snapShot.get());
0177 }
0178 }
0179
0180
0181
0182
0183
0184 inline
0185 G4int G4ITNavigator2::
0186 GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
0187 {
0188 G4int regId = 0;
0189 G4VPhysicalVolume *pVol;
0190
0191 if ( pLog->GetNoDaughters()==1 )
0192 {
0193 pVol = pLog->GetDaughter(0);
0194 regId = pVol->GetRegularStructureId();
0195 }
0196 return regId;
0197 }
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 inline
0208 const G4AffineTransform& G4ITNavigator2::GetGlobalToLocalTransform() const
0209 {
0210 CheckNavigatorStateIsValid();
0211 return fpNavigatorState->fHistory.GetTopTransform();
0212 }
0213
0214
0215
0216
0217
0218
0219
0220 inline
0221 const G4AffineTransform G4ITNavigator2::GetLocalToGlobalTransform() const
0222 {
0223 CheckNavigatorStateIsValid();
0224 G4AffineTransform tempTransform;
0225 tempTransform = fpNavigatorState->fHistory.GetTopTransform().Inverse();
0226 return tempTransform;
0227 }
0228
0229
0230
0231
0232
0233
0234
0235 inline
0236 G4ThreeVector G4ITNavigator2::NetTranslation() const
0237 {
0238 CheckNavigatorStateIsValid();
0239 G4AffineTransform tf(fpNavigatorState->fHistory.GetTopTransform().Inverse());
0240 return tf.NetTranslation();
0241 }
0242
0243
0244
0245
0246
0247
0248
0249 inline
0250 G4RotationMatrix G4ITNavigator2::NetRotation() const
0251 {
0252 CheckNavigatorStateIsValid();
0253 G4AffineTransform tf(fpNavigatorState->fHistory.GetTopTransform().Inverse());
0254 return tf.NetRotation();
0255 }
0256
0257
0258
0259
0260
0261
0262
0263 inline
0264 G4TouchableHistory* G4ITNavigator2::CreateTouchableHistory() const
0265 {
0266 CheckNavigatorStateIsValid();
0267 return new G4TouchableHistory(fpNavigatorState->fHistory);
0268 }
0269
0270
0271
0272
0273
0274
0275
0276 inline
0277 G4TouchableHistory*
0278 G4ITNavigator2::CreateTouchableHistory(const G4NavigationHistory* history) const
0279 {
0280 return new G4TouchableHistory(*history);
0281 }
0282
0283
0284
0285
0286
0287 inline
0288 void G4ITNavigator2::LocateGlobalPointAndUpdateTouchableHandle(
0289 const G4ThreeVector& position,
0290 const G4ThreeVector& direction,
0291 G4TouchableHandle& oldTouchableToUpdate,
0292 const G4bool RelativeSearch )
0293 {
0294 G4VPhysicalVolume* pPhysVol;
0295 pPhysVol = LocateGlobalPointAndSetup( position,&direction,RelativeSearch );
0296
0297 if( fpNavigatorState->fEnteredDaughter || fpNavigatorState->fExitedMother )
0298 {
0299 oldTouchableToUpdate = CreateTouchableHistory();
0300 if( pPhysVol == nullptr )
0301 {
0302
0303
0304
0305 oldTouchableToUpdate->UpdateYourself( pPhysVol, &fpNavigatorState->fHistory );
0306 }
0307 }
0308 return;
0309 }
0310
0311
0312
0313
0314
0315
0316
0317 inline
0318 void G4ITNavigator2::LocateGlobalPointAndUpdateTouchable(
0319 const G4ThreeVector& position,
0320 const G4ThreeVector& direction,
0321 G4VTouchable* touchableToUpdate,
0322 const G4bool RelativeSearch )
0323 {
0324 G4VPhysicalVolume* pPhysVol;
0325 pPhysVol = LocateGlobalPointAndSetup( position, &direction, RelativeSearch);
0326
0327 touchableToUpdate->UpdateYourself( pPhysVol, &fpNavigatorState->fHistory );
0328 }
0329
0330
0331
0332
0333
0334 inline
0335 void G4ITNavigator2::LocateGlobalPointAndUpdateTouchable(
0336 const G4ThreeVector& position,
0337 G4VTouchable* touchableToUpdate,
0338 const G4bool RelativeSearch )
0339 {
0340 G4VPhysicalVolume* pPhysVol;
0341 pPhysVol = LocateGlobalPointAndSetup( position, nullptr, RelativeSearch);
0342
0343 touchableToUpdate->UpdateYourself( pPhysVol, &fpNavigatorState->fHistory );
0344 }
0345
0346
0347
0348
0349
0350 inline
0351 G4int G4ITNavigator2::GetVerboseLevel() const
0352 {
0353 return fVerbose;
0354 }
0355
0356
0357
0358
0359
0360 inline
0361 void G4ITNavigator2::SetVerboseLevel(G4int level)
0362 {
0363 fVerbose = level;
0364 fnormalNav.SetVerboseLevel(level);
0365 fvoxelNav.SetVerboseLevel(level);
0366 fparamNav.SetVerboseLevel(level);
0367 freplicaNav.SetVerboseLevel(level);
0368 fregularNav.SetVerboseLevel(level);
0369 }
0370
0371
0372
0373
0374
0375 inline
0376 G4bool G4ITNavigator2::IsActive() const
0377 {
0378 return fActive;
0379 }
0380
0381
0382
0383
0384
0385 inline
0386 void G4ITNavigator2::Activate(G4bool flag)
0387 {
0388 fActive = flag;
0389 }
0390
0391
0392
0393
0394
0395
0396
0397 inline
0398 G4bool G4ITNavigator2::EnteredDaughterVolume() const
0399 {
0400 CheckNavigatorStateIsValid();
0401 return fpNavigatorState->fEnteredDaughter;
0402 }
0403
0404
0405
0406
0407
0408 inline
0409 G4bool G4ITNavigator2::ExitedMotherVolume() const
0410 {
0411 CheckNavigatorStateIsValid();
0412 return fpNavigatorState->fExitedMother;
0413 }
0414
0415
0416
0417
0418
0419 inline
0420 void G4ITNavigator2::CheckMode(G4bool mode)
0421 {
0422 fCheck = mode;
0423 fnormalNav.CheckMode(mode);
0424 fvoxelNav.CheckMode(mode);
0425 fparamNav.CheckMode(mode);
0426 freplicaNav.CheckMode(mode);
0427 fregularNav.CheckMode(mode);
0428 }
0429
0430
0431
0432
0433
0434 inline
0435 G4bool G4ITNavigator2::IsCheckModeActive() const
0436 {
0437 return fCheck;
0438 }
0439
0440
0441
0442
0443
0444 inline
0445 void G4ITNavigator2::SetPushVerbosity(G4bool mode)
0446 {
0447 fWarnPush = mode;
0448 }
0449
0450
0451
0452
0453
0454
0455
0456
0457 inline
0458 G4int G4ITNavigator2::SeverityOfZeroStepping( G4int* noZeroSteps ) const
0459 {
0460 CheckNavigatorStateIsValid();
0461 G4int severity=0, noZeros= fpNavigatorState->fNumberZeroSteps;
0462 if( noZeroSteps != nullptr) *noZeroSteps = fpNavigatorState->fNumberZeroSteps;
0463
0464 if( noZeros >= fAbandonThreshold_NoZeroSteps )
0465 {
0466 severity = 10;
0467 }
0468 if( noZeros > 0 && noZeros < fActionThreshold_NoZeroSteps )
0469 {
0470 severity = 5 * noZeros / fActionThreshold_NoZeroSteps;
0471 }
0472 else if( noZeros == fActionThreshold_NoZeroSteps )
0473 {
0474 severity = 5;
0475 }
0476 else if( noZeros >= fAbandonThreshold_NoZeroSteps - 2 )
0477 {
0478 severity = 9;
0479 }
0480 else if( noZeros < fAbandonThreshold_NoZeroSteps - 2 )
0481 {
0482 severity = 5 + 4 * (noZeros-fAbandonThreshold_NoZeroSteps)
0483 / fActionThreshold_NoZeroSteps;
0484 }
0485 return severity;
0486 }
0487
0488
0489
0490
0491
0492 inline void G4ITNavigator2::EnableBestSafety( G4bool value )
0493 {
0494 fvoxelNav.EnableBestSafety( value );
0495 }