#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 |
Definition at line 62 of file G4VoxelLimits.hh.
G4VoxelLimits::G4VoxelLimits | ( | ) |
Definition at line 48 of file G4VoxelLimits.cc.
00049 : fxAxisMin(-kInfinity),fxAxisMax(kInfinity), 00050 fyAxisMin(-kInfinity),fyAxisMax(kInfinity), 00051 fzAxisMin(-kInfinity),fzAxisMax(kInfinity) 00052 { 00053 }
G4VoxelLimits::~G4VoxelLimits | ( | ) |
Definition at line 65 of file G4VoxelLimits.cc.
References kXAxis, kYAxis, and kZAxis.
Referenced by G4ClippablePolygon::ClipAlongOneAxis(), G4VSolid::ClipPolygon(), and G4SmartVoxelHeader::RefineNodes().
00068 { 00069 if ( pAxis == kXAxis ) 00070 { 00071 if ( pMin > fxAxisMin ) fxAxisMin = pMin ; 00072 if ( pMax < fxAxisMax ) fxAxisMax = pMax ; 00073 } 00074 else if ( pAxis == kYAxis ) 00075 { 00076 if ( pMin > fyAxisMin ) fyAxisMin = pMin ; 00077 if ( pMax < fyAxisMax ) fyAxisMax = pMax ; 00078 } 00079 else 00080 { 00081 assert( pAxis == kZAxis ) ; 00082 00083 if ( pMin > fzAxisMin ) fzAxisMin = pMin ; 00084 if ( pMax < fzAxisMax ) fzAxisMax = pMax ; 00085 } 00086 }
G4bool G4VoxelLimits::ClipToLimits | ( | G4ThreeVector & | pStart, | |
G4ThreeVector & | pEnd | |||
) | const |
Definition at line 102 of file G4VoxelLimits.cc.
References OutCode().
Referenced by G4ClippablePolygon::ClipToSimpleLimits().
00104 { 00105 G4int sCode, eCode ; 00106 G4bool remainsAfterClip ; 00107 00108 // Determine if line is trivially inside (both outcodes==0) or outside 00109 // (logical AND of outcodes !=0) 00110 00111 sCode = OutCode(pStart) ; 00112 eCode = OutCode(pEnd) ; 00113 00114 if ( sCode & eCode ) 00115 { 00116 // Trivially outside, no intersection with region 00117 00118 remainsAfterClip = false; 00119 } 00120 else if ( sCode == 0 && eCode == 0 ) 00121 { 00122 // Trivially inside, no intersections 00123 00124 remainsAfterClip = true ; 00125 } 00126 else 00127 { 00128 // Line segment *may* cut volume boundaries 00129 // At most, one end point is inside 00130 00131 G4double x1, y1, z1, x2, y2, z2 ; 00132 00133 x1 = pStart.x() ; 00134 y1 = pStart.y() ; 00135 z1 = pStart.z() ; 00136 00137 x2 = pEnd.x() ; 00138 y2 = pEnd.y() ; 00139 z2 = pEnd.z() ; 00140 /* 00141 if( std::abs(x1-x2) < kCarTolerance*kCarTolerance) 00142 { 00143 G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl; 00144 } 00145 if( std::abs(y1-y2) < kCarTolerance*kCarTolerance) 00146 { 00147 G4cout<<"y1 = "<<y1<<"\t"<<"y2 = "<<y2<<G4endl; 00148 } 00149 if( std::abs(z1-z2) < kCarTolerance*kCarTolerance) 00150 { 00151 G4cout<<"z1 = "<<z1<<"\t"<<"z2 = "<<z2<<G4endl; 00152 } 00153 */ 00154 while ( sCode != eCode ) 00155 { 00156 // Copy vectors to work variables x1-z1,x2-z2 00157 // Ensure x1-z1 lies outside volume, swapping vectors and outcodes 00158 // if necessary 00159 00160 if ( sCode ) 00161 { 00162 if ( sCode & 0x01 ) // Clip against fxAxisMin 00163 { 00164 z1 += (fxAxisMin-x1)*(z2-z1)/(x2-x1); 00165 y1 += (fxAxisMin-x1)*(y2-y1)/(x2-x1); 00166 x1 = fxAxisMin; 00167 } 00168 else if ( sCode & 0x02 ) // Clip against fxAxisMax 00169 { 00170 z1 += (fxAxisMax-x1)*(z2-z1)/(x2-x1); 00171 y1 += (fxAxisMax-x1)*(y2-y1)/(x2-x1); 00172 x1 = fxAxisMax ; 00173 } 00174 else if ( sCode & 0x04 ) // Clip against fyAxisMin 00175 { 00176 x1 += (fyAxisMin-y1)*(x2-x1)/(y2-y1); 00177 z1 += (fyAxisMin-y1)*(z2-z1)/(y2-y1); 00178 y1 = fyAxisMin; 00179 } 00180 else if ( sCode & 0x08 ) // Clip against fyAxisMax 00181 { 00182 x1 += (fyAxisMax-y1)*(x2-x1)/(y2-y1); 00183 z1 += (fyAxisMax-y1)*(z2-z1)/(y2-y1); 00184 y1 = fyAxisMax; 00185 } 00186 else if ( sCode & 0x10 ) // Clip against fzAxisMin 00187 { 00188 x1 += (fzAxisMin-z1)*(x2-x1)/(z2-z1); 00189 y1 += (fzAxisMin-z1)*(y2-y1)/(z2-z1); 00190 z1 = fzAxisMin; 00191 } 00192 else if ( sCode & 0x20 ) // Clip against fzAxisMax 00193 { 00194 x1 += (fzAxisMax-z1)*(x2-x1)/(z2-z1); 00195 y1 += (fzAxisMax-z1)*(y2-y1)/(z2-z1); 00196 z1 = fzAxisMax; 00197 } 00198 } 00199 if ( eCode ) // Clip 2nd end: repeat of 1st, but 1<>2 00200 { 00201 if ( eCode & 0x01 ) // Clip against fxAxisMin 00202 { 00203 z2 += (fxAxisMin-x2)*(z1-z2)/(x1-x2); 00204 y2 += (fxAxisMin-x2)*(y1-y2)/(x1-x2); 00205 x2 = fxAxisMin; 00206 } 00207 else if ( eCode & 0x02 ) // Clip against fxAxisMax 00208 { 00209 z2 += (fxAxisMax-x2)*(z1-z2)/(x1-x2); 00210 y2 += (fxAxisMax-x2)*(y1-y2)/(x1-x2); 00211 x2 = fxAxisMax; 00212 } 00213 else if ( eCode & 0x04 ) // Clip against fyAxisMin 00214 { 00215 x2 += (fyAxisMin-y2)*(x1-x2)/(y1-y2); 00216 z2 += (fyAxisMin-y2)*(z1-z2)/(y1-y2); 00217 y2 = fyAxisMin; 00218 } 00219 else if (eCode&0x08) // Clip against fyAxisMax 00220 { 00221 x2 += (fyAxisMax-y2)*(x1-x2)/(y1-y2); 00222 z2 += (fyAxisMax-y2)*(z1-z2)/(y1-y2); 00223 y2 = fyAxisMax; 00224 } 00225 else if ( eCode & 0x10 ) // Clip against fzAxisMin 00226 { 00227 x2 += (fzAxisMin-z2)*(x1-x2)/(z1-z2); 00228 y2 += (fzAxisMin-z2)*(y1-y2)/(z1-z2); 00229 z2 = fzAxisMin; 00230 } 00231 else if ( eCode & 0x20 ) // Clip against fzAxisMax 00232 { 00233 x2 += (fzAxisMax-z2)*(x1-x2)/(z1-z2); 00234 y2 += (fzAxisMax-z2)*(y1-y2)/(z1-z2); 00235 z2 = fzAxisMax; 00236 } 00237 } 00238 // G4endl; G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl<<G4endl; 00239 pStart = G4ThreeVector(x1,y1,z1); 00240 pEnd = G4ThreeVector(x2,y2,z2); 00241 sCode = OutCode(pStart); 00242 eCode = OutCode(pEnd); 00243 } 00244 if ( sCode == 0 && eCode == 0 ) remainsAfterClip = true; 00245 else remainsAfterClip = false; 00246 } 00247 return remainsAfterClip; 00248 }
Definition at line 71 of file G4VoxelLimits.icc.
References GetMaxXExtent(), GetMaxYExtent(), GetMaxZExtent(), kXAxis, kYAxis, and kZAxis.
Referenced by G4SmartVoxelHeader::BuildNodes(), G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Torus::CalculateExtent(), G4TessellatedSolid::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4ClippablePolygon::ClipAlongOneAxis(), and G4SolidExtentList::G4SolidExtentList().
00072 { 00073 if (pAxis==kXAxis) 00074 { 00075 return GetMaxXExtent(); 00076 } 00077 else if (pAxis==kYAxis) 00078 { 00079 return GetMaxYExtent(); 00080 } 00081 else 00082 { 00083 assert(pAxis==kZAxis); 00084 return GetMaxZExtent(); 00085 } 00086 }
G4double G4VoxelLimits::GetMaxXExtent | ( | ) | const [inline] |
Definition at line 35 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMaxExtent(), Inside(), and operator<<().
G4double G4VoxelLimits::GetMaxYExtent | ( | ) | const [inline] |
Definition at line 41 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMaxExtent(), Inside(), and operator<<().
G4double G4VoxelLimits::GetMaxZExtent | ( | ) | const [inline] |
Definition at line 47 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMaxExtent(), Inside(), and operator<<().
Definition at line 89 of file G4VoxelLimits.icc.
References GetMinXExtent(), GetMinYExtent(), GetMinZExtent(), kXAxis, kYAxis, and kZAxis.
Referenced by G4SmartVoxelHeader::BuildNodes(), G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Torus::CalculateExtent(), G4TessellatedSolid::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4ClippablePolygon::ClipAlongOneAxis(), and G4SolidExtentList::G4SolidExtentList().
00090 { 00091 if (pAxis==kXAxis) 00092 { 00093 return GetMinXExtent(); 00094 } 00095 else if (pAxis==kYAxis) 00096 { 00097 return GetMinYExtent(); 00098 } 00099 else 00100 { 00101 assert(pAxis==kZAxis); 00102 return GetMinZExtent(); 00103 } 00104 }
G4double G4VoxelLimits::GetMinXExtent | ( | ) | const [inline] |
Definition at line 53 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMinExtent(), Inside(), and operator<<().
G4double G4VoxelLimits::GetMinYExtent | ( | ) | const [inline] |
Definition at line 59 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMinExtent(), Inside(), and operator<<().
G4double G4VoxelLimits::GetMinZExtent | ( | ) | const [inline] |
Definition at line 65 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), GetMinExtent(), Inside(), and operator<<().
G4bool G4VoxelLimits::Inside | ( | const G4ThreeVector & | pVec | ) | const [inline] |
Definition at line 149 of file G4VoxelLimits.icc.
References GetMaxXExtent(), GetMaxYExtent(), GetMaxZExtent(), GetMinXExtent(), GetMinYExtent(), and GetMinZExtent().
Referenced by G4ClippablePolygon::ClipToSimpleLimits().
00150 { 00151 return ((GetMinXExtent()<=pVec.x()) && 00152 (GetMaxXExtent()>=pVec.x()) && 00153 (GetMinYExtent()<=pVec.y()) && 00154 (GetMaxYExtent()>=pVec.y()) && 00155 (GetMinZExtent()<=pVec.z()) && 00156 (GetMaxZExtent()>=pVec.z()) ) ? true : false; 00157 }
Definition at line 131 of file G4VoxelLimits.icc.
References IsXLimited(), IsYLimited(), IsZLimited(), kXAxis, kYAxis, and kZAxis.
00132 { 00133 if (pAxis==kXAxis) 00134 { 00135 return IsXLimited(); 00136 } 00137 else if (pAxis==kYAxis) 00138 { 00139 return IsYLimited(); 00140 } 00141 else 00142 { 00143 assert(pAxis==kZAxis); 00144 return IsZLimited(); 00145 } 00146 }
G4bool G4VoxelLimits::IsLimited | ( | ) | const [inline] |
Definition at line 125 of file G4VoxelLimits.icc.
References IsXLimited(), IsYLimited(), and IsZLimited().
Referenced by G4SmartVoxelHeader::BuildNodes(), G4SmartVoxelHeader::BuildVoxelsWithinLimits(), G4VTwistedFaceted::CalculateExtent(), G4TessellatedSolid::CalculateExtent(), G4ReflectedSolid::CalculateExtent(), G4Box::CalculateExtent(), G4ClippablePolygon::Clip(), G4ClippablePolygon::ClipAlongOneAxis(), G4VSolid::ClipPolygon(), G4SolidExtentList::G4SolidExtentList(), and G4ClippablePolygon::PartialClip().
00126 { 00127 return (IsXLimited()||IsYLimited()||IsZLimited()); 00128 }
G4bool G4VoxelLimits::IsXLimited | ( | ) | const [inline] |
Definition at line 107 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), IsLimited(), operator<<(), OutCode(), and G4SmartVoxelHeader::RefineNodes().
G4bool G4VoxelLimits::IsYLimited | ( | ) | const [inline] |
Definition at line 113 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), IsLimited(), operator<<(), OutCode(), and G4SmartVoxelHeader::RefineNodes().
G4bool G4VoxelLimits::IsZLimited | ( | ) | const [inline] |
Definition at line 119 of file G4VoxelLimits.icc.
Referenced by G4VTwistedFaceted::CalculateExtent(), G4Tubs::CalculateExtent(), G4Trd::CalculateExtent(), G4Trap::CalculateExtent(), G4Torus::CalculateExtent(), G4Tet::CalculateExtent(), G4Sphere::CalculateExtent(), G4Paraboloid::CalculateExtent(), G4Para::CalculateExtent(), G4Orb::CalculateExtent(), G4GenericTrap::CalculateExtent(), G4Ellipsoid::CalculateExtent(), G4CutTubs::CalculateExtent(), G4Cons::CalculateExtent(), G4BREPSolid::CalculateExtent(), G4Box::CalculateExtent(), G4VSolid::ClipPolygon(), IsLimited(), operator<<(), OutCode(), and G4SmartVoxelHeader::RefineNodes().
G4int G4VoxelLimits::OutCode | ( | const G4ThreeVector & | pVec | ) | const |
Definition at line 262 of file G4VoxelLimits.cc.
References IsXLimited(), IsYLimited(), and IsZLimited().
Referenced by ClipToLimits().
00263 { 00264 G4int code = 0 ; // The outcode 00265 00266 if ( IsXLimited() ) 00267 { 00268 if ( pVec.x() < fxAxisMin ) code |= 0x01 ; 00269 if ( pVec.x() > fxAxisMax ) code |= 0x02 ; 00270 } 00271 if ( IsYLimited() ) 00272 { 00273 if ( pVec.y() < fyAxisMin ) code |= 0x04 ; 00274 if ( pVec.y() > fyAxisMax ) code |= 0x08 ; 00275 } 00276 if (IsZLimited()) 00277 { 00278 if ( pVec.z() < fzAxisMin ) code |= 0x10 ; 00279 if ( pVec.z() > fzAxisMax ) code |= 0x20 ; 00280 } 00281 return code; 00282 }