Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VCSGface.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// G4VCSGface
27//
28// Class description:
29//
30// Definition of the virtual base class G4VCSGface, one side (or face)
31// of a CSG-like solid. It should be possible to build a CSG entirely
32// out of connecting CSG faces.
33//
34// Each face has an inside and outside surface, the former represents
35// the inside of the volume, the latter, the outside.
36//
37// Virtual members:
38//
39// -------------------------------------------------------------------
40// Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
41// G4bool outGoing, G4double surfTolerance,
42// G4double& distance, G4double& distFromSurface,
43// G4ThreeVector& normal, G4bool& allBehind );
44//
45// p - (in) position
46// v - (in) direction (assumed to be a unit vector)
47// outgoing - (in) true, to consider only inside surfaces
48// false, to consider only outside surfaces
49// distance - (out) distance to intersection
50// distFromSurface - (out) distance from surface (along surface normal),
51// < 0 if the point is in front of the surface
52// normal - (out) normal of surface at intersection point
53// allBehind - (out) true, if entire surface is behind normal
54//
55// return value = true if there is an intersection,
56// false if there is no intersection
57// (all output arguments undefined)
58//
59// Determine the distance along a line to the face.
60//
61// -------------------------------------------------------------------
62// Distance( const G4ThreeVector& p, const G4bool outgoing );
63//
64// p - (in) position
65// outgoing - (in) true, to consider only inside surfaces
66// false, to consider only outside surfaces
67//
68// return value = distance to closest surface satisifying requirements
69// or kInfinity if no such surface exists
70//
71// Determine the distance of a point from either the inside or outside
72// surfaces of the face.
73//
74// -------------------------------------------------------------------
75// Inside( const G4ThreeVector& p, const G4double tolerance,
76// G4double* bestDistance );
77//
78// p - (in) position
79// tolerance - (in) tolerance defining the bounds of the "kSurface",
80// nominally equal to kCarTolerance/2
81// bestDistance - (out) distance to closest surface (in or out)
82//
83// return value = kInside if the point is closest to the inside surface
84// kOutside if the point is closest to the outside surface
85// kSurface if the point is withing tolerance of the surface
86//
87// Determine whether a point is inside, outside, or on the surface of
88// the face.
89//
90// -------------------------------------------------------------------
91// Normal( const G4ThreeVector& p, G4double* bestDistance );
92//
93// p - (in) position
94// bestDistance - (out) distance to closest surface (in or out)
95//
96// return value = the normal of the surface nearest the point
97//
98// Return normal of surface closest to the point.
99//
100// -------------------------------------------------------------------
101// Extent( const G4ThreeVector axis );
102//
103// axis - (in) unit vector defining direction
104//
105// return value = the largest point along the given axis of the
106// the face's extent.
107//
108// -------------------------------------------------------------------
109// CalculateExtent( const EAxis pAxis,
110// const G4VoxelLimit& pVoxelLimit,
111// const G4AffineTransform& pTransform,
112// G4double& min, G4double& max )
113//
114// pAxis - (in) The x,y, or z axis in which to check
115// the shapes 3D extent against
116// pVoxelLimit - (in) Limits along x, y, and/or z axes
117// pTransform - (in) A coordinate transformation on which
118// to apply to the shape before testing
119// min - (out) If the face has any point on its
120// surface after tranformation and limits
121// along pAxis that is smaller than the value
122// of min, than it is used to replace min.
123// Undefined if the return value is false.
124// max - (out) Same as min, except for the largest
125// point.
126// Undefined if the return value is false.
127//
128// return value = true if anything remains of the face
129//
130// Calculate the extent of the face for the voxel navigator.
131// In analogy with CalculateExtent for G4VCSGfaceted, this is
132// done in the following steps:
133//
134// 1. Transform the face using pTranform, an arbitrary 3D
135// rotation/offset/reflection
136// 2. Clip the face to those boundaries as specified in
137// pVoxelLimit. This may include limits in any number
138// of x, y, or z axes.
139// 3. For each part of the face that remains (there could
140// be many separate pieces in general):
141// 4. Check to see if the piece overlaps the currently
142// existing limits along axis pAxis. For
143// pVoxelLimit.IsLimited(pAxis) = false, there are
144// no limits.
145// 5. For a piece that does overlap, update min/max
146// accordingly (within confines of pre-existing
147// limits) along the direction pAxis.
148// 6. If min/max were updated, return true
149//
150// -------------------------------------------------------------------
151// G3VCSGface *Clone()
152//
153// This method is invoked by G4CSGfaceted during the copy constructor
154// or the assignment operator. Its purpose is to return a pointer
155// (of type G4VCSGface) to a duplicate copy of the face.
156// The implementation is straight forward for inherited classes. Example:
157//
158// G4VCSGface G4PolySideFace::Clone() { return new G4PolySideFace(*this); }
159//
160// Of course, this assumes the copy constructor of G4PolySideFace is
161// correctly implemented.
162//
163// Implementation notes:
164// * distance.
165// The meaning of distance includes the boundaries of the face.
166// For example, for a rectangular, planer face:
167//
168// A | B | C
169// | |
170// -------+--------------+-----
171// D | I | E
172// | |
173// -------+--------------+-----
174// F | G | H
175// | |
176//
177// A, C, F, and H: closest distance is the distance to
178// the adjacent corner.
179//
180// B, D, E, and G: closest distance is the distance to
181// the adjacent line.
182//
183// I: normal distance to plane
184//
185// For non-planer faces, one can use the normal to decide when
186// a point falls off the edge and then act accordingly.
187//
188//
189// Usage:
190//
191// A CSG shape can be defined by putting together any number of generic
192// faces, as long as the faces cover the entire surface of the shape
193// without overlapping.
194//
195// G4VSolid::CalculateExtent
196//
197// Define unit vectors along the specified transform axis.
198// Use the inverse of the specified coordinate transformation to rotate
199// these unit vectors. Loop over each face, call face->Extent, and save
200// the maximum value.
201//
202// G4VSolid::Inside
203//
204// To decide if a point is inside, outside, or on the surface of the shape,
205// loop through all faces, and find the answer from face->Inside which gives
206// a value of "bestDistance" smaller than any other. While looping, if any
207// face->Inside returns kSurface, this value can be returned immediately.
208//
209// EInside answer;
210// G4VCSGface *face = faces;
211// G4double best = kInfinity;
212// do {
213// G4double distance;
214// EInside result = (*face)->Inside( p, kCarTolerance/2, distance );
215// if (result == kSurface) return kSurface;
216// if (distance < best) {
217// best = distance;
218// answer = result;
219// }
220// } while( ++face < faces + numFaces );
221//
222// return(answer);
223//
224// G4VSolid::SurfaceNormal
225//
226// Loop over all faces, call face->Normal, and return the normal to the face
227// that is closest to the point.
228//
229// G4VSolid::DistanceToIn(p)
230//
231// Loop over all faces, invoking face->Distance with outgoing = false,
232// and save the answer that is smallest.
233//
234// G4VSolid::DistanceToIn(p,v)
235//
236// Loop over all faces, invoking face->Intersect with outgoing = false,
237// and save the answer that is smallest.
238//
239// G4VSolid::DistanceToOut(p)
240//
241// Loop over all faces, invoking face->Distance with outgoing = true,
242// and save the answer that is smallest.
243//
244// G4VSolid::DistanceToOut(p,v)
245//
246// Loop over all faces, invoking face->Intersect with outgoing = true,
247// and save the answer that is smallest. If there is more than one answer,
248// or if allBehind is false for the one answer, return validNorm as false.
249
250// Author: David C. Williams ([email protected])
251// --------------------------------------------------------------------
252#ifndef G4VCSGFACE_HH
253#define G4VCSGFACE_HH
254
255#include "G4Types.hh"
256#include "G4ThreeVector.hh"
257#include "geomdefs.hh"
258#include "G4VSolid.hh"
259
260class G4VoxelLimits;
263
265{
266 public: // with description
267
269 virtual ~G4VCSGface() {}
270
271 virtual G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
272 G4bool outgoing, G4double surfTolerance,
273 G4double& distance, G4double& distFromSurface,
274 G4ThreeVector& normal, G4bool& allBehind ) = 0;
275
276 virtual G4double Distance( const G4ThreeVector& p, G4bool outgoing ) = 0;
277
278 virtual EInside Inside( const G4ThreeVector& p, G4double tolerance,
279 G4double* bestDistance ) = 0;
280
282 G4double* bestDistance ) = 0;
283
284 virtual G4double Extent( const G4ThreeVector axis ) = 0;
285
286 virtual void CalculateExtent( const EAxis axis,
287 const G4VoxelLimits& voxelLimit,
288 const G4AffineTransform& tranform,
289 G4SolidExtentList& extentList ) = 0;
290
291 virtual G4VCSGface* Clone() = 0;
292
293 virtual G4double SurfaceArea() = 0;
295};
296
297#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
virtual G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)=0
virtual G4VCSGface * Clone()=0
virtual G4double Distance(const G4ThreeVector &p, G4bool outgoing)=0
virtual G4double Extent(const G4ThreeVector axis)=0
virtual void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)=0
virtual EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)=0
virtual G4ThreeVector GetPointOnFace()=0
virtual G4double SurfaceArea()=0
virtual ~G4VCSGface()
Definition: G4VCSGface.hh:269
virtual G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)=0
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67