Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VoxelLimits Class Reference

#include <G4VoxelLimits.hh>

Public Member Functions

 G4VoxelLimits ()
 
 ~G4VoxelLimits ()
 
void AddLimit (const EAxis pAxis, const G4double pMin, const G4double pMax)
 
G4double GetMaxXExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMaxZExtent () const
 
G4double GetMinXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxExtent (const EAxis pAxis) const
 
G4double GetMinExtent (const EAxis pAxis) const
 
G4bool IsXLimited () const
 
G4bool IsYLimited () const
 
G4bool IsZLimited () const
 
G4bool IsLimited () const
 
G4bool IsLimited (const EAxis pAxis) const
 
G4bool ClipToLimits (G4ThreeVector &pStart, G4ThreeVector &pEnd) const
 
G4bool Inside (const G4ThreeVector &pVec) const
 
G4int OutCode (const G4ThreeVector &pVec) const
 

Detailed Description

Definition at line 52 of file G4VoxelLimits.hh.

Constructor & Destructor Documentation

◆ G4VoxelLimits()

G4VoxelLimits::G4VoxelLimits ( )

Definition at line 39 of file G4VoxelLimits.cc.

40{
41}

◆ ~G4VoxelLimits()

G4VoxelLimits::~G4VoxelLimits ( )

Definition at line 43 of file G4VoxelLimits.cc.

44{
45}

Member Function Documentation

◆ AddLimit()

void G4VoxelLimits::AddLimit ( const EAxis  pAxis,
const G4double  pMin,
const G4double  pMax 
)

Definition at line 52 of file G4VoxelLimits.cc.

55{
56 if ( pAxis == kXAxis )
57 {
58 if ( pMin > fxAxisMin ) fxAxisMin = pMin ;
59 if ( pMax < fxAxisMax ) fxAxisMax = pMax ;
60 }
61 else if ( pAxis == kYAxis )
62 {
63 if ( pMin > fyAxisMin ) fyAxisMin = pMin ;
64 if ( pMax < fyAxisMax ) fyAxisMax = pMax ;
65 }
66 else
67 {
68 assert( pAxis == kZAxis ) ;
69
70 if ( pMin > fzAxisMin ) fzAxisMin = pMin ;
71 if ( pMax < fzAxisMax ) fzAxisMax = pMax ;
72 }
73}
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57

Referenced by G4ReflectedSolid::CalculateExtent(), G4BoundingEnvelope::CalculateExtent(), G4ClippablePolygon::ClipAlongOneAxis(), G4VSolid::ClipPolygon(), and G4SmartVoxelHeader::RefineNodes().

◆ ClipToLimits()

G4bool G4VoxelLimits::ClipToLimits ( G4ThreeVector pStart,
G4ThreeVector pEnd 
) const

Definition at line 88 of file G4VoxelLimits.cc.

90{
91 G4int sCode, eCode ;
92 G4bool remainsAfterClip ;
93
94 // Determine if line is trivially inside (both outcodes==0) or outside
95 // (logical AND of outcodes !=0)
96
97 sCode = OutCode(pStart) ;
98 eCode = OutCode(pEnd) ;
99
100 if ( sCode & eCode )
101 {
102 // Trivially outside, no intersection with region
103
104 remainsAfterClip = false;
105 }
106 else if ( sCode == 0 && eCode == 0 )
107 {
108 // Trivially inside, no intersections
109
110 remainsAfterClip = true ;
111 }
112 else
113 {
114 // Line segment *may* cut volume boundaries
115 // At most, one end point is inside
116
117 G4double x1, y1, z1, x2, y2, z2 ;
118
119 x1 = pStart.x() ;
120 y1 = pStart.y() ;
121 z1 = pStart.z() ;
122
123 x2 = pEnd.x() ;
124 y2 = pEnd.y() ;
125 z2 = pEnd.z() ;
126
127 while ( sCode != eCode ) // Loop checking, 06.08.2015, G.Cosmo
128 {
129 // Copy vectors to work variables x1-z1,x2-z2
130 // Ensure x1-z1 lies outside volume, swapping vectors and outcodes
131 // if necessary
132
133 if ( sCode )
134 {
135 if ( sCode & 0x01 ) // Clip against fxAxisMin
136 {
137 z1 += (fxAxisMin-x1)*(z2-z1)/(x2-x1);
138 y1 += (fxAxisMin-x1)*(y2-y1)/(x2-x1);
139 x1 = fxAxisMin;
140 }
141 else if ( sCode & 0x02 ) // Clip against fxAxisMax
142 {
143 z1 += (fxAxisMax-x1)*(z2-z1)/(x2-x1);
144 y1 += (fxAxisMax-x1)*(y2-y1)/(x2-x1);
145 x1 = fxAxisMax ;
146 }
147 else if ( sCode & 0x04 ) // Clip against fyAxisMin
148 {
149 x1 += (fyAxisMin-y1)*(x2-x1)/(y2-y1);
150 z1 += (fyAxisMin-y1)*(z2-z1)/(y2-y1);
151 y1 = fyAxisMin;
152 }
153 else if ( sCode & 0x08 ) // Clip against fyAxisMax
154 {
155 x1 += (fyAxisMax-y1)*(x2-x1)/(y2-y1);
156 z1 += (fyAxisMax-y1)*(z2-z1)/(y2-y1);
157 y1 = fyAxisMax;
158 }
159 else if ( sCode & 0x10 ) // Clip against fzAxisMin
160 {
161 x1 += (fzAxisMin-z1)*(x2-x1)/(z2-z1);
162 y1 += (fzAxisMin-z1)*(y2-y1)/(z2-z1);
163 z1 = fzAxisMin;
164 }
165 else if ( sCode & 0x20 ) // Clip against fzAxisMax
166 {
167 x1 += (fzAxisMax-z1)*(x2-x1)/(z2-z1);
168 y1 += (fzAxisMax-z1)*(y2-y1)/(z2-z1);
169 z1 = fzAxisMax;
170 }
171 }
172 if ( eCode ) // Clip 2nd end: repeat of 1st, but 1<>2
173 {
174 if ( eCode & 0x01 ) // Clip against fxAxisMin
175 {
176 z2 += (fxAxisMin-x2)*(z1-z2)/(x1-x2);
177 y2 += (fxAxisMin-x2)*(y1-y2)/(x1-x2);
178 x2 = fxAxisMin;
179 }
180 else if ( eCode & 0x02 ) // Clip against fxAxisMax
181 {
182 z2 += (fxAxisMax-x2)*(z1-z2)/(x1-x2);
183 y2 += (fxAxisMax-x2)*(y1-y2)/(x1-x2);
184 x2 = fxAxisMax;
185 }
186 else if ( eCode & 0x04 ) // Clip against fyAxisMin
187 {
188 x2 += (fyAxisMin-y2)*(x1-x2)/(y1-y2);
189 z2 += (fyAxisMin-y2)*(z1-z2)/(y1-y2);
190 y2 = fyAxisMin;
191 }
192 else if (eCode&0x08) // Clip against fyAxisMax
193 {
194 x2 += (fyAxisMax-y2)*(x1-x2)/(y1-y2);
195 z2 += (fyAxisMax-y2)*(z1-z2)/(y1-y2);
196 y2 = fyAxisMax;
197 }
198 else if ( eCode & 0x10 ) // Clip against fzAxisMin
199 {
200 x2 += (fzAxisMin-z2)*(x1-x2)/(z1-z2);
201 y2 += (fzAxisMin-z2)*(y1-y2)/(z1-z2);
202 z2 = fzAxisMin;
203 }
204 else if ( eCode & 0x20 ) // Clip against fzAxisMax
205 {
206 x2 += (fzAxisMax-z2)*(x1-x2)/(z1-z2);
207 y2 += (fzAxisMax-z2)*(y1-y2)/(z1-z2);
208 z2 = fzAxisMax;
209 }
210 }
211 pStart = G4ThreeVector(x1,y1,z1);
212 pEnd = G4ThreeVector(x2,y2,z2);
213 sCode = OutCode(pStart);
214 eCode = OutCode(pEnd);
215 }
216 if ( sCode == 0 && eCode == 0 ) remainsAfterClip = true;
217 else remainsAfterClip = false;
218 }
219 return remainsAfterClip;
220}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
double z() const
double x() const
double y() const
G4int OutCode(const G4ThreeVector &pVec) const

Referenced by G4ClippablePolygon::ClipToSimpleLimits().

◆ GetMaxExtent()

◆ GetMaxXExtent()

◆ GetMaxYExtent()

◆ GetMaxZExtent()

◆ GetMinExtent()

◆ GetMinXExtent()

◆ GetMinYExtent()

◆ GetMinZExtent()

◆ Inside()

G4bool G4VoxelLimits::Inside ( const G4ThreeVector pVec) const

◆ IsLimited() [1/2]

◆ IsLimited() [2/2]

G4bool G4VoxelLimits::IsLimited ( const EAxis  pAxis) const

◆ IsXLimited()

G4bool G4VoxelLimits::IsXLimited ( ) const

◆ IsYLimited()

G4bool G4VoxelLimits::IsYLimited ( ) const

◆ IsZLimited()

G4bool G4VoxelLimits::IsZLimited ( ) const

◆ OutCode()

G4int G4VoxelLimits::OutCode ( const G4ThreeVector pVec) const

Definition at line 233 of file G4VoxelLimits.cc.

234{
235 G4int code = 0 ; // The outcode
236
237 if ( IsXLimited() )
238 {
239 if ( pVec.x() < fxAxisMin ) code |= 0x01 ;
240 if ( pVec.x() > fxAxisMax ) code |= 0x02 ;
241 }
242 if ( IsYLimited() )
243 {
244 if ( pVec.y() < fyAxisMin ) code |= 0x04 ;
245 if ( pVec.y() > fyAxisMax ) code |= 0x08 ;
246 }
247 if (IsZLimited())
248 {
249 if ( pVec.z() < fzAxisMin ) code |= 0x10 ;
250 if ( pVec.z() > fzAxisMax ) code |= 0x20 ;
251 }
252 return code;
253}
G4bool IsYLimited() const
G4bool IsXLimited() const
G4bool IsZLimited() const
Definition: inftrees.h:24

Referenced by ClipToLimits().


The documentation for this class was generated from the following files: