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 G4Curve 00031 // 00032 // Class Description: 00033 // 00034 // Definition of a generic curve. 00035 // To Initialize objects derived from G4Curve: 00036 // - Construct curve (the constructor takes no parameters) 00037 // - call Init() 00038 // - if the curve is bounded, call one of the SetBounds() methods. 00039 00040 // Author: J.Sulkimo, P.Urban. 00041 // Revisions by: L.Broglia, G.Cosmo. 00042 // ---------------------------------------------------------------------- 00043 #ifndef __CURVE_H 00044 #define __CURVE_H 00045 00046 #include "geomdefs.hh" 00047 #include "G4Point3D.hh" 00048 #include "G4Vector3D.hh" 00049 #include "G4BoundingBox3D.hh" 00050 #include "G4Transform3D.hh" 00051 #include "G4Ray.hh" 00052 00053 class G4Ray; 00054 class G4CurveRayIntersection; 00055 class G4CurvePoint; 00056 class G4Surface; 00057 00058 class G4Curve 00059 { 00060 00061 public: // with description 00062 00063 G4Curve(); 00064 virtual ~G4Curve(); 00065 // Constructor & destructor. 00066 00067 G4Curve(const G4Curve& c); 00068 G4Curve& operator=(const G4Curve& c); 00069 // Copy contructor and assignment operator. 00070 00071 inline G4bool operator==(const G4Curve& right) const; 00072 // Equality operator. 00073 00074 virtual G4String GetEntityType() const; 00075 // Returns shape identifier. 00076 00077 virtual G4Curve* Project(const G4Transform3D& tr = 00078 G4Transform3D::Identity)= 0; 00079 // Projection onto the xy plane after the transformation tr. 00080 // The returned object is allocated dynamically; it's caller's 00081 // responsibility to delete it. 00082 // In case the projection maps two distinct points into one, 0 is returned. 00083 // NOTE: this should not occur when using projection with 00084 // G4SurfaceOfRevolution. 00085 00086 virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v)= 0; 00087 // Returns tangent vector v to a curve at the point cp. 00088 // Returns true if v exists. 00089 00090 virtual G4int IntersectRay2D(const G4Ray& ray)= 0; 00091 // Intersects a 2D curve with a ray. 00092 // The ray is projected onto the xy plane. 00093 // If no intersection it returns false, otherwise it returns true, 00094 // the intersection point is ray.start+ray.dir*intersection0. 00095 00096 inline const G4Point3D& GetStart() const; 00097 inline const G4Point3D& GetEnd() const; 00098 // Return start and endpoints in 3D space. 00099 00100 inline G4double GetPStart() const; 00101 inline G4double GetPEnd() const; 00102 // Return start and endpoints in parameter space. 00103 00104 inline void SetBounds(G4double p1, G4double p2); 00105 inline void SetBounds(G4double p1, const G4Point3D& p2); 00106 inline void SetBounds(const G4Point3D& p1, G4double p2); 00107 inline void SetBounds(const G4Point3D& p1, const G4Point3D& p2); 00108 // Set start and endpoints, given points as parameter values 00109 // or 3D points. 00110 00111 inline G4bool IsBounded() const; 00112 // Returns if the curve is bounded. 00113 00114 inline G4bool IsPOn(G4double param) const; 00115 // Returns if the parameter is on the curve. 00116 00117 inline void SetSameSense(G4int sameSense0); 00118 inline G4int GetSameSense() const; 00119 // The sameSense flag can be used to reverse the orientation 00120 // of the curve (value false). 00121 // The curves themselves never use the value of this flag; 00122 // this is just a convenient mean of storing this piece of 00123 // topological information. 00124 00125 virtual G4double GetPMax() const = 0; 00126 // If the parameter space is closed, return the max value 00127 // if not, return <=0. 00128 00129 virtual G4Point3D GetPoint(G4double param) const = 0; 00130 // Return the point in the 3D space, given correspondent parameter. 00131 00132 virtual G4double GetPPoint(const G4Point3D& p) const = 0; 00133 // Return parapmeter give a point in space. 00134 // In case the point is further off the curve than some tolerance 00135 // the result is undefined. 00136 00137 const G4BoundingBox3D* BBox() const; 00138 // Gets the bounding box for the curve 00139 // If the curve is not bounded, the result is undefined. 00140 00141 virtual const char* Name() const; 00142 // Returns type name. 00143 00144 public: // without description 00145 00146 // virtual void Transform(const G4Transform3D& tr); 00147 // Transformation of the curve. 00148 // virtual void IntersectRay2D(const G4Ray&, G4CurveRayIntersection&)= 0; 00149 00150 virtual void SetParentSrfPtr(const G4Surface*); 00151 // To be moved to a derived class. Is it really needed? 00152 00153 protected: 00154 00155 virtual void InitBounded()= 0; 00156 // This function will be called after the bounds are set. 00157 00158 protected: 00159 00160 G4BoundingBox3D bBox; 00161 G4Point3D start; 00162 G4Point3D end; 00163 G4double pStart; 00164 G4double pEnd; 00165 G4double pRange; 00166 G4bool bounded; 00167 G4int sameSense; 00168 G4double kCarTolerance; 00169 00170 private: 00171 00172 inline void SetStart(const G4Point3D& pt); 00173 inline void SetStart(G4double p); 00174 inline void SetEnd(const G4Point3D& p); 00175 inline void SetEnd(G4double p); 00176 inline void SetBoundsRest(); 00177 00178 }; 00179 00180 #include "G4Curve.icc" 00181 00182 #endif