Geant4 11.4.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// -------------------------------------------------------------------
38//
39// Implementation notes:
40// * distance.
41// The meaning of distance includes the boundaries of the face.
42// For example, for a rectangular, planer face:
43//
44// A | B | C
45// | |
46// -------+--------------+-----
47// D | I | E
48// | |
49// -------+--------------+-----
50// F | G | H
51// | |
52//
53// A, C, F, and H: closest distance is the distance to
54// the adjacent corner.
55//
56// B, D, E, and G: closest distance is the distance to
57// the adjacent line.
58//
59// I: normal distance to plane
60//
61// For non-planer faces, one can use the normal to decide when
62// a point falls off the edge and then act accordingly.
63//
64//
65// Usage:
66//
67// A CSG shape can be defined by putting together any number of generic
68// faces, as long as the faces cover the entire surface of the shape
69// without overlapping.
70//
71// G4VSolid::CalculateExtent
72//
73// Define unit vectors along the specified transform axis.
74// Use the inverse of the specified coordinate transformation to rotate
75// these unit vectors. Loop over each face, call face->Extent, and save
76// the maximum value.
77//
78// G4VSolid::Inside
79//
80// To decide if a point is inside, outside, or on the surface of the shape,
81// loop through all faces, and find the answer from face->Inside which gives
82// a value of "bestDistance" smaller than any other. While looping, if any
83// face->Inside returns kSurface, this value can be returned immediately.
84//
85// EInside answer;
86// G4VCSGface *face = faces;
87// G4double best = kInfinity;
88// do
89// {
90// G4double distance;
91// EInside result = (*face)->Inside( p, kCarTolerance/2, distance );
92// if (result == kSurface) return kSurface;
93// if (distance < best)
94// {
95// best = distance;
96// answer = result;
97// }
98// } while( ++face < faces + numFaces );
99//
100// return(answer);
101//
102// G4VSolid::SurfaceNormal
103//
104// Loop over all faces, call face->Normal, and return the normal to the face
105// that is closest to the point.
106//
107// G4VSolid::DistanceToIn(p)
108//
109// Loop over all faces, invoking face->Distance with outgoing = false,
110// and save the answer that is smallest.
111//
112// G4VSolid::DistanceToIn(p,v)
113//
114// Loop over all faces, invoking face->Intersect with outgoing = false,
115// and save the answer that is smallest.
116//
117// G4VSolid::DistanceToOut(p)
118//
119// Loop over all faces, invoking face->Distance with outgoing = true,
120// and save the answer that is smallest.
121//
122// G4VSolid::DistanceToOut(p,v)
123//
124// Loop over all faces, invoking face->Intersect with outgoing = true,
125// and save the answer that is smallest. If there is more than one answer,
126// or if allBehind is false for the one answer, return validNorm as false.
127
128// Author: David C. Williams (UCSC), 1998 - Created
129// --------------------------------------------------------------------
130#ifndef G4VCSGFACE_HH
131#define G4VCSGFACE_HH
132
133#include "G4Types.hh"
134#include "G4ThreeVector.hh"
135#include "geomdefs.hh"
136#include "G4VSolid.hh"
137
138class G4VoxelLimits;
141
142/**
143 * @brief G4VCSGface is virtual base class, representing one side (or face)
144 * of a CSG-like solid. It should be possible to build a CSG entirely
145 * out of connecting CSG faces. Each face has an inside and outside surface,
146 * the former represents the inside of the volume, the latter, the outside.
147 */
148
150{
151 public:
152
153 /**
154 * Default Constructor and Destructor.
155 */
156 G4VCSGface() = default;
157 virtual ~G4VCSGface() = default;
158
159 /**
160 * Determines the distance along a line to the face.
161 * @param[in] p Position.
162 * @param[in] v Direction (assumed to be a unit vector).
163 * @param[in] outgoing Flag true, to consider only inside surfaces;
164 * false, to consider only outside surfaces.
165 * @param[in] surfTolerance Minimum distance from the surface.
166 * @param[out] distance Distance to intersection.
167 * @param[out] distFromSurface Distance from surface (along surface normal),
168 * < 0 if the point is in front of the surface.
169 * @param[out] normal Normal of surface at intersection point.
170 * @param[out] allBehind Flag, true, if entire surface is behind normal.
171 * @returns true if there is an intersection, false otherwise.
172 */
173 virtual G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
174 G4bool outgoing, G4double surfTolerance,
175 G4double& distance, G4double& distFromSurface,
176 G4ThreeVector& normal, G4bool& allBehind ) = 0;
177
178 /**
179 * Determines the distance of a point from either the inside or outside
180 * surfaces of the face.
181 * @param[in] p Position.
182 * @param[in] outgoing Flag, true, to consider only inside surfaces
183 * or false, to consider only outside surfaces.
184 * @returns The distance to the closest surface satisfying requirements
185 * or kInfinity if no such surface exists.
186 */
187 virtual G4double Distance( const G4ThreeVector& p, G4bool outgoing ) = 0;
188
189 /**
190 * Determines whether a point is inside, outside, or on the surface of
191 * the face.
192 * @param[in] p Position.
193 * @param[in] tolerance Tolerance defining the bounds of the "kSurface",
194 * nominally equal to kCarTolerance/2.
195 * @param[out] bestDistance Distance to the closest surface (in or out).
196 * @returns kInside if the point is closest to the inside surface;
197 * kOutside if the point is closest to the outside surface;
198 * kSurface if the point is withing tolerance of the surface.
199 */
200 virtual EInside Inside( const G4ThreeVector& p, G4double tolerance,
201 G4double* bestDistance ) = 0;
202
203 /**
204 * Returns the normal of surface closest to the point.
205 * @param[in] p Position.
206 * @param[out] bestDistance Distance to the closest surface (in or out).
207 * @returns The normal of the surface nearest the point.
208 */
210 G4double* bestDistance ) = 0;
211
212 /**
213 * Returns the face extent along the axis.
214 * @param[in] axis Unit vector defining the direction.
215 * @returns The largest point along the given axis of the face's extent.
216 */
217 virtual G4double Extent( const G4ThreeVector axis ) = 0;
218
219 /**
220 * Calculates the extent of the face for the voxel navigator.
221 * @param[in] axis The axis in which to check the shapes 3D extent against.
222 * @param[in] voxelLimit Limits along x, y, and/or z axes.
223 * @param[in] tranform A coordinate transformation on which to apply to
224 * the shape before testing.
225 * @param[out] extentList The list of (voxel) extents along the axis.
226 */
227 virtual void CalculateExtent( const EAxis axis,
228 const G4VoxelLimits& voxelLimit,
229 const G4AffineTransform& tranform,
230 G4SolidExtentList& extentList ) = 0;
231
232 /**
233 * Method invoked by the copy constructor or the assignment operator.
234 * Its purpose is to return a pointer to a duplicate copy of the face.
235 */
236 virtual G4VCSGface* Clone() = 0;
237
238 /**
239 * Returning an estimation of the face surface area, in internal units.
240 */
241 virtual G4double SurfaceArea() = 0;
242
243 /**
244 * Auxiliary method for GetPointOnSurface().
245 */
247};
248
249#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4SolidExtentList is utility class designed for calculating the extent of a CSG-like solid for a voxe...
virtual G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)=0
virtual G4VCSGface * Clone()=0
virtual ~G4VCSGface()=default
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
G4VCSGface()=default
virtual G4double SurfaceArea()=0
virtual G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)=0
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668