[vtk-developers] How to detect a data read failure?

B.W.H. van Beest bwvb at xs4all.nl
Sun Jun 13 08:07:55 EDT 2010


Dear vtk-developers,

In getting myself aquainted with VTK, by displaying the contents of a
few sample vtk-files, I encountered
the problem that one of these sample vtk-files could not be read,
followed by a core dump.
Failure of data reading of course can always happen, so I need to have a
robust approach.
 
While VTK does print an error message, from a c++ coding point of view
this does not help much. 
What are the options to detect such a situation programmatically?

The following code snippet illustrates my problem:
================================================
       ...
    reader = vtkSmartPointer<vtkPolyDataReader>::New();
    reader->SetFileName(  "erroneousFile.vtk"  );
//  reader->Update();
    ...
    //  Add mapper, etc. and render the data
===============================================

When the file is being read, VTK detects an error and prints a message
to the screen. however,
With the  Update() vpmmand commented out, the
But I don't see any way how I could be aware -on the c++ level that this
error has occurred.

Browsing the web for an answer, I found  similar complaints like this ,
but not more recent than 2005!)
Is it really impossible to write an vtk-application that is robust for
errors that may occur on data import?

Regards,
Bertwim



More information about the vtk-developers mailing list