IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36576


Ignore:
Timestamp:
Mar 6, 2014, 9:33:47 AM (12 years ago)
Author:
eugene
Message:

add automatic neighbor search to region hosts

Location:
branches/eam_branches/ipp-20140206/Ohana/src/libdvo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h

    r36575 r36576  
    286286
    287287// A RegionHost processes data for some region in parallel with other regions
    288 typedef struct {
    289   double Rmin;
    290   double Rmax;
    291   double Dmin;
    292   double Dmax;
    293 
    294   double RminCat;
    295   double RmaxCat;
    296   double DminCat;
     288typedef struct RegionHostInfo {
     289  double Rmin;        // (Rmin,Rmax),(Dmin,Dmax) arehard RA,DEC boundaries of the
     290  double Rmax;        // region for which each host is responsible.  A given host
     291  double Dmin;        // calibrates the images for which the fiducial point (center)
     292  double Dmax;        // lands in the region, and all objects in the region
     293
     294  double RminCat;      // (RminCat,RmaxCat),(DminCat,DmaxCat) are the region for which
     295  double RmaxCat;      // the catalogs need to be loaded : this is the outer bounds
     296  double DminCat;      // of the region containing all images completely
    297297  double DmaxCat;
    298298
     
    310310  Image *image;
    311311  off_t *imseq;
     312
     313  int *neighbors;
     314  int Nneighbors;
    312315} RegionHostInfo;
    313316
  • branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/RegionHostTable.c

    r36575 r36576  
    2727    hosts[i].Nimage = 0;
    2828    hosts[i].NIMAGE = 0;
     29
     30    hosts[i].neighbors = NULL;
     31    hosts[i].Nneighbors = 0;
    2932  }
    3033  return;
     
    167170  }
    168171
     172  for (i = 0; i < table->Nhosts; i++) {
     173    RegionHostFindNeighbors (table, i);
     174  }
     175
    169176  free (filename);
    170177  fclose (f);
    171178  return table;
     179}
     180
     181int RegionHostFindNeighbors (RegionHostTable *table, int Nhost) {
     182
     183  // given a specific host (by table sequence), find all of its neighbors
     184  // (eg, (host->Rmin == althost->Rmax && (host->Dmin <= althost->Dmax) && (host->Dmax >= althost->Dmin)
     185
     186  RegionHostInfo *myhost = &table->hosts[Nhost];
     187  myAssert (!myhost->neighbors, "myhost neighbors already allocated");
     188  myAssert (!myhost->Nneighbors, "myhost Nneighbors not zero?");
     189  ALLOCATE (myhost->neighbors, int, 1); // always allocate 1 extra
     190
     191  for (i = 0; i < table->Nhosts; i++) {
     192
     193    if (i == Nhost) continue;
     194    RegionHostInfo *althost = &table->hosts[i];
     195   
     196    int onBorder;
     197
     198    onBorder =
     199      (myhost->Rmin == altHost->Rmax) &&
     200      (myhost->Dmin <= altHost->Dmax) &&
     201      (myhost->Dmax >= altHost->Dmin);
     202    if (onBorder) goto add_neighbor;
     203
     204    onBorder =
     205      (myhost->Rmax == altHost->Rmin) &&
     206      (myhost->Dmin <= altHost->Dmax) &&
     207      (myhost->Dmax >= altHost->Dmin);
     208    if (onBorder) goto add_neighbor;
     209
     210    onBorder =
     211      (myhost->Dmin == altHost->Dmax) &&
     212      (myhost->Rmin <= altHost->Rmax) &&
     213      (myhost->Rmax >= altHost->Rmin);
     214    if (onBorder) goto add_neighbor;
     215
     216    onBorder =
     217      (myhost->Dmax == altHost->Dmin) &&
     218      (myhost->Rmin <= altHost->Rmax) &&
     219      (myhost->Rmax >= altHost->Rmin);
     220    if (onBorder) goto add_neighbor;
     221   
     222    continue;
     223
     224  add_neighbor:
     225      myhost->neighbors[myhost->Nneighbors] = i;
     226      myhost->Nneighbors ++;
     227      REALLOCATE (myhost->neighbors, int, myhost->Nneighbors + 1);
     228  }
     229  return TRUE;
    172230}
    173231
Note: See TracChangeset for help on using the changeset viewer.