2 // ********************************************************************
3 // * License and Disclaimer *
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. *
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. *
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 // ********************************************************************
27 // $Id: G4AuxiliaryNavServices.icc 90836 2015-06-10 09:31:06Z gcosmo $
30 // class G4AuxiliaryNavServices Inline implementation
32 // --------------------------------------------------------------------
35 G4AuxiliaryNavServices::
36 CheckPointOnSurface( const G4VSolid* sampleSolid,
37 const G4ThreeVector& localPoint,
38 const G4ThreeVector* globalDirection,
39 const G4AffineTransform& sampleTransform,
40 const G4bool locatedOnEdge)
42 G4ThreeVector localDirection, sampleNormal;
45 EInside insideSolid = sampleSolid->Inside(localPoint);
46 if ( insideSolid!=kOutside )
48 G4bool checkDirection= locatedOnEdge && (globalDirection!=0);
49 if( (insideSolid==kSurface) && checkDirection)
51 // We are probably located on an edge.
53 localDirection= sampleTransform.TransformAxis(*globalDirection);
55 // Check whether we enter the volume
57 sampleNormal = sampleSolid->SurfaceNormal(localPoint);
59 G4double dotProd= sampleNormal.dot(localDirection);
61 #ifdef G4DEBUG_AUX_NAVIGATION
62 G4cout << " dir.norm= " << dotProd // sampleNormal.dot(localDirection)
63 << " localDirection= " << localDirection
64 << " sampleNormal= " << sampleNormal;
67 G4cout << " distanceToIn = "
68 << sampleSolid->DistanceToIn( localPoint, localDirection );
76 // We can't decide yet, let's make sure we're entering the solid.
77 // If by a confusion we entered the next solid we find out now
78 // whether to leave or to enter.
79 // This happens when we're on the surface or edge shared by two
82 G4double distanceToIn =
83 sampleSolid->DistanceToIn( localPoint, localDirection );
84 if( distanceToIn != kInfinity )
100 #ifdef G4DEBUG_AUX_NAVIGATION
101 G4cout << " enter = " << (enter ? "true" : "false" ) << G4endl;
107 // --------------------------------------------------------------------
110 G4AuxiliaryNavServices::
111 CheckPointExiting( const G4VSolid* sampleSolid,
112 const G4ThreeVector& localPoint,
113 const G4ThreeVector* globalDirection,
114 const G4AffineTransform& sampleTransform )
116 if( !globalDirection ) { return false; }
118 G4ThreeVector localDirection, sampleNormal;
119 G4bool exiting = false;
121 EInside insideSolid = sampleSolid->Inside(localPoint);
122 if( insideSolid==kSurface )
124 localDirection= sampleTransform.TransformAxis(*globalDirection);
126 // Check whether we are exiting the volume
128 sampleNormal = sampleSolid->SurfaceNormal(localPoint);
129 if ( sampleNormal.dot(localDirection) >= 0 )
131 if( sampleNormal.dot(localDirection) == 0 )
133 // We can't decide yet, let's make sure we're entering the solid.
134 // If by a confusion we entered the next solid we find out now
135 // whether to leave or to exiting.
136 // This happens when we're on the surface or edge shared by two
139 G4double distanceToIn =
140 sampleSolid->DistanceToIn( localPoint, localDirection );
141 if( distanceToIn != kInfinity )