[vtkusers] How to use "IsTypeOf "?

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


Question 1:

I want to judge the type of cell that I have pick in the window. 
The type is include triangle line. 

My program is as follows, vtkMyInteractorStyle is derived from vtkInteractorStyleUser.

class vtkMyView :public CView
{
    ...
     vtkMyInteractorStyle* m_vtkMyInteractorStyle;
    ...
}

void vtkMyInteractorStyle::OnRightButtonDown()
{
     int iPickDisplayX,iPickDisplayY;
     float aiPickPosition[3];

     this->GetLastPos(iPickDisplayX,iPickDisplayY);
     m_Picker->Pick(iPickDisplayX,iPickDisplayY,0,GetCurrentRenderer());
     m_Picker->GetPickPosition(aiPickPosition);
     CString str;
     if (m_Picker->GetCellId()>=0)
     {
          if (m_Picker->IsTypeOf("vtkTriangle")==1)                        < < < <return 0 ???why
               str.Format(_T("Triangle ID = %d"),m_Picker->GetCellId());
          if (m_Picker->IsTypeOf("vtkLine")==1)                            < < < <return 0 ???why
               str.Format(_T("Line ID = %d"),m_Picker->GetCellId());
          AfxMessageBox(str);
     }
     else
          AfxMessageBox("Nothing Selected !");
}

How to judge the cells type that I have picked , a triangle or a line ?  

Question 2:

    I want to  send the array aiPickPosition[3] to vtkMyView . How to do ?

    thanks.

----------------------------
      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 9:57 PM
Subject: Re: [vtkusers] How to use "IsTypeOf "?


It's just a way of checking the type of an object without using a dynamic 
cast.

if you did this:

int m = randomObject->IsTypeOf("vtkDataSet");

then m would be 1 if the random object is any kind of vtkDataSet, otherwise m 
would be 0.

Le Dimanche 26 Octobre 2003 12:57, B.su a écrit :
> Hi vtkusers:
>
>    In help documents ,it says :
>
>               int vtkCellPicker::IsTypeOf  (  const char *    type  ) 
> [static]
>
>  Return 1 if this class type is the same type of (or a subclass of) the
> named class. Returns 0 otherwise. This method works in combination with
> vtkTypeRevisionMacro found in vtkSetGet.h.
>
>    What is the meaning of "the named class" ? How to call this function?
>     Thanks a lot.
>
> ----------------------------
>       B.su



More information about the vtkusers mailing list