Changeset 5448 for trunk/Ohana/src/opihi/dvo/region_list.c
- Timestamp:
- Oct 27, 2005, 10:38:30 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/region_list.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/region_list.c
r4689 r5448 1 1 # include "dvo1.h" 2 3 /* XXX note : for RegionName or RegionList, we need to free the skylist 4 elements, but not in the case of radius selection - this implies 5 information carried back up */ 2 6 3 7 static int RegionSelect; … … 42 46 } 43 47 44 RegionFile *SelectRegions (char *RegionName, char *RegionList, int *nregions) {48 SkyList *SelectRegions (char *RegionName, char *RegionList) { 45 49 46 50 double Radius; 47 51 int Ngraph; 48 52 Graphdata graphsky; 49 RegionFile *regions; 53 SkyTable *sky; 54 SkyList *skylist; 50 55 51 56 /* determine region-file names */ 52 57 if (RegionName != NULL) { 53 *nregions = 1; 54 ALLOCATE (regions, RegionFile, 1); 55 strcpy (regions[0].name, RegionName); 58 ALLOCATE (skylist, SkyList, 1); 59 ALLOCATE (skylist[0].regions[0], SkyRegion *, 1); 60 ALLOCATE (skylist[0].regions[0][0], SkyRegion, 1); 61 strcpy (skylist[0].regions[0][0].name, RegionName); 62 sprintf (filename, "%s/%s.cpt", CATDIR, RegionName); 63 skylist[0].regions[0][0].filename = strcreate (filename); 56 64 free (RegionName); 57 65 RegionName = NULL; 58 return ( regions);66 return (skylist); 59 67 } 60 68 if (RegionList != NULL) { 61 regions = region_list (RegionList, nregions);69 skylist = SkyListLoadFile (RegionList); 62 70 free (RegionList); 63 71 RegionList = NULL; 64 return ( regions);72 return (skylist); 65 73 } 66 74 … … 72 80 73 81 Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax)); 74 regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, nregions); 75 return (regions); 82 83 /* load sky from correct table */ 84 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE); 85 SkyTableSetFilenames (sky, CATDIR, "cpt"); 86 skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius); 87 88 return (skylist); 76 89 } 77 90 91 /* XXX EAM this should perhaps return a skytable? */ 78 92 /* returns a list of region files names from file */ 79 RegionFile *region_list (char *filename, int *Nregions) {93 SkyList *SkyListFromFile (char *filename) { 80 94 95 FILE *f; 81 96 int NREGIONS, nregion; 82 RegionFile *regions; 83 FILE *f; 97 SkyList *skylist; 98 99 ALLOCATE (skylist, SkyList, 1); 84 100 85 101 f = fopen (filename, "r"); 86 102 if (f == NULL) { 87 103 fprintf (stderr, "ERROR: can't find region list file %s\n", filename); 88 *Nregions = 0; 89 return (NULL); 104 skylist[0].Nregions = 0; 105 skylist[0].regions = NULL; 106 return (skylist); 90 107 } 91 108 109 Nregions = 0; 92 110 NREGIONS = 50; 93 ALLOCATE (regions, RegionFile, NREGIONS); 94 nregion = 0; 111 ALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS); 95 112 96 while (fscanf (f, "%s", regions[nregion].name) != EOF) { 97 nregion ++; 98 if (nregion == NREGIONS) { 99 NREGIONS += 50; 100 REALLOCATE (regions, RegionFile, NREGIONS); 113 while (fscanf (f, "%s", filename) != EOF) { 114 ALLOCATE (skylist[0].regions[Nregions], SkyRegion, 1); 115 strcpy (skylist[0].regions[Nregions][0].name, filename); 116 sprintf (filename, "%s/%s.cpt", CATDIR, skylist[0].regions[Nregions][0].name); 117 skylist[0].regions[Nregions][0].filename = strcreate (filename); 118 Nregions ++; 119 CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 50); 101 120 } 102 121 }
Note:
See TracChangeset
for help on using the changeset viewer.
