[vtkusers] vtkProbeFilter not probing volume
Seth Gilchrist
seth at mech.ubc.ca
Thu May 23 15:08:28 EDT 2013
Hello all,
I'm having a problem with the vtkProbeFilter. I have a vtkUnstructuredGrid
volume with one data field called MinPStrain and I am trying to probe it
with a vtkPolyData surface. The output indicates that the two interact in
only a very small portion of the surface, when in reality they almost
completely overlap.
There are some screen shots at:
https://plus.google.com/photos/101839812291734892344/albums/5881253191058882961?authkey=CIOdsYjQi8zKjQE
On the left is the surface and volume in their actual positions. On the
right is the output of the probe, translated so that it can be viewed.
Most recently I have tried using the vtkAppendFilter to convert the
vtkPolyData to a vtkUnstructuredGrid, but to no avail. The latest code is:
#include <vtkUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkPolyData.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkProbeFilter.h>
#include <vtkSmartPointer.h>
#include <vtkAppendFilter.h>
#include <vtkPointData.h>
int main(int argc, char **argv)
{
// Read the volume
vtkSmartPointer<vtkUnstructuredGridReader> volumeReader =
vtkSmartPointer<vtkUnstructuredGridReader>::New();
volumeReader->SetFileName("/home/seth/Desktop/volume.vtk");
volumeReader->Update();
// Read the surface
vtkSmartPointer<vtkXMLPolyDataReader> polyReader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
polyReader->SetFileName("/home/seth/Desktop/aligned.vtp");
polyReader->Update();
// remove pre-existing array data
vtkSmartPointer<vtkPolyData> inputSurface = polyReader->GetOutput();
unsigned int numberOfArrays =
inputSurface->GetPointData()->GetNumberOfArrays();
for (unsigned int i = 0; i < numberOfArrays; ++i)
{
inputSurface->GetPointData()->RemoveArray(i);
}
std::cout<<"Images Read"<<std::endl;
// convert the surface from vtkPolyData to vtkUnstructuredGrid
vtkSmartPointer<vtkAppendFilter> appender =
vtkSmartPointer<vtkAppendFilter>::New();
appender->SetInput(inputSurface);
appender->Update();
// probe the volume with the surface
vtkSmartPointer<vtkProbeFilter> probe =
vtkSmartPointer<vtkProbeFilter>::New();
probe->SetInput(appender->GetOutput());
probe->SetSource(volumeReader->GetOutput());
// write the probed surface out
vtkSmartPointer<vtkXMLUnstructuredGridWriter> polyWirter =
vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
polyWirter->SetInputConnection(probe->GetOutputPort());
polyWirter->SetFileName("/home/seth/Desktop/testProbe.vtu");
polyWirter->Write();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130523/a4ba99f5/attachment.htm>
More information about the vtkusers
mailing list