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.<div>

<br><br><div class="gmail_quote">On Sun, Feb 14, 2010 at 8:19 AM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><div>On Sun, Feb 14, 2010 at 7:18 AM, Will Schroeder <span dir="ltr"><<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>></span> wrote:</div><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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.<div>




</div></blockquote></div><br></div><div>Here is the type of check I was thinking of:</div><div><br></div><div><div>  for(vtkIdType cellId = 0; cellId < numCells; cellId++)</div><div>    {</div><div>    vtkSmartPointer<vtkIdList> pointList =</div>


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


<div>      vtkIdType id = pointList->GetId(p);</div><div>      if(id < 0 || id >= numPoints)</div><div>        {</div><div>        cout << "The data contains a cell which is defined on invalid geometry!" << endl;</div>


<div>        cout << "In particular, cell " << cellId << " tries to reference point " << id << </div><div>            ", but there are only " << numPoints << " points." << endl;</div>


<div>        return EXIT_FAILURE;</div><div>        }</div><div>      }</div><div>    }</div><div><br></div><div>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?</div>


<div><br></div><div>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.</div>


<div><br></div><div>I think the user should do:</div><div><br></div><div>reader->SetValidityCheck(true);</div><div><br></div><div>then in vtkXMLReader::RequestData have:</div><div><br></div><div>if(this->ValidityCheck)</div>


<div>  {</div><div>   ... the function I pasted above ... </div><div>  }</div><div><br></div><div>Of course, we could make that function into a class so that it could be reused elsewhere besides the vtkXMLReader (probably a good idea).</div>


<div><br></div>Thanks,<br><br>David<br></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><br><br clear="all"><br>-- <br>William J. Schroeder, PhD<br>Kitware, Inc.<br>28 Corporate Drive<br>Clifton Park, NY 12065<br><a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a><br>

<a href="http://www.kitware.com">http://www.kitware.com</a><br>(518) 881-4902<br>
</div>