IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 4, 2007, 10:15:51 AM (19 years ago)
Author:
eugene
Message:

extensive updates to the avextract / mextract / skyregion system

Location:
trunk/Ohana/src/libdvo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/include/dvo.h

    r14263 r14401  
    153153typedef struct {
    154154  int Nregions;
     155  int ownElements;                                /* does this list own filename, regions? */
    155156  char **filename;
    156157  SkyRegion **regions;
     
    428429SkyList   *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax));
    429430int        SkyListMerge            PROTO((SkyList **outlist, SkyList *newlist));
    430 int        SkyListFree             PROTO((SkyList *list, int ELEMENTS));
     431int        SkyListFree             PROTO((SkyList *list));
    431432int        SkyTableFree            PROTO((SkyTable *table));
    432433int        SkyListSetFilenames     PROTO((SkyList *list, char *path, char *ext));
  • trunk/Ohana/src/libdvo/src/skyregion_ops.c

    r14289 r14401  
    1919  ALLOCATE (list[0].filename,  char *, 1);
    2020  list[0].Nregions = 0;
     21  list[0].ownElements = FALSE; // this list is only holding a view to the elements
    2122
    2223  region = table[0].regions;
     
    6566  ALLOCATE (list[0].filename, char *, NREGIONS);
    6667  list[0].Nregions = N;
     68  list[0].ownElements = FALSE; // this list is only holding a view to the elements
    6769
    6870  region = table[0].regions;
     
    99101  ALLOCATE (list[0].filename,  char *, NREGIONS);
    100102  list[0].Nregions = N;
     103  list[0].ownElements = FALSE; // this list is only holding a view to the elements
    101104
    102105  region = table[0].regions;
     
    232235    }
    233236    list[0].Nregions = Ns;
    234     SkyListFree (extra, FALSE);
     237    SkyListFree (extra);
    235238  } else {
    236239    list = SkyListChildrenByBounds (table, -1, depth, Rmin, Rmax, Dmin, Dmax);
     
    253256  ALLOCATE (list[0].regions, SkyRegion *, NNEW);
    254257  ALLOCATE (list[0].filename, char *, NNEW);
     258  list[0].ownElements = FALSE; // this list is only holding a view to the elements
    255259
    256260  region = table[0].regions;
     
    289293      }
    290294      Nnew += children[0].Nregions;
    291       SkyListFree (children, FALSE);
     295      SkyListFree (children);
    292296    } else {
    293297      list[0].regions[Nnew] = &region[i];
     
    332336}
    333337
    334 int SkyListFree (SkyList *list, int ELEMENTS) {
     338int SkyListFree (SkyList *list) {
    335339
    336340  int i;
     
    339343  if (list == NULL) return (TRUE);
    340344  if (list[0].regions != NULL) {
    341     if (ELEMENTS) {
     345    if (list[0].ownElements) {
    342346      for (i = 0; i < list[0].Nregions; i++) {
    343347        if (list[0].filename[i] != NULL) {
     
    384388        ALLOCATE (list[0].regions, SkyRegion *, 1);
    385389        ALLOCATE (list[0].filename, char *, 1);
     390        list[0].ownElements = FALSE; // this list is only holding a view to the elements
    386391        list[0].Nregions = 0;
    387392        *outlist = list;
     
    412417    return (TRUE);
    413418}
    414 
    415 # if (0)
    416 
    417 /* find regions contained within rectangular region  c1 - c2 */
    418 SkyRegion **SkyFindArea (SkyRegion *db, SkyCoord c1, SkyCoord c2, int *nlist) {
    419 
    420   int Nlist;
    421   SkyRegion *list, *new, *sub;
    422 
    423   while (c1.r > 360.0) c1.r -= 360.0;
    424   while (c1.r <   0.0) c1.r += 360.0;
    425   while (c2.r > 360.0) c2.r -= 360.0;
    426   while (c2.r <   0.0) c2.r += 360.0;
    427 
    428   /* check on c1.r > c2.r : cross boundary */
    429   if (c1.r > c2.r) {
    430     c0 = c2; c0.r = 360.0;
    431     list = SkyFindArea (db, c1, c0, &Nlist);
    432     c0 = c1; c0.r = 0.0;
    433     new  = SkyFindArea (db, c0, c2, &Nnew);
    434     REALLOCATE (list, SkyRegion *, MAX (1, Nlist + Nnew));
    435     memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
    436     free (new);
    437     Nlist += Nnew;
    438     *nlist = Nlist;
    439     return (list);
    440   }   
    441 
    442   Ns = 0;
    443   Ne = 1;
    444   Nlist = 1;
    445   ALLOCATE (list, SkyRegion *, Nlist);
    446   list[0] = &region[0];
    447   getchild = region[0].child;
    448 
    449   while (getchild) {
    450 
    451     getchild = FALSE;
    452     Nnew = 0;
    453     NNEW = 100;
    454     ALLOCATE (new, SkyRegion *, NNEW);
    455 
    456     for (i = Ns; i < Ne; i++) {
    457       children = SkyFindChildren(db, list[i], c1, c2, &Nchildren);
    458       if (children == NULL) continue;
    459       if (Nnew + Nchildren >= NNEW) {
    460         NNEW += 100;
    461         REALLOCATE (new, SkyRegion *, NNEW);
    462       }
    463       for (i = 0; i < Nchildren; i++) {
    464         getchild |= children[i][0].child;
    465         new[Nnew] = children[i];
    466         Nnew++;
    467       }
    468       free (children);
    469     }
    470 
    471     REALLOCATE (list, SkyRegion *, Nlist + Nnew);
    472     memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
    473     free (new);
    474     Nlist += Nnew;
    475   }
    476   return (list);
    477   *nlist = Nlist;
    478 }
    479 
    480 /* find all children of the given sky region */
    481 SkyRegion **SkyFindChildren (SkyRegion *db, SkyRegion *parent, SkyCoord c1, SkyCoord c2, int *Nchildren) {
    482 
    483   int i, Ns, Ne, Nregion, NREGIONS;
    484   SkyRegion **region;
    485  
    486   *Nchildren = 0;
    487   if (!parent[0].child) return (NULL);
    488 
    489   Ns = parent[0].childS;
    490   Ne = parent[0].childE;
    491 
    492   Nregion = 0;
    493   NREGIONS = 100;
    494   ALLOCATE (region, SkyRegion *, NREGIONS);
    495 
    496   for (i = Ns; i < Ne; i++) {
    497     if (region[i].Rmax < c1.r) continue;
    498     if (region[i].Rmin > c2.r) continue;
    499     if (region[i].Dmax < c1.d) continue;
    500     if (region[i].Dmin > c2.d) continue;
    501     region[Nregion] = &region[i];
    502     Nregion++;
    503     if (Nregion == NREGIONS) {
    504       NREGIONS += 100;
    505       REALLOCATE (region, SkyRegion *, NREGIONS);
    506     }     
    507   }
    508   *Nchildren = Nregion;
    509   return (region);
    510 }
    511 
    512 /* region is pointer to entry in db */
    513 SkyRegion *SkyExtend (SkyRegion *db, SkyRegion *region) {
    514 
    515   fprintf (stderr, "not implemented\n");
    516 
    517 }
    518 
    519 /* region is pointer to entry in db */
    520 SkyRegion *SkyContract (SkyRegion *db, SkyRegion *region) {
    521 
    522   fprintf (stderr, "not implemented\n");
    523 
    524 }
    525 
    526 SkyRegion *SkyFindGCircle (SkyRegion *db, SkyCoord c1, SkyCoord c2) {
    527 
    528   fprintf (stderr, "not implemented\n");
    529 
    530 }
    531 # endif
Note: See TracChangeset for help on using the changeset viewer.