Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BREPSolid.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 G4BREPSolid
31//
32// Class description:
33//
34// Base class for generic Boundary REPresentation solid.
35
36// Authors: J.Sulkimo, P.Urban.
37// Revisions by: L.Broglia, G.Cosmo.
38// ----------------------------------------------------------------------
39#ifndef __SOLID_H
40#define __SOLID_H
41
42#include "G4VSolid.hh"
43#include "G4Surface.hh"
44#include "G4Axis2Placement3D.hh"
45#include "G4PointRat.hh"
46#include "G4BoundingBox3D.hh"
47
48class G4Ray;
49
50class G4BREPSolid : public G4VSolid
51{
52
53public: // with description
54
55 G4BREPSolid(const G4String& name);
57 virtual ~G4BREPSolid();
58 // Constructors & destructor
59
60 virtual void Initialize();
61 // Calculates the bounding box for solids and surfaces.
62 // Converts concave planes to convex.
63
64 G4bool CalculateExtent(const EAxis pAxis ,
65 const G4VoxelLimits& pVoxelLimit,
66 const G4AffineTransform& pTransform ,
67 G4double& pMin ,
68 G4double& pMax ) const;
69 // Calculate the minimum and maximum extent of the solid, when under the
70 // specified transform, and within the specified limits. If the solid
71 // is not intersected by the region, return false, else return true.
72
73 virtual EInside Inside(register const G4ThreeVector& Pt) const;
74 // Determines if the point Pt is inside, outside or on the surface
75 // of the solid.
76
77 virtual G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
78 // Calculates the normal of the surface at a point on the surface
79 // The sense of the normal depends on the sense of the surface.
80
81 virtual G4double DistanceToIn(const G4ThreeVector&) const;
82 // Calculates the shortest distance ("safety") from a point
83 // outside the solid to any boundary of this solid.
84 // Return 0 if the point is already inside.
85
86 virtual G4double DistanceToIn(register const G4ThreeVector& Pt,
87 register const G4ThreeVector& V) const;
88 // Calculates the distance from a point Pt outside the solid
89 // to the solid's boundary along a specified direction vector V.
90 // Note: Intersections with boundaries less than the tolerance must
91 // be ignored if the direction is away from the boundary.
92
93 virtual G4double DistanceToOut(const G4ThreeVector&) const;
94 // Calculates the shortest distance ("safety") from a point inside the
95 // solid to any boundary of this solid.
96 // Return 0 if the point is already outside.
97
98 virtual G4double DistanceToOut(register const G4ThreeVector& Pt,
99 register const G4ThreeVector& V,
100 const G4bool calcNorm=false ,
101 G4bool *validNorm=0 ,
102 G4ThreeVector *n=0 ) const;
103 // Calculates the distance from a point inside the solid to the solid`s
104 // boundary along a specified direction vector.
105 // Return 0 if the point is already outside.
106 // Note: If the shortest distance to a boundary is less than the
107 // tolerance, it is ignored. This allows for a point within a
108 // tolerant boundary to leave immediately.
109
110 G4Point3D Scope() const;
111 // Utility function to determine the maximum scope of the solid
112 // in the coordinates X, Y, Z. Returned as a G4Point3D.
113
114 virtual G4String GetEntityType() const;
115 // Returns identifier for solid type entity.
116 // A generic BREP solid is considered a "Closed_Shell".
117
118 virtual G4VSolid* Clone() const;
119 // Returns a pointer of a dynamically allocated copy of the solid.
120 // The caller has responsibility for ownership.
121
122 virtual std::ostream& StreamInfo(std::ostream& os) const;
123 // Streams solid contents to output stream.
124
125 void DescribeYourselfTo (G4VGraphicsScene& scene) const;
126 // Dispatch function which identifies the solid to the graphics scene.
127
129 G4NURBS* CreateNURBS () const;
130 // Create a G4Polyhedron/G4NURBS/... (It is the caller's responsibility
131 // to delete it). A null pointer means "not created".
132 virtual G4Polyhedron* GetPolyhedron () const;
133 // Smart access function - creates on request and stores for future
134 // access. A null pointer means "not available".
135
136 G4int Intersect(register const G4Ray&) const;
137 // Gets the roughly calculated closest intersection point for
138 // a b_spline and the accurate point for others.
139
140 inline G4Surface* GetSurface(G4int) const;
141 inline void Active(G4int) const;
142 inline G4int Active() const;
144 inline G4int GetId() const;
145 inline void SetId(G4int);
146 inline const G4String& GetName() const;
147 inline void SetName(const G4String& name);
148 inline G4int GetNumberOfFaces() const;
149 inline G4int GetNumberOfSolids() const;
150 inline const G4Axis2Placement3D* GetPlace() const;
151 inline const G4BoundingBox3D* GetBBox() const;
152 // Accessors methods.
153
156 inline void SetCubVolStatistics(G4int st);
157 inline void SetCubVolEpsilon(G4double ep);
158 inline G4int GetAreaStatistics() const;
159 inline G4double GetAreaAccuracy() const;
160 inline void SetAreaStatistics(G4int st);
161 inline void SetAreaAccuracy(G4double ep);
162 // Accessors methods.
163
164public:
165
167 // Returns an estimation of the geometrical cubic volume of the
168 // solid. Caches the computed value once computed the first time.
170 // Returns an estimation of the geometrical surface area of the
171 // solid. Caches the computed value once computed the first time.
172
174 inline void IntersectionDistance(G4double) const;
175 // Gets and sets intersection distance.
176
177 virtual void Reset() const;
178 // Resets all distance attributes.
179
180public: // without description
181
182 G4BREPSolid(__void__&);
183 // Fake default constructor for usage restricted to direct object
184 // persistency for clients requiring preallocation of memory for
185 // persistifiable objects.
186
187 G4BREPSolid(const G4BREPSolid& rhs);
188 G4BREPSolid& operator=(const G4BREPSolid& rhs);
189 // Copy constructor and assignment operator.
190
191protected:
192
195
196 virtual void CalcBBoxes();
197 // Calculates the bounding boxes for the surfaces and for the solid.
198
199 void CheckSurfaceNormals();
200 void RemoveHiddenFaces(register const G4Ray& G4Rayref, G4int) const;
201 // Deactivates the planar faces that are on the "back" side of a solid.
202 // B-splines are not handled by this function. Also cases where the ray
203 // starting point is Inside the bbox of the solid are ignored as we don't
204 // know if the starting point is Inside the actual solid except for
205 // axis-oriented box-like solids.
206
207 void TestSurfaceBBoxes(register const G4Ray&) const;
208 // Tests the bounding-box to all surfaces in List.
209 // For planar faces the intersection is instead evaluated.
210
211 inline G4int StartInside() const;
212 inline void StartInside(G4int si) const;
213
214 inline void QuickSort( register G4Surface** SrfVec,
215 register G4int left, register G4int right) const;
216
217protected:
218
220 static G4Ray Track;
222
235
236
237private:
238
239 G4int IsBox();
240 G4int FinalEvaluation(register const G4Ray&, G4int =0) const;
241
242private:
243
244 G4int fStatistics;
245 G4double fCubVolEpsilon;
246 G4double fAreaAccuracy;
247 G4double fCubicVolume;
248 G4double fSurfaceArea;
249 // Statistics, error accuracy and cached value for volume and area.
250
251 mutable G4Polyhedron* fpPolyhedron;
252
253};
254
255#include "G4BREPSolid.icc"
256
257#endif
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:85
G4Axis2Placement3D * place
Definition: G4BREPSolid.hh:224
void SetAreaStatistics(G4int st)
G4int GetId() const
G4double GetShortestDistance() const
static G4Ray Track
Definition: G4BREPSolid.hh:220
G4int Active() const
G4Surface ** SurfaceVec
Definition: G4BREPSolid.hh:231
G4int GetAreaStatistics() const
virtual G4Polyhedron * GetPolyhedron() const
G4double intersectionDistance
Definition: G4BREPSolid.hh:226
void QuickSort(register G4Surface **SrfVec, register G4int left, register G4int right) const
virtual G4double DistanceToOut(const G4ThreeVector &) const
G4BREPSolid & operator=(const G4BREPSolid &rhs)
Definition: G4BREPSolid.cc:138
void SetId(G4int)
G4double GetAreaAccuracy() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
Definition: G4BREPSolid.cc:596
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4int StartInside() const
void Active(G4int) const
const G4Axis2Placement3D * GetPlace() const
G4int Intersect(register const G4Ray &) const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &) const
Definition: G4BREPSolid.cc:863
G4Point3D Scope() const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &) const
Definition: G4BREPSolid.cc:756
G4bool IsConvex()
Definition: G4BREPSolid.cc:460
G4int nb_of_surfaces
Definition: G4BREPSolid.hh:229
void IntersectionDistance(G4double) const
G4BoundingBox3D * bbox
Definition: G4BREPSolid.hh:225
void SetAreaAccuracy(G4double ep)
virtual std::ostream & StreamInfo(std::ostream &os) const
G4double GetCubVolEpsilon() const
virtual EInside Inside(register const G4ThreeVector &Pt) const
Definition: G4BREPSolid.cc:793
void SetName(const G4String &name)
void SetCubVolStatistics(G4int st)
static G4int NumberOfSolids
Definition: G4BREPSolid.hh:219
G4int GetCubVolStatistics() const
G4int startInside
Definition: G4BREPSolid.hh:228
virtual G4String GetEntityType() const
Definition: G4BREPSolid.cc:191
virtual ~G4BREPSolid()
Definition: G4BREPSolid.cc:112
void RemoveHiddenFaces(register const G4Ray &G4Rayref, G4int) const
G4Polyhedron * CreatePolyhedron() const
G4int PlaneSolid
Definition: G4BREPSolid.hh:223
virtual void Reset() const
Definition: G4BREPSolid.cc:201
void SetCubVolEpsilon(G4double ep)
virtual G4VSolid * Clone() const
Definition: G4BREPSolid.cc:196
void CheckSurfaceNormals()
Definition: G4BREPSolid.cc:213
G4int GetNumberOfFaces() const
G4double GetSurfaceArea()
G4double GetCubicVolume()
virtual G4double DistanceToIn(const G4ThreeVector &) const
Definition: G4BREPSolid.cc:888
G4double RealDist
Definition: G4BREPSolid.hh:232
G4Point3D intersection_point
Definition: G4BREPSolid.hh:230
G4String solidname
Definition: G4BREPSolid.hh:233
G4double IntersectionDistance() const
virtual void CalcBBoxes()
virtual void Initialize()
Definition: G4BREPSolid.cc:171
const G4BoundingBox3D * GetBBox() const
void StartInside(G4int si) const
G4NURBS * CreateNURBS() const
G4Surface * GetSurface(G4int) const
static G4double ShortestDistance
Definition: G4BREPSolid.hh:221
G4int GetNumberOfSolids() const
void TestSurfaceBBoxes(register const G4Ray &) const
const G4String & GetName() const
Definition: G4Ray.hh:49
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:58