读入Dicom 数据,然后将Dicom体素网格化,生成体素网格模型,一个体素就是一个立方体。
public vtkPolyData GenrateImageGridModel(vtkImageData imageData)
{
int[] extent = imageData.GetExtent();
vtkImageWrapPad pad = new vtkImageWrapPad();
pad.SetInputData(imageData);
pad.SetOutputWholeExtent(extent[0], extent[1] + 1, extent[2], extent[3] + 1, extent[4], extent[5] + 1);
pad.Update();
pad.GetOutput().GetCellData().SetScalars(imageData.GetPointData().GetScalars());
vtkThreshold threshold = new vtkThreshold();
threshold.SetInputArrayToProcess(0, 0, 0, (int)vtkDataObject.FieldAssociations.FIELD_ASSOCIATION_CELLS, (int)vtkDataSetAttributes.AttributeTypes.SCALARS);
threshold.SetInputConnection(pad.GetOutputPort());
threshold.SetLowerThreshold(0);
threshold.SetUpperThreshold(255);
threshold.Update();
vtkGeometryFilter geometryFilter = new vtkGeometryFilter();
geometryFilter.SetInputData(threshold.GetOutput());
geometryFilter.Update();
vtkPolyData polydata = new vtkPolyData();
polydata.DeepCopy(geometryFilter.GetOutput());
return polydata;
}