Esempio n. 1
0
static int
Rast3d_tile2xdrTile(RASTER3D_Map * map, const void *tile, int rows, int cols,
		 int depths, int xRedundant, int yRedundant, int zRedundant,
		 int nofNum, int type)
{
    int y, z;

    if (!Rast3d_init_copy_to_xdr(map, type)) {
	Rast3d_error("Rast3d_tile2xdrTile: error in Rast3d_init_copy_to_xdr");
	return 0;
    }


    if (nofNum == map->tileSize) {
	if (!Rast3d_copy_to_xdr(tile, map->tileSize)) {
	    Rast3d_error("Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
	    return 0;
	}
	return 1;
    }

    if (xRedundant) {
	for (z = 0; z < depths; z++) {
	    for (y = 0; y < rows; y++) {
		if (!Rast3d_copy_to_xdr(tile, cols)) {
		    Rast3d_error("Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
		    return 0;
		}
		tile = G_incr_void_ptr(tile, map->tileX * Rast3d_length(type));
	    }
	    if (yRedundant)
		tile =
		    G_incr_void_ptr(tile,
				    map->tileX * yRedundant *
				    Rast3d_length(type));
	}
	return 1;
    }

    if (yRedundant) {
	for (z = 0; z < depths; z++) {
	    if (!Rast3d_copy_to_xdr(tile, map->tileX * rows)) {
		Rast3d_error("Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
		return 0;
	    }
	    tile = G_incr_void_ptr(tile, map->tileXY * Rast3d_length(type));
	}
	return 1;
    }

    if (!Rast3d_copy_to_xdr(tile, map->tileXY * depths)) {
	Rast3d_error("Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
	return 0;
    }
    return 1;
}
Esempio n. 2
0
int Rast3d_init_copy_from_xdr(RASTER3D_Map * map, int dType)
{
    xdrTmp = xdr;
    useXdr = map->useXdr;
    dstType = dType;

    if (useXdr == RASTER3D_USE_XDR) {
	if (!xdr_setpos(&(xdrDecodeStream), 0)) {
	    Rast3d_error("Rast3d_init_copy_from_xdr: positioning xdr failed");
	    return 0;
	}
	xdrs = &(xdrDecodeStream);
    }

    type = map->type;
    isFloat = (type == FCELL_TYPE);
    externLength = Rast3d_extern_length(type);
    eltLength = Rast3d_length(dstType);
    if (isFloat)
	xdrFun = xdr_float;
    else
	xdrFun = xdr_double;
    tmp = &tmpValue;

    return 1;
}
Esempio n. 3
0
void *Rast3d_alloc_tiles_type(RASTER3D_Map * map, int nofTiles, int type)
{
    void *tiles;

    tiles = Rast3d_malloc(map->tileSize * Rast3d_length(type) * nofTiles);
    if (tiles == NULL) {
	Rast3d_error("Rast3d_alloc_tiles_type: error in Rast3d_malloc");
	return NULL;
    }

    return tiles;
}
Esempio n. 4
0
void
Rast3d_copy_values(const void *src, int offsSrc, int typeSrc, void *dst,
                   int offsDst, int typeDst, int nElts)
{
    int eltLength;

    if ((typeSrc == FCELL_TYPE) && (typeDst == DCELL_TYPE)) {
        Rast3d_copy_float2Double(src, offsSrc, dst, offsDst, nElts);
        return;
    }

    if ((typeSrc == DCELL_TYPE) && (typeDst == FCELL_TYPE)) {
        Rast3d_copy_double2Float(src, offsSrc, dst, offsDst, nElts);
        return;
    }

    eltLength = Rast3d_length(typeSrc);

    src = G_incr_void_ptr(src, eltLength * offsSrc);
    dst = G_incr_void_ptr(dst, eltLength * offsDst);

    memcpy(dst, src, nElts * eltLength);
}