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// ********************************************************************
26// class G4AuxiliaryNavServices Inline implementation
28// --------------------------------------------------------------------
31G4AuxiliaryNavServices::
32CheckPointOnSurface( const G4VSolid* sampleSolid,
33 const G4ThreeVector& localPoint,
34 const G4ThreeVector* globalDirection,
35 const G4AffineTransform& sampleTransform,
36 const G4bool locatedOnEdge)
38 G4ThreeVector localDirection, sampleNormal;
41 EInside insideSolid = sampleSolid->Inside(localPoint);
42 if ( insideSolid!=kOutside )
44 G4bool checkDirection = locatedOnEdge && (globalDirection!=0);
45 if( (insideSolid==kSurface) && checkDirection)
47 // We are probably located on an edge.
49 localDirection = sampleTransform.TransformAxis(*globalDirection);
51 // Check whether we enter the volume
53 sampleNormal = sampleSolid->SurfaceNormal(localPoint);
55 G4double dotProd = sampleNormal.dot(localDirection);
57#ifdef G4DEBUG_AUX_NAVIGATION
58 G4cout << " dir.norm= " << dotProd // sampleNormal.dot(localDirection)
59 << " localDirection= " << localDirection
60 << " sampleNormal= " << sampleNormal;
63 G4cout << " distanceToIn = "
64 << sampleSolid->DistanceToIn( localPoint, localDirection );
72 // We can't decide yet, let's make sure we're entering the solid.
73 // If by a confusion we entered the next solid we find out now
74 // whether to leave or to enter.
75 // This happens when we're on the surface or edge shared by two
78 G4double distanceToIn =
79 sampleSolid->DistanceToIn( localPoint, localDirection );
80 if( distanceToIn != kInfinity )
96#ifdef G4DEBUG_AUX_NAVIGATION
97 G4cout << " enter = " << (enter ? "true" : "false" ) << G4endl;
103// --------------------------------------------------------------------
106G4AuxiliaryNavServices::
107CheckPointExiting( const G4VSolid* sampleSolid,
108 const G4ThreeVector& localPoint,
109 const G4ThreeVector* globalDirection,
110 const G4AffineTransform& sampleTransform )
112 if( !globalDirection ) { return false; }
114 G4ThreeVector localDirection, sampleNormal;
115 G4bool exiting = false;
117 EInside insideSolid = sampleSolid->Inside(localPoint);
118 if( insideSolid==kSurface )
120 localDirection = sampleTransform.TransformAxis(*globalDirection);
122 // Check whether we are exiting the volume
124 sampleNormal = sampleSolid->SurfaceNormal(localPoint);
125 if ( sampleNormal.dot(localDirection) >= 0 )
127 if( sampleNormal.dot(localDirection) == 0 )
129 // We can't decide yet, let's make sure we're entering the solid.
130 // If by a confusion we entered the next solid we find out now
131 // whether to leave or to exiting.
132 // This happens when we're on the surface or edge shared by two
135 G4double distanceToIn =
136 sampleSolid->DistanceToIn( localPoint, localDirection );
137 if( distanceToIn != kInfinity )