[vtkusers] Correct way to save the output of vtkProbeFilter
Sujin Philip
sujin.philip at kitware.com
Thu Sep 28 16:33:44 EDT 2017
Hi Siming,
Without looking at the full code it is difficult to say if you are creating
the structured grid correctly. Why don't you directly write the output of
the probe filter. Something like this:
vtkSmartPointer<vtkXMLDataSetWriter> sWriter = vtkSmartPointer<
vtkXMLDataSetWriter>::New();
sWriter->SetFileName("test.vts");
sWriter->SetInputData(probe->GetOutput());
sWriter->Write();
Thanks
Sujin
On Wed, Sep 27, 2017 at 12:36 PM, Siming Bayer <siming.bayer at gmail.com>
wrote:
> Dear all,
>
> Could somebody please provide a correct way to save the output of
> vtkProbeFilter?
>
> I used the following code to save it as vtkStructuredGrid (probe ist a
> vtkProbeFilter)
> vtkSmartPointer<vtkProbeFilter> probe = vtkSmartPointer<vtkProbeFilter
> >::New();
> …...
>
> //save the output of probefileter as .vtu file
>
> vtkSmartPointer<vtkStructuredGrid> sgrid = vtkSmartPointer<vtkStructure
> dGrid>::New();
>
> sgrid->SetDimensions(256, 256, 256);
>
> sgrid->SetPoints(probePoints);
>
> unsigned int numberOfArrays = probe->GetOutput()->GetPointData()->
> GetNumberOfArrays();
>
> std::cout << "Copying arrays:" << std::endl;
>
> for (unsigned int i = 0; i < numberOfArrays; i++)
>
> {
>
> std::cout << "\t" << probe->GetOutput()->GetPointData()->
> GetArray(i)->GetName() << std::endl;
>
> sgrid->GetPointData()->AddArray(probe->GetOutput()->
> GetPointData()->GetArray(i));
>
> }
>
> std::cout << "Writing .vts output" << std::endl;
>
> vtkSmartPointer<vtkXMLStructuredGridWriter> sWriter = vtkSmartPointer<
> vtkXMLStructuredGridWriter>::New();
>
> sWriter->SetFileName("test.vts");
>
> sWriter->SetInputData(sgrid);
>
> sWriter->Write();
>
> But I got errors when I try to load the .vts file in paraview:
>
> ERROR: In C:\bbd\7cc78367\build\superbuild\paraview\src\VTK\IO\XML\
> vtkXMLStructuredDataReader.cxx, line 360
> vtkXMLStructuredGridReader (000000000BA5C060): Error reading extent 0 255
> 0 255 0 255 from piece 0
>
> ERROR: In C:\bbd\7cc78367\build\superbuild\paraview\src\VTK\IO\XML\vtkXMLDataReader.cxx,
> line 443
> vtkXMLStructuredGridReader (000000000BA5C060): Cannot read point data
> array "position" from PointData in piece 0. The data array in the element
> may be too short.
>
>
> What do I do wrong?
>
> Thanks!
>
> best,
> Siming
>
>
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170928/1dd3bcda/attachment.html>
More information about the vtkusers
mailing list