Exemple #1
0
void *Rast3d_get_tile_ptr(RASTER3D_Map * map, int tileIndex)
{
    void *ptr;

    if ((tileIndex >= map->nTiles) || (tileIndex < 0)) {
	Rast3d_error("Rast3d_get_tile_ptr: tileIndex out of range");
	return NULL;
    }

    if (map->useCache) {
	ptr = Rast3d_cache_elt_ptr(map->cache, tileIndex);
	if (ptr == NULL) {
	    Rast3d_error("Rast3d_get_tile_ptr: error in Rast3d_cache_elt_ptr");
	    return NULL;
	}
	return ptr;
    }

    if (map->currentIndex == tileIndex)
	return map->data;

    map->currentIndex = tileIndex;
    if (!Rast3d_read_tile(map, map->currentIndex, map->data, map->typeIntern)) {
	Rast3d_error("Rast3d_get_tile_ptr: error in Rast3d_read_tile");
	return NULL;
    }

    return map->data;
}
Exemple #2
0
static void cache_test_print(RASTER3D_cache * c)
{
    int i, al;
    int *a;

    al = c->autoLock;
    Rast3d_cache_autolock_off(c);

    printf("\n--------------------------------\n");
    for (i = 0; i < c->nofElts; i++) {
	printf("elt %d: ", i);
	if (IS_NOT_ACTIVE_ELT(i)) {
	    printf("na\n");
	    continue;
	}

	a = (int *)Rast3d_cache_elt_ptr(c, c->names[i]);
	/*Rast3d_cache_get_elt (c, c->names[i], a); */
	printf("name %d val %d %s\n", c->names[i], a[17],
	       (IS_LOCKED_ELT(i) ? "locked" :
		IS_UNLOCKED_ELT(i) ? "unlocked" : ""));
    }
    printf("\n--------------------------------\n");

    if (al)
	Rast3d_cache_autolock_on(c);
}
Exemple #3
0
int Rast3d_cache_load(RASTER3D_cache * c, int name)
{
    if (Rast3d_cache_elt_ptr(c, name) == NULL) {
	Rast3d_error("Rast3d_cache_load: error in Rast3d_cache_elt_ptr");
	return 0;
    }

    return 1;
}
Exemple #4
0
int Rast3d_cache_put_elt(RASTER3D_cache * c, int name, const void *src)
{
    void *elt;

    elt = Rast3d_cache_elt_ptr(c, name);
    if (elt == NULL) {
	Rast3d_error("Rast3d_cache_put_elt: error in Rast3d_cache_elt_ptr");
	return 0;
    }

    memcpy(elt, src, c->eltSize);

    return 1;
}
Exemple #5
0
int Rast3d_cache_get_elt(RASTER3D_cache * c, int name, void *dst)
{
    const void *elt;

    elt = Rast3d_cache_elt_ptr(c, name);
    if (elt == NULL) {
	Rast3d_error("Rast3d_cache_get_elt: error in Rast3d_cache_elt_ptr");
	return 0;
    }

    memcpy(dst, elt, c->eltSize);

    return 1;
}