Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/navigation/src/G4VoxelNavigation.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/navigation/src/G4VoxelNavigation.cc (Version 11.3.0) and /geometry/navigation/src/G4VoxelNavigation.cc (Version 9.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 //
                                                   >>  27 // $Id: G4VoxelNavigation.cc,v 1.13 2010-11-04 18:18:00 japost Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-04-patch-01 $
                                                   >>  29 //
                                                   >>  30 //
 26 // class G4VoxelNavigation Implementation          31 // class G4VoxelNavigation Implementation
 27 //                                                 32 //
 28 // Author: P.Kent, 1996                            33 // Author: P.Kent, 1996
 29 //                                                 34 //
 30 // -------------------------------------------     35 // --------------------------------------------------------------------
                                                   >>  36 
 31 #include "G4VoxelNavigation.hh"                    37 #include "G4VoxelNavigation.hh"
 32 #include "G4GeometryTolerance.hh"                  38 #include "G4GeometryTolerance.hh"
 33 #include "G4VoxelSafety.hh"                        39 #include "G4VoxelSafety.hh"
 34                                                    40 
 35 #include "G4AuxiliaryNavServices.hh"           << 
 36                                                << 
 37 #include <cassert>                             << 
 38 #include <ostream>                             << 
 39                                                << 
 40 // *******************************************     41 // ********************************************************************
 41 // Constructor                                     42 // Constructor
 42 // *******************************************     43 // ********************************************************************
 43 //                                                 44 //
 44 G4VoxelNavigation::G4VoxelNavigation()             45 G4VoxelNavigation::G4VoxelNavigation()
 45   : fVoxelAxisStack(kNavigatorVoxelStackMax,kX <<  46   : fBList(), fVoxelDepth(-1),
                                                   >>  47     fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
 46     fVoxelNoSlicesStack(kNavigatorVoxelStackMa     48     fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
 47     fVoxelSliceWidthStack(kNavigatorVoxelStack     49     fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
 48     fVoxelNodeNoStack(kNavigatorVoxelStackMax,     50     fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
 49     fVoxelHeaderStack(kNavigatorVoxelStackMax, <<  51     fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
                                                   >>  52     fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
 50 {                                                  53 {
 51   fLogger= new G4NavigationLogger("G4VoxelNavi <<  54   fLogger = new G4NavigationLogger("G4VoxelNavigation");
 52   fpVoxelSafety= new G4VoxelSafety();          <<  55   fpVoxelSafety = new G4VoxelSafety (); 
 53   fHalfTolerance= 0.5*G4GeometryTolerance::Get << 
 54                                                << 
 55 #ifdef G4DEBUG_NAVIGATION                      << 
 56   SetVerboseLevel(5);   // Reports most about  << 
 57 #endif                                         << 
 58 }                                                  56 }
 59                                                    57 
 60 // *******************************************     58 // ********************************************************************
 61 // Destructor                                      59 // Destructor
 62 // *******************************************     60 // ********************************************************************
 63 //                                                 61 //
 64 G4VoxelNavigation::~G4VoxelNavigation()            62 G4VoxelNavigation::~G4VoxelNavigation()
 65 {                                                  63 {
 66   delete fpVoxelSafety;                            64   delete fpVoxelSafety;
 67   delete fLogger;                                  65   delete fLogger;
 68 }                                                  66 }
 69                                                    67 
 70 // ------------------------------------------- << 
 71 // Input:                                      << 
 72 //    exiting:         : last step exited      << 
 73 //    blockedPhysical  : phys volume last exit << 
 74 //    blockedReplicaNo : copy/replica number o << 
 75 // Output:                                     << 
 76 //    entering         : if true, found candid << 
 77 //    blockedPhysical  : candidate phys volume << 
 78 //    blockedReplicaNo : copy/replica number   << 
 79 //    exiting:         : will exit current (mo << 
 80 // In/Out                                      << 
 81 // ------------------------------------------- << 
 82                                                << 
 83 // *******************************************     68 // ********************************************************************
 84 // ComputeStep                                     69 // ComputeStep
 85 // *******************************************     70 // ********************************************************************
 86 //                                                 71 //
 87 G4double                                           72 G4double
 88 G4VoxelNavigation::ComputeStep( const G4ThreeV     73 G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
 89                                 const G4ThreeV     74                                 const G4ThreeVector& localDirection,
 90                                 const G4double     75                                 const G4double currentProposedStepLength,
 91                                       G4double     76                                       G4double& newSafety,
 92                           /* const */ G4Naviga <<  77                                       G4NavigationHistory& history,
 93                                       G4bool&      78                                       G4bool& validExitNormal,
 94                                       G4ThreeV     79                                       G4ThreeVector& exitNormal,
 95                                       G4bool&      80                                       G4bool& exiting,
 96                                       G4bool&      81                                       G4bool& entering,
 97                                       G4VPhysi <<  82                                       G4VPhysicalVolume *(*pBlockedPhysical),
 98                                       G4int& b     83                                       G4int& blockedReplicaNo )
 99 {                                                  84 {
100   G4VPhysicalVolume *motherPhysical, *samplePh <<  85   G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0;
101   G4LogicalVolume *motherLogical;                  86   G4LogicalVolume *motherLogical;
102   G4VSolid *motherSolid;                           87   G4VSolid *motherSolid;
103   G4ThreeVector sampleDirection;                   88   G4ThreeVector sampleDirection;
104   G4double ourStep=currentProposedStepLength,  <<  89   G4double ourStep=currentProposedStepLength, motherSafety, ourSafety;
105   G4double motherSafety, motherStep = DBL_MAX; << 
106   G4int localNoDaughters, sampleNo;                90   G4int localNoDaughters, sampleNo;
107                                                    91 
108   G4bool initialNode, noStep;                      92   G4bool initialNode, noStep;
109   G4SmartVoxelNode *curVoxelNode;                  93   G4SmartVoxelNode *curVoxelNode;
110   G4long curNoVolumes, contentNo;              <<  94   G4int curNoVolumes, contentNo;
111   G4double voxelSafety;                            95   G4double voxelSafety;
112                                                    96 
113   motherPhysical = history.GetTopVolume();         97   motherPhysical = history.GetTopVolume();
114   motherLogical = motherPhysical->GetLogicalVo     98   motherLogical = motherPhysical->GetLogicalVolume();
115   motherSolid = motherLogical->GetSolid();         99   motherSolid = motherLogical->GetSolid();
116                                                   100 
117   //                                              101   //
118   // Compute mother safety                        102   // Compute mother safety
119   //                                              103   //
120                                                   104 
121   motherSafety = motherSolid->DistanceToOut(lo    105   motherSafety = motherSolid->DistanceToOut(localPoint);
122   ourSafety = motherSafety;                 //    106   ourSafety = motherSafety;                 // Working isotropic safety
123                                                   107   
124 #ifdef G4VERBOSE                                  108 #ifdef G4VERBOSE
125   if ( fCheck )                                   109   if ( fCheck )
126   {                                               110   {
127     fLogger->PreComputeStepLog (motherPhysical    111     fLogger->PreComputeStepLog (motherPhysical, motherSafety, localPoint);
128   }                                               112   }
129 #endif                                            113 #endif
130                                                   114 
131   //                                              115   //
132   // Compute daughter safeties & intersections    116   // Compute daughter safeties & intersections
133   //                                              117   //
134                                                   118 
135   // Exiting normal optimisation                  119   // Exiting normal optimisation
136   //                                              120   //
137   if ( exiting && validExitNormal )               121   if ( exiting && validExitNormal )
138   {                                               122   {
139     if ( localDirection.dot(exitNormal)>=kMinE    123     if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine )
140     {                                             124     {
141       // Block exited daughter volume             125       // Block exited daughter volume
142       //                                          126       //
143       blockedExitedVol = *pBlockedPhysical;       127       blockedExitedVol = *pBlockedPhysical;
144       ourSafety = 0;                              128       ourSafety = 0;
145     }                                             129     }
146   }                                               130   }
147   exiting = false;                                131   exiting = false;
148   entering = false;                               132   entering = false;
149                                                   133 
150   // For extra checking,  get the distance to  << 134   localNoDaughters = motherLogical->GetNoDaughters();
151   G4bool motherValidExitNormal = false;        << 
152   G4ThreeVector motherExitNormal(0.0, 0.0, 0.0 << 
153                                                << 
154 #ifdef G4VERBOSE                               << 
155   if ( fCheck )                                << 
156   {                                            << 
157     // Compute early -- a) for validity        << 
158     //                  b) to check against an << 
159     motherStep = motherSolid->DistanceToOut(lo << 
160                                             lo << 
161                                             tr << 
162                                            &mo << 
163                                            &mo << 
164   }                                            << 
165 #endif                                         << 
166                                                << 
167   localNoDaughters = (G4int)motherLogical->Get << 
168                                                   135 
169   fBList.Enlarge(localNoDaughters);               136   fBList.Enlarge(localNoDaughters);
170   fBList.Reset();                                 137   fBList.Reset();
171                                                   138 
172   initialNode = true;                             139   initialNode = true;
173   noStep = true;                                  140   noStep = true;
174                                                   141 
175   while (noStep)                                  142   while (noStep)
176   {                                               143   {
177     curVoxelNode = fVoxelNode;                    144     curVoxelNode = fVoxelNode;
178     curNoVolumes = curVoxelNode->GetNoContaine    145     curNoVolumes = curVoxelNode->GetNoContained();
179     for (contentNo=curNoVolumes-1; contentNo>=    146     for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
180     {                                             147     {
181       sampleNo = curVoxelNode->GetVolume((G4in << 148       sampleNo = curVoxelNode->GetVolume(contentNo);
182       if ( !fBList.IsBlocked(sampleNo) )          149       if ( !fBList.IsBlocked(sampleNo) )
183       {                                           150       {
184         fBList.BlockVolume(sampleNo);             151         fBList.BlockVolume(sampleNo);
185         samplePhysical = motherLogical->GetDau    152         samplePhysical = motherLogical->GetDaughter(sampleNo);
186         if ( samplePhysical!=blockedExitedVol     153         if ( samplePhysical!=blockedExitedVol )
187         {                                         154         {
188           G4AffineTransform sampleTf(samplePhy    155           G4AffineTransform sampleTf(samplePhysical->GetRotation(),
189                                      samplePhy    156                                      samplePhysical->GetTranslation());
190           sampleTf.Invert();                      157           sampleTf.Invert();
191           const G4ThreeVector samplePoint =       158           const G4ThreeVector samplePoint =
192                      sampleTf.TransformPoint(l    159                      sampleTf.TransformPoint(localPoint);
193           const G4VSolid *sampleSolid     =       160           const G4VSolid *sampleSolid     =
194                      samplePhysical->GetLogica    161                      samplePhysical->GetLogicalVolume()->GetSolid();
195           const G4double sampleSafety     =       162           const G4double sampleSafety     =
196                      sampleSolid->DistanceToIn    163                      sampleSolid->DistanceToIn(samplePoint);
197                                                << 164 #ifdef G4VERBOSE
                                                   >> 165           if( fCheck )
                                                   >> 166           {
                                                   >> 167             fLogger->PrintDaughterLog(sampleSolid,samplePoint,sampleSafety,0);
                                                   >> 168           }
                                                   >> 169 #endif
198           if ( sampleSafety<ourSafety )           170           if ( sampleSafety<ourSafety )
199           {                                       171           {
200             ourSafety = sampleSafety;             172             ourSafety = sampleSafety;
201           }                                       173           }
202           if ( sampleSafety<=ourStep )            174           if ( sampleSafety<=ourStep )
203           {                                       175           {
204             sampleDirection = sampleTf.Transfo    176             sampleDirection = sampleTf.TransformAxis(localDirection);
205             G4double sampleStep =                 177             G4double sampleStep =
206                      sampleSolid->DistanceToIn    178                      sampleSolid->DistanceToIn(samplePoint, sampleDirection);
207 #ifdef G4VERBOSE                                  179 #ifdef G4VERBOSE
208             if( fCheck )                          180             if( fCheck )
209             {                                     181             {
210               fLogger->PrintDaughterLog(sample    182               fLogger->PrintDaughterLog(sampleSolid, samplePoint,
211                                         sample << 183                                         sampleSafety, sampleStep);
212                                         sample << 
213             }                                     184             }
214 #endif                                            185 #endif
215             if ( sampleStep<=ourStep )            186             if ( sampleStep<=ourStep )
216             {                                     187             {
217               ourStep = sampleStep;               188               ourStep = sampleStep;
218               entering = true;                    189               entering = true;
219               exiting = false;                    190               exiting = false;
220               *pBlockedPhysical = samplePhysic    191               *pBlockedPhysical = samplePhysical;
221               blockedReplicaNo = -1;              192               blockedReplicaNo = -1;
222 #ifdef G4VERBOSE                                  193 #ifdef G4VERBOSE
223               // Check to see that the resulti    194               // Check to see that the resulting point is indeed in/on volume.
224               // This could be done only for s << 195               // This check could eventually be made only for successful
                                                   >> 196               // candidate.
                                                   >> 197 
225               if ( fCheck )                       198               if ( fCheck )
226               {                                   199               {
227                 fLogger->AlongComputeStepLog (    200                 fLogger->AlongComputeStepLog (sampleSolid, samplePoint,
228                   sampleDirection, localDirect    201                   sampleDirection, localDirection, sampleSafety, sampleStep);
229               }                                   202               }
230 #endif                                            203 #endif
231             }                                     204             }
232 #ifdef G4VERBOSE                               << 
233             if ( fCheck && ( sampleStep < kInf << 
234                         && ( sampleStep >= mot << 
235             {                                  << 
236                // The intersection point with  << 
237                // point from the mother volume << 
238                fLogger->CheckDaughterEntryPoin << 
239                                                << 
240                                                << 
241                                                << 
242                                                << 
243             }                                  << 
244 #endif                                         << 
245           }                                    << 
246 #ifdef G4VERBOSE                               << 
247           else // ie if sampleSafety > outStep << 
248           {                                    << 
249             if( fCheck )                       << 
250             {                                  << 
251               fLogger->PrintDaughterLog(sample << 
252                                         sample << 
253                                         G4Thre << 
254             }                                  << 
255           }                                       205           }
256 #endif                                         << 
257         }                                         206         }
258       }                                           207       }
259     }                                             208     }
260     if (initialNode)                              209     if (initialNode)
261     {                                             210     {
262       initialNode = false;                        211       initialNode = false;
263       voxelSafety = ComputeVoxelSafety(localPo    212       voxelSafety = ComputeVoxelSafety(localPoint);
264       if ( voxelSafety<ourSafety )                213       if ( voxelSafety<ourSafety )
265       {                                           214       {
266         ourSafety = voxelSafety;                  215         ourSafety = voxelSafety;
267       }                                           216       }
268       if ( currentProposedStepLength<ourSafety    217       if ( currentProposedStepLength<ourSafety )
269       {                                           218       {
270         // Guaranteed physics limited             219         // Guaranteed physics limited
271         //                                        220         //      
272         noStep = false;                           221         noStep = false;
273         entering = false;                         222         entering = false;
274         exiting = false;                          223         exiting = false;
275         *pBlockedPhysical = nullptr;           << 224         *pBlockedPhysical = 0;
276         ourStep = kInfinity;                      225         ourStep = kInfinity;
277       }                                           226       }
278       else                                        227       else
279       {                                           228       {
280         //                                        229         //
281         // Compute mother intersection if requ    230         // Compute mother intersection if required
282         //                                        231         //
283         if ( motherSafety<=ourStep )              232         if ( motherSafety<=ourStep )
284         {                                         233         {
285           // In case of check mode this is a d << 234           G4double motherStep =
286           motherStep = motherSolid->DistanceTo << 235               motherSolid->DistanceToOut(localPoint,
287                               true, &motherVal << 236                                          localDirection,
                                                   >> 237                                          true, &validExitNormal, &exitNormal);
288 #ifdef G4VERBOSE                                  238 #ifdef G4VERBOSE
289           if ( fCheck )                           239           if ( fCheck )
290           {                                       240           {
291             fLogger->PostComputeStepLog(mother    241             fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
292                                         mother    242                                         motherStep, motherSafety);
293             if( motherValidExitNormal )        << 
294             {                                  << 
295               fLogger->CheckAndReportBadNormal << 
296                                                << 
297                                                << 
298                                         "From  << 
299             }                                  << 
300           }                                       243           }
301 #endif                                            244 #endif
302           if( (motherStep >= kInfinity) || (mo << 
303           {                                    << 
304 #ifdef G4VERBOSE                               << 
305             if( fCheck ) // Error - indication << 
306             {                                  << 
307               fLogger->ReportOutsideMother(loc << 
308                                            mot << 
309             }                                  << 
310 #endif                                         << 
311             motherStep = 0.0;                  << 
312             ourStep = 0.0;                     << 
313             exiting = true;                    << 
314             entering = false;                  << 
315                                                << 
316             // validExitNormal= motherValidExi << 
317             // exitNormal= motherExitNormal;   << 
318             // Useful only if the point is ver << 
319             // => but it would need to be rota << 
320             validExitNormal= false;            << 
321                                                << 
322             *pBlockedPhysical = nullptr; // or << 
323             blockedReplicaNo = 0;  // or mothe << 
324                                                << 
325             newSafety = 0.0;                   << 
326             return ourStep;                    << 
327           }                                    << 
328                                                << 
329           if ( motherStep<=ourStep )              245           if ( motherStep<=ourStep )
330           {                                       246           {
331             ourStep = motherStep;                 247             ourStep = motherStep;
332             exiting = true;                       248             exiting = true;
333             entering = false;                     249             entering = false;
334                                                << 
335             // Exit normal: Natural location t << 
336             //                                 << 
337             validExitNormal = motherValidExitN << 
338             exitNormal = motherExitNormal;     << 
339                                                << 
340             if ( validExitNormal )                250             if ( validExitNormal )
341             {                                     251             {
342               const G4RotationMatrix *rot = mo    252               const G4RotationMatrix *rot = motherPhysical->GetRotation();
343               if (rot != nullptr)              << 253               if (rot)
344               {                                   254               {
345                 exitNormal *= rot->inverse();     255                 exitNormal *= rot->inverse();
346 #ifdef G4VERBOSE                               << 
347                 if( fCheck )                   << 
348                 {                              << 
349                   fLogger->CheckAndReportBadNo << 
350                                                << 
351                                                << 
352                                                << 
353                 }                              << 
354 #endif                                         << 
355               }                                   256               }
356             }                                  << 257             }  
357           }                                       258           }
358           else                                    259           else
359           {                                       260           {
360             validExitNormal = false;              261             validExitNormal = false;
361           }                                       262           }
362         }                                         263         }
363       }                                           264       }
364       newSafety = ourSafety;                      265       newSafety = ourSafety;
365     }                                             266     }
366     if (noStep)                                   267     if (noStep)
367     {                                             268     {
368       noStep = LocateNextVoxel(localPoint, loc    269       noStep = LocateNextVoxel(localPoint, localDirection, ourStep);
369     }                                             270     }
370   }  // end -while (noStep)- loop                 271   }  // end -while (noStep)- loop
371                                                   272 
372   return ourStep;                                 273   return ourStep;
373 }                                                 274 }
374                                                   275 
375 // *******************************************    276 // ********************************************************************
376 // ComputeVoxelSafety                             277 // ComputeVoxelSafety
377 //                                                278 //
378 // Computes safety from specified point to vox    279 // Computes safety from specified point to voxel boundaries
379 // using already located point                    280 // using already located point
380 // o collected boundaries for most derived lev    281 // o collected boundaries for most derived level
381 // o adjacent boundaries for previous levels      282 // o adjacent boundaries for previous levels
382 // *******************************************    283 // ********************************************************************
383 //                                                284 //
384 G4double                                          285 G4double
385 G4VoxelNavigation::ComputeVoxelSafety(const G4    286 G4VoxelNavigation::ComputeVoxelSafety(const G4ThreeVector& localPoint) const
386 {                                                 287 {
387   G4SmartVoxelHeader *curHeader;                  288   G4SmartVoxelHeader *curHeader;
388   G4double voxelSafety, curNodeWidth;             289   G4double voxelSafety, curNodeWidth;
389   G4double curNodeOffset, minCurCommonDelta, m    290   G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
390   G4int minCurNodeNoDelta, maxCurNodeNoDelta;     291   G4int minCurNodeNoDelta, maxCurNodeNoDelta;
391   G4int localVoxelDepth, curNodeNo;               292   G4int localVoxelDepth, curNodeNo;
392   EAxis curHeaderAxis;                            293   EAxis curHeaderAxis;
393                                                   294 
394   localVoxelDepth = fVoxelDepth;                  295   localVoxelDepth = fVoxelDepth;
395                                                   296 
396   curHeader = fVoxelHeaderStack[localVoxelDept    297   curHeader = fVoxelHeaderStack[localVoxelDepth];
397   curHeaderAxis = fVoxelAxisStack[localVoxelDe    298   curHeaderAxis = fVoxelAxisStack[localVoxelDepth];
398   curNodeNo = fVoxelNodeNoStack[localVoxelDept    299   curNodeNo = fVoxelNodeNoStack[localVoxelDepth];
399   curNodeWidth = fVoxelSliceWidthStack[localVo    300   curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth];
400                                                   301   
401   // Compute linear intersection distance to b    302   // Compute linear intersection distance to boundaries of max/min
402   // to collected nodes at current level          303   // to collected nodes at current level
403   //                                              304   //
404   curNodeOffset = curNodeNo*curNodeWidth;         305   curNodeOffset = curNodeNo*curNodeWidth;
405   maxCurNodeNoDelta = fVoxelNode->GetMaxEquiva    306   maxCurNodeNoDelta = fVoxelNode->GetMaxEquivalentSliceNo()-curNodeNo;
406   minCurNodeNoDelta = curNodeNo-fVoxelNode->Ge    307   minCurNodeNoDelta = curNodeNo-fVoxelNode->GetMinEquivalentSliceNo();
407   minCurCommonDelta = localPoint(curHeaderAxis    308   minCurCommonDelta = localPoint(curHeaderAxis)
408                       - curHeader->GetMinExten    309                       - curHeader->GetMinExtent() - curNodeOffset;
409   maxCurCommonDelta = curNodeWidth-minCurCommo    310   maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
410                                                   311 
411   if ( minCurNodeNoDelta<maxCurNodeNoDelta )      312   if ( minCurNodeNoDelta<maxCurNodeNoDelta )
412   {                                               313   {
413     voxelSafety = minCurNodeNoDelta*curNodeWid    314     voxelSafety = minCurNodeNoDelta*curNodeWidth;
414     voxelSafety += minCurCommonDelta;             315     voxelSafety += minCurCommonDelta;
415   }                                               316   }
416   else if (maxCurNodeNoDelta < minCurNodeNoDel    317   else if (maxCurNodeNoDelta < minCurNodeNoDelta)
417   {                                               318   {
418     voxelSafety = maxCurNodeNoDelta*curNodeWid    319     voxelSafety = maxCurNodeNoDelta*curNodeWidth;
419     voxelSafety += maxCurCommonDelta;             320     voxelSafety += maxCurCommonDelta;
420   }                                               321   }
421   else    // (maxCurNodeNoDelta == minCurNodeN    322   else    // (maxCurNodeNoDelta == minCurNodeNoDelta)
422   {                                               323   {
423     voxelSafety = minCurNodeNoDelta*curNodeWid    324     voxelSafety = minCurNodeNoDelta*curNodeWidth;
424     voxelSafety += std::min(minCurCommonDelta,    325     voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
425   }                                               326   }
426                                                   327 
427   // Compute isotropic safety to boundaries of    328   // Compute isotropic safety to boundaries of previous levels
428   // [NOT to collected boundaries]                329   // [NOT to collected boundaries]
429                                                << 330   //
430   // Loop checking, 07.10.2016, JA             << 
431   while ( (localVoxelDepth>0) && (voxelSafety>    331   while ( (localVoxelDepth>0) && (voxelSafety>0) )
432   {                                               332   {
433     localVoxelDepth--;                            333     localVoxelDepth--;
434     curHeader = fVoxelHeaderStack[localVoxelDe    334     curHeader = fVoxelHeaderStack[localVoxelDepth];
435     curHeaderAxis = fVoxelAxisStack[localVoxel    335     curHeaderAxis = fVoxelAxisStack[localVoxelDepth];
436     curNodeNo = fVoxelNodeNoStack[localVoxelDe    336     curNodeNo = fVoxelNodeNoStack[localVoxelDepth];
437     curNodeWidth = fVoxelSliceWidthStack[local    337     curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth];
438     curNodeOffset = curNodeNo*curNodeWidth;       338     curNodeOffset = curNodeNo*curNodeWidth;
439     minCurCommonDelta = localPoint(curHeaderAx    339     minCurCommonDelta = localPoint(curHeaderAxis)
440                         - curHeader->GetMinExt    340                         - curHeader->GetMinExtent() - curNodeOffset;
441     maxCurCommonDelta = curNodeWidth-minCurCom    341     maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
442                                                   342     
443     if ( minCurCommonDelta<voxelSafety )          343     if ( minCurCommonDelta<voxelSafety )
444     {                                             344     {
445       voxelSafety = minCurCommonDelta;            345       voxelSafety = minCurCommonDelta;
446     }                                             346     }
447     if ( maxCurCommonDelta<voxelSafety )          347     if ( maxCurCommonDelta<voxelSafety )
448     {                                             348     {
449       voxelSafety = maxCurCommonDelta;            349       voxelSafety = maxCurCommonDelta;
450     }                                             350     }
451   }                                               351   }
452   if ( voxelSafety<0 )                            352   if ( voxelSafety<0 )
453   {                                               353   {
454     voxelSafety = 0;                              354     voxelSafety = 0;
455   }                                               355   }
456                                                   356 
457   return voxelSafety;                             357   return voxelSafety;
458 }                                                 358 }
459                                                   359 
460 // *******************************************    360 // ********************************************************************
461 // LocateNextVoxel                                361 // LocateNextVoxel
462 //                                                362 //
463 // Finds the next voxel from the current voxel    363 // Finds the next voxel from the current voxel and point
464 // in the specified direction                     364 // in the specified direction
465 //                                                365 //
466 // Returns false if all voxels considered         366 // Returns false if all voxels considered
467 //              [current Step ends inside same    367 //              [current Step ends inside same voxel or leaves all voxels]
468 //         true  otherwise                        368 //         true  otherwise
469 //              [the information on the next v    369 //              [the information on the next voxel is put into the set of
470 //               fVoxel* variables & "stacks"]    370 //               fVoxel* variables & "stacks"] 
471 // *******************************************    371 // ********************************************************************
472 //                                                372 // 
473 G4bool                                            373 G4bool
474 G4VoxelNavigation::LocateNextVoxel(const G4Thr    374 G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
475                                    const G4Thr    375                                    const G4ThreeVector& localDirection,
476                                    const G4dou    376                                    const G4double currentStep)
477 {                                                 377 {
478   G4SmartVoxelHeader *workHeader=nullptr, *new << 378   G4SmartVoxelHeader *workHeader=0, *newHeader=0;
479   G4SmartVoxelProxy *newProxy=nullptr;         << 379   G4SmartVoxelProxy *newProxy=0;
480   G4SmartVoxelNode *newVoxelNode=nullptr;      << 380   G4SmartVoxelNode *newVoxelNode=0;
481   G4ThreeVector targetPoint, voxelPoint;          381   G4ThreeVector targetPoint, voxelPoint;
482   G4double workNodeWidth, workMinExtent, workC    382   G4double workNodeWidth, workMinExtent, workCoord;
483   G4double minVal, maxVal, newDistance=0.;        383   G4double minVal, maxVal, newDistance=0.;
484   G4double newHeaderMin, newHeaderNodeWidth;      384   G4double newHeaderMin, newHeaderNodeWidth;
485   G4int depth=0, newDepth=0, workNodeNo=0, new    385   G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
486   EAxis workHeaderAxis, newHeaderAxis;            386   EAxis workHeaderAxis, newHeaderAxis;
487   G4bool isNewVoxel = false;                   << 387   G4bool isNewVoxel=false;
488                                                   388   
489   G4double currentDistance = currentStep;         389   G4double currentDistance = currentStep;
                                                   >> 390   static const G4double sigma = 0.5*G4GeometryTolerance::GetInstance()
                                                   >> 391                                     ->GetSurfaceTolerance();
490                                                   392 
491   // Determine if end of Step within current v    393   // Determine if end of Step within current voxel
492   //                                              394   //
493   for (depth=0; depth<fVoxelDepth; ++depth)    << 395   for (depth=0; depth<fVoxelDepth; depth++)
494   {                                               396   {
495     targetPoint = localPoint+localDirection*cu    397     targetPoint = localPoint+localDirection*currentDistance;
496     newDistance = currentDistance;                398     newDistance = currentDistance;
497     workHeader = fVoxelHeaderStack[depth];        399     workHeader = fVoxelHeaderStack[depth];
498     workHeaderAxis = fVoxelAxisStack[depth];      400     workHeaderAxis = fVoxelAxisStack[depth];
499     workNodeNo = fVoxelNodeNoStack[depth];        401     workNodeNo = fVoxelNodeNoStack[depth];
500     workNodeWidth = fVoxelSliceWidthStack[dept    402     workNodeWidth = fVoxelSliceWidthStack[depth];
501     workMinExtent = workHeader->GetMinExtent()    403     workMinExtent = workHeader->GetMinExtent();
502     workCoord = targetPoint(workHeaderAxis);      404     workCoord = targetPoint(workHeaderAxis);
503     minVal = workMinExtent+workNodeNo*workNode    405     minVal = workMinExtent+workNodeNo*workNodeWidth;
504                                                   406 
505     if ( minVal<=workCoord+fHalfTolerance )    << 407     if ( minVal<=workCoord+sigma )
506     {                                             408     {
507       maxVal = minVal+workNodeWidth;              409       maxVal = minVal+workNodeWidth;
508       if ( maxVal<=workCoord-fHalfTolerance )  << 410       if ( maxVal<=workCoord-sigma )
509       {                                           411       {
510         // Must consider next voxel               412         // Must consider next voxel
511         //                                        413         //
512         newNodeNo = workNodeNo+1;                 414         newNodeNo = workNodeNo+1;
513         newHeader = workHeader;                   415         newHeader = workHeader;
514         newDistance = (maxVal-localPoint(workH    416         newDistance = (maxVal-localPoint(workHeaderAxis))
515                     / localDirection(workHeade    417                     / localDirection(workHeaderAxis);
516         isNewVoxel = true;                        418         isNewVoxel = true;
517         newDepth = depth;                         419         newDepth = depth;
518       }                                           420       }
519     }                                             421     }
520     else                                          422     else
521     {                                             423     {
522       newNodeNo = workNodeNo-1;                   424       newNodeNo = workNodeNo-1;
523       newHeader = workHeader;                     425       newHeader = workHeader;
524       newDistance = (minVal-localPoint(workHea    426       newDistance = (minVal-localPoint(workHeaderAxis))
525                   / localDirection(workHeaderA    427                   / localDirection(workHeaderAxis);
526       isNewVoxel = true;                          428       isNewVoxel = true;
527       newDepth = depth;                           429       newDepth = depth;
528     }                                             430     }
529     currentDistance = newDistance;                431     currentDistance = newDistance;
530   }                                               432   }
531   targetPoint = localPoint+localDirection*curr    433   targetPoint = localPoint+localDirection*currentDistance;
532                                                   434 
533   // Check if end of Step within collected bou    435   // Check if end of Step within collected boundaries of current voxel
534   //                                              436   //
535   depth = fVoxelDepth;                            437   depth = fVoxelDepth;
536   {                                               438   {
537     workHeader = fVoxelHeaderStack[depth];        439     workHeader = fVoxelHeaderStack[depth];
538     workHeaderAxis = fVoxelAxisStack[depth];      440     workHeaderAxis = fVoxelAxisStack[depth];
539     workNodeNo = fVoxelNodeNoStack[depth];        441     workNodeNo = fVoxelNodeNoStack[depth];
540     workNodeWidth = fVoxelSliceWidthStack[dept    442     workNodeWidth = fVoxelSliceWidthStack[depth];
541     workMinExtent = workHeader->GetMinExtent()    443     workMinExtent = workHeader->GetMinExtent();
542     workCoord = targetPoint(workHeaderAxis);      444     workCoord = targetPoint(workHeaderAxis);
543     minVal = workMinExtent+fVoxelNode->GetMinE    445     minVal = workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth;
544                                                   446 
545     if ( minVal<=workCoord+fHalfTolerance )    << 447     if ( minVal<=workCoord+sigma )
546     {                                             448     {
547       maxVal = workMinExtent+(fVoxelNode->GetM    449       maxVal = workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1)
548                             *workNodeWidth;       450                             *workNodeWidth;
549       if ( maxVal<=workCoord-fHalfTolerance )  << 451       if ( maxVal<=workCoord-sigma )
550       {                                           452       {
551         newNodeNo = fVoxelNode->GetMaxEquivale    453         newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
552         newHeader = workHeader;                   454         newHeader = workHeader;
553         newDistance = (maxVal-localPoint(workH    455         newDistance = (maxVal-localPoint(workHeaderAxis))
554                     / localDirection(workHeade    456                     / localDirection(workHeaderAxis);
555         isNewVoxel = true;                        457         isNewVoxel = true;
556         newDepth = depth;                         458         newDepth = depth;
557       }                                           459       }
558     }                                             460     }
559     else                                          461     else
560     {                                             462     {
561       newNodeNo = fVoxelNode->GetMinEquivalent    463       newNodeNo = fVoxelNode->GetMinEquivalentSliceNo()-1;
562       newHeader = workHeader;                     464       newHeader = workHeader;
563       newDistance = (minVal-localPoint(workHea    465       newDistance = (minVal-localPoint(workHeaderAxis))
564                   / localDirection(workHeaderA    466                   / localDirection(workHeaderAxis);
565       isNewVoxel = true;                          467       isNewVoxel = true;
566       newDepth = depth;                           468       newDepth = depth;
567     }                                             469     }
568     currentDistance = newDistance;                470     currentDistance = newDistance;
569   }                                               471   }
570   if (isNewVoxel)                                 472   if (isNewVoxel)
571   {                                               473   {
572     // Compute new voxel & adjust voxel stack     474     // Compute new voxel & adjust voxel stack
573     //                                            475     //
574     // newNodeNo=Candidate node no at             476     // newNodeNo=Candidate node no at 
575     // newDepth =refinement depth of crossed v    477     // newDepth =refinement depth of crossed voxel boundary
576     // newHeader=Header for crossed voxel         478     // newHeader=Header for crossed voxel
577     // newDistance=distance to crossed voxel b    479     // newDistance=distance to crossed voxel boundary (along the track)
578     //                                            480     //
579     if ( (newNodeNo<0) || (newNodeNo>=G4int(ne << 481     if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
580     {                                             482     {
581       // Leaving mother volume                    483       // Leaving mother volume
582       //                                          484       //
583       isNewVoxel = false;                         485       isNewVoxel = false;
584     }                                             486     }
585     else                                          487     else
586     {                                             488     {
587       // Compute intersection point on the lea    489       // Compute intersection point on the least refined
588       // voxel boundary that is hit               490       // voxel boundary that is hit
589       //                                          491       //
590       voxelPoint = localPoint+localDirection*n    492       voxelPoint = localPoint+localDirection*newDistance;
591       fVoxelNodeNoStack[newDepth] = newNodeNo;    493       fVoxelNodeNoStack[newDepth] = newNodeNo;
592       fVoxelDepth = newDepth;                     494       fVoxelDepth = newDepth;
593       newVoxelNode = nullptr;                  << 495       newVoxelNode = 0;
594       while ( newVoxelNode == nullptr )        << 496       while ( !newVoxelNode )
595       {                                           497       {
596         newProxy = newHeader->GetSlice(newNode    498         newProxy = newHeader->GetSlice(newNodeNo);
597         if (newProxy->IsNode())                   499         if (newProxy->IsNode())
598         {                                         500         {
599           newVoxelNode = newProxy->GetNode();     501           newVoxelNode = newProxy->GetNode();
600         }                                         502         }
601         else                                      503         else
602         {                                         504         {
603           ++fVoxelDepth;                       << 505           fVoxelDepth++;
604           newHeader = newProxy->GetHeader();      506           newHeader = newProxy->GetHeader();
605           newHeaderAxis = newHeader->GetAxis()    507           newHeaderAxis = newHeader->GetAxis();
606           newHeaderNoSlices = (G4int)newHeader << 508           newHeaderNoSlices = newHeader->GetNoSlices();
607           newHeaderMin = newHeader->GetMinExte    509           newHeaderMin = newHeader->GetMinExtent();
608           newHeaderNodeWidth = (newHeader->Get    510           newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
609                              / newHeaderNoSlic    511                              / newHeaderNoSlices;
610           newNodeNo = G4int( (voxelPoint(newHe    512           newNodeNo = G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
611                              / newHeaderNodeWi    513                              / newHeaderNodeWidth );
612           // Rounding protection                  514           // Rounding protection
613           //                                      515           //
614           if ( newNodeNo<0 )                      516           if ( newNodeNo<0 )
615           {                                       517           {
616             newNodeNo=0;                          518             newNodeNo=0;
617           }                                       519           }
618           else if ( newNodeNo>=newHeaderNoSlic    520           else if ( newNodeNo>=newHeaderNoSlices )
619           {                                    << 521                {
620             newNodeNo = newHeaderNoSlices-1;   << 522                  newNodeNo = newHeaderNoSlices-1;
621           }                                    << 523                }
622           // Stack info for stepping              524           // Stack info for stepping
623           //                                      525           //
624           fVoxelAxisStack[fVoxelDepth] = newHe    526           fVoxelAxisStack[fVoxelDepth] = newHeaderAxis;
625           fVoxelNoSlicesStack[fVoxelDepth] = n    527           fVoxelNoSlicesStack[fVoxelDepth] = newHeaderNoSlices;
626           fVoxelSliceWidthStack[fVoxelDepth] =    528           fVoxelSliceWidthStack[fVoxelDepth] = newHeaderNodeWidth;
627           fVoxelNodeNoStack[fVoxelDepth] = new    529           fVoxelNodeNoStack[fVoxelDepth] = newNodeNo;
628           fVoxelHeaderStack[fVoxelDepth] = new    530           fVoxelHeaderStack[fVoxelDepth] = newHeader;
629         }                                         531         }
630       }                                           532       }
631       fVoxelNode = newVoxelNode;                  533       fVoxelNode = newVoxelNode;
632     }                                             534     }
633   }                                               535   }
634   return isNewVoxel;                              536   return isNewVoxel;        
635 }                                                 537 }
636                                                   538 
637 // *******************************************    539 // ********************************************************************
638 // ComputeSafety                                  540 // ComputeSafety
639 //                                                541 //
640 // Calculates the isotropic distance to the ne    542 // Calculates the isotropic distance to the nearest boundary from the
641 // specified point in the local coordinate sys    543 // specified point in the local coordinate system. 
642 // The localpoint utilised must be within the     544 // The localpoint utilised must be within the current volume.
643 // *******************************************    545 // ********************************************************************
644 //                                                546 //
645 G4double                                          547 G4double
646 G4VoxelNavigation::ComputeSafety(const G4Three    548 G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
647                                  const G4Navig    549                                  const G4NavigationHistory& history,
648                                  const G4doubl << 550                                  const G4double       maxLength)
649 {                                                 551 {
650   G4VPhysicalVolume *motherPhysical, *samplePh    552   G4VPhysicalVolume *motherPhysical, *samplePhysical;
651   G4LogicalVolume *motherLogical;                 553   G4LogicalVolume *motherLogical;
652   G4VSolid *motherSolid;                          554   G4VSolid *motherSolid;
653   G4double motherSafety, ourSafety;               555   G4double motherSafety, ourSafety;
654   G4int sampleNo;                              << 556   G4int localNoDaughters, sampleNo;
655   G4SmartVoxelNode *curVoxelNode;                 557   G4SmartVoxelNode *curVoxelNode;
656   G4long curNoVolumes, contentNo;              << 558   G4int curNoVolumes, contentNo;
657   G4double voxelSafety;                           559   G4double voxelSafety;
658                                                   560 
659   motherPhysical = history.GetTopVolume();        561   motherPhysical = history.GetTopVolume();
660   motherLogical = motherPhysical->GetLogicalVo    562   motherLogical = motherPhysical->GetLogicalVolume();
661   motherSolid = motherLogical->GetSolid();        563   motherSolid = motherLogical->GetSolid();
662                                                   564 
663   if( fBestSafety )                               565   if( fBestSafety )
664   {                                               566   { 
665     return fpVoxelSafety->ComputeSafety( local    567     return fpVoxelSafety->ComputeSafety( localPoint,*motherPhysical,maxLength );
666   }                                               568   }
667                                                   569 
668   //                                              570   //
669   // Compute mother safety                        571   // Compute mother safety
670   //                                              572   //
671                                                   573 
672   motherSafety = motherSolid->DistanceToOut(lo    574   motherSafety = motherSolid->DistanceToOut(localPoint);
673   ourSafety = motherSafety;                 //    575   ourSafety = motherSafety;                 // Working isotropic safety
674                                                   576 
675   if( motherSafety == 0.0 )                    << 
676   {                                            << 
677 #ifdef G4DEBUG_NAVIGATION                      << 
678     // Check that point is inside mother volum << 
679     EInside  insideMother = motherSolid->Insid << 
680                                                << 
681     if( insideMother == kOutside )             << 
682     {                                          << 
683       G4ExceptionDescription message;          << 
684       message << "Safety method called for loc << 
685          << "Location for safety is Outside th << 
686          << "The approximate distance to the s << 
687          << "(safety from outside) is: "       << 
688          << motherSolid->DistanceToIn( localPo << 
689       message << "  Problem occurred with phys << 
690          << " Name: " << motherPhysical->GetNa << 
691          << " Copy No: " << motherPhysical->Ge << 
692          << "    Local Point = " << localPoint << 
693       message << "  Description of solid: " << << 
694             << *motherSolid << G4endl;         << 
695       G4Exception("G4VoxelNavigation::ComputeS << 
696                   JustWarning, message);       << 
697     }                                          << 
698                                                << 
699     // Following check is NOT for an issue - i << 
700     //  It is allowed that a solid gives appro << 
701     //                                         << 
702     if( insideMother == kInside ) // && fVerbo << 
703     {                                          << 
704       G4ExceptionDescription messageIn;        << 
705                                                << 
706       messageIn << " Point is Inside, but safe << 
707       messageIn << " Inexact safety for volume << 
708              << "  Solid: Name= " << motherSol << 
709              << "   Type= " << motherSolid->Ge << 
710       messageIn << "  Local point= " << localP << 
711       messageIn << "  Solid parameters: " << G << 
712       G4Exception("G4VoxelNavigation::ComputeS << 
713                   JustWarning, messageIn);     << 
714     }                                          << 
715 #endif                                         << 
716     // if( insideMother != kInside )           << 
717     return 0.0;                                << 
718   }                                            << 
719                                                << 
720 #ifdef G4VERBOSE                                  577 #ifdef G4VERBOSE
721   if( fCheck )                                    578   if( fCheck )
722   {                                               579   {
723     fLogger->ComputeSafetyLog (motherSolid,loc << 580     fLogger->ComputeSafetyLog (motherSolid, localPoint, motherSafety, true);
724   }                                               581   }
725 #endif                                            582 #endif
726   //                                              583   //
727   // Compute daughter safeties                 << 584   // Compute daughter safeties 
728   //                                              585   //
729   // Look only inside the current Voxel only ( << 586 
                                                   >> 587   localNoDaughters = motherLogical->GetNoDaughters();
                                                   >> 588 
                                                   >> 589   //  Look only inside the current Voxel only (in the first version).
730   //                                              590   //
731   curVoxelNode = fVoxelNode;                      591   curVoxelNode = fVoxelNode;
732   curNoVolumes = curVoxelNode->GetNoContained(    592   curNoVolumes = curVoxelNode->GetNoContained();
733                                                   593 
734   for ( contentNo=curNoVolumes-1; contentNo>=0    594   for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
735   {                                               595   {
736     sampleNo = curVoxelNode->GetVolume((G4int) << 596     sampleNo = curVoxelNode->GetVolume(contentNo);
737     samplePhysical = motherLogical->GetDaughte    597     samplePhysical = motherLogical->GetDaughter(sampleNo);
738                                                   598 
739     G4AffineTransform sampleTf(samplePhysical-    599     G4AffineTransform sampleTf(samplePhysical->GetRotation(),
740                                samplePhysical-    600                                samplePhysical->GetTranslation());
741     sampleTf.Invert();                            601     sampleTf.Invert();
742     const G4ThreeVector samplePoint = sampleTf << 602     const G4ThreeVector samplePoint =
743     const G4VSolid* sampleSolid= samplePhysica << 603                           sampleTf.TransformPoint(localPoint);
                                                   >> 604     const G4VSolid *sampleSolid     =
                                                   >> 605                           samplePhysical->GetLogicalVolume()->GetSolid();
744     G4double sampleSafety = sampleSolid->Dista    606     G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint);
745     if ( sampleSafety<ourSafety )                 607     if ( sampleSafety<ourSafety )
746     {                                             608     {
747       ourSafety = sampleSafety;                   609       ourSafety = sampleSafety;
748     }                                             610     }
749 #ifdef G4VERBOSE                                  611 #ifdef G4VERBOSE
750     if( fCheck )                                  612     if( fCheck )
751     {                                             613     {
752       fLogger->ComputeSafetyLog(sampleSolid, s << 614       fLogger->ComputeSafetyLog (sampleSolid,samplePoint,sampleSafety,false);
753                                 sampleSafety,  << 
754     }                                             615     }
755 #endif                                            616 #endif
756   }                                               617   }
757   voxelSafety = ComputeVoxelSafety(localPoint)    618   voxelSafety = ComputeVoxelSafety(localPoint);
758   if ( voxelSafety<ourSafety )                    619   if ( voxelSafety<ourSafety )
759   {                                               620   {
760     ourSafety = voxelSafety;                      621     ourSafety = voxelSafety;
761   }                                               622   }
762   return ourSafety;                               623   return ourSafety;
763 }                                                 624 }
764                                                   625 
765 void G4VoxelNavigation::RelocateWithinVolume(  << 
766                                                << 
767 {                                              << 
768   auto motherLogical = motherPhysical->GetLogi << 
769                                                << 
770   assert(motherLogical != nullptr);            << 
771                                                << 
772   if ( auto pVoxelHeader = motherLogical->GetV << 
773     VoxelLocate( pVoxelHeader, localPoint );   << 
774 }                                              << 
775                                                << 
776 // *******************************************    626 // ********************************************************************
777 // SetVerboseLevel                                627 // SetVerboseLevel
778 // *******************************************    628 // ********************************************************************
779 //                                                629 //
780 void  G4VoxelNavigation::SetVerboseLevel(G4int    630 void  G4VoxelNavigation::SetVerboseLevel(G4int level)
781 {                                                 631 {
782   if( fLogger != nullptr ) { fLogger->SetVerbo << 632   if( fLogger )       fLogger->SetVerboseLevel(level);
783   if( fpVoxelSafety != nullptr) { fpVoxelSafet << 633   if( fpVoxelSafety)  fpVoxelSafety->SetVerboseLevel( level ); 
784 }                                                 634 }
785                                                   635