David,<br><br>Instead of saving a file and opening it in paraview, you could try:<br><br><span style="font-family: arial,sans-serif; font-size: 12.5px; border-collapse: collapse;"> filter->GetOutput()</span>->Print(cout);<br>
<br>This will display all the point & cell arrays on the output and their names and data types. Make sure you have updated the filter first. Also, if you notice that SafeDownCast has failed, you can do a debug print to get the correct class type:<br>
<br><span style="font-family: arial,sans-serif; font-size: 12.5px; border-collapse: collapse;"> cout << filter->GetOutput()->GetArray("RegionId")</span>->GetClassName() << endl;<br><br>
this would print: vtkIdTypeArray<br><br>GetClassName is great for debugging, but I wouldn't recommend it for comparisons. For example, instead of:<br><br> if (array->GetClassName() == std::string("vtkIdTypeArray")) cout << "It's an id type array";<br>
<br>it is preferable to use:<br><br> if (vtkIdTypeArray::SafeDownCast(array)) cout << "It's an id type array";<br><br>The compiler can error check a SafeDownCast statement, but can't catch a typo in a string comparison.<br>
<br>Pat<br><br><br><div class="gmail_quote">On Fri, Sep 17, 2010 at 4:03 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi David,<br>
<br>
I think you misunderstand what "SafeDownCast" does.<br>
After every SafeDownCast(), you must check the result<br>
to make sure that it isn't NULL. That is what dynamic<br>
casting is all about: it is an _attempt_ to do a cast when<br>
you aren't sure if the object is of the correct type.<br>
<br>
You can write code that is robust to a large number of<br>
array types by adding a "switch" statement. If you combine<br>
the switch with a templated function, then you will<br>
end up with the same mechanism that VTK's image filters<br>
use to deal with arrays of different types.<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5"><br>
<br>
On Fri, Sep 17, 2010 at 1:53 PM, David Doria <<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>> wrote:<br>
> On Fri, Sep 17, 2010 at 3:50 PM, David Cole <<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>> wrote:<br>
>><br>
>> That's not a C++ cast, that's a transformation operation....<br>
>> All the array classes are siblings of each other, aren't they?<br>
>><br>
><br>
> Maybe my terminology is off, but whatever it is called I feel that it should<br>
> work and it currently doesn't :)<br>
> Yes, they are all siblings. Are you recommending first SafeDownCasting to a<br>
> vtkDataArray, checking the type, and then performing the appropriate<br>
> SafeDownCast? That seems like a lot of trouble, no?<br>
> David<br>
</div></div><div><div></div><div class="h5">> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <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>
><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>
</div></div></blockquote></div><br>