G4Surface.hh

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 // Class G4Surface
00031 //
00032 // Class description:
00033 // 
00034 // Base class for a generic surface.
00035 
00036 // Authors: J.Sulkimo, P.Urban.
00037 // Revisions by: L.Broglia, G.Cosmo.
00038 // ----------------------------------------------------------------------
00039 #ifndef __surface_h
00040 #define __surface_h 1
00041 
00042 #include "geomdefs.hh"
00043 #include "G4CurveVector.hh"
00044 #include "G4PointRat.hh"
00045 #include "G4Ray.hh"
00046 #include "G4BoundingBox3D.hh"
00047 #include "G4STEPEntity.hh"
00048 #include "G4SurfaceBoundary.hh"
00049 
00050 class G4Surface : public G4STEPEntity
00051 {
00052 
00053  public:  // with description
00054 
00055   G4Surface();
00056   virtual ~G4Surface();
00057     // Constructor & destructor.
00058 
00059   G4int operator==( const G4Surface& s );
00060     // Equality operator.
00061 
00062   virtual G4String GetEntityType() const;
00063     // Returns type information, needed for STEP output.
00064 
00065   virtual const char* Name() const;
00066   virtual G4int MyType() const;
00067     // Returns type information, redundant versions...
00068 
00069   void SetBoundaries(G4CurveVector*);
00070     // Sets the boundaries of the surface. The curves in the CurveVector
00071     // must be non-intersecting closed curves.
00072 
00073   virtual G4double HowNear( const G4Vector3D& x ) const; 
00074     // Returns the distance from the point x to the Surface.
00075     // The default for a Surface is the distance from the point to the
00076     // origin. Overridden by derived classes to take into account boundaries.
00077 
00078   virtual G4double ClosestDistanceToPoint(const G4Point3D& Pt);
00079     // Returns the closest distance to point Pt, as for HowNear() above.
00080     // This one is used by G4BREPSolid.
00081 
00082   inline G4Vector3D GetOrigin() const;
00083   inline G4double GetDistance() const;
00084   inline void SetDistance(G4double Dist);
00085   inline G4int IsActive() const;
00086   inline void SetActive(G4int act);
00087   inline void Deactivate();
00088   inline void SetSameSense(G4int sameSense0);
00089   inline G4int GetSameSense() const;
00090   inline G4BoundingBox3D* GetBBox();
00091   inline const G4Point3D& GetClosestHit() const;
00092   inline void SetNextNode(G4Surface*);
00093   inline G4Surface* GetNextNode();
00094     // Get/Set methods for surface's attributes.
00095 
00096   virtual void Reset();
00097     // Resets basic attributes.
00098 
00099   virtual G4int Intersect(const G4Ray&);
00100     // Should return the intersection with a ray. Cannot be called from
00101     // G4Surface base class. Overridden by subclasses.
00102 
00103   virtual G4Vector3D Normal( const G4Vector3D& p ) const;
00104     // Returns the Normal unit vector to a Surface at the point p on
00105     // (or nearly on) the Surface. The default is not well defined,
00106     // so return ( 0, 0, 0 ). Overridden by subclasses.
00107 
00108   virtual void CalcBBox();
00109     // Calculates the bounds for a bounding box to the surface.
00110     // The bounding box is used for a preliminary check of intersection.
00111 
00112  public:  // without description
00113 
00114   static void Project (G4double& Coord, const G4Point3D& Pt, 
00115                                         const G4Plane& Pl);
00116     // Utility function returning the projection (Coord) of a point Pt
00117     // on a plane Pl.
00118 
00119   virtual G4double GetUHit() const;
00120   virtual G4double GetVHit() const;
00121     // Overriden by BSplineSurface.
00122     // uhit and vhit are never set.
00123 
00124   virtual G4Point3D Evaluation(const G4Ray& G4Rayref);
00125   virtual G4int Evaluate(register const G4Ray& Rayref);  
00126     // For NURBS, there is a two pass intersection algorithm.
00127     // Sometimes, the result of the cheap one tells us 
00128     // that execution of the expensive one is not necessary.
00129     // Evaluation (Evaluate?) is one of them. Better names wanted!
00130 
00131   virtual void Project();
00132     // Used by BREPSolid. Thus it's probably needed.
00133 
00134   virtual void CalcNormal();
00135     // Used only in G4FPlane. Should be private to that class?
00136 
00137   virtual G4int IsConvex() const;
00138     // Only in G4FPlane. BREPSolid::IsConvex uses it.
00139     // But who uses BREPSolid::IsConvex? Thus: probably not needed.
00140     // However, knowing if the surface is convex could be used for
00141     // optimization. 
00142 
00143   virtual G4int GetConvex() const;
00144     // Only in G4FPlane, but G4BREPSolid uses them.
00145 
00146   virtual G4int GetNumberOfPoints() const;
00147   virtual const G4Point3D& GetPoint(G4int Count) const;
00148     // ???
00149 
00150   virtual G4Ray* Norm();
00151   virtual G4Vector3D SurfaceNormal(const G4Point3D& Pt) const = 0;  
00152     // There is Normal as well -- so what do these do?
00153 
00154 /*
00155   virtual G4double distanceAlongRay( G4int which_way, const G4Ray* ry,
00156                                      G4Vector3D& p ) const;
00157     // Returns distance along a Ray (straight line with G4ThreeVec) to leave
00158     // or enter a Surface. The input variable which_way should be set to +1
00159     // to indicate leaving a Surface, -1 to indicate entering a Surface.
00160     // p is the point of intersection of the Ray with the Surface.
00161     // This is a default function which just gives the distance
00162     // between the origin of the Ray and the origin of the Surface.
00163     // Since a generic Surface doesn't have a well-defined Normal, no
00164     // further checks are Done. It must be overwritten by derived classes.
00165 
00166   virtual G4double G4Surface::distanceAlongHelix( G4int which_way,
00167                                                   const Helix* hx,
00168                                                   G4ThreeVec& p ) const;
00169     // Returns the distance along a Helix to leave or enter a Surface.  
00170     // The input variable which_way should be set to +1 to indicate
00171     // leaving a Surface, -1 to indicate entering a Surface.
00172     // p is the point of intersection of the Helix with the Surface.
00173     // This is a default function which just gives the distance
00174     // between the origin of the Helix and the origin of the Surface.
00175     // Since a generic Surface doesn't have a well-defined Normal, no
00176     // further checks are Done. It must be overwritten by derived classes.
00177 */
00178 
00179  protected:
00180 
00181   virtual void InitBounded();
00182 
00183  protected:
00184 
00185   G4BoundingBox3D* bbox;
00186   G4Point3D closest_hit;
00187   G4Surface* next;
00188 
00189   G4SurfaceBoundary surfaceBoundary;
00190     // The boundaries of the surface.
00191 
00192   G4double kCarTolerance, kAngTolerance;
00193 
00194   G4int Intersected;
00195     // BSplineSurface and FPlane sets it, no one gets it.
00196 
00197   G4Vector3D origin;
00198     // Origin of Surface.
00199 
00200   G4int Type;
00201   G4int AdvancedFace;
00202   G4int active;
00203   G4double distance;
00204   G4double uhit,vhit;
00205     // Generic attributes...
00206 
00207   G4int sameSense;
00208     // by L. Broglia
00209 
00210  private:
00211 
00212   G4Surface(const G4Surface&);
00213   G4Surface& operator=(const G4Surface&);
00214     // Private copy constructor and assignment operator.
00215 
00216 };
00217 
00218 #include "G4Surface.icc"
00219 
00220 #endif

Generated on Mon May 27 17:49:56 2013 for Geant4 by  doxygen 1.4.7