Changeset 14401 for trunk/Ohana/src/libdvo
- Timestamp:
- Aug 4, 2007, 10:15:51 AM (19 years ago)
- Location:
- trunk/Ohana/src/libdvo
- Files:
-
- 2 edited
-
include/dvo.h (modified) (2 diffs)
-
src/skyregion_ops.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libdvo/include/dvo.h
r14263 r14401 153 153 typedef struct { 154 154 int Nregions; 155 int ownElements; /* does this list own filename, regions? */ 155 156 char **filename; 156 157 SkyRegion **regions; … … 428 429 SkyList *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 429 430 int SkyListMerge PROTO((SkyList **outlist, SkyList *newlist)); 430 int SkyListFree PROTO((SkyList *list , int ELEMENTS));431 int SkyListFree PROTO((SkyList *list)); 431 432 int SkyTableFree PROTO((SkyTable *table)); 432 433 int SkyListSetFilenames PROTO((SkyList *list, char *path, char *ext)); -
trunk/Ohana/src/libdvo/src/skyregion_ops.c
r14289 r14401 19 19 ALLOCATE (list[0].filename, char *, 1); 20 20 list[0].Nregions = 0; 21 list[0].ownElements = FALSE; // this list is only holding a view to the elements 21 22 22 23 region = table[0].regions; … … 65 66 ALLOCATE (list[0].filename, char *, NREGIONS); 66 67 list[0].Nregions = N; 68 list[0].ownElements = FALSE; // this list is only holding a view to the elements 67 69 68 70 region = table[0].regions; … … 99 101 ALLOCATE (list[0].filename, char *, NREGIONS); 100 102 list[0].Nregions = N; 103 list[0].ownElements = FALSE; // this list is only holding a view to the elements 101 104 102 105 region = table[0].regions; … … 232 235 } 233 236 list[0].Nregions = Ns; 234 SkyListFree (extra , FALSE);237 SkyListFree (extra); 235 238 } else { 236 239 list = SkyListChildrenByBounds (table, -1, depth, Rmin, Rmax, Dmin, Dmax); … … 253 256 ALLOCATE (list[0].regions, SkyRegion *, NNEW); 254 257 ALLOCATE (list[0].filename, char *, NNEW); 258 list[0].ownElements = FALSE; // this list is only holding a view to the elements 255 259 256 260 region = table[0].regions; … … 289 293 } 290 294 Nnew += children[0].Nregions; 291 SkyListFree (children , FALSE);295 SkyListFree (children); 292 296 } else { 293 297 list[0].regions[Nnew] = ®ion[i]; … … 332 336 } 333 337 334 int SkyListFree (SkyList *list , int ELEMENTS) {338 int SkyListFree (SkyList *list) { 335 339 336 340 int i; … … 339 343 if (list == NULL) return (TRUE); 340 344 if (list[0].regions != NULL) { 341 if ( ELEMENTS) {345 if (list[0].ownElements) { 342 346 for (i = 0; i < list[0].Nregions; i++) { 343 347 if (list[0].filename[i] != NULL) { … … 384 388 ALLOCATE (list[0].regions, SkyRegion *, 1); 385 389 ALLOCATE (list[0].filename, char *, 1); 390 list[0].ownElements = FALSE; // this list is only holding a view to the elements 386 391 list[0].Nregions = 0; 387 392 *outlist = list; … … 412 417 return (TRUE); 413 418 } 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] = ®ion[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] = ®ion[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.
