Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-19 08:16:28

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Class G4AuxiliaryNavServices Inline implementation
0027 //
0028 // Author: Paul Kent (CERN), August 1996
0029 // --------------------------------------------------------------------
0030 
0031 inline G4bool
0032 G4AuxiliaryNavServices::
0033 CheckPointOnSurface( const G4VSolid* sampleSolid, 
0034                      const G4ThreeVector& localPoint, 
0035                      const G4ThreeVector* globalDirection, 
0036                      const G4AffineTransform& sampleTransform,
0037                      const G4bool locatedOnEdge)
0038 {
0039   G4ThreeVector localDirection, sampleNormal;
0040   G4bool enter = false;
0041 
0042   EInside insideSolid = sampleSolid->Inside(localPoint); 
0043   if ( insideSolid!=kOutside ) 
0044   {
0045     G4bool checkDirection = locatedOnEdge && (globalDirection!=nullptr);
0046     if( (insideSolid==kSurface) && checkDirection)
0047     {
0048       // We are probably located on an edge.
0049       //
0050       localDirection = sampleTransform.TransformAxis(*globalDirection); 
0051 
0052       // Check whether we enter the volume
0053       // 
0054       sampleNormal = sampleSolid->SurfaceNormal(localPoint);
0055 
0056       G4double dotProd = sampleNormal.dot(localDirection);
0057       
0058 #ifdef G4DEBUG_AUX_NAVIGATION
0059       G4cout << " dir.norm= " << dotProd // sampleNormal.dot(localDirection) 
0060              << " localDirection= " << localDirection
0061              << " sampleNormal= " << sampleNormal;
0062       if( dotProd == 0.0 )
0063       {
0064         G4cout << " distanceToIn = " 
0065                << sampleSolid->DistanceToIn( localPoint, localDirection );
0066       }
0067 #endif
0068 
0069       if ( dotProd <= 0.0 )         
0070       {
0071         if( dotProd == 0.0 )
0072         {
0073           // We can't decide yet, let's make sure we're entering the solid.
0074           // If by a confusion we entered the next solid we find out now
0075           // whether to leave or to enter.
0076           // This happens when we're on the surface or edge shared by two
0077           // solids
0078           //
0079           G4double distanceToIn =
0080                    sampleSolid->DistanceToIn( localPoint, localDirection );
0081           if( distanceToIn != kInfinity )
0082           {
0083             enter = true;
0084           } 
0085         }
0086         else
0087         {
0088           enter = true;
0089         }
0090       }
0091     }
0092     else
0093     {
0094       enter = true;
0095     }
0096   }
0097 #ifdef G4DEBUG_AUX_NAVIGATION  
0098   G4cout << " enter = " << (enter ? "true" : "false" ) << G4endl;
0099 #endif
0100   
0101   return enter;
0102 }
0103 
0104 // --------------------------------------------------------------------
0105 
0106 inline G4bool
0107 G4AuxiliaryNavServices::
0108 CheckPointExiting( const G4VSolid* sampleSolid, 
0109                    const G4ThreeVector& localPoint, 
0110                    const G4ThreeVector* globalDirection, 
0111                    const G4AffineTransform& sampleTransform )
0112 {
0113   if( globalDirection == nullptr )  { return false; }
0114 
0115   G4ThreeVector localDirection, sampleNormal;
0116   G4bool exiting = false;
0117 
0118   EInside insideSolid = sampleSolid->Inside(localPoint); 
0119   if( insideSolid==kSurface )
0120   {
0121     localDirection = sampleTransform.TransformAxis(*globalDirection); 
0122 
0123     // Check whether we are exiting the volume
0124     // 
0125     sampleNormal = sampleSolid->SurfaceNormal(localPoint);
0126     if ( sampleNormal.dot(localDirection) >= 0 )
0127     {
0128       if( sampleNormal.dot(localDirection) == 0 )
0129       {
0130         // We can't decide yet, let's make sure we're entering the solid.
0131         // If by a confusion we entered the next solid we find out now
0132         // whether to leave or to exiting.
0133         // This happens when we're on the surface or edge shared by two
0134         // solids
0135         //
0136         G4double distanceToIn =
0137                  sampleSolid->DistanceToIn( localPoint, localDirection );
0138         if( distanceToIn != kInfinity )
0139         {
0140           exiting = true;
0141         } 
0142       }
0143       else
0144       {
0145         exiting = true;
0146       }
0147     }
0148   }
0149   return exiting;
0150 }