Geant4 9.6.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 62 of file G4VoxelLimits.hh.

Constructor & Destructor Documentation

◆ G4VoxelLimits()

G4VoxelLimits::G4VoxelLimits ( )

Definition at line 48 of file G4VoxelLimits.cc.

49 : fxAxisMin(-kInfinity),fxAxisMax(kInfinity),
50 fyAxisMin(-kInfinity),fyAxisMax(kInfinity),
51 fzAxisMin(-kInfinity),fzAxisMax(kInfinity)
52{
53}

◆ ~G4VoxelLimits()

G4VoxelLimits::~G4VoxelLimits ( )

Definition at line 55 of file G4VoxelLimits.cc.

56{
57}

Member Function Documentation

◆ AddLimit()

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

Definition at line 65 of file G4VoxelLimits.cc.

68{
69 if ( pAxis == kXAxis )
70 {
71 if ( pMin > fxAxisMin ) fxAxisMin = pMin ;
72 if ( pMax < fxAxisMax ) fxAxisMax = pMax ;
73 }
74 else if ( pAxis == kYAxis )
75 {
76 if ( pMin > fyAxisMin ) fyAxisMin = pMin ;
77 if ( pMax < fyAxisMax ) fyAxisMax = pMax ;
78 }
79 else
80 {
81 assert( pAxis == kZAxis ) ;
82
83 if ( pMin > fzAxisMin ) fzAxisMin = pMin ;
84 if ( pMax < fzAxisMax ) fzAxisMax = pMax ;
85 }
86}
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54

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

◆ ClipToLimits()

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

Definition at line 102 of file G4VoxelLimits.cc.

104{
105 G4int sCode, eCode ;
106 G4bool remainsAfterClip ;
107
108 // Determine if line is trivially inside (both outcodes==0) or outside
109 // (logical AND of outcodes !=0)
110
111 sCode = OutCode(pStart) ;
112 eCode = OutCode(pEnd) ;
113
114 if ( sCode & eCode )
115 {
116 // Trivially outside, no intersection with region
117
118 remainsAfterClip = false;
119 }
120 else if ( sCode == 0 && eCode == 0 )
121 {
122 // Trivially inside, no intersections
123
124 remainsAfterClip = true ;
125 }
126 else
127 {
128 // Line segment *may* cut volume boundaries
129 // At most, one end point is inside
130
131 G4double x1, y1, z1, x2, y2, z2 ;
132
133 x1 = pStart.x() ;
134 y1 = pStart.y() ;
135 z1 = pStart.z() ;
136
137 x2 = pEnd.x() ;
138 y2 = pEnd.y() ;
139 z2 = pEnd.z() ;
140 /*
141 if( std::abs(x1-x2) < kCarTolerance*kCarTolerance)
142 {
143 G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl;
144 }
145 if( std::abs(y1-y2) < kCarTolerance*kCarTolerance)
146 {
147 G4cout<<"y1 = "<<y1<<"\t"<<"y2 = "<<y2<<G4endl;
148 }
149 if( std::abs(z1-z2) < kCarTolerance*kCarTolerance)
150 {
151 G4cout<<"z1 = "<<z1<<"\t"<<"z2 = "<<z2<<G4endl;
152 }
153 */
154 while ( sCode != eCode )
155 {
156 // Copy vectors to work variables x1-z1,x2-z2
157 // Ensure x1-z1 lies outside volume, swapping vectors and outcodes
158 // if necessary
159
160 if ( sCode )
161 {
162 if ( sCode & 0x01 ) // Clip against fxAxisMin
163 {
164 z1 += (fxAxisMin-x1)*(z2-z1)/(x2-x1);
165 y1 += (fxAxisMin-x1)*(y2-y1)/(x2-x1);
166 x1 = fxAxisMin;
167 }
168 else if ( sCode & 0x02 ) // Clip against fxAxisMax
169 {
170 z1 += (fxAxisMax-x1)*(z2-z1)/(x2-x1);
171 y1 += (fxAxisMax-x1)*(y2-y1)/(x2-x1);
172 x1 = fxAxisMax ;
173 }
174 else if ( sCode & 0x04 ) // Clip against fyAxisMin
175 {
176 x1 += (fyAxisMin-y1)*(x2-x1)/(y2-y1);
177 z1 += (fyAxisMin-y1)*(z2-z1)/(y2-y1);
178 y1 = fyAxisMin;
179 }
180 else if ( sCode & 0x08 ) // Clip against fyAxisMax
181 {
182 x1 += (fyAxisMax-y1)*(x2-x1)/(y2-y1);
183 z1 += (fyAxisMax-y1)*(z2-z1)/(y2-y1);
184 y1 = fyAxisMax;
185 }
186 else if ( sCode & 0x10 ) // Clip against fzAxisMin
187 {
188 x1 += (fzAxisMin-z1)*(x2-x1)/(z2-z1);
189 y1 += (fzAxisMin-z1)*(y2-y1)/(z2-z1);
190 z1 = fzAxisMin;
191 }
192 else if ( sCode & 0x20 ) // Clip against fzAxisMax
193 {
194 x1 += (fzAxisMax-z1)*(x2-x1)/(z2-z1);
195 y1 += (fzAxisMax-z1)*(y2-y1)/(z2-z1);
196 z1 = fzAxisMax;
197 }
198 }
199 if ( eCode ) // Clip 2nd end: repeat of 1st, but 1<>2
200 {
201 if ( eCode & 0x01 ) // Clip against fxAxisMin
202 {
203 z2 += (fxAxisMin-x2)*(z1-z2)/(x1-x2);
204 y2 += (fxAxisMin-x2)*(y1-y2)/(x1-x2);
205 x2 = fxAxisMin;
206 }
207 else if ( eCode & 0x02 ) // Clip against fxAxisMax
208 {
209 z2 += (fxAxisMax-x2)*(z1-z2)/(x1-x2);
210 y2 += (fxAxisMax-x2)*(y1-y2)/(x1-x2);
211 x2 = fxAxisMax;
212 }
213 else if ( eCode & 0x04 ) // Clip against fyAxisMin
214 {
215 x2 += (fyAxisMin-y2)*(x1-x2)/(y1-y2);
216 z2 += (fyAxisMin-y2)*(z1-z2)/(y1-y2);
217 y2 = fyAxisMin;
218 }
219 else if (eCode&0x08) // Clip against fyAxisMax
220 {
221 x2 += (fyAxisMax-y2)*(x1-x2)/(y1-y2);
222 z2 += (fyAxisMax-y2)*(z1-z2)/(y1-y2);
223 y2 = fyAxisMax;
224 }
225 else if ( eCode & 0x10 ) // Clip against fzAxisMin
226 {
227 x2 += (fzAxisMin-z2)*(x1-x2)/(z1-z2);
228 y2 += (fzAxisMin-z2)*(y1-y2)/(z1-z2);
229 z2 = fzAxisMin;
230 }
231 else if ( eCode & 0x20 ) // Clip against fzAxisMax
232 {
233 x2 += (fzAxisMax-z2)*(x1-x2)/(z1-z2);
234 y2 += (fzAxisMax-z2)*(y1-y2)/(z1-z2);
235 z2 = fzAxisMax;
236 }
237 }
238 // G4endl; G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl<<G4endl;
239 pStart = G4ThreeVector(x1,y1,z1);
240 pEnd = G4ThreeVector(x2,y2,z2);
241 sCode = OutCode(pStart);
242 eCode = OutCode(pEnd);
243 }
244 if ( sCode == 0 && eCode == 0 ) remainsAfterClip = true;
245 else remainsAfterClip = false;
246 }
247 return remainsAfterClip;
248}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
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()

◆ IsYLimited()

◆ IsZLimited()

◆ OutCode()

G4int G4VoxelLimits::OutCode ( const G4ThreeVector pVec) const

Definition at line 262 of file G4VoxelLimits.cc.

263{
264 G4int code = 0 ; // The outcode
265
266 if ( IsXLimited() )
267 {
268 if ( pVec.x() < fxAxisMin ) code |= 0x01 ;
269 if ( pVec.x() > fxAxisMax ) code |= 0x02 ;
270 }
271 if ( IsYLimited() )
272 {
273 if ( pVec.y() < fyAxisMin ) code |= 0x04 ;
274 if ( pVec.y() > fyAxisMax ) code |= 0x08 ;
275 }
276 if (IsZLimited())
277 {
278 if ( pVec.z() < fzAxisMin ) code |= 0x10 ;
279 if ( pVec.z() > fzAxisMax ) code |= 0x20 ;
280 }
281 return code;
282}
G4bool IsYLimited() const
G4bool IsXLimited() const
G4bool IsZLimited() const

Referenced by ClipToLimits().


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