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