Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Curve.hh
Go to the documentation of this file.
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$
28 //
29 // ----------------------------------------------------------------------
30 // Class G4Curve
31 //
32 // Class Description:
33 //
34 // Definition of a generic curve.
35 // To Initialize objects derived from G4Curve:
36 // - Construct curve (the constructor takes no parameters)
37 // - call Init()
38 // - if the curve is bounded, call one of the SetBounds() methods.
39 
40 // Author: J.Sulkimo, P.Urban.
41 // Revisions by: L.Broglia, G.Cosmo.
42 // ----------------------------------------------------------------------
43 #ifndef __CURVE_H
44 #define __CURVE_H
45 
46 #include "geomdefs.hh"
47 #include "G4Point3D.hh"
48 #include "G4Vector3D.hh"
49 #include "G4BoundingBox3D.hh"
50 #include "G4Transform3D.hh"
51 #include "G4Ray.hh"
52 
53 class G4Ray;
55 class G4CurvePoint;
56 class G4Surface;
57 
58 class G4Curve
59 {
60 
61  public: // with description
62 
63  G4Curve();
64  virtual ~G4Curve();
65  // Constructor & destructor.
66 
67  G4Curve(const G4Curve& c);
68  G4Curve& operator=(const G4Curve& c);
69  // Copy contructor and assignment operator.
70 
71  inline G4bool operator==(const G4Curve& right) const;
72  // Equality operator.
73 
74  virtual G4String GetEntityType() const;
75  // Returns shape identifier.
76 
77  virtual G4Curve* Project(const G4Transform3D& tr =
79  // Projection onto the xy plane after the transformation tr.
80  // The returned object is allocated dynamically; it's caller's
81  // responsibility to delete it.
82  // In case the projection maps two distinct points into one, 0 is returned.
83  // NOTE: this should not occur when using projection with
84  // G4SurfaceOfRevolution.
85 
86  virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v)= 0;
87  // Returns tangent vector v to a curve at the point cp.
88  // Returns true if v exists.
89 
90  virtual G4int IntersectRay2D(const G4Ray& ray)= 0;
91  // Intersects a 2D curve with a ray.
92  // The ray is projected onto the xy plane.
93  // If no intersection it returns false, otherwise it returns true,
94  // the intersection point is ray.start+ray.dir*intersection0.
95 
96  inline const G4Point3D& GetStart() const;
97  inline const G4Point3D& GetEnd() const;
98  // Return start and endpoints in 3D space.
99 
100  inline G4double GetPStart() const;
101  inline G4double GetPEnd() const;
102  // Return start and endpoints in parameter space.
103 
104  inline void SetBounds(G4double p1, G4double p2);
105  inline void SetBounds(G4double p1, const G4Point3D& p2);
106  inline void SetBounds(const G4Point3D& p1, G4double p2);
107  inline void SetBounds(const G4Point3D& p1, const G4Point3D& p2);
108  // Set start and endpoints, given points as parameter values
109  // or 3D points.
110 
111  inline G4bool IsBounded() const;
112  // Returns if the curve is bounded.
113 
114  inline G4bool IsPOn(G4double param) const;
115  // Returns if the parameter is on the curve.
116 
117  inline void SetSameSense(G4int sameSense0);
118  inline G4int GetSameSense() const;
119  // The sameSense flag can be used to reverse the orientation
120  // of the curve (value false).
121  // The curves themselves never use the value of this flag;
122  // this is just a convenient mean of storing this piece of
123  // topological information.
124 
125  virtual G4double GetPMax() const = 0;
126  // If the parameter space is closed, return the max value
127  // if not, return <=0.
128 
129  virtual G4Point3D GetPoint(G4double param) const = 0;
130  // Return the point in the 3D space, given correspondent parameter.
131 
132  virtual G4double GetPPoint(const G4Point3D& p) const = 0;
133  // Return parapmeter give a point in space.
134  // In case the point is further off the curve than some tolerance
135  // the result is undefined.
136 
137  const G4BoundingBox3D* BBox() const;
138  // Gets the bounding box for the curve
139  // If the curve is not bounded, the result is undefined.
140 
141  virtual const char* Name() const;
142  // Returns type name.
143 
144  public: // without description
145 
146  // virtual void Transform(const G4Transform3D& tr);
147  // Transformation of the curve.
148  // virtual void IntersectRay2D(const G4Ray&, G4CurveRayIntersection&)= 0;
149 
150  virtual void SetParentSrfPtr(const G4Surface*);
151  // To be moved to a derived class. Is it really needed?
152 
153  protected:
154 
155  virtual void InitBounded()= 0;
156  // This function will be called after the bounds are set.
157 
158  protected:
159 
169 
170  private:
171 
172  inline void SetStart(const G4Point3D& pt);
173  inline void SetStart(G4double p);
174  inline void SetEnd(const G4Point3D& p);
175  inline void SetEnd(G4double p);
176  inline void SetBoundsRest();
177 
178 };
179 
180 #include "G4Curve.icc"
181 
182 #endif