[vtkusers] Check for class type
David Doria
daviddoria at gmail.com
Thu Oct 21 08:41:11 EDT 2010
On Thu, Oct 21, 2010 at 8:33 AM, Leonardo M. Ramé <l.rame at griensu.com>wrote:
> Hi, I would like to know how to check for class type in a subclassed
> vtkCommand, in the Execute method.
>
> The skeleton of the method is this:
>
> virtual void Execute(vtkObject *caller, unsigned long, void*)
>
> I would like to do something like this:
>
> if(caller is vtkSomeThing)
> {
> // do something
> }
> else
> {
> // do else.
> }
>
> I thought that the "is" operator will work, but it doesn't.
>
> How can I do that?
>
>
Here is a quote from Pat Marion:
GetClassName is great for debugging, but I wouldn't recommend it for
comparisons. For example, instead of:
if (array->GetClassName() == std::string("vtkIdTypeArray")) cout <<
"It's an id type array";
it is preferable to use:
if (vtkIdTypeArray::SafeDownCast(array)) cout << "It's an id type
array";
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101021/b41751b8/attachment.htm>
More information about the vtkusers
mailing list