[vtk-developers] Handling invalid vtp files

Will Schroeder will.schroeder at kitware.com
Sun Feb 14 08:28:56 EST 2010


Okay David how ambitious do you want to get? This "validity" filters could
also have code to fix problems, maybe as simple as throwing out bad data. Or
simply count issues and provide a reporting mechanism, which the application
could respond to appropriately.


On Sun, Feb 14, 2010 at 8:19 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> 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
>
> _______________________________________________
> 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
>
>
>


-- 
William J. Schroeder, PhD
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
will.schroeder at kitware.com
http://www.kitware.com
(518) 881-4902
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100214/4cbd1686/attachment.html>


More information about the vtk-developers mailing list