Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SolidExtentList.cc
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// G4SolidExtentList implementation; a list of (voxel) extents along one axis.
27//
28// Author: David C. Williams (UCSC), 1998
29// --------------------------------------------------------------------
30
31#include "G4SolidExtentList.hh"
32#include "G4VoxelLimits.hh"
34
35// Constructor (default)
36//
38{
39 axis = kZAxis;
40 minLimit = -INT_MAX/2;
41 maxLimit = INT_MAX/2;
42}
43
44// Constructor (limited case)
45//
47 const G4VoxelLimits &voxelLimits )
48{
49 axis = targetAxis;
50
51 limited = voxelLimits.IsLimited( axis );
52 if (limited)
53 {
54 minLimit = voxelLimits.GetMinExtent( axis );
55 maxLimit = voxelLimits.GetMaxExtent( axis );
56 }
57 else
58 {
59 minLimit = -INT_MAX/2;
60 maxLimit = INT_MAX/2;
61 }
62}
63
64// AddSurface
65//
66//
68{
69 //
70 // Keep track of four surfaces
71 //
72 G4double smin=.0, smax=0.;
73
74 surface.GetExtent( axis, smin, smax );
75
76 if (smin > maxLimit)
77 {
78 //
79 // Nearest surface beyond maximum limit
80 //
81 if (surface.InFrontOf(minAbove,axis)) { minAbove = surface; }
82 }
83 else if (smax < minLimit)
84 {
85 //
86 // Nearest surface below minimum limit
87 //
88 if (surface.BehindOf(maxBelow,axis)) { maxBelow = surface; }
89 }
90 else
91 {
92 //
93 // Max and min surfaces inside
94 //
95 if (surface.BehindOf(maxSurface,axis)) { maxSurface = surface; }
96 if (surface.InFrontOf(minSurface,axis)) { minSurface = surface; }
97 }
98}
99
100// GetExtent
101//
102// Return extent after processing all surfaces
103//
105{
108 //
109 // Did we have any surfaces within the limits?
110 //
111 if (minSurface.Empty())
112 {
113 //
114 // Nothing! Do we have anything above?
115 //
116 if (minAbove.Empty()) { return false; }
117
118 //
119 // Yup. Is it facing inwards?
120 //
121 if (minAbove.GetNormal().operator()(axis) < 0) { return false; }
122
123 //
124 // No. We must be entirely within the solid
125 //
126 emax = maxLimit + kCarTolerance;
127 emin = minLimit - kCarTolerance;
128 return true;
129 }
130
131 //
132 // Check max surface
133 //
134 if (maxSurface.GetNormal().operator()(axis) < 0)
135 {
136 //
137 // Inward facing: max limit must be embedded within solid
138 //
139 emax = maxLimit + kCarTolerance;
140 }
141 else
142 {
143 G4double sMin=0., sMax=0.;
144 maxSurface.GetExtent( axis, sMin, sMax );
145 emax = ( (sMax > maxLimit) ? maxLimit : sMax ) + kCarTolerance;
146 }
147
148 //
149 // Check min surface
150 //
151 if (minSurface.GetNormal().operator()(axis) > 0)
152 {
153 //
154 // Inward facing: max limit must be embedded within solid
155 //
156 emin = minLimit - kCarTolerance;
157 }
158 else
159 {
160 G4double sMin=0., sMax=0.;
161 minSurface.GetExtent( axis, sMin, sMax );
162 emin = ( (sMin < minLimit) ? minLimit : sMin ) - kCarTolerance;
163 }
164
165 return true;
166}
167
const G4double kCarTolerance
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4ClippablePolygon in a utility class defining a polygon that can be clipped by a voxel.
G4bool GetExtent(const EAxis axis, G4double &min, G4double &max) const
G4bool InFrontOf(const G4ClippablePolygon &other, EAxis axis) const
G4bool BehindOf(const G4ClippablePolygon &other, EAxis axis) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
void AddSurface(const G4ClippablePolygon &surface)
G4bool GetExtent(G4double &min, G4double &max) const
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const
G4bool IsLimited() const
EAxis
Definition geomdefs.hh:54
@ kZAxis
Definition geomdefs.hh:57
#define INT_MAX
Definition templates.hh:90