G4CurveRayIntersection.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 // GEANT 4 inline definitions file
00031 //
00032 // G4CurveRayIntersection.icc
00033 //
00034 // Implementation of inline methods of G4CurveRayIntersection
00035 // --------------------------------------------------------------------
00036 
00037 inline
00038 void G4CurveRayIntersection::Init(G4Curve& c0, const G4Ray& r0)
00039 {
00040   c= &c0;
00041   r= &r0;
00042   d= kInfinity;
00043   notComputed= allFlags;
00044 }
00045 
00047 
00048 inline
00049 const G4Ray& G4CurveRayIntersection::GetRay() const
00050 {
00051   return *r;
00052 }
00053 
00055 
00056 inline
00057 void G4CurveRayIntersection::Reset()
00058 {
00059   d= +kInfinity;
00060   notComputed= uFlag|pFlag;
00061 }
00062 
00063 inline void
00064 G4CurveRayIntersection::ResetPPoint(G4double u0)
00065 {
00066   d= 0;
00067   u= u0;
00068   notComputed= pFlag|dFlag;
00069 }
00070 
00071 inline void
00072 G4CurveRayIntersection::Reset(const G4Point3D& p0)
00073 {
00074   d= 0;
00075   p= p0;
00076   notComputed= uFlag|dFlag;
00077 }
00078 
00079 inline
00080 void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0)
00081 {
00082   d= 0;
00083   u= u0;
00084   p= p0;
00085   notComputed= dFlag;
00086 }
00087 
00088 inline void
00089 G4CurveRayIntersection::ResetDistance(G4double d0)
00090 {
00091   d= d0;
00092   notComputed= uFlag|pFlag;
00093 }
00094 
00095 inline
00096 void G4CurveRayIntersection::Reset(G4double u0, G4double d0)
00097 {
00098   d= d0;
00099   u= u0;
00100   notComputed= pFlag;
00101 }
00102 
00103 inline
00104 void G4CurveRayIntersection::Reset(const G4Point3D& p0, G4double d0)
00105 {
00106   d= d0;
00107   p= p0;
00108   notComputed= uFlag;
00109 }
00110 
00111 inline
00112 void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0,
00113                                    G4double d0)
00114 {
00115   d= d0;
00116   u= u0;
00117   p= p0;
00118   notComputed= 0;
00119 }
00120 
00122 
00123 inline
00124 G4double G4CurveRayIntersection::GetPPoint()
00125 {
00126   if (notComputed & uFlag) {
00127     if (notComputed & pFlag) {
00128       p= r->GetPoint(d);
00129       notComputed &= ~pFlag;
00130     }
00131     u= c->GetPPoint(p);
00132     notComputed &= ~uFlag;
00133   }
00134   return u;
00135 }
00136 
00137 inline
00138 const G4Point3D& G4CurveRayIntersection::GetPoint()
00139 {
00140   if (notComputed & pFlag) {
00141     if (notComputed & dFlag) {
00142       p= c->GetPoint(u);
00143     } else {
00144       p= r->GetPoint(d);
00145     }
00146     notComputed &= ~pFlag;
00147   }
00148   return p;
00149 }
00150 
00151 inline
00152 G4double G4CurveRayIntersection::GetDistance()
00153 {
00154   if (notComputed & dFlag) {
00155     if (notComputed & pFlag) {
00156       p= c->GetPoint(u);
00157       notComputed &= ~pFlag;
00158     }
00159     d= r->GetPPoint(p);
00160     notComputed &= ~dFlag;
00161   }
00162   return d;
00163 }
00164 
00166 
00167 inline
00168 void G4CurveRayIntersection::UpdateWithPointOnCurve(G4CurveRayIntersection& is)
00169 {
00170   if (d!=kInfinity) {
00171     // not the first intersection
00172     G4double dTmp= is.GetDistance();
00173     if (dTmp < kCarTolerance || GetDistance() <= dTmp) {
00174       // not on ray or not the closest intersection
00175       return;
00176     }
00177   }
00178   // accepted
00179   *this= is;
00180 }       
00181 
00182 inline
00183 void G4CurveRayIntersection::Update(G4CurveRayIntersection& is)
00184 {
00185   if (c->IsBounded()) {
00186     if (!c->IsPOn(is.GetPPoint())) {
00187       return;
00188     }   
00189   }
00190   UpdateWithPointOnCurve(is);
00191 }

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