[vtkusers] convert polydata to volume

Bill Lorensen bill.lorensen at gmail.com
Sat Dec 19 10:41:23 EST 2009


Karl,

The ProbeFIlter takes each point in its input and samples the source
the point attributes by interpolating the point position in the
source.

It cannot convert a polydata into a volume.

Can you explain what your end goal is? What is the ultimate problem
you are trying to solve? What is contained in the polydata?

Bill

On Sat, Dec 19, 2009 at 2:18 AM, Karl <bulkmailaddress at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list