source: trunk/source/geometry/navigation/include/G4AuxiliaryNavServices.icc @ 921

Last change on this file since 921 was 921, checked in by garnier, 15 years ago

en test de gl2ps. Problemes de libraries

File size: 4.8 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
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.                             *
10// *                                                                  *
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.         *
17// *                                                                  *
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// ********************************************************************
25//
26//
27// $Id: G4AuxiliaryNavServices.icc,v 1.4 2007/05/22 07:48:08 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-cand-01 $
29//
30//
31// class G4AuxiliaryNavServices Inline implementation
32//
33// --------------------------------------------------------------------
34
35inline G4bool
36G4AuxiliaryNavServices::
37CheckPointOnSurface( const G4VSolid* sampleSolid,
38                     const G4ThreeVector& localPoint,
39                     const G4ThreeVector* globalDirection,
40                     const G4AffineTransform& sampleTransform,
41                     const G4bool locatedOnEdge)
42{
43  G4ThreeVector localDirection, sampleNormal;
44  G4bool        enter = false;
45
46  EInside insideSolid = sampleSolid->Inside(localPoint);
47  if ( insideSolid!=kOutside )
48  {
49    G4bool checkDirection= locatedOnEdge && (globalDirection!=0);
50    if( (insideSolid==kSurface) && checkDirection)
51    {
52      // We are probably located on an edge.
53      //
54      localDirection= sampleTransform.TransformAxis(*globalDirection);
55
56      // Check whether we enter the volume
57      //
58      sampleNormal = sampleSolid->SurfaceNormal(localPoint);
59      if ( sampleNormal.dot(localDirection) <= 0 )
60      {
61        if( sampleNormal.dot(localDirection) == 0 )
62        {
63          // We can't decide yet, let's make sure we're entering the solid.
64          // If by a confusion we entered the next solid we find out now
65          // whether to leave or to enter.
66          // This happens when we're on the surface or edge shared by two
67          // solids
68          //
69          G4double distanceToIn =
70                   sampleSolid->DistanceToIn( localPoint, localDirection );
71          if( distanceToIn != kInfinity )
72          {
73            enter = true;
74          }
75        }
76        else
77        {
78          enter = true;
79        }
80      }
81    }
82    else
83    {
84      enter = true;
85    }
86  }
87  return enter;
88}
89
90// --------------------------------------------------------------------
91
92inline G4bool
93G4AuxiliaryNavServices::
94CheckPointExiting( const G4VSolid* sampleSolid,
95                   const G4ThreeVector& localPoint,
96                   const G4ThreeVector* globalDirection,
97                   const G4AffineTransform& sampleTransform )
98{
99  if( !globalDirection )  { return false; }
100
101  G4ThreeVector localDirection, sampleNormal;
102  G4bool        exiting = false;
103
104  EInside insideSolid = sampleSolid->Inside(localPoint);
105  if( (insideSolid==kSurface) )
106  {
107    localDirection= sampleTransform.TransformAxis(*globalDirection);
108
109    // Check whether we are exiting the volume
110    //
111    sampleNormal = sampleSolid->SurfaceNormal(localPoint);
112    if ( sampleNormal.dot(localDirection) >= 0 )
113    {
114      if( sampleNormal.dot(localDirection) == 0 )
115      {
116        // We can't decide yet, let's make sure we're entering the solid.
117        // If by a confusion we entered the next solid we find out now
118        // whether to leave or to exiting.
119        // This happens when we're on the surface or edge shared by two
120        // solids
121        //
122        G4double distanceToIn =
123                 sampleSolid->DistanceToIn( localPoint, localDirection );
124        if( distanceToIn != kInfinity )
125        {
126          exiting = true;
127        }
128      }
129      else
130      {
131        exiting = true;
132      }
133    }
134  }
135  return exiting;
136}
Note: See TracBrowser for help on using the repository browser.