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