<div class="gmail_quote">On Sat, Feb 13, 2010 at 7:10 PM, Berk Geveci <span dir="ltr"><<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>
<font color="#888888">
<br>-berk<br><br></font></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">Is vtkXMLReader::RequestData the right place in the pipeline to do this kind of check?</div><div class="gmail_quote"><br></div>
<div class="gmail_quote">A simple thing could be to add something like:</div><div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">if(this->CurrentOutput->GetNumberOfElements(vtkDataObject::POINT) == 0)</div>
<div class="gmail_quote"> {</div><div class="gmail_quote"> return 0;</div><div class="gmail_quote"> }</div><div class="gmail_quote"><br></div><div class="gmail_quote">(Is there ever a time where there could be 0 points but still some reasonable data set?)</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">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?</div><div class="gmail_quote">
<br></div><div class="gmail_quote">reader->SetValidityCheck(true);</div><div class="gmail_quote"><br></div><div class="gmail_quote">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.</div>
</div><div class="gmail_quote"><br></div>Thoughts?</div><div class="gmail_quote"><br clear="all">Thanks,<br><br><div>David</div></div>