[vtk-developers] Handling invalid vtp files

David Doria daviddoria+vtk at gmail.com
Sun Feb 14 08:19:29 EST 2010


On Sun, Feb 14, 2010 at 7:18 AM, Will Schroeder
<will.schroeder at kitware.com>wrote:

> Another option here is to create a filter (or family of filters) that can
> be inserted into the pipeline to check for validity (there could be
> different sorts of checks). The filter could be removed, or disabled with a
> flag, once the application is being tuned for performance and the data is
> known to be good. In my mind these validity checks are more like debugging
> tools and should be able to easily removed when debugging is complete.
>

Here is the type of check I was thinking of:

  for(vtkIdType cellId = 0; cellId < numCells; cellId++)
    {
    vtkSmartPointer<vtkIdList> pointList =
        vtkSmartPointer<vtkIdList>::New();
    data->GetCellPoints(cellId, pointList);

    for(vtkIdType p = 0; p < pointList->GetNumberOfIds(); p++)
      {
      vtkIdType id = pointList->GetId(p);
      if(id < 0 || id >= numPoints)
        {
        cout << "The data contains a cell which is defined on invalid
geometry!" << endl;
        cout << "In particular, cell " << cellId << " tries to reference
point " << id <<
            ", but there are only " << numPoints << " points." << endl;
        return EXIT_FAILURE;
        }
      }
    }

In vtkXMLReader::RequestData, we have a vtkDataObject, so I guess we would
just cast it to a vtkDataSet and if the cast passes then we could use the
above function?

Will - if we make it a separate class (something like vtkVerifyDataSet) then
when would it get called? Still from vtkXMLReader::RequestData? I still
think the flag is a good idea, but I don't think it makes sense for the user
to call it and then manually remove it because it needs to be between the
reader and the processing (normals, etc) that Paraview does to prevent
Paraview from segfaulting.

I think the user should do:

reader->SetValidityCheck(true);

then in vtkXMLReader::RequestData have:

if(this->ValidityCheck)
  {
   ... the function I pasted above ...
  }

Of course, we could make that function into a class so that it could be
reused elsewhere besides the vtkXMLReader (probably a good idea).

Thanks,

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


More information about the vtk-developers mailing list