<meta http-equiv="content-type" content="text/html; charset=utf-8"><div class="gmail_quote">On Thu, Oct 21, 2010 at 8:33 AM, Leonardo M. Ramé <span dir="ltr"><<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi, I would like to know how to check for class type in a subclassed<br>
vtkCommand, in the Execute method.<br>
<br>
The skeleton of the method is this:<br>
<br>
virtual void Execute(vtkObject *caller, unsigned long, void*)<br>
<br>
I would like to do something like this:<br>
<br>
if(caller is vtkSomeThing)<br>
{<br>
// do something<br>
}<br>
else<br>
{<br>
// do else.<br>
}<br>
<br>
I thought that the "is" operator will work, but it doesn't.<br>
<br>
How can I do that?<br><br></blockquote><div><br></div><div>Here is a quote from Pat Marion: </div><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; border-collapse: collapse; font-size: 10.4167px; "><span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 136); color: rgb(34, 34, 34); ">GetClassName</span> is great for debugging, but I wouldn't recommend it for comparisons. For example, instead of:<br>
<br> if (array-><span class="il" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 136); color: rgb(34, 34, 34); ">GetClassName</span>() == 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";</span></div><div class="gmail_quote"><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font><div>David </div></div>