vtf-logo

DAGHCluster.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_DAGHCluster_h
00004 #define _included_DAGHCluster_h
00005 
00010 #include "DAGH.h"
00011 
00012 /*************************************************************************/
00013 /* The Cluster Routines (by Paul Walker) */
00014 /*************************************************************************/
00015 template <int dim>
00016 void Cluster(GridData<short,dim> &flag, BBoxList& bblexclude, double Efficiency,
00017              int MinWidth, int MaxWidth, int BufferWidth, BBoxList &Result);
00018 
00019 /* dimension-specific specializations */
00020 template <>
00021 void Cluster(GridData<short,1> &flag, BBoxList& bblexclude, double Efficiency,
00022              int MinWidth, int MaxWidth, int BufferWidth, BBoxList &Result);
00023 template <>
00024 void Cluster(GridData<short,2> &flag, BBoxList& bblexclude, double Efficiency,
00025              int MinWidth, int MaxWidth, int BufferWidth, BBoxList &Result);
00026 template <>
00027 void Cluster(GridData<short,3> &flag, BBoxList& bblexclude, double Efficiency,
00028              int MinWidth, int MaxWidth, int BufferWidth, BBoxList &Result);
00029 
00030 template <class Type, int dim>
00031 void DAGHCluster(GridFunction<Type,dim>& gf, const int time, const int level, 
00032                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00033                  const double min_eff, const Type thresh, 
00034                  BBoxList& bbl, BBoxList& bblexclude);
00035 template <class Type, int dim>
00036 void DAGHCluster(GridFunction<Type,dim>& gf, const int time, const int level, 
00037                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00038                  const double min_eff, const Type thresh, 
00039                  BBoxList& nest_bbl, BBoxList& bbl, BBoxList& bblexclude);
00040 /*************************************************************************/
00041 
00042 template <class Type>
00043 void DAGHCluster(GridFunction<Type,3>& gf, const int time, const int level, 
00044                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00045                  const double min_eff, const Type thresh, 
00046                  BBoxList& bbl, BBoxList& bblexclude)
00047  {
00048   BBox bb;
00049   forall(gf,time,level,c)
00050     bb += gf.boundingbbox(time,level,c);
00051   end_forall 
00052 
00053   if (bb.empty()) {
00054     bbl.empty();
00055     return;
00056   }
00057 
00058   GridData<short,3> flag_array(bb);
00059   flag_array = 0;
00060   
00061 #ifdef DEBUG_PRINT_RG_CLUST
00062   ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00063                         << bb
00064                         << "\n************* ***************** *************\n"
00065                         ).flush();
00066 #endif
00067 
00068   forall(gf,time,level,c)
00069      const GridData<Type,3>& gd = gf(time,level,c);
00070      const BBox& b = gf.boundingbbox(time,level,c);
00071      for_3(i,j,k,b,b.stepsize())
00072        if (gd(i,j,k) > thresh) flag_array(i,j,k) = 1;
00073      end_for
00074   end_forall 
00075 
00076   bbl.empty();
00077 
00078   Cluster(flag_array,
00079           bblexclude,
00080           min_eff,
00081           min_blk_width,
00082           max_blk_width,
00083           buf_width,bbl);
00084 
00085   short olap[3];
00086   for (int i=0;i<3;i++) olap[i]=0;
00087   bbl.mergeboxes(olap);
00088 
00089 #ifdef DEBUG_PRINT_RG_CLUST
00090      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00091                            << bbl
00092                            << "\n************* ***************** *************\n"
00093                            ).flush();
00094 #endif
00095  }
00096 
00097 template <class Type>
00098 void DAGHCluster(GridFunction<Type,3>& gf, const int time, const int level, 
00099                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00100                  const double min_eff, const Type thresh, 
00101                  BBoxList& nest_bbl, BBoxList& bbl, BBoxList& bblexclude)
00102  {
00103 
00104 #ifdef DEBUG_PRINT_RG_CLUST
00105      ( comm_service::log() << "\n************* Clustering: Nest BBoxList  *************\n"
00106                            << nest_bbl
00107                            << "\n************* ***************** *************\n"
00108                            ).flush();
00109 #endif
00110 
00111   BBox bb;
00112   forall(gf,time,level,c)
00113     bb += gf.boundingbbox(time,level,c) ;
00114   end_forall 
00115 
00116   if (bb.empty()) {
00117     bbl.empty();
00118     return;
00119   }
00120 
00121   GridData<short,3> flag_array(bb);
00122   flag_array = 0;
00123   
00124 #ifdef DEBUG_PRINT_RG_CLUST
00125      ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00126                            << bb
00127                            << "\n************* ***************** *************\n"
00128                            ).flush();
00129 #endif
00130 
00131   BBox *_b = nest_bbl.first();
00132   for (;_b;_b=nest_bbl.next()) {
00133     flag_array.equals(1,*_b);
00134   }
00135 
00136   forall(gf,time,level,c)
00137      const GridData<Type,3>& gd = gf(time,level,c);
00138      const BBox& b = gf.boundingbbox(time,level,c);
00139      for_3(i,j,k,b,b.stepsize())
00140        if (gd(i,j,k) > thresh) flag_array(i,j,k) = 1;
00141      end_for
00142   end_forall 
00143 
00144   bbl.empty();
00145 
00146   Cluster(flag_array,
00147           bblexclude,
00148           min_eff,
00149           min_blk_width,
00150           max_blk_width,
00151           buf_width,bbl);
00152 
00153   short olap[3];
00154   for (int i=0;i<3;i++) olap[i]=0;
00155   bbl.mergeboxes(olap);
00156 
00157 #ifdef DEBUG_PRINT_RG_CLUST
00158      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00159                            << bbl
00160                            << "\n************* ***************** *************\n"
00161                            ).flush();
00162 #endif
00163  }
00164 
00165 /*************************************************************************/
00166 /* 2-D Clustering */
00167 /*************************************************************************/
00168 template <class Type>
00169 void DAGHCluster(GridFunction<Type,2>& gf, const int time, const int level, 
00170                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00171                  const double min_eff, const Type thresh, 
00172                  BBoxList& bbl, BBoxList& bblexclude)
00173 {
00174   BBox bb;
00175   forall(gf,time,level,c)
00176     bb += gf.boundingbbox(time,level,c);
00177   end_forall 
00178 
00179   if (bb.empty()) {
00180     bbl.empty();
00181     return;
00182   }
00183 
00184   GridData<short,2> flag_array(bb);
00185   flag_array = 0;
00186   
00187 #ifdef DEBUG_PRINT_RG_CLUST
00188   ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00189                         << bb
00190                         << "\n************* ***************** *************\n"
00191                         ).flush();
00192 #endif
00193 
00194   forall(gf,time,level,c)
00195      const GridData<Type,2>& gd = gf(time,level,c);
00196      const BBox& b = gf.boundingbbox(time,level,c);
00197      for_2(i,j,b,b.stepsize())
00198        if (gd(i,j) > thresh) flag_array(i,j) = 1;
00199      end_for
00200   end_forall 
00201 
00202   bbl.empty();
00203 
00204   Cluster(flag_array,
00205           bblexclude,
00206           min_eff,
00207           min_blk_width,
00208           max_blk_width,
00209           buf_width,bbl);
00210 
00211   short olap[2];
00212   for (int i=0;i<2;i++) olap[i]=0;
00213   bbl.mergeboxes(olap);
00214 
00215 #ifdef DEBUG_PRINT_RG_CLUST
00216      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00217                            << bbl
00218                            << "\n************* ***************** *************\n"
00219                            ).flush();
00220 #endif
00221  }
00222 
00223 template <class Type>
00224 void DAGHCluster(GridFunction<Type,2>& gf, const int time, const int level, 
00225                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00226                  const double min_eff, const Type thresh, 
00227                  BBoxList& nest_bbl, BBoxList& bbl, BBoxList& bblexclude)
00228 {
00229 
00230 #ifdef DEBUG_PRINT_RG_CLUST
00231      ( comm_service::log() << "\n************* Clustering: Nest BBoxList  *************\n"
00232                            << nest_bbl
00233                            << "\n************* ***************** *************\n"
00234                            ).flush();
00235 #endif
00236 
00237   BBox bb;
00238   forall(gf,time,level,c)
00239     bb += gf.boundingbbox(time,level,c);
00240   end_forall 
00241 
00242   if (bb.empty()) {
00243     bbl.empty();
00244     return;
00245   }
00246 
00247   GridData<short,2> flag_array(bb);
00248   flag_array = 0;
00249   
00250 #ifdef DEBUG_PRINT_RG_CLUST
00251      ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00252                            << bb
00253                            << "\n************* ***************** *************\n"
00254                            ).flush();
00255 #endif
00256 
00257   BBox *_b = nest_bbl.first();
00258   for (;_b;_b=nest_bbl.next()) {
00259     flag_array.equals(1,*_b);
00260   }
00261 
00262   forall(gf,time,level,c)
00263      const GridData<Type,2>& gd = gf(time,level,c);
00264      const BBox& b = gf.boundingbbox(time,level,c);
00265      for_2(i,j,b,b.stepsize())
00266        if (gd(i,j) > thresh) flag_array(i,j) = 1;
00267      end_for
00268   end_forall 
00269 
00270   bbl.empty();
00271 
00272   Cluster(flag_array,
00273           bblexclude,
00274           min_eff,
00275           min_blk_width,
00276           max_blk_width,
00277           buf_width,bbl);
00278 
00279   short olap[2];
00280   for (int i=0;i<2;i++) olap[i]=0;
00281   bbl.mergeboxes(olap);
00282 
00283 #ifdef DEBUG_PRINT_RG_CLUST
00284      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00285                            << bbl
00286                            << "\n************* ***************** *************\n"
00287                            ).flush();
00288 #endif
00289  }
00290 
00291 /*************************************************************************/
00292 /* 1-D Clustering */
00293 /*************************************************************************/
00294 template <class Type>
00295 void DAGHCluster(GridFunction<Type,1>& gf, const int time, const int level, 
00296                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00297                  const double min_eff, const Type thresh, 
00298                  BBoxList& bbl, BBoxList& bblexclude)
00299  {
00300   BBox bb;
00301   forall(gf,time,level,c)
00302     bb += gf.boundingbbox(time,level,c);
00303   end_forall 
00304 
00305   if (bb.empty()) {
00306     bbl.empty();
00307     return;
00308   }
00309 
00310   GridData<short,1> flag_array(bb);
00311   flag_array = 0;
00312   
00313 #ifdef DEBUG_PRINT_RG_CLUST
00314   ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00315                         << bb
00316                         << "\n************* ***************** *************\n"
00317                         ).flush();
00318 #endif
00319 
00320   forall(gf,time,level,c)
00321      const GridData<Type,1>& gd = gf(time,level,c);
00322      const BBox& b = gf.boundingbbox(time,level,c);
00323      for_1(i,b,b.stepsize())
00324        if (gd(i) > thresh) flag_array(i) = 1;
00325      end_for
00326   end_forall 
00327 
00328   bbl.empty();
00329 
00330   Cluster(flag_array,
00331           bblexclude,
00332           min_eff,
00333           min_blk_width,
00334           max_blk_width,
00335           buf_width,bbl);
00336 
00337   short olap[1];
00338   for (int i=0;i<1;i++) olap[i]=0;
00339   bbl.mergeboxes(olap);
00340 
00341 #ifdef DEBUG_PRINT_RG_CLUST
00342      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00343                            << bbl
00344                            << "\n************* ***************** *************\n"
00345                            ).flush();
00346 #endif
00347  }
00348 
00349 template <class Type>
00350 void DAGHCluster(GridFunction<Type,1>& gf, const int time, const int level, 
00351                  const int min_blk_width, const int max_blk_width, const int buf_width, 
00352                  const double min_eff, const Type thresh, 
00353                  BBoxList& nest_bbl, BBoxList& bbl, BBoxList& bblexclude)
00354  {
00355 
00356 #ifdef DEBUG_PRINT_RG_CLUST
00357      ( comm_service::log() << "\n************* Clustering: Nest BBoxList  *************\n"
00358                            << nest_bbl
00359                            << "\n************* ***************** *************\n"
00360                            ).flush();
00361 #endif
00362 
00363   BBox bb;
00364   forall(gf,time,level,c)
00365     bb += gf.boundingbbox(time,level,c);
00366   end_forall 
00367 
00368   if (bb.empty()) {
00369     bbl.empty();
00370     return;
00371   }
00372 
00373   GridData<short,1> flag_array(bb);
00374   flag_array = 0;
00375   
00376 #ifdef DEBUG_PRINT_RG_CLUST
00377      ( comm_service::log() << "\n************* Clustering: Flag Array Size *************\n"
00378                            << bb
00379                            << "\n************* ***************** *************\n"
00380                            ).flush();
00381 #endif
00382 
00383   BBox *_b = nest_bbl.first();
00384   for (;_b;_b=nest_bbl.next()) {
00385     flag_array.equals(1,*_b);
00386   }
00387 
00388   forall(gf,time,level,c)
00389      const GridData<Type,1>& gd = gf(time,level,c);
00390      const BBox& b = gf.boundingbbox(time,level,c);
00391      for_1(i,b,b.stepsize())
00392        if (gd(i) > thresh) flag_array(i) = 1;
00393      end_for
00394   end_forall 
00395 
00396   bbl.empty();
00397 
00398   Cluster(flag_array,
00399           bblexclude,
00400           min_eff,
00401           min_blk_width,
00402           max_blk_width,
00403           buf_width,bbl);
00404 
00405   short olap[1];
00406   for (int i=0;i<1;i++) olap[i]=0;
00407   bbl.mergeboxes(olap);
00408 
00409 #ifdef DEBUG_PRINT_RG_CLUST
00410      ( comm_service::log() << "\n************* Clustering: Output BBoxList  *************\n"
00411                            << bbl
00412                            << "\n************* ***************** *************\n"
00413                            ).flush();
00414 #endif
00415  }
00416 
00417 #endif

Generated on Fri Aug 24 13:00:29 2007 for AMROC's Hierachical Data Structures - by  doxygen 1.4.7