예제 #1
0
void interp_edge(float val, Cell cell, int edge, Point point)
{
	EdgeInfo *ei = &edgeinfo[edge];
	
	switch(ei->dir) {
	case 0:
		interp_x(cell.id[0]+ei->di, cell.id[1]+ei->dj, cell.id[2]+ei->dk,
				 ei->d1, ei->d2, val, cell, point);
		break;
	case 1:
		interp_y(cell.id[0]+ei->di, cell.id[1]+ei->dj, cell.id[2]+ei->dk,
				 ei->d1, ei->d2, val, cell, point);
		break;
	case 2:
		interp_z(cell.id[0]+ei->di, cell.id[1]+ei->dj, cell.id[2]+ei->dk,
				 ei->d1, ei->d2, val, cell, point);
		break;
	}
}
예제 #2
0
파일: map.c 프로젝트: drafnel/Vis5d
int     bend_line_to_fit_surf (float *verts, int ncols, int nrows,
                               int grid_scheme,
                               float xmin, float ymin, float xmax, float ymax,
                               float zoff,
                               float *xyz_in, int n_in, float *xyz_out)
{

    int         i, nnew;
    float       xfac, yfac, xend, yend;
    FLOAT2      *xy, *xynew;



    if (verts   == NULL) return 0;
    if (ncols   <=    1) return 0;
    if (nrows   <=    1) return 0;
    if (xyz_in  == NULL) return 0;
    if (n_in    <=    1) return 0;
    if (xyz_out == NULL) return 0;


    xfac = ((float) (ncols - 1)) / (xmax - xmin);
    yfac = ((float) (nrows - 1)) / (ymax - ymin);



    xy = (FLOAT2 *) malloc (n_in * sizeof (FLOAT2));
    if (xy == NULL) return 0;

    for (i = 0; i < n_in; i++)
    {
        xy[i][0] = (xyz_in[(i*3)+0] - xmin)* xfac;
        xy[i][1] = (ymax - xyz_in[(i*3)+1]) * yfac;
    }

    i    = n_in - 1;
    xend = xyz_in[(i*3)+0];
    yend = xyz_in[(i*3)+1];

    line2d_regrid (xy, n_in, grid_scheme, &xynew, &nnew);



    i = 0;
    xyz_out[(i*3)+0] = xyz_in[(i*3)+0];
    xyz_out[(i*3)+1] = xyz_in[(i*3)+1];
    xyz_out[(i*3)+2] = interp_z (verts, ncols, nrows, grid_scheme,
                                 xy[0][0], xy[0][1]) + zoff;

    for (i = 1; i < nnew-1; i++)
    {
        xyz_out[(i*3)+0] = (xynew[i][0] / xfac) + xmin;
        xyz_out[(i*3)+1] = ymax - (xynew[i][1] / yfac);
        xyz_out[(i*3)+2] = interp_z (verts, ncols, nrows, grid_scheme,
                                     xynew[i][0], xynew[i][1]) + zoff;
    }

    xyz_out[(i*3)+0] = xend;
    xyz_out[(i*3)+1] = yend;
    xyz_out[(i*3)+2] = interp_z (verts, ncols, nrows, grid_scheme,
                                 xy[1][0], xy[1][1]) + zoff;


    if (xynew != NULL) free (xynew);
    free (xy);


    return nnew;
}