Ok, now the planeWidget is oriented as expected (turns out that the method GetResliceOutput() from vtkImagePlaneWidget wasn't giving me the correct ImageData information, but I sorted it out).<div><br></div><div>Now I'm using the transformation to update both the planeWidget and the vtkImageResliceViewer with the new orientation. However, when I try to update all four views only the pane containing the 3D volume is correctly updated, the other views remain the same (see code below).</div>
<div><br></div><div>How can I correctly update all four views? Is there something wrong during rendering? (the last block of code below).</div><div><br></div><div>Thanks,</div><div>Miguel</div><div><br></div><div><br></div>
<div>// Transform</div><div><div>vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();</div><div>transform->PreMultiply();</div><div>transform->Translate(wc[0],wc[1],wc[2]);</div>
<div>transform->RotateWXYZ(90,v2[0],v2[1],v2[2]);</div><div>transform->Translate(-wc[0],-wc[1],-wc[2]);</div></div><div><br></div><div><div>// Modify resliceImageViewer using transformation ("whichPlane": the plane I'm rotating; riw: the corresponding ResliceImageViewer)</div>
<div>double newpt[3];</div><div>vtkPlaneSource * ps = static_cast<vtkPlaneSource *> (this->riw[whichPlane]->GetResliceCursorWidget()-></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>GetResliceCursorRepresentation()->GetPlaneSource());</div>
<div>transform->TransformPoint(this->planeWidget[whichPlane]->GetPoint1(),newpt);</div><div>ps->SetPoint1(newpt);</div><div>transform->TransformPoint(this->planeWidget[whichPlane]->GetPoint2(),newpt);</div>
<div>ps->SetPoint2(newpt);</div><div>transform->TransformPoint(this->planeWidget[whichPlane]->GetOrigin(),newpt);</div><div>ps->SetOrigin(newpt);</div><div><br></div></div><div>// Update placement of all planeWidgets</div>
<div><div>for(int i = 0; i < 3; i++)</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPlaneSource * psw = static_cast< vtkPlaneSource * ></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>(this->planeWidget[i]->GetPolyDataAlgorithm());</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>psw->SetOrigin(this->riw[i]->GetResliceCursorWidget()-></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>GetResliceCursorRepresentation()->GetPlaneSource()->GetOrigin());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>psw->SetPoint1(this->riw[i]->GetResliceCursorWidget()-></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>GetResliceCursorRepresentation()->GetPlaneSource()->GetPoint1());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>psw->SetPoint2(this->riw[i]->GetResliceCursorWidget()-></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>GetResliceCursorRepresentation()->GetPlaneSource()->GetPoint2());</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>this->planeWidget[i]->UpdatePlacement();</div><div>}</div></div><div><br></div>
<div>// So far so good. Up to this point only the pane containing the 3D view is updated. When rendering (block below) nothing happens (????)</div><div><div>for (int i = 0; i < 3; i++</div><div>{</div><div> this->riw[i]->Render();</div>
<div>}</div></div><div><br><br><div class="gmail_quote">2012/3/24 Miguel Sotaquirá <span dir="ltr"><<a href="mailto:msotaquira@gmail.com">msotaquira@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I tried normalizing v2 and I obtained the exact same result. In both cases (with and without normalization) the plane has the correct orientation but is always located on one of the edges of the volume, not on its center.<span class="HOEnZb"><font color="#888888"><div>
<br></div></font></span><div><span class="HOEnZb"><font color="#888888">Miguel</font></span><div><div class="h5"><br><br><div class="gmail_quote">2012/3/23 Darshan Pai <span dir="ltr"><<a href="mailto:darshanpai@gmail.com" target="_blank">darshanpai@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF"><div>I think you need to normalize v2 before you compose the transform<br><br>Sent from my iPad</div><div><div><div><br>On Mar 23, 2012, at 3:09 PM, Miguel Sotaquirá <<a href="mailto:msotaquira@gmail.com" target="_blank">msotaquira@gmail.com</a>> wrote:<br>
<br></div><div></div><blockquote type="cite"><div>Hi again,<div><br></div><div>So I've managed to rotate the plane widget 90 degrees (see code below) but somehow the rotated plane is not located on the center of the 3D volume. In the code below I define the origin of the plane widget (wc) as the center of the volume in x,y,z coordinates. I don't know if I'm not defining correctly this center or the transformation (or both?)</div>
<div><br></div><div>How can I ensure that the center of the plane matches the center of the volume?</div><div><br></div><div>Thanks,</div><div>Miguel</div><div><br></div><div>// Get volume's center</div><div><div>vtkSmartPointer<vtkImageData> imageData = this->planeWidget[whichPlane]->GetResliceOutput();</div>
<div>double spacing[3];</div><div>imageData->GetSpacing(spacing);</div><div>double origin[3];</div><div>imageData->GetOrigin(origin);</div>
<div>int extent[6];</div><div>imageData->GetWholeExtent(extent);</div><div><span style="white-space:pre-wrap">        </span></div>
<div>// Define widget's center as the center of the volume</div><div>double wc[3];</div><div>wc[0] = origin[0] + 0.5 * spacing[0] * ( extent[0] + extent[1] );</div>
<div>wc[1] = origin[1] + 0.5 * spacing[1] * ( extent[2] + extent[3] );</div><div>wc[2] = origin[2] + 0.5 * spacing[2] * ( extent[4] + extent[5] );</div>
<div><span style="white-space:pre-wrap">        </span></div><div>// planeWidget's vector 2 (used as the axis of rotation)</div><div>double v2[3];</div>
<div>this->planeWidget[whichPlane]->GetVector2(v2);</div><div><span style="white-space:pre-wrap">        </span></div><div>// Transform</div>
<div>vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();</div>
<div>transform->PreMultiply();</div><div>transform->Translate(wc[0],wc[1],wc[2]);</div><div>transform->RotateWXYZ(90,v2[0],v2[1],v2[2]);</div>
<div>transform->Translate(-wc[0],-wc[1],-wc[2]);</div><div><span style="white-space:pre-wrap">        </span></div><div>// Modify and update planeWidget</div>
<div>double newpt[3];</div><div>transform->TransformPoint(this->planeWidget[whichPlane]->GetPoint1(),newpt);</div>
<div>this->planeWidget[whichPlane]->SetPoint1(newpt);</div><div>transform->TransformPoint(this->planeWidget[whichPlane]->GetPoint2(),newpt);</div>
<div>this->planeWidget[whichPlane]->SetPoint2(newpt);</div><div>transform->TransformPoint(this->planeWidget[whichPlane]->GetOrigin(),newpt);</div>
<div>this->planeWidget[whichPlane]->SetOrigin(newpt);</div><div><span style="white-space:pre-wrap">        </span></div><div>planeWidget[whichPlane]->UpdatePlacement();</div>
</div><div><br></div><div><br><br><div class="gmail_quote">2012/3/23 Miguel Sotaquirá <span dir="ltr"><<a href="mailto:msotaquira@gmail.com" target="_blank">msotaquira@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi everybody!<div><br></div><div>I've implemented a four pane viewer using the example found at Examples/GUI/Qt/FourPaneViewer/QtVTKRenderWindows.cxx. This viewer allows me to explore a 3-D volume using a set of three vtkImagePlaneWidgets that can be interactively placed (translated, rotated) by the user using mouse events.</div>
<div><br></div><div>What I want to do now after user interaction is to take one of these planes and rotate it 90 degrees along its normal, and update the four panes accordingly. In order to do so I'm using this workflow:</div>
<div><br></div><div>- Define a vtkTransform (transform) and SetMatrix as vtkImagePlaneWidget's current orientation: </div><div><div> vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();</div>
<div> transform->PreMultiply();</div><div><span> transform->SetMatrix(</span>planeWidget->GetResliceAxes()<span>);</span></div><div><span><br>
</span></div><div><span>- Apply 90 degrees rotation around Y axis:</span></div><div><span> transform->RotateY(90);</span></div><div><span><br>
</span></div><div><span>- Update planeWidget using methods SetOrigin, SetPoint1, SetPoint2 and UpdatePlacement, where origin, point1, point2 are extracted from "transform"</span></div><div>
<span><br></span></div><div>When using this approach I get strange results: neither planeWidget's origin nor its extension are well defined, and I'm not able to update the four panes accordingly. The origin is located outside the 3-D volume, and the extension does not cover the entire volume.</div>
</div><div><br></div><div>Am I missing something? How to correctly update planeWidget's orientation? Thanks for your help,</div><div><br></div><div>Miguel</div>
</blockquote></div><br></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a></span><br>
<span></span><br><span>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br>
<span>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br>
<span><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a></span><br></div></blockquote></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>