Geant4  10.02.p02
G4NormalNavigation.icc
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: G4NormalNavigation.icc 90009 2015-05-08 07:42:39Z gcosmo $
28 //
29 //
30 // G4NormalNavigation Inline Implementation
31 //
32 // --------------------------------------------------------------------
33 
34 // ********************************************************************
35 // CheckMode
36 // ********************************************************************
37 //
38 inline
39 void G4NormalNavigation::CheckMode(G4bool mode)
40 {
41  fCheck = mode;
42 }
43 
44 // ********************************************************************
45 // LevelLocate
46 // ********************************************************************
47 //
48 inline
49 G4bool
50 G4NormalNavigation::LevelLocate( G4NavigationHistory& history,
51  const G4VPhysicalVolume* blockedVol,
52  const G4int,
53  const G4ThreeVector& globalPoint,
54  const G4ThreeVector* globalDirection,
55  const G4bool pLocatedOnEdge,
56  G4ThreeVector &localPoint )
57 {
58  G4VPhysicalVolume *targetPhysical, *samplePhysical;
59  G4LogicalVolume *targetLogical;
60  G4VSolid *sampleSolid;
61  G4ThreeVector samplePoint;
62  G4int targetNoDaughters;
63 
64  targetPhysical = history.GetTopVolume();
65  targetLogical = targetPhysical->GetLogicalVolume();
66  targetNoDaughters = targetLogical->GetNoDaughters();
67 
68  G4bool found = false;
69 
70  if (targetNoDaughters!=0)
71  {
72  //
73  // Search daughters in volume
74  //
75  for ( G4int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
76  {
77  samplePhysical = targetLogical->GetDaughter(sampleNo);
78  if ( samplePhysical!=blockedVol )
79  {
80  // Setup history
81  //
82  history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
83  sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
84  samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
85  if( G4AuxiliaryNavServices::
86  CheckPointOnSurface(sampleSolid, samplePoint, globalDirection,
87  history.GetTopTransform(), pLocatedOnEdge) )
88  {
89  // Enter this daughter
90  //
91  localPoint = samplePoint;
92  found = true;
93  break;
94  }
95  else
96  {
97  history.BackLevel();
98  }
99  }
100  }
101  }
102  return found;
103 }