Hi,
I'm not personally familiar with the DICOM API, but this is roughly the way you'd set up the Field3D data structure:
int xDim = [dicom slice x resolution];
int yDim = [dicom slice y resolution];
int zDim = [number of dicom slices];
DenseField<float>::Ptr dense(new DenseField<float>);
DenseField<float> *rawPtr = dense.get();
dense->name = "dicom_data";
dense->attribute = "density";
dense->setSize(Imath::V3i(xDim, yDim, zDim));
Then, you would traverse each slice and copy each pixel value into a voxel:
for (int k = 0; k < zDim; ++k) {
for (int j = 0; j < yDim; ++j) {
for (int i = 0; i < xDim; ++i) {
rawPtr->fastValue(i, j, k) = dicomSlices[z].pixel(i, j);
}
}
}
Finally, to write the data to disk:
Field3DOutputFile out;
out.create("filename.f3d");
out.writeScalarLayer<float>(dense);
I hope that helps,
Magnus