Changeset 10505
- Timestamp:
- Dec 6, 2006, 12:43:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/images.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/images.c
r7917 r10505 1 1 # include "dvoshell.h" 2 # define BETA 0.41421 2 3 3 4 int images (int argc, char **argv) { … … 5 6 int i, j, Nimage, status, InPic, leftside, *plist, TimeSelect, ByName; 6 7 time_t tzero, tend; 7 int N, NPTS, n, npts ;8 int N, NPTS, n, npts, Npts; 8 9 Vector Xvec, Yvec; 9 double r , d, x[4], y[4], Rmin, Rmax, Rmid, trange;10 double r[8], d[8], x[8], y[8], Rmin, Rmax, Rmid, trange, Radius; 10 11 Image *image; 11 12 Graphdata graphmode; … … 20 21 remove_argument (N, &argc, argv); 21 22 ByName = TRUE; 23 } 24 25 Radius = 45; 26 if ((N = get_argument (argc, argv, "-radius"))) { 27 remove_argument (N, &argc, argv); 28 Radius = atof (argv[N]); 29 remove_argument (N, &argc, argv); 22 30 } 23 31 … … 97 105 x[3] = 0; y[3] = image[i].NY; 98 106 } 99 status = FALSE; 100 107 108 Npts = 4; 109 status = TRUE; 101 110 leftside = FALSE; 102 111 for (j = 0; j < 4; j++) { 103 XY_to_RD (&r, &d, x[j], y[j], &image[i].coords); 104 while (r < Rmin) { r += 360.0; } 105 while (r > Rmax) { r -= 360.0; } 112 status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[i].coords); 113 if (!status) break; 114 while (r[j] < Rmin) { r[j] += 360.0; } 115 while (r[j] > Rmax) { r[j] -= 360.0; } 106 116 if (j == 0) { 107 leftside = (r < Rmid);117 leftside = (r[j] < Rmid); 108 118 } 109 119 if (j > 0) { 110 if ( leftside && (r > Rmid + 90)) { r -= 360.0; } 111 if (!leftside && (r < Rmid - 90)) { r += 360.0; } 112 } 113 status |= fRD_to_XY (&Xvec.elements[N+2*j], &Yvec.elements[N+2*j], r, d, &graphmode.coords); 120 if ( leftside && (r[j] > Rmid + 90)) { r[j] -= 360.0; } 121 if (!leftside && (r[j] < Rmid - 90)) { r[j] += 360.0; } 122 } 123 } 124 125 // extremely large-scale images with certain projections will have odd boundaries. 126 // eg, the ASCA images are essentially circles of radius ~60 degrees. plot these as 127 // octagons with some dummy size. 128 if (!status) { 129 int jp, xo, yo; 130 double rc, dc; 131 xo = 0.5*image[i].NX; 132 yo = 0.5*image[i].NY; 133 // is the image center on the screen? 134 status = XY_to_RD (&rc, &dc, 0.5*x[2], 0.5*y[2], &image[i].coords); 135 if (status && (image[i].NX * image[i].coords.cdelt2 > 90)) { 136 // draw an octagon with radius 45 degrees 137 double dX = Radius / image[i].coords.cdelt2; 138 x[0] = xo+dX; y[0] = yo+BETA*dX; 139 x[1] = xo+BETA*dX; y[1] = yo+dX; 140 x[2] = xo-BETA*dX; y[2] = yo+dX; 141 x[3] = xo-dX; y[3] = yo+BETA*dX; 142 x[4] = xo-dX; y[4] = yo-BETA*dX; 143 x[5] = xo-BETA*dX; y[5] = yo-dX; 144 x[6] = xo+BETA*dX; y[6] = yo-dX; 145 x[7] = xo+dX; y[7] = yo-BETA*dX; 146 Npts = 8; 147 j = 0; 148 for (jp = 0; jp < 8; jp++) { 149 status = XY_to_RD (&r[j], &d[j], x[jp], y[jp], &image[i].coords); 150 if (!status) continue; 151 while (r[j] < Rmin) { r[j] += 360.0; } 152 while (r[j] > Rmax) { r[j] -= 360.0; } 153 if (j == 0) { 154 leftside = (r[j] < Rmid); 155 } 156 if (j > 0) { 157 if ( leftside && (r[j] > Rmid + 90)) { r[j] -= 360.0; } 158 if (!leftside && (r[j] < Rmid - 90)) { r[j] += 360.0; } 159 } 160 j++; 161 } 162 Npts = j; 163 } else { 164 continue; 165 } 166 } 167 if (Npts == 0) continue; 168 169 // if any of the points is on the screen, plot the image 170 status = FALSE; 171 for (j = 0; j < Npts; j++) { 172 status |= fRD_to_XY (&Xvec.elements[N+2*j], &Yvec.elements[N+2*j], r[j], d[j], &graphmode.coords); 114 173 if (j > 0) { 115 174 Xvec.elements[N+2*j - 1] = Xvec.elements[N+2*j]; … … 117 176 } 118 177 } 119 Xvec.elements[N+ 7] = Xvec.elements[N];120 Yvec.elements[N+ 7] = Yvec.elements[N];178 Xvec.elements[N+2*Npts-1] = Xvec.elements[N]; 179 Yvec.elements[N+2*Npts-1] = Yvec.elements[N]; 121 180 InPic = FALSE; 122 for (j = 0; j < 8; j+=2) {181 for (j = 0; j < 2*Npts; j+=2) { 123 182 if ((Xvec.elements[N+j] >= graphmode.xmin) && 124 183 (Xvec.elements[N+j] <= graphmode.xmax) && … … 134 193 REALLOCATE (plist, int, npts); 135 194 } 136 N+= 8;137 if (N > NPTS - 1) { /* this is OK because NPTS is made always a multiple of 8*/138 NPTS += 200;195 N+=2*Npts; 196 if (N + 16 >= NPTS) { /* need to leave room for 8 point image */ 197 NPTS += 400; 139 198 REALLOCATE (Xvec.elements, float, NPTS); 140 199 REALLOCATE (Yvec.elements, float, NPTS); … … 143 202 } 144 203 145 gprint (GP_ERR, "plotting %d images\n", N/8);204 gprint (GP_ERR, "plotting %d images\n", n); 146 205 Xvec.Nelements = Xvec.Nelements = N; 147 206 if (N > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
