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 66356 2012-12-18 09:02:32Z 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);
 
   58       if ( sampleNormal.dot(localDirection) <= 0 )
 
   60         if( sampleNormal.dot(localDirection) == 0 )
 
   62           // We can't decide yet, let's make sure we're entering the solid.
 
   63           // If by a confusion we entered the next solid we find out now
 
   64           // whether to leave or to enter.
 
   65           // This happens when we're on the surface or edge shared by two
 
   68           G4double distanceToIn =
 
   69                    sampleSolid->DistanceToIn( localPoint, localDirection );
 
   70           if( distanceToIn != kInfinity )
 
   89 // --------------------------------------------------------------------
 
   92 G4AuxiliaryNavServices::
 
   93 CheckPointExiting( const G4VSolid* sampleSolid, 
 
   94                    const G4ThreeVector& localPoint, 
 
   95                    const G4ThreeVector* globalDirection, 
 
   96                    const G4AffineTransform& sampleTransform )
 
   98   if( !globalDirection )  { return false; }
 
  100   G4ThreeVector localDirection, sampleNormal;
 
  101   G4bool        exiting = false;
 
  103   EInside insideSolid = sampleSolid->Inside(localPoint); 
 
  104   if( insideSolid==kSurface )
 
  106     localDirection= sampleTransform.TransformAxis(*globalDirection); 
 
  108     // Check whether we are exiting the volume
 
  110     sampleNormal = sampleSolid->SurfaceNormal(localPoint);
 
  111     if ( sampleNormal.dot(localDirection) >= 0 )
 
  113       if( sampleNormal.dot(localDirection) == 0 )
 
  115         // We can't decide yet, let's make sure we're entering the solid.
 
  116         // If by a confusion we entered the next solid we find out now
 
  117         // whether to leave or to exiting.
 
  118         // This happens when we're on the surface or edge shared by two
 
  121         G4double distanceToIn =
 
  122                  sampleSolid->DistanceToIn( localPoint, localDirection );
 
  123         if( distanceToIn != kInfinity )