[vtk-developers] Handling invalid vtp files

David Doria daviddoria+vtk at gmail.com
Sat Feb 13 20:57:24 EST 2010


On Sat, Feb 13, 2010 at 7:10 PM, Berk Geveci <berk.geveci at kitware.com>wrote:

> I think the best approach is to perform more error checking in the reader.
> If you catch an invalid file while it is being loaded, it is easier to
> report what the problem is to the user. If you catch it later in the
> pipeline, it is much harder to do anything about it. For example, the fix
> that David suggested, is going to cause GetTuple() to keep values from a
> previous call (or worse junk from uninitialized memory) UNLESS the developer
> wipes the contents of tuple between every call.  This is much harder to
> debug than a simple error at read time or even the current behavior of
> crashing. Of course, you could add a return value or exception but it is
> still not much help to the end user.
>
> -berk
>
>
Is vtkXMLReader::RequestData the right place in the pipeline to do this kind
of check?

A simple thing could be to add something like:

if(this->CurrentOutput->GetNumberOfElements(vtkDataObject::POINT) == 0)
  {
  return 0;
  }

(Is there ever a time where there could be 0 points but still some
reasonable data set?)

An extensive check would be to go through all the cells and make sure the
points that they reference actually exist. Maybe this could be a flag?

reader->SetValidityCheck(true);

The above would make the reader traverse the cells checking that they are
defined on valid geometry. If speed is a priority (for large data sets),
this option could be turned off.

Thoughts?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100213/dfb85626/attachment.html>


More information about the vtk-developers mailing list