Geant4_10
G4USolid.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 // GEANT4 tag $Name:$
29 //
30 //
31 // class G4USolid
32 //
33 // Class description:
34 //
35 // Bridge base class for solids defined in the Unified Solids Library.
36 
37 // --------------------------------------------------------------------
38 #ifndef G4USolid_HH
39 #define G4USolid_HH
40 
41 #include "G4VSolid.hh"
42 #include "VUSolid.hh"
43 
44 class G4USolid : public G4VSolid
45 {
46  public: // with description
47 
48  G4USolid(const G4String& pName, VUSolid* shape);
49  // Creates a new shape, with the supplied name. No provision is made
50  // for sharing a common name amongst multiple classes.
51  virtual ~G4USolid();
52  // Default destructor.
53 
54  G4bool operator==(const G4USolid& s) const;
55  // Return true only if addresses are the same.
56 
57  virtual G4bool CalculateExtent(const EAxis pAxis,
58  const G4VoxelLimits& pVoxelLimit,
59  const G4AffineTransform& pTransform,
60  G4double& pMin, G4double& pMax) const;
61  // Calculate the minimum and maximum extent of the solid, when under the
62  // specified transform, and within the specified limits. If the solid
63  // is not intersected by the region, return false, else return true.
64 
65  virtual EInside Inside(const G4ThreeVector& p) const;
66  // Returns kOutside if the point at offset p is outside the shapes
67  // boundaries plus Tolerance/2, kSurface if the point is <= Tolerance/2
68  // from a surface, otherwise kInside.
69 
70  virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
71  // Returns the outwards pointing unit normal of the shape for the
72  // surface closest to the point at offset p.
73 
74  virtual G4double DistanceToIn(const G4ThreeVector& p,
75  const G4ThreeVector& v) const;
76  // Return the distance along the normalised vector v to the shape,
77  // from the point at offset p. If there is no intersection, return
78  // kInfinity. The first intersection resulting from `leaving' a
79  // surface/volume is discarded. Hence, it is tolerant of points on
80  // the surface of the shape.
81 
82  virtual G4double DistanceToIn(const G4ThreeVector& p) const;
83  // Calculate the distance to the nearest surface of a shape from an
84  // outside point. The distance can be an underestimate.
85 
86  virtual G4double DistanceToOut(const G4ThreeVector& p,
87  const G4ThreeVector& v,
88  const G4bool calcNorm = false,
89  G4bool* validNorm = 0,
90  G4ThreeVector* n = 0) const;
91  // Return the distance along the normalised vector v to the shape,
92  // from a point at an offset p inside or on the surface of the shape.
93  // Intersections with surfaces, when the point is < Tolerance/2 from a
94  // surface must be ignored.
95  // If calcNorm==true:
96  // validNorm set true if the solid lies entirely behind or on the
97  // exiting surface.
98  // n set to exiting outwards normal vector (undefined Magnitude).
99  // validNorm set to false if the solid does not lie entirely behind
100  // or on the exiting surface
101  // If calcNorm==false:
102  // validNorm and n are unused.
103  //
104  // Must be called as solid.DistanceToOut(p,v) or by specifying all
105  // the parameters.
106 
107  virtual G4double DistanceToOut(const G4ThreeVector& p) const;
108  // Calculate the distance to the nearest surface of a shape from an
109  // inside point. The distance can be an underestimate.
110 
111 
112  virtual G4double GetCubicVolume();
113  // Returns an estimation of the solid volume in internal units.
114  // This method may be overloaded by derived classes to compute the
115  // exact geometrical quantity for solids where this is possible,
116  // or anyway to cache the computed value.
117  // Note: the computed value is NOT cached.
118 
119  virtual G4double GetSurfaceArea();
120  // Return an estimation of the solid surface area in internal units.
121  // This method may be overloaded by derived classes to compute the
122  // exact geometrical quantity for solids where this is possible,
123  // or anyway to cache the computed value.
124  // Note: the computed value is NOT cached.
125 
126  virtual G4GeometryType GetEntityType() const;
127  // Provide identification of the class of an object.
128  // (required for persistency and STEP interface)
129 
130  virtual G4ThreeVector GetPointOnSurface() const;
131  // Returns a random point located on the surface of the solid.
132 
133  virtual G4VSolid* Clone() const;
134  // Returns a pointer of a dynamically allocated copy of the solid.
135  // Returns NULL pointer with warning in case the concrete solid does not
136  // implement this method. The caller has responsibility for ownership.
137 
138  virtual std::ostream& StreamInfo(std::ostream& os) const;
139  // Dumps contents of the solid to a stream.
140 
141  virtual void DescribeYourselfTo(G4VGraphicsScene& scene) const;
142  // A "double dispatch" function which identifies the solid
143  // to the graphics scene for visualization.
144 
145  virtual G4VisExtent GetExtent() const;
146  // Provide extent (bounding box) as possible hint to the graphics view.
148  // Create Polyhedron used for Visualisation
149  virtual G4Polyhedron* GetPolyhedron() const;
150  // Smart access function - creates on request and stores for future
151  // access. A null pointer means "not available".
152  virtual void ResetPolyhedron() const;
153  //Reset Polyhedron used by Parametrisation
154  public: // without description
155 
156  G4USolid(__void__&);
157  // Fake default constructor for usage restricted to direct object
158  // persistency for clients requiring preallocation of memory for
159  // persistifiable objects.
160 
161  G4USolid(const G4USolid& rhs);
162  G4USolid& operator=(const G4USolid& rhs);
163  // Copy constructor and assignment operator.
164 
165  VUSolid* GetSolid() const
166  {
167  return fShape;
168  }
169 
170  protected:
171 
173 
174  protected: // data
175 
177 
178  private:
179 
180  mutable G4Polyhedron* fPolyhedron;
181 };
182 
183 #endif
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pT) const
Definition: G4USolid.cc:383
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4USolid.cc:330
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4USolid.cc:118
G4Polyhedron * CreatePolyhedron() const
Definition: G4USolid.cc:423
const XML_Char * s
Definition: expat.h:262
const char * p
Definition: xmltok.h:285
virtual std::ostream & StreamInfo(std::ostream &os) const
Definition: G4USolid.cc:341
virtual G4double GetCubicVolume()
Definition: G4USolid.cc:158
virtual G4double GetSurfaceArea()
Definition: G4USolid.cc:163
virtual EInside Inside(const G4ThreeVector &p) const
Definition: G4USolid.cc:63
VUSolid * GetSolid() const
Definition: G4USolid.hh:165
G4bool operator==(const G4USolid &s) const
Definition: G4USolid.cc:58
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4USolid.cc:530
Char_t n[5]
VUSolid * fShape
Definition: G4USolid.hh:176
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
tuple v
Definition: test.py:18
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4USolid.cc:91
G4USolid(const G4String &pName, VUSolid *shape)
Definition: G4USolid.cc:44
virtual void ResetPolyhedron() const
Definition: G4USolid.cc:536
EInside
Definition: geomdefs.hh:58
EAxis
Definition: geomdefs.hh:54
virtual G4VisExtent GetExtent() const
Definition: G4USolid.cc:541
G4USolid & operator=(const G4USolid &rhs)
Definition: G4USolid.cc:357
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4USolid.cc:80
virtual ~G4USolid()
Definition: G4USolid.cc:54
double G4double
Definition: G4Types.hh:76
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
Definition: G4USolid.cc:175
virtual G4VSolid * Clone() const
Definition: G4USolid.cc:377
virtual G4GeometryType GetEntityType() const
Definition: G4USolid.cc:334
virtual G4ThreeVector GetPointOnSurface() const
Definition: G4USolid.cc:168