[vtkusers] How to use "IsTypeOf "?

B.su supersub at ccea.zju.edu.cn
Sun Oct 26 09:48:32 EST 2003


^_^

But i  want to know the type of object that m_Picker have picked .
As we can see, m_Picker->GetClassName() return vtkCellPicker.  It isn't what i want to get.
Since my scene is consisted of lines and triangles, I need a function which will return vtkTriangle or vtkLine, then I can judge which type I have picked.  
Can I do it ?

thanks a lot.


----------------------------
    b.su

----- Original Message ----- 
From: "N Smethurst" <nick.smethurst at free.fr>
To: "B.su" <supersub at ccea.zju.edu.cn>; <vtkusers at vtk.org>
Sent: Sunday, October 26, 2003 10:57 PM
Subject: Re: [vtkusers] How to use "IsTypeOf "?


> If you think you should have a specific type of object but your code isn't 
> doing what you think it should, you could sprinkle code like
> 
> std::cout << "Class name = " << m_Picker->GetClassName() << std::endl;
> 
> whereever it would be useful to see if your object is what you think it is.  
> Try something like
> 
> if (m_Picker->GetCellId()>=0)
>      {
>           std::cout << "Class name = " << m_Picker->GetClassName() 
>                     << std::endl;
> 
>           if (m_Picker->IsTypeOf("vtkTriangle")==1)
>                str.Format(_T("Triangle ID = %d"),m_Picker->GetCellId());
>           if (m_Picker->IsTypeOf("vtkLine")==1) 
>                str.Format(_T("Line ID = %d"),m_Picker->GetCellId());
>           AfxMessageBox(str);
>      }
> 
> then you can easily debug your code.
> 
> Are you sure you want to inherit from vtkInteractorStyleUser? I was under the 
> impression that this class was specifically designed for passing it function 
> pointers instead of needing to subclass.
> 
> For sending messages around, maybe you could create a class derived from 
> vtkCommand?
> 
> Nic
> 


More information about the vtkusers mailing list