151 lines
5.3 KiB
Plaintext
151 lines
5.3 KiB
Plaintext
//
|
|
// ********************************************************************
|
|
// * License and Disclaimer *
|
|
// * *
|
|
// * The Geant4 software is copyright of the Copyright Holders of *
|
|
// * the Geant4 Collaboration. It is provided under the terms and *
|
|
// * conditions of the Geant4 Software License, included in the file *
|
|
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
|
// * include a list of copyright holders. *
|
|
// * *
|
|
// * Neither the authors of this software system, nor their employing *
|
|
// * institutes,nor the agencies providing financial support for this *
|
|
// * work make any representation or warranty, express or implied, *
|
|
// * regarding this software system or assume any liability for its *
|
|
// * use. Please see the license in the file LICENSE and URL above *
|
|
// * for the full disclaimer and the limitation of liability. *
|
|
// * *
|
|
// * This code implementation is the result of the scientific and *
|
|
// * technical work of the GEANT4 collaboration. *
|
|
// * By using, copying, modifying or distributing the software (or *
|
|
// * any work based on the software) you agree to acknowledge its *
|
|
// * use in resulting scientific publications, and indicate your *
|
|
// * acceptance of all terms of the Geant4 Software license. *
|
|
// ********************************************************************
|
|
//
|
|
// Class G4AuxiliaryNavServices Inline implementation
|
|
//
|
|
// Author: Paul Kent (CERN), August 1996
|
|
// --------------------------------------------------------------------
|
|
|
|
inline G4bool
|
|
G4AuxiliaryNavServices::
|
|
CheckPointOnSurface( const G4VSolid* sampleSolid,
|
|
const G4ThreeVector& localPoint,
|
|
const G4ThreeVector* globalDirection,
|
|
const G4AffineTransform& sampleTransform,
|
|
const G4bool locatedOnEdge)
|
|
{
|
|
G4ThreeVector localDirection, sampleNormal;
|
|
G4bool enter = false;
|
|
|
|
EInside insideSolid = sampleSolid->Inside(localPoint);
|
|
if ( insideSolid!=kOutside )
|
|
{
|
|
G4bool checkDirection = locatedOnEdge && (globalDirection!=nullptr);
|
|
if( (insideSolid==kSurface) && checkDirection)
|
|
{
|
|
// We are probably located on an edge.
|
|
//
|
|
localDirection = sampleTransform.TransformAxis(*globalDirection);
|
|
|
|
// Check whether we enter the volume
|
|
//
|
|
sampleNormal = sampleSolid->SurfaceNormal(localPoint);
|
|
|
|
G4double dotProd = sampleNormal.dot(localDirection);
|
|
|
|
#ifdef G4DEBUG_AUX_NAVIGATION
|
|
G4cout << " dir.norm= " << dotProd // sampleNormal.dot(localDirection)
|
|
<< " localDirection= " << localDirection
|
|
<< " sampleNormal= " << sampleNormal;
|
|
if( dotProd == 0.0 )
|
|
{
|
|
G4cout << " distanceToIn = "
|
|
<< sampleSolid->DistanceToIn( localPoint, localDirection );
|
|
}
|
|
#endif
|
|
|
|
if ( dotProd <= 0.0 )
|
|
{
|
|
if( dotProd == 0.0 )
|
|
{
|
|
// We can't decide yet, let's make sure we're entering the solid.
|
|
// If by a confusion we entered the next solid we find out now
|
|
// whether to leave or to enter.
|
|
// This happens when we're on the surface or edge shared by two
|
|
// solids
|
|
//
|
|
G4double distanceToIn =
|
|
sampleSolid->DistanceToIn( localPoint, localDirection );
|
|
if( distanceToIn != kInfinity )
|
|
{
|
|
enter = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
enter = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
enter = true;
|
|
}
|
|
}
|
|
#ifdef G4DEBUG_AUX_NAVIGATION
|
|
G4cout << " enter = " << (enter ? "true" : "false" ) << G4endl;
|
|
#endif
|
|
|
|
return enter;
|
|
}
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
inline G4bool
|
|
G4AuxiliaryNavServices::
|
|
CheckPointExiting( const G4VSolid* sampleSolid,
|
|
const G4ThreeVector& localPoint,
|
|
const G4ThreeVector* globalDirection,
|
|
const G4AffineTransform& sampleTransform )
|
|
{
|
|
if( globalDirection == nullptr ) { return false; }
|
|
|
|
G4ThreeVector localDirection, sampleNormal;
|
|
G4bool exiting = false;
|
|
|
|
EInside insideSolid = sampleSolid->Inside(localPoint);
|
|
if( insideSolid==kSurface )
|
|
{
|
|
localDirection = sampleTransform.TransformAxis(*globalDirection);
|
|
|
|
// Check whether we are exiting the volume
|
|
//
|
|
sampleNormal = sampleSolid->SurfaceNormal(localPoint);
|
|
if ( sampleNormal.dot(localDirection) >= 0 )
|
|
{
|
|
if( sampleNormal.dot(localDirection) == 0 )
|
|
{
|
|
// We can't decide yet, let's make sure we're entering the solid.
|
|
// If by a confusion we entered the next solid we find out now
|
|
// whether to leave or to exiting.
|
|
// This happens when we're on the surface or edge shared by two
|
|
// solids
|
|
//
|
|
G4double distanceToIn =
|
|
sampleSolid->DistanceToIn( localPoint, localDirection );
|
|
if( distanceToIn != kInfinity )
|
|
{
|
|
exiting = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
exiting = true;
|
|
}
|
|
}
|
|
}
|
|
return exiting;
|
|
}
|