/* * create - creates a dimxdim image aligned to a BSIZE byte boundary */ static void create(int dim) { int i, j; /* Align the images to BSIZE byte boundaries */ orig = data; while ((unsigned long)orig % BSIZE) { orig = (pixel *)(((char *)orig)+1); } result = orig + dim*dim; copy_of_orig = result + dim*dim; for (i = 0; i < dim; i++) { for (j = 0; j < dim; j++) { /* Original image initialized to random colors */ orig[RIDX(i,j,dim)].red = random_in_interval(0, 65536); orig[RIDX(i,j,dim)].green = random_in_interval(0, 65536); orig[RIDX(i,j,dim)].blue = random_in_interval(0, 65536); /* Copy of original image for checking result */ copy_of_orig[RIDX(i,j,dim)].red = orig[RIDX(i,j,dim)].red; copy_of_orig[RIDX(i,j,dim)].green = orig[RIDX(i,j,dim)].green; copy_of_orig[RIDX(i,j,dim)].blue = orig[RIDX(i,j,dim)].blue; /* Result image initialized to all black */ result[RIDX(i,j,dim)].red = 0; result[RIDX(i,j,dim)].green = 0; result[RIDX(i,j,dim)].blue = 0; } } return; }
/* * create - creates a dimxdim image aligned to a BSIZE byte boundary */ static void create(int dim) { int i, j; /* Align the images to BSIZE byte boundaries */ orig = data; while ((unsigned long)orig % BSIZE) { /* +++++ egm 10/26/2005 * gcc 4.0.2 reports when buildling driver.o: * * error: invalid lvalue in increment * * on the below code: * * ((char *)orig)++; * * I rewrote it to move through a local variable. * ----- */ char *tmp = (char *) orig; tmp++; orig = (pixel *) tmp; } result = orig + dim*dim; copy_of_orig = result + dim*dim; for (i = 0; i < dim; i++) { for (j = 0; j < dim; j++) { /* Original image initialized to random colors */ orig[RIDX(i,j,dim)].red = random_in_interval(0, 65536); orig[RIDX(i,j,dim)].green = random_in_interval(0, 65536); orig[RIDX(i,j,dim)].blue = random_in_interval(0, 65536); /* Copy of original image for checking result */ copy_of_orig[RIDX(i,j,dim)].red = orig[RIDX(i,j,dim)].red; copy_of_orig[RIDX(i,j,dim)].green = orig[RIDX(i,j,dim)].green; copy_of_orig[RIDX(i,j,dim)].blue = orig[RIDX(i,j,dim)].blue; /* Result image initialized to all black */ result[RIDX(i,j,dim)].red = 0; result[RIDX(i,j,dim)].green = 0; result[RIDX(i,j,dim)].blue = 0; } } return; }
static OverlapInfo * overlap(double t, stateVector *st, BeamModeInfo *bmi, double look_angle, int zone, double clat, double clon, Poly *aoi) { Poly *viewable_region = get_viewable_region(st, bmi, look_angle, zone, clat, clon, NULL, NULL); if (!viewable_region) return NULL; // no overlap if (polygon_overlap(aoi, viewable_region)) { // need a good method to test for overlap amount! // for now we have this sort of kludgey method... which is // probably a bit slow: // generate 1000 points in the aoi -- pct is how many are also // in the viewable region srand(42); int i=0,pct=0,n=1000; double xmin, xmax, ymin, ymax; polygon_get_bbox(aoi, &xmin, &xmax, &ymin, &ymax); while (i<n) { double x = random_in_interval(xmin, xmax); double y = random_in_interval(ymin, ymax); if (point_in_polygon(aoi, x, y)) { ++i; if (point_in_polygon(viewable_region, x, y)) ++pct; } } return overlap_new(pct, n, viewable_region, zone, clat, clon, st, t); } else { // no overlap polygon_free(viewable_region); return NULL; } }