vector<Chunk> chunk_file(const char *path)
{
    FILE* is = fopen(path, "r");
    DataSource* ds= new RawFileDataSource(is);
    vector<Chunk> chunk= processChunks(ds,path);
    fclose(is);
    return chunk;
}
void Coeff3DTriLin4x4 ( int *theDim, /* dimensions of this buffer */
                        float* resBuf, /* result buffer */
                        int *resDim,  /* dimensions of this buffer */
                        double* mat,   /* transformation matrix */
                        int index
                        )
{
  char *proc = "Coeff3DTriLin4x4";
  size_t first = 0;
  size_t last;
  int i;
  typeChunks chunks;
  _LinearCoefficientParam p;
  
  /* preparing parallelism
   */
  first = 0;
  last = (size_t)resDim[2] * (size_t)resDim[1] * (size_t)resDim[0] - 1;
  initChunks( &chunks );
  if ( buildChunks( &chunks, first, last, proc ) != 1 ) {
    if ( _verbose_ )
      fprintf( stderr, "%s: unable to compute chunks\n", proc );
    return;
  }
  
  p.theDim = theDim;
  p.resBuf = resBuf;
  p.resDim = resDim;
  p.mat = mat;
  p.index = index;
  if ( index < 0 ) index = 0;
  if ( index > 7 ) index = 7;

  
  for ( i=0; i<chunks.n_allocated_chunks; i++ ) 
    chunks.data[i].parameters = (void*)(&p);
  
  /* processing
   */
  if ( processChunks( &_Coeff3DTriLin4x4, &chunks, proc ) != 1 ) {
    if ( _verbose_ )
      fprintf( stderr, "%s: unable to resample image\n", proc );
    freeChunks( &chunks );
    return;
  }
  
  freeChunks( &chunks );
}