AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

GridDataOpsRel2.h

Go to the documentation of this file.
00001 #ifndef _included_GridDataOpsRel_2_h
00002 #define _included_GridDataOpsRel_2_h
00003 
00009 /****************************** == ***************************************/
00010 
00011 template <class Type>
00012 BBox GridData(2)<Type>::is_eq (Type const &val, BBox const &where)
00013   {
00014     BBox intersection = _bbox * where;
00015     if (!intersection.empty())
00016       {
00017        Coords max_step = _step.getmax(where.stepsize());
00018        BBox to(intersection); to.setstepsize(_step);
00019        BBox from(intersection); from.setstepsize(where.stepsize());
00020        BBox bb(2,max_step);
00021        gd_OperateRegion(is_eq)(val, to, from, max_step, bb);
00022        return (bb);
00023       }
00024     else 
00025      { BBox bb(2,1); return (bb); }
00026   }
00027 
00028 template <class Type>
00029 BBox GridData(2)<Type>::is_eq (GridData(2)<Type> const &gd, BBox const &to,
00030                                                 BBox const &from)
00031   {
00032    const Coords  toshift = from.lower() - to.lower();
00033    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00034    if (!newfrom.empty())
00035      {
00036       BBox newto = shiftabs(newfrom, -toshift);
00037       Coords max_step = _step.getmax(gd._step);
00038       newto.setstepsize(_step);
00039       newfrom.setstepsize(gd._step);
00040       BBox bb(2,max_step);
00041       gd_OperateRegion(is_eq)(gd, newto, newfrom, max_step, bb);
00042       return (bb);
00043      }
00044     else 
00045      { BBox bb(2,1); return (bb); }
00046   }
00047 
00048 template <class Type>
00049 void GridData(2)<Type>::gd_OperateRegion(is_eq) (Type const &val, 
00050                         BBox const &to, BBox const &from, Coords const &step, 
00051                         BBox &bb)
00052   {
00053    GridData(2)<Type> &dst = *this;
00054 
00055    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00056 
00057    for_2(i, j, to, step)
00058       if (FastIndex2(dst,i,j) == val) bb += Coords(2,i,j);
00059    end_for
00060 
00061    EndFastIndex2(dst);
00062   }
00063 
00064 template <class Type>
00065 void GridData(2)<Type>::gd_OperateRegion(is_eq) (GridData(2)<Type> const &src, 
00066                         BBox const &to, BBox const &from, Coords const &step,
00067                         BBox &bb)
00068   {
00069    GridData(2)<Type> &dst = *this;
00070    const int di = from.lower(0)-to.lower(0);
00071    const int dj = from.lower(1)-to.lower(1);
00072 
00073    BeginFastIndex2(src, src._bbox, src._data, const Type);
00074    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00075 
00076    for_2(i, j, to, step)
00077       if (FastIndex2(dst,i,j) == FastIndex2(src,i+di,j+dj))
00078         bb += Coords(2,i,j);
00079    end_for
00080 
00081    EndFastIndex2(dst);
00082    EndFastIndex2(src);
00083   }
00084 
00085 /************************************************************************/
00086 
00087 /****************************** != ***************************************/
00088 
00089 template <class Type>
00090 BBox GridData(2)<Type>::is_neq (Type const &val, BBox const &where)
00091   {
00092     BBox intersection = _bbox * where;
00093     if (!intersection.empty())
00094       {
00095        Coords max_step = _step.getmax(where.stepsize());
00096        BBox to(intersection); to.setstepsize(_step);
00097        BBox from(intersection); from.setstepsize(where.stepsize());
00098        BBox bb(2,max_step);
00099        gd_OperateRegion(is_neq)(val, to, from, max_step, bb);
00100        return (bb);
00101       }
00102     else 
00103      { BBox bb(2,1); return (bb); }
00104   }
00105 
00106 template <class Type>
00107 BBox GridData(2)<Type>::is_neq (GridData(2)<Type> const &gd, BBox const &to,
00108                                                 BBox const &from)
00109   {
00110    const Coords  toshift = from.lower() - to.lower();
00111    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00112    if (!newfrom.empty())
00113      {
00114       BBox newto = shiftabs(newfrom, -toshift);
00115       Coords max_step = _step.getmax(gd._step);
00116       newto.setstepsize(_step);
00117       newfrom.setstepsize(gd._step);
00118       BBox bb(2,max_step);
00119       gd_OperateRegion(is_neq)(gd, newto, newfrom, max_step, bb);
00120       return (bb);
00121      }
00122     else 
00123      { BBox bb(2,1); return (bb); }
00124   }
00125 
00126 template <class Type>
00127 void GridData(2)<Type>::gd_OperateRegion(is_neq) (Type const &val, 
00128                         BBox const &to, BBox const &from, Coords const &step, 
00129                         BBox &bb)
00130   {
00131    GridData(2)<Type> &dst = *this;
00132 
00133    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00134 
00135    for_2(i, j, to, step)
00136       if (FastIndex2(dst,i,j) != val) bb += Coords(2,i,j);
00137    end_for
00138 
00139    EndFastIndex2(dst);
00140   }
00141 
00142 template <class Type>
00143 void GridData(2)<Type>::gd_OperateRegion(is_neq) (GridData(2)<Type> const &src, 
00144                         BBox const &to, BBox const &from, Coords const &step,
00145                         BBox &bb)
00146   {
00147    GridData(2)<Type> &dst = *this;
00148    const int di = from.lower(0)-to.lower(0);
00149    const int dj = from.lower(1)-to.lower(1);
00150 
00151    BeginFastIndex2(src, src._bbox, src._data, const Type);
00152    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00153 
00154    for_2(i, j, to, step)
00155       if (FastIndex2(dst,i,j) != FastIndex2(src,i+di,j+dj))
00156         bb += Coords(2,i,j);
00157    end_for
00158 
00159    EndFastIndex2(dst);
00160    EndFastIndex2(src);
00161   }
00162 
00163 /************************************************************************/
00164 
00165 /****************************** > ***************************************/
00166 
00167 template <class Type>
00168 BBox GridData(2)<Type>::is_gt (Type const &val, BBox const &where)
00169   {
00170     BBox intersection = _bbox * where;
00171     if (!intersection.empty())
00172       {
00173        Coords max_step = _step.getmax(where.stepsize());
00174        BBox to(intersection); to.setstepsize(_step);
00175        BBox from(intersection); from.setstepsize(where.stepsize());
00176        BBox bb(2,max_step);
00177        gd_OperateRegion(is_gt)(val, to, from, max_step, bb);
00178        return (bb);
00179       }
00180     else 
00181      { BBox bb(2,1); return (bb); }
00182   }
00183 
00184 template <class Type>
00185 BBox GridData(2)<Type>::is_gt (GridData(2)<Type> const &gd, BBox const &to,
00186                                                 BBox const &from)
00187   {
00188    const Coords  toshift = from.lower() - to.lower();
00189    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00190    if (!newfrom.empty())
00191      {
00192       BBox newto = shiftabs(newfrom, -toshift);
00193       Coords max_step = _step.getmax(gd._step);
00194       newto.setstepsize(_step);
00195       newfrom.setstepsize(gd._step);
00196       BBox bb(2,max_step);
00197       gd_OperateRegion(is_gt)(gd, newto, newfrom, max_step, bb);
00198       return (bb);
00199      }
00200     else 
00201      { BBox bb(2,1); return (bb); }
00202   }
00203 
00204 template <class Type>
00205 void GridData(2)<Type>::gd_OperateRegion(is_gt) (Type const &val, 
00206                         BBox const &to, BBox const &from, Coords const &step, 
00207                         BBox &bb)
00208   {
00209    GridData(2)<Type> &dst = *this;
00210 
00211    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00212 
00213    for_2(i, j, to, step)
00214       if (FastIndex2(dst,i,j) > val) bb += Coords(2,i,j);
00215    end_for
00216 
00217    EndFastIndex2(dst);
00218   }
00219 
00220 template <class Type>
00221 void GridData(2)<Type>::gd_OperateRegion(is_gt) (GridData(2)<Type> const &src, 
00222                         BBox const &to, BBox const &from, Coords const &step,
00223                         BBox &bb)
00224   {
00225    GridData(2)<Type> &dst = *this;
00226    const int di = from.lower(0)-to.lower(0);
00227    const int dj = from.lower(1)-to.lower(1);
00228 
00229    BeginFastIndex2(src, src._bbox, src._data, const Type);
00230    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00231 
00232    for_2(i, j, to, step)
00233       if (FastIndex2(dst,i,j) > FastIndex2(src,i+di,j+dj))
00234         bb += Coords(2,i,j);
00235    end_for
00236 
00237    EndFastIndex2(dst);
00238    EndFastIndex2(src);
00239   }
00240 
00241 /************************************************************************/
00242 
00243 /****************************** >= ***************************************/
00244 
00245 template <class Type>
00246 BBox GridData(2)<Type>::is_ge (Type const &val, BBox const &where)
00247   {
00248     BBox intersection = _bbox * where;
00249     if (!intersection.empty())
00250       {
00251        Coords max_step = _step.getmax(where.stepsize());
00252        BBox to(intersection); to.setstepsize(_step);
00253        BBox from(intersection); from.setstepsize(where.stepsize());
00254        BBox bb(2,max_step);
00255        gd_OperateRegion(is_ge)(val, to, from, max_step, bb);
00256        return (bb);
00257       }
00258     else 
00259      { BBox bb(2,1); return (bb); }
00260   }
00261 
00262 template <class Type>
00263 BBox GridData(2)<Type>::is_ge (GridData(2)<Type> const &gd, BBox const &to,
00264                                                 BBox const &from)
00265   {
00266    const Coords  toshift = from.lower() - to.lower();
00267    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00268    if (!newfrom.empty())
00269      {
00270       BBox newto = shiftabs(newfrom, -toshift);
00271       Coords max_step = _step.getmax(gd._step);
00272       newto.setstepsize(_step);
00273       newfrom.setstepsize(gd._step);
00274       BBox bb(2,max_step);
00275       gd_OperateRegion(is_ge)(gd, newto, newfrom, max_step, bb);
00276       return (bb);
00277      }
00278     else 
00279      { BBox bb(2,1); return (bb); }
00280   }
00281 
00282 template <class Type>
00283 void GridData(2)<Type>::gd_OperateRegion(is_ge) (Type const &val, 
00284                         BBox const &to, BBox const &from, Coords const &step, 
00285                         BBox &bb)
00286   {
00287    GridData(2)<Type> &dst = *this;
00288 
00289    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00290 
00291    for_2(i, j, to, step)
00292       if (FastIndex2(dst,i,j) >= val) bb += Coords(2,i,j);
00293    end_for
00294 
00295    EndFastIndex2(dst);
00296   }
00297 
00298 template <class Type>
00299 void GridData(2)<Type>::gd_OperateRegion(is_ge) (GridData(2)<Type> const &src, 
00300                         BBox const &to, BBox const &from, Coords const &step,
00301                         BBox &bb)
00302   {
00303    GridData(2)<Type> &dst = *this;
00304    const int di = from.lower(0)-to.lower(0);
00305    const int dj = from.lower(1)-to.lower(1);
00306 
00307    BeginFastIndex2(src, src._bbox, src._data, const Type);
00308    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00309 
00310    for_2(i, j, to, step)
00311       if (FastIndex2(dst,i,j) >= FastIndex2(src,i+di,j+dj))
00312         bb += Coords(2,i,j);
00313    end_for
00314 
00315    EndFastIndex2(dst);
00316    EndFastIndex2(src);
00317   }
00318 
00319 /************************************************************************/
00320 
00321 /****************************** < ***************************************/
00322 
00323 template <class Type>
00324 BBox GridData(2)<Type>::is_lt (Type const &val, BBox const &where)
00325   {
00326     BBox intersection = _bbox * where;
00327     if (!intersection.empty())
00328       {
00329        Coords max_step = _step.getmax(where.stepsize());
00330        BBox to(intersection); to.setstepsize(_step);
00331        BBox from(intersection); from.setstepsize(where.stepsize());
00332        BBox bb(2,max_step);
00333        gd_OperateRegion(is_lt)(val, to, from, max_step, bb);
00334        return (bb);
00335       }
00336     else 
00337      { BBox bb(2,1); return (bb); }
00338   }
00339 
00340 template <class Type>
00341 BBox GridData(2)<Type>::is_lt (GridData(2)<Type> const &gd, BBox const &to,
00342                                                 BBox const &from)
00343   {
00344    const Coords  toshift = from.lower() - to.lower();
00345    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00346    if (!newfrom.empty())
00347      {
00348       BBox newto = shiftabs(newfrom, -toshift);
00349       Coords max_step = _step.getmax(gd._step);
00350       newto.setstepsize(_step);
00351       newfrom.setstepsize(gd._step);
00352       BBox bb(2,max_step);
00353       gd_OperateRegion(is_lt)(gd, newto, newfrom, max_step, bb);
00354       return (bb);
00355      }
00356     else 
00357      { BBox bb(2,1); return (bb); }
00358   }
00359 
00360 template <class Type>
00361 void GridData(2)<Type>::gd_OperateRegion(is_lt) (Type const &val, 
00362                         BBox const &to, BBox const &from, Coords const &step, 
00363                         BBox &bb)
00364   {
00365    GridData(2)<Type> &dst = *this;
00366 
00367    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00368 
00369    for_2(i, j, to, step)
00370       if (FastIndex2(dst,i,j) < val) bb += Coords(2,i,j);
00371    end_for
00372 
00373    EndFastIndex2(dst);
00374   }
00375 
00376 template <class Type>
00377 void GridData(2)<Type>::gd_OperateRegion(is_lt) (GridData(2)<Type> const &src, 
00378                         BBox const &to, BBox const &from, Coords const &step,
00379                         BBox &bb)
00380   {
00381    GridData(2)<Type> &dst = *this;
00382    const int di = from.lower(0)-to.lower(0);
00383    const int dj = from.lower(1)-to.lower(1);
00384 
00385    BeginFastIndex2(src, src._bbox, src._data, const Type);
00386    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00387 
00388    for_2(i, j, to, step)
00389       if (FastIndex2(dst,i,j) < FastIndex2(src,i+di,j+dj))
00390         bb += Coords(2,i,j);
00391    end_for
00392 
00393    EndFastIndex2(dst);
00394    EndFastIndex2(src);
00395   }
00396 
00397 /************************************************************************/
00398 
00399 /****************************** <= ***************************************/
00400 
00401 template <class Type>
00402 BBox GridData(2)<Type>::is_le (Type const &val, BBox const &where)
00403   {
00404     BBox intersection = _bbox * where;
00405     if (!intersection.empty())
00406       {
00407        Coords max_step = _step.getmax(where.stepsize());
00408        BBox to(intersection); to.setstepsize(_step);
00409        BBox from(intersection); from.setstepsize(where.stepsize());
00410        BBox bb(2,max_step);
00411        gd_OperateRegion(is_le)(val, to, from, max_step, bb);
00412        return (bb);
00413       }
00414     else 
00415      { BBox bb(2,1); return (bb); }
00416   }
00417 
00418 template <class Type>
00419 BBox GridData(2)<Type>::is_le (GridData(2)<Type> const &gd, BBox const &to,
00420                                                 BBox const &from)
00421   {
00422    const Coords  toshift = from.lower() - to.lower();
00423    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00424    if (!newfrom.empty())
00425      {
00426       BBox newto = shiftabs(newfrom, -toshift);
00427       Coords max_step = _step.getmax(gd._step);
00428       newto.setstepsize(_step);
00429       newfrom.setstepsize(gd._step);
00430       BBox bb(2,max_step);
00431       gd_OperateRegion(is_le)(gd, newto, newfrom, max_step, bb);
00432       return (bb);
00433      }
00434     else 
00435      { BBox bb(2,1); return (bb); }
00436   }
00437 
00438 template <class Type>
00439 void GridData(2)<Type>::gd_OperateRegion(is_le) (Type const &val, 
00440                         BBox const &to, BBox const &from, Coords const &step, 
00441                         BBox &bb)
00442   {
00443    GridData(2)<Type> &dst = *this;
00444 
00445    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00446 
00447    for_2(i, j, to, step)
00448       if (FastIndex2(dst,i,j) <= val) bb += Coords(2,i,j);
00449    end_for
00450 
00451    EndFastIndex2(dst);
00452   }
00453 
00454 template <class Type>
00455 void GridData(2)<Type>::gd_OperateRegion(is_le) (GridData(2)<Type> const &src, 
00456                         BBox const &to, BBox const &from, Coords const &step,
00457                         BBox &bb)
00458   {
00459    GridData(2)<Type> &dst = *this;
00460    const int di = from.lower(0)-to.lower(0);
00461    const int dj = from.lower(1)-to.lower(1);
00462 
00463    BeginFastIndex2(src, src._bbox, src._data, const Type);
00464    BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00465 
00466    for_2(i, j, to, step)
00467       if (FastIndex2(dst,i,j) <= FastIndex2(src,i+di,j+dj))
00468         bb += Coords(2,i,j);
00469    end_for
00470 
00471    EndFastIndex2(dst);
00472    EndFastIndex2(src);
00473   }
00474 
00475 /************************************************************************/
00476 
00477 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04