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