Geant4-11
Public Member Functions | Private Attributes
G4VoxelLimits Class Reference

#include <G4VoxelLimits.hh>

Public Member Functions

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

Private Attributes

G4double fxAxisMax = kInfinity
 
G4double fxAxisMin = -kInfinity
 
G4double fyAxisMax = kInfinity
 
G4double fyAxisMin = -kInfinity
 
G4double fzAxisMax = kInfinity
 
G4double fzAxisMin = -kInfinity
 

Detailed Description

Definition at line 52 of file G4VoxelLimits.hh.

Constructor & Destructor Documentation

◆ G4VoxelLimits()

G4VoxelLimits::G4VoxelLimits ( )
default

◆ ~G4VoxelLimits()

G4VoxelLimits::~G4VoxelLimits ( )
default

Member Function Documentation

◆ AddLimit()

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

Definition at line 40 of file G4VoxelLimits.cc.

43{
44 if ( pAxis == kXAxis )
45 {
46 if ( pMin > fxAxisMin ) fxAxisMin = pMin ;
47 if ( pMax < fxAxisMax ) fxAxisMax = pMax ;
48 }
49 else if ( pAxis == kYAxis )
50 {
51 if ( pMin > fyAxisMin ) fyAxisMin = pMin ;
52 if ( pMax < fyAxisMax ) fyAxisMax = pMax ;
53 }
54 else
55 {
56 assert( pAxis == kZAxis ) ;
57
58 if ( pMin > fzAxisMin ) fzAxisMin = pMin ;
59 if ( pMax < fzAxisMax ) fzAxisMax = pMax ;
60 }
61}
static const G4double pMax
static const G4double pMin
G4double fzAxisMax
G4double fzAxisMin
G4double fxAxisMin
G4double fxAxisMax
G4double fyAxisMax
G4double fyAxisMin
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57

References fxAxisMax, fxAxisMin, fyAxisMax, fyAxisMin, fzAxisMax, fzAxisMin, kXAxis, kYAxis, kZAxis, pMax, and pMin.

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

◆ ClipToLimits()

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

Definition at line 76 of file G4VoxelLimits.cc.

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

References fxAxisMax, fxAxisMin, fyAxisMax, fyAxisMin, fzAxisMax, fzAxisMin, OutCode(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4VSolid::ClipPolygonToSimpleLimits(), and G4ClippablePolygon::ClipToSimpleLimits().

◆ GetMaxExtent()

G4double G4VoxelLimits::GetMaxExtent ( const EAxis  pAxis) const

◆ GetMaxXExtent()

G4double G4VoxelLimits::GetMaxXExtent ( ) const

◆ GetMaxYExtent()

G4double G4VoxelLimits::GetMaxYExtent ( ) const

◆ GetMaxZExtent()

G4double G4VoxelLimits::GetMaxZExtent ( ) const

◆ GetMinExtent()

G4double G4VoxelLimits::GetMinExtent ( const EAxis  pAxis) const

◆ GetMinXExtent()

G4double G4VoxelLimits::GetMinXExtent ( ) const

◆ GetMinYExtent()

G4double G4VoxelLimits::GetMinYExtent ( ) const

◆ GetMinZExtent()

G4double G4VoxelLimits::GetMinZExtent ( ) const

◆ Inside()

G4bool G4VoxelLimits::Inside ( const G4ThreeVector pVec) const

◆ IsLimited() [1/2]

G4bool G4VoxelLimits::IsLimited ( ) const

◆ 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 221 of file G4VoxelLimits.cc.

222{
223 G4int code = 0 ; // The outcode
224
225 if ( IsXLimited() )
226 {
227 if ( pVec.x() < fxAxisMin ) code |= 0x01 ;
228 if ( pVec.x() > fxAxisMax ) code |= 0x02 ;
229 }
230 if ( IsYLimited() )
231 {
232 if ( pVec.y() < fyAxisMin ) code |= 0x04 ;
233 if ( pVec.y() > fyAxisMax ) code |= 0x08 ;
234 }
235 if (IsZLimited())
236 {
237 if ( pVec.z() < fzAxisMin ) code |= 0x10 ;
238 if ( pVec.z() > fzAxisMax ) code |= 0x20 ;
239 }
240 return code;
241}
G4bool IsYLimited() const
G4bool IsXLimited() const
G4bool IsZLimited() const
Definition: inftrees.h:24

References fxAxisMax, fxAxisMin, fyAxisMax, fyAxisMin, fzAxisMax, fzAxisMin, IsXLimited(), IsYLimited(), IsZLimited(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by ClipToLimits().

Field Documentation

◆ fxAxisMax

G4double G4VoxelLimits::fxAxisMax = kInfinity
private

Definition at line 118 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().

◆ fxAxisMin

G4double G4VoxelLimits::fxAxisMin = -kInfinity
private

Definition at line 118 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().

◆ fyAxisMax

G4double G4VoxelLimits::fyAxisMax = kInfinity
private

Definition at line 119 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().

◆ fyAxisMin

G4double G4VoxelLimits::fyAxisMin = -kInfinity
private

Definition at line 119 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().

◆ fzAxisMax

G4double G4VoxelLimits::fzAxisMax = kInfinity
private

Definition at line 120 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().

◆ fzAxisMin

G4double G4VoxelLimits::fzAxisMin = -kInfinity
private

Definition at line 120 of file G4VoxelLimits.hh.

Referenced by AddLimit(), ClipToLimits(), and OutCode().


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