[vtkusers] vtkImagePlaneWidget Oblique Reslice Bug!?

Istvan Matis i_matis at yahoo.de
Mon Sep 6 14:57:18 EDT 2004


Hello!

When rotating a vtkImagePlaneWidget plane around 2 axes (not just one, but ex: X & Y), the image on the plane is getting distorted, translated to the left or to the right, not being in concordance with the content of the volume (or with an orthogonal IPW reslice for example).
Furthermore, after rotating to more then 60-70 degrees on both of the two axes (when the image is very distorted) I am receiving "Undhandled Exception"s in vtkImagePlaneWidget.cxx line 1465.

I am using the IPW->SetPoint1(), SetPoint2(), and SetOrigin() methods, after computing the 3 new points, after the rotation.

How can I solve this? Is this a bug in vtk or is there something that I'm doing wrong?
See my code below:

Thanks,
Istvan


void CVtkView::UpdateAngles(float A1, float A2)
{
 float o[3]; vImagePlaneWidget[i4]->GetOrigin(o);
 float p1[3]; vImagePlaneWidget[i4]->GetPoint1(p1);
 float p2[3]; vImagePlaneWidget[i4]->GetPoint2(p2);

...

 float o_[3], p1_[3], p2_[3];    //coordinates after 1st rotation
 float o__[3], p1__[3], p2__[3];    //coordinates after 2nd rotation

...

 float *RP=m_vRefPointPos;    //The point which defines the 2 axes, around which I will rotate the IPW
 float R1[3];
 R1[i1]=p1[i1];
 R1[i2]=RP[i2];
 R1[i3]=RP[i3]; //z
 float R2[3];
 R2[i1]=p2[i1];
 R2[i2]=RP[i2];
 R2[i3]=RP[i3]; //z

 //First rotate around i1 (say x: => y=Ry 
 o_[i1]=o[i1]; 
 o_[i2]=(o[i2]-R1[i2])*cos(A1)-(o[i3]-R1[i3])*sin(A1)+R1[i2];
 o_[i3]=(o[i2]-R1[i2])*sin(A1)+(o[i3]-R1[i3])*cos(A1)+R1[i3];

 p1_[i1]=p1[i1]; 
 p1_[i2]=(p1[i2]-R1[i2])*cos(A1)-(p1[i3]-R1[i3])*sin(A1)+R1[i2];
 p1_[i3]=(p1[i2]-R1[i2])*sin(A1)+(p1[i3]-R1[i3])*cos(A1)+R1[i3];

 p2_[i1]=p2[i1]; 
 p2_[i2]=(p2[i2]-R2[i2])*cos(A1)-(p2[i3]-R2[i3])*sin(A1)+R2[i2];
 p2_[i3]=(p2[i2]-R2[i2])*sin(A1)+(p2[i3]-R2[i3])*cos(A1)+R2[i3];

 //Second rotate around i2 (y) => x=Rx

 float R1_[3];
 R1_[i1]=RP[i1];
 R1_[i2]=p1_[i2];
 R1_[i3]=p1_[i3]; //z
 float R2_[3];
 R2_[i1]=RP[i1];
 R2_[i2]=p2_[i2]; //=o_[i2]
 R2_[i3]=p2_[i3]; //=o_[i3]

 o__[i1]=(o_[i1]-R2_[i1])*cos(A2)-(o_[i3]-R2_[i3])*sin(A2)+R2_[i1];
 o__[i2]=o_[i2];
 o__[i3]=(o_[i1]-R2_[i1])*sin(A2)+(o_[i3]-R2_[i3])*cos(A2)+R2_[i3];

 p1__[i1]=(p1_[i1]-R1_[i1])*cos(A2)-(p1_[i3]-R1_[i3])*sin(A2)+R1_[i1];
 p1__[i2]=p1_[i2];
 p1__[i3]=(p1_[i1]-R1_[i1])*sin(A2)+(p1_[i3]-R1_[i3])*cos(A2)+R1_[i3];

 p2__[i1]=(p2_[i1]-R2_[i1])*cos(A2)+(p2_[i3]-R2_[i3])*sin(A2)+R2_[i1];
 p2__[i2]=p2_[i2];
 p2__[i3]=(p2_[i1]-R2_[i1])*sin(A2)+(p2_[i3]-R2_[i3])*cos(A2)+R2_[i3];


 vImagePlaneWidget[3]->SetOrigin(o__);
 vImagePlaneWidget[3]->SetPoint1(p1__);
 vImagePlaneWidget[3]->SetPoint2(p2__);
 vImagePlaneWidget[3]->RestrictPlaneToVolumeOff();     //I thought this would solve the problem, but did not ....
 vImagePlaneWidget[3]->UpdatePlacement();

...
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040906/7db6918e/attachment.htm>


More information about the vtkusers mailing list