[vtkusers] convert polydata to volume

Karl bulkmailaddress at gmail.com
Sat Dec 19 02:18:13 EST 2009


Hi,
I am attempting to use vtkProbeFilter convert a polydata into a volume data
set that will have colored lines corresponding to the contours of the
polydata.  So far the produced image is always empty.  Can anyone see
anything wrong with the following code?  Any help would be appreciated?

// polydata to be converted
vtkPolyData* polyData = ...
double bounds[6];
polyData->GetBounds(bounds);

// identify sampling locations
int samples = 30;
vtkImageData* samplingArray = vtkImageData::New();
samplingArray->SetNumberOfScalarComponents(3);
samplingArray->SetScalarTypeToUnsignedChar();
samplingArray->SetSpacing((bounds[1]-bounds[0])/samples,(bounds[3]-bounds[2]
)/samples,(bounds[5]-bounds[4])/samples);
samplingArray->SetDimensions(samples, samples, samples);
samplingArray->SetOrigin( bounds[0], bounds[2], bounds[3] );
samplingArray->Update();

// sample polydata
vtkProbeFilter *probe = vtkProbeFilter::New();
probe->SetInput(samplingArray);
probe->SetSource(poly);

// save results
vtkTIFFWriter* tiff = vtkTIFFWriter::New();
tiff->SetInputConnection(probe->GetOutputPort());
tiff->SetFilePrefix("sampled");
tiff->Write();


Thanks,
KB




More information about the vtkusers mailing list