[vtk-developers] Handling invalid vtp files

pat marion pat.marion at kitware.com
Sat Feb 13 18:42:49 EST 2010


Methods like GetTuple should be fast, and therefore not perform bounds
checking for each call.  For methods requiring speed, usually it's the
caller's responsibility to do the bounds checking.  Maybe the proper fix
would be somewhere higher in the stack like
vtkPolygon::ComputeNormal or PVGeometryFilter::ExecuteCellNormals?

Pat

On Sat, Feb 13, 2010 at 6:18 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> I noticed this problem a while back:
> http://public.kitware.com/Bug/view.php?id=9814
>
> The demo file I added to the bug contains a triangle cell but 0 points.
> Clearly this is a bad situation. It doesn't crash the XMLPolyDataReader, but
> if you load the file in Paraview, the call stack shows:
>
> vtkDataArrayTemplate<float>::GetTuple (line 613)
> vtkPoints::GetPoint
> vtkPolygon::ComputeNormal
> PVGeometryFilter::ExecuteCellNormals
>
> The problem occurs on line 610 of vtkDataArrayTemplate.txx - 't' is NULL,
> so then on line 613 it segfaults.
>
> Is this type of thing where we would want to allow a crash (the assumption
> being that only good data files are loaded)? Or could we change:
>
> template <class T>
> void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
> {
>   T* t = this->Array + this->NumberOfComponents*i;
>   for(int j=0; j < this->NumberOfComponents; ++j)
>     {
>     tuple[j] = static_cast<double>(t[j]);
>     }
> }
>
> to something like:
>
> template <class T>
> void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
> {
>   T* t = this->Array + this->NumberOfComponents*i;
>
>   if(!t)
>     {
>     return;
>     }
>
>   for(int j=0; j < this->NumberOfComponents; ++j)
>     {
>     tuple[j] = static_cast<double>(t[j]);
>     }
> }
>
> Thanks,
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100213/8d94a59f/attachment.html>


More information about the vtk-developers mailing list