#include <BfldMeshRect2d.h>
Public Member Functions | |
BfldMeshRect2d () | |
BfldMeshRect2d (BfldMapRect2d *map) | |
virtual | ~BfldMeshRect2d () |
virtual TVector3 | GetGeneratorPosition (Int_t generator) |
virtual Bool_t | InBounds (Float_t x, Float_t y) |
virtual Int_t | InQuadrant (Float_t x, Float_t y) |
virtual Int_t | GetQuadFlag (Int_t iquadrant) |
virtual Int_t | GetQuadFlag (Float_t x, Float_t y) |
virtual void | Pick3Generators (Float_t x, Float_t y, Int_t &gen_near, Int_t &gen_cw, Int_t &gen_ccw) |
virtual void | Pick4Generators (Float_t x, Float_t y, Int_t &gen_ll, Int_t &gen_lr, Int_t &gen_ur, Int_t &gen_ul) |
virtual Int_t | IndicesToGenerator (Int_t ix, Int_t iy) |
virtual void | GeneratorToIndices (Int_t gen, Int_t &ix, Int_t &iy) |
virtual Int_t | NearestGenerator (Float_t x, Float_t y) |
virtual Int_t | NearestGenerator (TVector3 xyz) |
virtual Int_t | LowerLeftGenerator (Float_t x, Float_t y) |
virtual Int_t | LowerLeftGenerator (TVector3 xyz) |
virtual Int_t | NeighborGenerator (Int_t gen, Int_t dnx, Int_t dny) |
Protected Member Functions | |
virtual void | CopyMapRect2d (BfldMapRect2d *map) |
virtual void | GeneratorToXY (Int_t gen, Float_t &x, Float_t &y) |
Protected Attributes | |
Float_t | fX0 |
Float_t | fDx |
Int_t | fNx |
Float_t | fXmax |
Float_t | fY0 |
Float_t | fDy |
Int_t | fNy |
Float_t | fYmax |
Bool_t | fQuadrant |
Int_t | fQuadFlags [4] |
Definition at line 20 of file BfldMeshRect2d.h.
BfldMeshRect2d::BfldMeshRect2d | ( | ) |
Definition at line 25 of file BfldMeshRect2d.cxx.
00026 : BfldMesh() 00027 { 00028 00029 }
BfldMeshRect2d::BfldMeshRect2d | ( | BfldMapRect2d * | map | ) |
Definition at line 32 of file BfldMeshRect2d.cxx.
References CopyMapRect2d().
00033 : BfldMesh(bmap->GetGrid(),bmap->GetVariant()) 00034 { 00035 CopyMapRect2d(bmap); 00036 }
BfldMeshRect2d::~BfldMeshRect2d | ( | ) | [virtual] |
Definition at line 39 of file BfldMeshRect2d.cxx.
References bfld::AsString(), BfldMesh::fGrid, BfldMesh::fVariant, Msg::kDebug, and MSG.
00040 { 00041 MSG("Bfld",Msg::kDebug) 00042 << "~BfldMeshRect2d grid " << BfldGrid::AsString(fGrid) 00043 << " variant " << fVariant 00044 << endl; 00045 }
void BfldMeshRect2d::CopyMapRect2d | ( | BfldMapRect2d * | map | ) | [protected, virtual] |
Definition at line 103 of file BfldMeshRect2d.cxx.
References fDx, fDy, BfldMesh::fIsUVZ, fNx, fNy, fQuadFlags, fQuadrant, fX0, fXmax, fY0, fYmax, BfldMapRect2d::GetDx(), BfldMapRect2d::GetDy(), BfldMapRect2d::GetIsUVZ(), BfldMapRect2d::GetNx(), BfldMapRect2d::GetNy(), BfldMapRect2d::GetQuadFlags(), BfldMapRect2d::GetX0(), and BfldMapRect2d::GetY0().
Referenced by BfldMeshRect2d().
00104 { 00105 // The Rect2d mesh must be told which map it is using 00106 // as the position info gets read in with the field vectors 00107 // and isn't available independently 00108 00109 BfldMapRect2d *fMap; // for Rect2d the mesh info is actually 00110 fMap = map; 00111 00112 // grab the position info from the map 00113 fX0 = fMap->GetX0(); 00114 fY0 = fMap->GetY0(); 00115 fDx = fMap->GetDx(); 00116 fDy = fMap->GetDy(); 00117 fNx = fMap->GetNx(); 00118 fNy = fMap->GetNy(); 00119 00120 // determine upper limit (lowest point *is* X0 or Y0) 00121 fXmax = fX0 + (fNx-1)*fDx; 00122 fYmax = fY0 + (fNy-1)*fDy; 00123 00124 fIsUVZ = fMap->GetIsUVZ(); 00125 00126 // if x0=0,y0=0 assume map only has one quadrant 00127 fQuadrant = ( 0 == fX0 && 0 == fY0 ); 00128 00129 fQuadFlags[0] = fMap->GetQuadFlags()[0]; 00130 fQuadFlags[1] = fMap->GetQuadFlags()[1]; 00131 fQuadFlags[2] = fMap->GetQuadFlags()[2]; 00132 fQuadFlags[3] = fMap->GetQuadFlags()[3]; 00133 00134 }
void BfldMeshRect2d::GeneratorToIndices | ( | Int_t | gen, | |
Int_t & | ix, | |||
Int_t & | iy | |||
) | [virtual] |
Definition at line 254 of file BfldMeshRect2d.cxx.
References fNy.
Referenced by BfldMapRect2d::BfldMapRect2d(), GeneratorToXY(), BfldHandlerRect2d::GetBFieldMeshCoord(), and NeighborGenerator().
void BfldMeshRect2d::GeneratorToXY | ( | Int_t | gen, | |
Float_t & | x, | |||
Float_t & | y | |||
) | [protected, virtual] |
Definition at line 231 of file BfldMeshRect2d.cxx.
References fDx, fDy, fX0, fY0, and GeneratorToIndices().
Referenced by GetGeneratorPosition(), and Pick3Generators().
00232 { 00233 // return the TVector3 associated with a generator (mesh node) 00234 00235 // BfldMeshRect2d doesn't hold actual positions 00236 00237 Int_t ix,iy; 00238 GeneratorToIndices(generator,ix,iy); 00239 00240 x = ix * fDx + fX0; 00241 y = iy * fDy + fY0; 00242 00243 }
TVector3 BfldMeshRect2d::GetGeneratorPosition | ( | Int_t | generator | ) | [virtual] |
Reimplemented from BfldMesh.
Definition at line 48 of file BfldMeshRect2d.cxx.
References GeneratorToXY().
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord().
00049 { 00050 // return the TVector3 associated with a generator (mesh node) 00051 00052 Float_t x, y; 00053 GeneratorToXY(generator,x,y); 00054 return TVector3(x,y,0.); 00055 }
virtual Int_t BfldMeshRect2d::GetQuadFlag | ( | Float_t | x, | |
Float_t | y | |||
) | [inline, virtual] |
Definition at line 35 of file BfldMeshRect2d.h.
References fQuadFlags, and InQuadrant().
00036 { return fQuadFlags[InQuadrant(x,y)]; }
virtual Int_t BfldMeshRect2d::GetQuadFlag | ( | Int_t | iquadrant | ) | [inline, virtual] |
Definition at line 33 of file BfldMeshRect2d.h.
References fQuadFlags.
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord().
00034 { return fQuadFlags[iquadrant]; }
Bool_t BfldMeshRect2d::InBounds | ( | Float_t | x, | |
Float_t | y | |||
) | [virtual] |
Definition at line 58 of file BfldMeshRect2d.cxx.
References fQuadrant, fX0, fY0, and fYmax.
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord().
00059 { 00060 // Is x-y within the limits of the map? 00061 00062 if (fQuadrant) { 00063 x = TMath::Abs(x); 00064 y = TMath::Abs(y); 00065 } 00066 00067 // assume upper and right boundary lines isn't "in bounds" 00068 // but that lower and left boundary lines are "in bounds" 00069 // this simplifies other things (picking bounding triangles) 00070 return ( x >= fX0 && x < fXmax && y >= fY0 && y < fYmax ); 00071 00072 }
Int_t BfldMeshRect2d::IndicesToGenerator | ( | Int_t | ix, | |
Int_t | iy | |||
) | [virtual] |
Definition at line 246 of file BfldMeshRect2d.cxx.
References fNy.
Referenced by LowerLeftGenerator(), NearestGenerator(), and NeighborGenerator().
00247 { 00248 // return the generator (indx) based on x-y indices 00249 00250 return ix*fNy + iy; 00251 }
Int_t BfldMeshRect2d::InQuadrant | ( | Float_t | x, | |
Float_t | y | |||
) | [virtual] |
Definition at line 75 of file BfldMeshRect2d.cxx.
References fQuadrant, fX0, and fY0.
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord(), and GetQuadFlag().
00076 { 00077 // Is x-y in which quadrant (if applicable) 00078 // 1 | 0 00079 // ----+---- + centered at (x0,y0) 00080 // 2 | 3 00081 00082 00083 if (fQuadrant) { 00084 if (x >= fX0) { 00085 if (y >= fY0) { 00086 return 0; 00087 } else { 00088 return 3; 00089 } 00090 } else { 00091 if (y >= fY0) { 00092 return 1; 00093 } else { 00094 return 2; 00095 } 00096 } 00097 00098 } else return 0; 00099 00100 }
Int_t BfldMeshRect2d::LowerLeftGenerator | ( | TVector3 | xyz | ) | [virtual] |
Definition at line 328 of file BfldMeshRect2d.cxx.
References LowerLeftGenerator().
00329 { 00330 // return the generator (indx) associated with the (x,y) position 00331 00332 return LowerLeftGenerator(xyz.X(),xyz.Y()); 00333 }
Int_t BfldMeshRect2d::LowerLeftGenerator | ( | Float_t | x, | |
Float_t | y | |||
) | [virtual] |
Definition at line 301 of file BfldMeshRect2d.cxx.
References fDx, fDy, fNx, fNy, fQuadrant, fX0, fY0, and IndicesToGenerator().
Referenced by LowerLeftGenerator(), Pick3Generators(), and Pick4Generators().
00302 { 00303 // return the generator (indx) associated with the (x,y) position 00304 00305 if ( fQuadrant ) { 00306 // symmetry case -- assume quadrant symmetry 00307 x = TMath::Abs(x); 00308 y = TMath::Abs(y); 00309 } 00310 00311 Float_t xx = (x - fX0) / fDx; 00312 Float_t yy = (y - fY0) / fDy; 00313 00314 // Lower Left means taking the floor first, not just the nearest integer 00315 Int_t ix = TMath::Nint(floor(xx)); 00316 Int_t iy = TMath::Nint(floor(yy)); 00317 00318 ix = TMath::Min(ix,fNx-1); 00319 iy = TMath::Min(iy,fNy-1); 00320 00321 ix = TMath::Max(ix,0); 00322 iy = TMath::Max(iy,0); 00323 00324 return IndicesToGenerator(ix,iy); 00325 }
Int_t BfldMeshRect2d::NearestGenerator | ( | TVector3 | xyz | ) | [virtual] |
Definition at line 293 of file BfldMeshRect2d.cxx.
References NearestGenerator().
00294 { 00295 // return the generator (indx) associated with the (x,y) position 00296 00297 return NearestGenerator(xyz.X(),xyz.Y()); 00298 }
Int_t BfldMeshRect2d::NearestGenerator | ( | Float_t | x, | |
Float_t | y | |||
) | [virtual] |
Definition at line 266 of file BfldMeshRect2d.cxx.
References fDx, fDy, fNx, fNy, fQuadrant, fX0, fY0, and IndicesToGenerator().
Referenced by BfldMapRect2d::BfldMapRect2d(), BfldHandlerRect2d::GetBFieldMeshCoord(), and NearestGenerator().
00267 { 00268 // return the generator (indx) associated with the (x,y) position 00269 00270 if ( fQuadrant ) { 00271 // symmetry case -- assume quadrant symmetry 00272 x = TMath::Abs(x); 00273 y = TMath::Abs(y); 00274 } 00275 00276 Float_t xx = (x - fX0) / fDx; 00277 Float_t yy = (y - fY0) / fDy; 00278 00279 // Nearest generator use Nint (while LowerLeft means taking the floor first) 00280 Int_t ix = TMath::Nint(xx); 00281 Int_t iy = TMath::Nint(yy); 00282 00283 ix = TMath::Min(ix,fNx-1); 00284 iy = TMath::Min(iy,fNy-1); 00285 00286 ix = TMath::Max(ix,0); 00287 iy = TMath::Max(iy,0); 00288 00289 return IndicesToGenerator(ix,iy); 00290 }
Int_t BfldMeshRect2d::NeighborGenerator | ( | Int_t | gen, | |
Int_t | dnx, | |||
Int_t | dny | |||
) | [virtual] |
Definition at line 336 of file BfldMeshRect2d.cxx.
References fNx, fNy, GeneratorToIndices(), and IndicesToGenerator().
Referenced by Pick3Generators(), and Pick4Generators().
00337 { 00338 // return the generator (indx) which is a neighbor to the input one 00339 // return -1 if no such index 00340 00341 Int_t ix = 0; 00342 Int_t iy = 0; 00343 00344 GeneratorToIndices(gen,ix,iy); 00345 00346 ix = ix + dnx; 00347 iy = iy + dny; 00348 00349 if (ix<0 || ix>=fNx) return -1; 00350 if (iy<0 || iy>=fNy) return -1; 00351 00352 return IndicesToGenerator(ix,iy); 00353 00354 }
void BfldMeshRect2d::Pick3Generators | ( | Float_t | x, | |
Float_t | y, | |||
Int_t & | gen_near, | |||
Int_t & | gen_cw, | |||
Int_t & | gen_ccw | |||
) | [virtual] |
Definition at line 137 of file BfldMeshRect2d.cxx.
References fDx, fDy, fQuadrant, GeneratorToXY(), Msg::kFatal, LowerLeftGenerator(), MSG, and NeighborGenerator().
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord().
00140 { 00141 // return the generator (indx) closest to the (x,y) position 00142 // and those clockwise and clockwise around it 00143 // (cw/ccw relative to pointing at center of cell) 00144 00145 if ( fQuadrant ) { 00146 // symmetry case -- assume quadrant symmetry 00147 x = TMath::Abs(x); 00148 y = TMath::Abs(y); 00149 } 00150 00151 // let the map figure out what the generator to the lower left is... 00152 Int_t llgen = LowerLeftGenerator(x,y); 00153 00154 Int_t dnx = 0; 00155 Int_t dny = 0; 00156 00157 Float_t xllgen = 0; 00158 Float_t yllgen = 0; 00159 GeneratorToXY(llgen,xllgen,yllgen); 00160 00161 if ( x - xllgen > 0.5*fDx) dnx = 1; 00162 if ( y - yllgen > 0.5*fDy) dny = 1; 00163 00164 // for now ignore special cases 00165 // which shouldn't arise anyway 00166 // (ie. because we're outside the map region). 00167 00168 Int_t sval = dny<<1 | dnx; 00169 switch (sval) { 00170 case 0: 00171 // nearest _was_ the lower left corner 00172 gen_near = llgen; 00173 gen_cw = NeighborGenerator(llgen,1,0); 00174 gen_ccw = NeighborGenerator(llgen,0,1); 00175 break; 00176 case 1: 00177 // nearest was +x but same y 00178 gen_near = NeighborGenerator(llgen,1,0); 00179 gen_cw = NeighborGenerator(llgen,1,1); 00180 gen_ccw = llgen; 00181 break; 00182 case 2: 00183 // nearest was +y but same x 00184 gen_near = NeighborGenerator(llgen,0,1); 00185 gen_cw = llgen; 00186 gen_ccw = NeighborGenerator(llgen,1,1); 00187 break; 00188 case 3: 00189 // nearest was +x,+y 00190 gen_near = NeighborGenerator(llgen,1,1); 00191 gen_cw = NeighborGenerator(llgen,0,1); 00192 gen_ccw = NeighborGenerator(llgen,1,0); 00193 break; 00194 default: 00195 MSG("Bfld",Msg::kFatal) << 00196 "BfldMeshRect2d.cxx::Pick3Generators sval " << sval << endl; 00197 gen_near = llgen; 00198 gen_cw = NeighborGenerator(llgen,1,0); 00199 gen_ccw = NeighborGenerator(llgen,0,1); 00200 break; 00201 } 00202 00203 00204 Int_t generator = NeighborGenerator(llgen,dnx,dny); 00205 if (generator < 0) generator = llgen; 00206 00207 00208 }
void BfldMeshRect2d::Pick4Generators | ( | Float_t | x, | |
Float_t | y, | |||
Int_t & | gen_ll, | |||
Int_t & | gen_lr, | |||
Int_t & | gen_ur, | |||
Int_t & | gen_ul | |||
) | [virtual] |
Definition at line 211 of file BfldMeshRect2d.cxx.
References fQuadrant, LowerLeftGenerator(), and NeighborGenerator().
Referenced by BfldHandlerRect2d::GetBFieldMeshCoord().
00214 { 00215 // return the generator (indx) that surround this point 00216 00217 if ( fQuadrant ) { 00218 // symmetry case -- assume quadrant symmetry 00219 x = TMath::Abs(x); 00220 y = TMath::Abs(y); 00221 } 00222 00223 gen_ll = LowerLeftGenerator(x,y); 00224 gen_lr = NeighborGenerator(gen_ll,1,0); 00225 gen_ur = NeighborGenerator(gen_ll,1,1); 00226 gen_ul = NeighborGenerator(gen_ll,0,1); 00227 00228 }
Float_t BfldMeshRect2d::fDx [protected] |
Definition at line 62 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), GeneratorToXY(), LowerLeftGenerator(), NearestGenerator(), and Pick3Generators().
Float_t BfldMeshRect2d::fDy [protected] |
Definition at line 67 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), GeneratorToXY(), LowerLeftGenerator(), NearestGenerator(), and Pick3Generators().
Int_t BfldMeshRect2d::fNx [protected] |
Definition at line 63 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), LowerLeftGenerator(), NearestGenerator(), and NeighborGenerator().
Int_t BfldMeshRect2d::fNy [protected] |
Definition at line 68 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), GeneratorToIndices(), IndicesToGenerator(), LowerLeftGenerator(), NearestGenerator(), and NeighborGenerator().
Int_t BfldMeshRect2d::fQuadFlags[4] [protected] |
Definition at line 72 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), and GetQuadFlag().
Bool_t BfldMeshRect2d::fQuadrant [protected] |
Definition at line 71 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), InBounds(), InQuadrant(), LowerLeftGenerator(), NearestGenerator(), Pick3Generators(), and Pick4Generators().
Float_t BfldMeshRect2d::fX0 [protected] |
Definition at line 61 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), GeneratorToXY(), InBounds(), InQuadrant(), LowerLeftGenerator(), and NearestGenerator().
Float_t BfldMeshRect2d::fXmax [protected] |
Definition at line 64 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d().
Float_t BfldMeshRect2d::fY0 [protected] |
Definition at line 66 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), GeneratorToXY(), InBounds(), InQuadrant(), LowerLeftGenerator(), and NearestGenerator().
Float_t BfldMeshRect2d::fYmax [protected] |
Definition at line 69 of file BfldMeshRect2d.h.
Referenced by CopyMapRect2d(), and InBounds().