| 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: G4CurveRayIntersection.icc,v 1.4 2006/06/29 18:39:07 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | // --------------------------------------------------------------------
|
|---|
| 31 | // GEANT 4 inline definitions file
|
|---|
| 32 | //
|
|---|
| 33 | // G4CurveRayIntersection.icc
|
|---|
| 34 | //
|
|---|
| 35 | // Implementation of inline methods of G4CurveRayIntersection
|
|---|
| 36 | // --------------------------------------------------------------------
|
|---|
| 37 |
|
|---|
| 38 | inline
|
|---|
| 39 | void G4CurveRayIntersection::Init(G4Curve& c0, const G4Ray& r0)
|
|---|
| 40 | {
|
|---|
| 41 | c= &c0;
|
|---|
| 42 | r= &r0;
|
|---|
| 43 | d= kInfinity;
|
|---|
| 44 | notComputed= allFlags;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 48 |
|
|---|
| 49 | inline
|
|---|
| 50 | const G4Ray& G4CurveRayIntersection::GetRay() const
|
|---|
| 51 | {
|
|---|
| 52 | return *r;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 56 |
|
|---|
| 57 | inline
|
|---|
| 58 | void G4CurveRayIntersection::Reset()
|
|---|
| 59 | {
|
|---|
| 60 | d= +kInfinity;
|
|---|
| 61 | notComputed= uFlag|pFlag;
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | inline void
|
|---|
| 65 | G4CurveRayIntersection::ResetPPoint(G4double u0)
|
|---|
| 66 | {
|
|---|
| 67 | d= 0;
|
|---|
| 68 | u= u0;
|
|---|
| 69 | notComputed= pFlag|dFlag;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | inline void
|
|---|
| 73 | G4CurveRayIntersection::Reset(const G4Point3D& p0)
|
|---|
| 74 | {
|
|---|
| 75 | d= 0;
|
|---|
| 76 | p= p0;
|
|---|
| 77 | notComputed= uFlag|dFlag;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | inline
|
|---|
| 81 | void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0)
|
|---|
| 82 | {
|
|---|
| 83 | d= 0;
|
|---|
| 84 | u= u0;
|
|---|
| 85 | p= p0;
|
|---|
| 86 | notComputed= dFlag;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | inline void
|
|---|
| 90 | G4CurveRayIntersection::ResetDistance(G4double d0)
|
|---|
| 91 | {
|
|---|
| 92 | d= d0;
|
|---|
| 93 | notComputed= uFlag|pFlag;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | inline
|
|---|
| 97 | void G4CurveRayIntersection::Reset(G4double u0, G4double d0)
|
|---|
| 98 | {
|
|---|
| 99 | d= d0;
|
|---|
| 100 | u= u0;
|
|---|
| 101 | notComputed= pFlag;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | inline
|
|---|
| 105 | void G4CurveRayIntersection::Reset(const G4Point3D& p0, G4double d0)
|
|---|
| 106 | {
|
|---|
| 107 | d= d0;
|
|---|
| 108 | p= p0;
|
|---|
| 109 | notComputed= uFlag;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | inline
|
|---|
| 113 | void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0,
|
|---|
| 114 | G4double d0)
|
|---|
| 115 | {
|
|---|
| 116 | d= d0;
|
|---|
| 117 | u= u0;
|
|---|
| 118 | p= p0;
|
|---|
| 119 | notComputed= 0;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 123 |
|
|---|
| 124 | inline
|
|---|
| 125 | G4double G4CurveRayIntersection::GetPPoint()
|
|---|
| 126 | {
|
|---|
| 127 | if (notComputed & uFlag) {
|
|---|
| 128 | if (notComputed & pFlag) {
|
|---|
| 129 | p= r->GetPoint(d);
|
|---|
| 130 | notComputed &= ~pFlag;
|
|---|
| 131 | }
|
|---|
| 132 | u= c->GetPPoint(p);
|
|---|
| 133 | notComputed &= ~uFlag;
|
|---|
| 134 | }
|
|---|
| 135 | return u;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | inline
|
|---|
| 139 | const G4Point3D& G4CurveRayIntersection::GetPoint()
|
|---|
| 140 | {
|
|---|
| 141 | if (notComputed & pFlag) {
|
|---|
| 142 | if (notComputed & dFlag) {
|
|---|
| 143 | p= c->GetPoint(u);
|
|---|
| 144 | } else {
|
|---|
| 145 | p= r->GetPoint(d);
|
|---|
| 146 | }
|
|---|
| 147 | notComputed &= ~pFlag;
|
|---|
| 148 | }
|
|---|
| 149 | return p;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | inline
|
|---|
| 153 | G4double G4CurveRayIntersection::GetDistance()
|
|---|
| 154 | {
|
|---|
| 155 | if (notComputed & dFlag) {
|
|---|
| 156 | if (notComputed & pFlag) {
|
|---|
| 157 | p= c->GetPoint(u);
|
|---|
| 158 | notComputed &= ~pFlag;
|
|---|
| 159 | }
|
|---|
| 160 | d= r->GetPPoint(p);
|
|---|
| 161 | notComputed &= ~dFlag;
|
|---|
| 162 | }
|
|---|
| 163 | return d;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 167 |
|
|---|
| 168 | inline
|
|---|
| 169 | void G4CurveRayIntersection::UpdateWithPointOnCurve(G4CurveRayIntersection& is)
|
|---|
| 170 | {
|
|---|
| 171 | if (d!=kInfinity) {
|
|---|
| 172 | // not the first intersection
|
|---|
| 173 | G4double dTmp= is.GetDistance();
|
|---|
| 174 | if (dTmp < kCarTolerance || GetDistance() <= dTmp) {
|
|---|
| 175 | // not on ray or not the closest intersection
|
|---|
| 176 | return;
|
|---|
| 177 | }
|
|---|
| 178 | }
|
|---|
| 179 | // accepted
|
|---|
| 180 | *this= is;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | inline
|
|---|
| 184 | void G4CurveRayIntersection::Update(G4CurveRayIntersection& is)
|
|---|
| 185 | {
|
|---|
| 186 | if (c->IsBounded()) {
|
|---|
| 187 | if (!c->IsPOn(is.GetPPoint())) {
|
|---|
| 188 | return;
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 | UpdateWithPointOnCurve(is);
|
|---|
| 192 | }
|
|---|