The code below is copied from Voxeliens. It might not work as-is but should show you how to start.
Code:
//Based on code from Sproxel
bool loadCSV(const QString& filename, Thermite::Volume* volume, qint32 posX, qint32 posY, qint32 posZ)
{
PolyVox::SimpleVolume<PolyVox::Material16>* pPolyVoxVolume = volume->m_pPolyVoxVolume;
int fscanfStatus = 0;
FILE* fp = fopen(filename.toAscii().constData(), "rb");
if (!fp) return false;
// Read the dimensions
int sizeX = 0, sizeY = 0, sizeZ = 0;
fscanfStatus = fscanf(fp, "%d,%d,%d\n", &sizeX, &sizeY, &sizeZ);
// Read the data
QColor color;
for (int y = sizeY-1; y >= 0; y--)
{
for (int z = 0; z < sizeZ; z++)
{
for (int x = 0; x < sizeX; x++)
{
int ir, ig, ib, ia;
fscanfStatus = fscanf(fp, "#%02X%02X%02X%02X,", &ir, &ig, &ib, &ia);
/*float r = ir / (float)0xff;
float g = ig / (float)0xff;
float b = ib / (float)0xff;
float a = ia / (float)0xff;*/
QColor color(ir, ig, ib, ia);
if(ia > 0)
{
PolyVox::Material16 voxel;
voxel.setMaterial(QColorToMaterial(color));
int xToWrite = posX + x;
int yToWrite = posY + y;
int zToWrite = posZ + z;
if((xToWrite >= 0) && (xToWrite < pPolyVoxVolume->getWidth()) &&
(yToWrite >= 0) && (yToWrite < pPolyVoxVolume->getHeight()) &&
(zToWrite >= 0) && (zToWrite < pPolyVoxVolume->getDepth()))
{
pPolyVoxVolume->setVoxelAt(xToWrite, yToWrite, zToWrite, voxel);
}
}
if (x != sizeZ-1)
fscanfStatus = fscanf(fp, ",");
}
fscanfStatus = fscanf(fp, "\n");
}
fscanfStatus = fscanf(fp, "\n");
}
fclose(fp);
return true;
}