| 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: G4Surface.hh,v 1.10 2007/05/11 13:49:32 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03 $
|
|---|
| 29 | //
|
|---|
| 30 | // ----------------------------------------------------------------------
|
|---|
| 31 | // Class G4Surface
|
|---|
| 32 | //
|
|---|
| 33 | // Class description:
|
|---|
| 34 | //
|
|---|
| 35 | // Base class for a generic surface.
|
|---|
| 36 |
|
|---|
| 37 | // Authors: J.Sulkimo, P.Urban.
|
|---|
| 38 | // Revisions by: L.Broglia, G.Cosmo.
|
|---|
| 39 | // ----------------------------------------------------------------------
|
|---|
| 40 | #ifndef __surface_h
|
|---|
| 41 | #define __surface_h 1
|
|---|
| 42 |
|
|---|
| 43 | #include "geomdefs.hh"
|
|---|
| 44 | #include "G4CurveVector.hh"
|
|---|
| 45 | #include "G4PointRat.hh"
|
|---|
| 46 | #include "G4Ray.hh"
|
|---|
| 47 | #include "G4BoundingBox3D.hh"
|
|---|
| 48 | #include "G4STEPEntity.hh"
|
|---|
| 49 | #include "G4SurfaceBoundary.hh"
|
|---|
| 50 |
|
|---|
| 51 | class G4Surface : public G4STEPEntity
|
|---|
| 52 | {
|
|---|
| 53 |
|
|---|
| 54 | public: // with description
|
|---|
| 55 |
|
|---|
| 56 | G4Surface();
|
|---|
| 57 | virtual ~G4Surface();
|
|---|
| 58 | // Constructor & destructor.
|
|---|
| 59 |
|
|---|
| 60 | G4int operator==( const G4Surface& s );
|
|---|
| 61 | // Equality operator.
|
|---|
| 62 |
|
|---|
| 63 | virtual G4String GetEntityType() const;
|
|---|
| 64 | // Returns type information, needed for STEP output.
|
|---|
| 65 |
|
|---|
| 66 | virtual const char* Name() const;
|
|---|
| 67 | virtual G4int MyType() const;
|
|---|
| 68 | // Returns type information, redundant versions...
|
|---|
| 69 |
|
|---|
| 70 | void SetBoundaries(G4CurveVector*);
|
|---|
| 71 | // Sets the boundaries of the surface. The curves in the CurveVector
|
|---|
| 72 | // must be non-intersecting closed curves.
|
|---|
| 73 |
|
|---|
| 74 | virtual G4double HowNear( const G4Vector3D& x ) const;
|
|---|
| 75 | // Returns the distance from the point x to the Surface.
|
|---|
| 76 | // The default for a Surface is the distance from the point to the
|
|---|
| 77 | // origin. Overridden by derived classes to take into account boundaries.
|
|---|
| 78 |
|
|---|
| 79 | virtual G4double ClosestDistanceToPoint(const G4Point3D& Pt);
|
|---|
| 80 | // Returns the closest distance to point Pt, as for HowNear() above.
|
|---|
| 81 | // This one is used by G4BREPSolid.
|
|---|
| 82 |
|
|---|
| 83 | inline G4Vector3D GetOrigin() const;
|
|---|
| 84 | inline G4double GetDistance() const;
|
|---|
| 85 | inline void SetDistance(G4double Dist);
|
|---|
| 86 | inline G4int IsActive() const;
|
|---|
| 87 | inline void SetActive(G4int act);
|
|---|
| 88 | inline void Deactivate();
|
|---|
| 89 | inline void SetSameSense(G4int sameSense0);
|
|---|
| 90 | inline G4int GetSameSense() const;
|
|---|
| 91 | inline G4BoundingBox3D* GetBBox();
|
|---|
| 92 | inline const G4Point3D& GetClosestHit() const;
|
|---|
| 93 | inline void SetNextNode(G4Surface*);
|
|---|
| 94 | inline G4Surface* GetNextNode();
|
|---|
| 95 | // Get/Set methods for surface's attributes.
|
|---|
| 96 |
|
|---|
| 97 | virtual void Reset();
|
|---|
| 98 | // Resets basic attributes.
|
|---|
| 99 |
|
|---|
| 100 | virtual G4int Intersect(const G4Ray&);
|
|---|
| 101 | // Should return the intersection with a ray. Cannot be called from
|
|---|
| 102 | // G4Surface base class. Overridden by subclasses.
|
|---|
| 103 |
|
|---|
| 104 | virtual G4Vector3D Normal( const G4Vector3D& p ) const;
|
|---|
| 105 | // Returns the Normal unit vector to a Surface at the point p on
|
|---|
| 106 | // (or nearly on) the Surface. The default is not well defined,
|
|---|
| 107 | // so return ( 0, 0, 0 ). Overridden by subclasses.
|
|---|
| 108 |
|
|---|
| 109 | virtual void CalcBBox();
|
|---|
| 110 | // Calculates the bounds for a bounding box to the surface.
|
|---|
| 111 | // The bounding box is used for a preliminary check of intersection.
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | public: // without description
|
|---|
| 115 |
|
|---|
| 116 | static void Project (G4double& Coord, const G4Point3D& Pt,
|
|---|
| 117 | const G4Plane& Pl);
|
|---|
| 118 | // Utility function returning the projection (Coord) of a point Pt
|
|---|
| 119 | // on a plane Pl.
|
|---|
| 120 |
|
|---|
| 121 | virtual G4double GetUHit() const;
|
|---|
| 122 | virtual G4double GetVHit() const;
|
|---|
| 123 | // Overriden by BSplineSurface.
|
|---|
| 124 | // uhit and vhit are never set.
|
|---|
| 125 |
|
|---|
| 126 | virtual G4Point3D Evaluation(const G4Ray& G4Rayref);
|
|---|
| 127 | virtual G4int Evaluate(register const G4Ray& Rayref);
|
|---|
| 128 | // For NURBS, there is a two pass intersection algorithm.
|
|---|
| 129 | // Sometimes, the result of the cheap one tells us
|
|---|
| 130 | // that execution of the expensive one is not necessary.
|
|---|
| 131 | // Evaluation (Evaluate?) is one of them. Better names wanted!
|
|---|
| 132 |
|
|---|
| 133 | virtual void Project();
|
|---|
| 134 | // Used by BREPSolid. Thus it's probably needed.
|
|---|
| 135 |
|
|---|
| 136 | virtual void CalcNormal();
|
|---|
| 137 | // Used only in G4FPlane. Should be private to that class?
|
|---|
| 138 |
|
|---|
| 139 | virtual G4int IsConvex() const;
|
|---|
| 140 | // Only in G4FPlane. BREPSolid::IsConvex uses it.
|
|---|
| 141 | // But who uses BREPSolid::IsConvex? Thus: probably not needed.
|
|---|
| 142 | // However, knowing if the surface is convex could be used for
|
|---|
| 143 | // optimization.
|
|---|
| 144 |
|
|---|
| 145 | virtual G4int GetConvex() const;
|
|---|
| 146 | // Only in G4FPlane, but G4BREPSolid uses them.
|
|---|
| 147 |
|
|---|
| 148 | virtual G4int GetNumberOfPoints() const;
|
|---|
| 149 | virtual const G4Point3D& GetPoint(G4int Count) const;
|
|---|
| 150 | // ???
|
|---|
| 151 |
|
|---|
| 152 | virtual G4Ray* Norm();
|
|---|
| 153 | virtual G4Vector3D SurfaceNormal(const G4Point3D& Pt) const = 0;
|
|---|
| 154 | // There is Normal as well -- so what do these do?
|
|---|
| 155 |
|
|---|
| 156 | /*
|
|---|
| 157 | virtual G4double distanceAlongRay( G4int which_way, const G4Ray* ry,
|
|---|
| 158 | G4Vector3D& p ) const;
|
|---|
| 159 | // Returns distance along a Ray (straight line with G4ThreeVec) to leave
|
|---|
| 160 | // or enter a Surface. The input variable which_way should be set to +1
|
|---|
| 161 | // to indicate leaving a Surface, -1 to indicate entering a Surface.
|
|---|
| 162 | // p is the point of intersection of the Ray with the Surface.
|
|---|
| 163 | // This is a default function which just gives the distance
|
|---|
| 164 | // between the origin of the Ray and the origin of the Surface.
|
|---|
| 165 | // Since a generic Surface doesn't have a well-defined Normal, no
|
|---|
| 166 | // further checks are Done. It must be overwritten by derived classes.
|
|---|
| 167 |
|
|---|
| 168 | virtual G4double G4Surface::distanceAlongHelix( G4int which_way,
|
|---|
| 169 | const Helix* hx,
|
|---|
| 170 | G4ThreeVec& p ) const;
|
|---|
| 171 | // Returns the distance along a Helix to leave or enter a Surface.
|
|---|
| 172 | // The input variable which_way should be set to +1 to indicate
|
|---|
| 173 | // leaving a Surface, -1 to indicate entering a Surface.
|
|---|
| 174 | // p is the point of intersection of the Helix with the Surface.
|
|---|
| 175 | // This is a default function which just gives the distance
|
|---|
| 176 | // between the origin of the Helix and the origin of the Surface.
|
|---|
| 177 | // Since a generic Surface doesn't have a well-defined Normal, no
|
|---|
| 178 | // further checks are Done. It must be overwritten by derived classes.
|
|---|
| 179 | */
|
|---|
| 180 |
|
|---|
| 181 | protected:
|
|---|
| 182 |
|
|---|
| 183 | virtual void InitBounded();
|
|---|
| 184 |
|
|---|
| 185 | protected:
|
|---|
| 186 |
|
|---|
| 187 | G4BoundingBox3D* bbox;
|
|---|
| 188 | G4Point3D closest_hit;
|
|---|
| 189 | G4Surface* next;
|
|---|
| 190 |
|
|---|
| 191 | G4SurfaceBoundary surfaceBoundary;
|
|---|
| 192 | // The boundaries of the surface.
|
|---|
| 193 |
|
|---|
| 194 | G4double kCarTolerance;
|
|---|
| 195 |
|
|---|
| 196 | G4int Intersected;
|
|---|
| 197 | // BSplineSurface and FPlane sets it, no one gets it.
|
|---|
| 198 |
|
|---|
| 199 | G4Vector3D origin;
|
|---|
| 200 | // Origin of Surface.
|
|---|
| 201 |
|
|---|
| 202 | G4int Type;
|
|---|
| 203 | G4int AdvancedFace;
|
|---|
| 204 | G4int active;
|
|---|
| 205 | G4double distance;
|
|---|
| 206 | G4double uhit,vhit;
|
|---|
| 207 | // Generic attributes...
|
|---|
| 208 |
|
|---|
| 209 | G4int sameSense;
|
|---|
| 210 | // by L. Broglia
|
|---|
| 211 |
|
|---|
| 212 | protected:
|
|---|
| 213 |
|
|---|
| 214 | const G4double FLT_MAXX;
|
|---|
| 215 | // Maybe kInfinity instead?
|
|---|
| 216 |
|
|---|
| 217 | const G4double FLT_EPSILO;
|
|---|
| 218 | // Maybe kCarTolerance instead?
|
|---|
| 219 |
|
|---|
| 220 | private:
|
|---|
| 221 |
|
|---|
| 222 | G4Surface(const G4Surface&);
|
|---|
| 223 | G4Surface& operator=(const G4Surface&);
|
|---|
| 224 | // Private copy constructor and assignment operator.
|
|---|
| 225 |
|
|---|
| 226 | };
|
|---|
| 227 |
|
|---|
| 228 | #include "G4Surface.icc"
|
|---|
| 229 |
|
|---|
| 230 | #endif
|
|---|