   // Compute the ID on depthmap values according to pixel position and dpeth map dimensions
   int depthMapId = computeVoxelID(pixel, 0);
   int gridId = computeVoxelID(voxelCoordinate, 1);
-  //gridId = (c_gridDims[0] - 1) * (c_gridDims[1] - 1) * (c_gridDims[2] - 1);
   double depth = depths[depthMapId];
   double currentScalarValue = output[gridId];
   double newValue = cumulFunction(realDepth - depth, currentScalarValue);

  // Update the value to the output
  output[gridId] = newValue;
}




// ----------------------------------------------------------------------------

  int dimX = c_gridDims.x - 1;
  int dimY = c_gridDims.y - 1;
  if (type == 0)
    {
    dimX = c_depthMapDims.x;
    dimY = c_depthMapDims.y;
    }
  int i = coordinates[0];
  int j = coordinates[1];
  int k = coordinates[2];
  return (k*dimY + j)*dimX + i;
}

__device__ void computeVoxelCenter(int voxelCoordinate[3], double output[3])
{
  output[0] = c_gridOrig.x + (voxelCoordinate[0] + 0.5) * c_gridSpacing.x;
  output[1] = c_gridOrig.y + (voxelCoordinate[1] + 0.5) * c_gridSpacing.y;
  output[2] = c_gridOrig.z + (voxelCoordinate[2] + 0.5) * c_gridSpacing.z;
}


// ----------------------------------------------------------------------------
