G4AuxiliaryNavServices.icc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 // class G4AuxiliaryNavServices Inline implementation
00031 //
00032 // --------------------------------------------------------------------
00033 
00034 inline G4bool
00035 G4AuxiliaryNavServices::
00036 CheckPointOnSurface( const G4VSolid* sampleSolid, 
00037                      const G4ThreeVector& localPoint, 
00038                      const G4ThreeVector* globalDirection, 
00039                      const G4AffineTransform& sampleTransform,
00040                      const G4bool locatedOnEdge)
00041 {
00042   G4ThreeVector localDirection, sampleNormal;
00043   G4bool        enter = false;
00044 
00045   EInside insideSolid = sampleSolid->Inside(localPoint); 
00046   if ( insideSolid!=kOutside ) 
00047   {
00048     G4bool checkDirection= locatedOnEdge && (globalDirection!=0);
00049     if( (insideSolid==kSurface) && checkDirection)
00050     {
00051       // We are probably located on an edge.
00052       //
00053       localDirection= sampleTransform.TransformAxis(*globalDirection); 
00054 
00055       // Check whether we enter the volume
00056       // 
00057       sampleNormal = sampleSolid->SurfaceNormal(localPoint);
00058       if ( sampleNormal.dot(localDirection) <= 0 )
00059       {
00060         if( sampleNormal.dot(localDirection) == 0 )
00061         {
00062           // We can't decide yet, let's make sure we're entering the solid.
00063           // If by a confusion we entered the next solid we find out now
00064           // whether to leave or to enter.
00065           // This happens when we're on the surface or edge shared by two
00066           // solids
00067           //
00068           G4double distanceToIn =
00069                    sampleSolid->DistanceToIn( localPoint, localDirection );
00070           if( distanceToIn != kInfinity )
00071           {
00072             enter = true;
00073           } 
00074         }
00075         else
00076         {
00077           enter = true;
00078         }
00079       }
00080     }
00081     else
00082     {
00083       enter = true;
00084     }
00085   }
00086   return enter;
00087 }
00088 
00089 // --------------------------------------------------------------------
00090 
00091 inline G4bool
00092 G4AuxiliaryNavServices::
00093 CheckPointExiting( const G4VSolid* sampleSolid, 
00094                    const G4ThreeVector& localPoint, 
00095                    const G4ThreeVector* globalDirection, 
00096                    const G4AffineTransform& sampleTransform )
00097 {
00098   if( !globalDirection )  { return false; }
00099 
00100   G4ThreeVector localDirection, sampleNormal;
00101   G4bool        exiting = false;
00102 
00103   EInside insideSolid = sampleSolid->Inside(localPoint); 
00104   if( insideSolid==kSurface )
00105   {
00106     localDirection= sampleTransform.TransformAxis(*globalDirection); 
00107 
00108     // Check whether we are exiting the volume
00109     // 
00110     sampleNormal = sampleSolid->SurfaceNormal(localPoint);
00111     if ( sampleNormal.dot(localDirection) >= 0 )
00112     {
00113       if( sampleNormal.dot(localDirection) == 0 )
00114       {
00115         // We can't decide yet, let's make sure we're entering the solid.
00116         // If by a confusion we entered the next solid we find out now
00117         // whether to leave or to exiting.
00118         // This happens when we're on the surface or edge shared by two
00119         // solids
00120         //
00121         G4double distanceToIn =
00122                  sampleSolid->DistanceToIn( localPoint, localDirection );
00123         if( distanceToIn != kInfinity )
00124         {
00125           exiting = true;
00126         } 
00127       }
00128       else
00129       {
00130         exiting = true;
00131       }
00132     }
00133   }
00134   return exiting;
00135 }

Generated on Mon May 27 17:47:42 2013 for Geant4 by  doxygen 1.4.7