<p dir="ltr">I would really appreciate a comment about this.<br>
Thanks in advance,</p>
<p dir="ltr">Marco<br>
</p>
<div class="gmail_quote">Il giorno 05/apr/2013 12:40, "Marco Sambin" <<a href="mailto:m.sambin@gmail.com">m.sambin@gmail.com</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Berk,<div><br></div><div>thank you for your message and explanation, which makes perfect sense.</div><div><br></div><div>However, in this case I believe there may be an issue in the source code of the vtkImagePlaneWidget class. In particular, in the method vtkImagePlaneWidget::OnMouseMove(), I see:</div>
<div><br></div><div><div>void vtkImagePlaneWidget::OnMouseMove()</div><div>{</div></div><div>[...]</div><div><div> else if ( this->State == vtkImagePlaneWidget::Rotating )</div><div> {</div><div> camera->GetViewPlaneNormal(vpn);</div>
<div> this->Rotate(prevPickPoint, pickPoint, vpn);</div><div> this->UpdatePlane();</div><div> this->UpdateMargins();</div><div> this->BuildRepresentation();</div><div> }</div></div><div>[...]<br>
<div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">The Rotate() method, in turn, ends with the following calls:</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<div class="gmail_extra">void vtkImagePlaneWidget::Rotate(double *p1, double *p2, double *vpn)</div><div class="gmail_extra">{</div></div><div class="gmail_extra">[...]</div><div class="gmail_extra"><div class="gmail_extra">
double newpt[3];</div><div class="gmail_extra"> this->Transform->TransformPoint(this->PlaneSource->GetPoint1(),newpt);</div><div class="gmail_extra"> this->PlaneSource->SetPoint1(newpt);</div><div class="gmail_extra">
this->Transform->TransformPoint(this->PlaneSource->GetPoint2(),newpt);</div><div class="gmail_extra"> this->PlaneSource->SetPoint2(newpt);</div><div class="gmail_extra"> this->Transform->TransformPoint(this->PlaneSource->GetOrigin(),newpt);</div>
<div class="gmail_extra"> this->PlaneSource->SetOrigin(newpt);</div></div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">Hence, the Point1, Point2, and Origin of the vtkPlaneSource are changed in this order.</div>
<div class="gmail_extra">Now, the OnMouseMove() method calls UpdatePlane() immediately after Rotate(), and UpdatePlane in turn calls GetNormal() on PlaneSource without calling any Update() on it first:</div><div class="gmail_extra">
<br></div><div class="gmail_extra"><div class="gmail_extra">void vtkImagePlaneWidget::UpdatePlane()</div><div class="gmail_extra">{</div><div class="gmail_extra">[...] // No call to "this->PlaneSource->Update()" is present in the omitted code...</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra"> double normal[3];</div><div class="gmail_extra"> this->PlaneSource->GetNormal(normal); // At this point the retrieved normal may be incorrect</div>
</div><div class="gmail_extra">[...]<br></div><div class="gmail_extra">}</div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Maybe a "this->PlaneSource->Update()" call is missing somewhere?</div>
<div class="gmail_extra">Thanks again for your comments.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Best regards,</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Marco Sambin</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 2, 2013 at 5:19 PM, Berk Geveci <span dir="ltr"><<a href="mailto:berk.geveci@kitware.com" target="_blank">berk.geveci@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Please note that this is not a utility class. It is an algorithm. ALL output that matters is produced after Update(). The fact that the normal is updated in some cases before Update() is coincidental and you should not rely on this behavior. If you are interested in calculating the normal of a plane given 2 vectors, I suggest using a cross product as provided by vtkMath.<div>
<br></div><div>Best,</div><div>-berk</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 28, 2013 at 7:15 AM, Marco Sambin <span dir="ltr"><<a href="mailto:m.sambin@gmail.com" target="_blank">m.sambin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all.<div><br></div><div>I am using the vtkPlaneSource class in a VTK-derived class. I noticed that the following simple sequence of calls:</div>
<div><br></div><div>=========================</div>
<div>CODE A:</div><div><br></div><div><div>double newO[3];</div><div>double newP1[3];</div><div>double newP2[3];</div><div>double newNormal[3];</div><div><br></div><div>// [...] set new values...</div><div>
<br></div><div>myPlaneSource->SetPoint1(newP1);</div><div>myPlaneSource->SetPoint2(newP2);</div><div>myPlaneSource->SetOrigin(newO);</div><div>myPlaneSource->GetNormal(newNormal);</div></div><div>=========================</div>
<div><br></div><div>finally returns a normal which seems INCORRECT to me.</div><div>On the other side, the following sequence of calls (which differs from CODE A in the position of the SetOrigin() call):</div>
<div><br></div><div><div>=========================</div><div>CODE B:</div><div><br></div><div><div>double newO[3];</div><div>double newP1[3];</div><div>double newP2[3];</div><div>double newNormal[3];</div><div>
<br></div><div>// [...] set new values...</div><div><br></div><div>myPlaneSource->SetOrigin(newO);<br></div><div>myPlaneSource->SetPoint1(newP1);</div><div>myPlaneSource->SetPoint2(newP2);</div><div>myPlaneSource->GetNormal(newNormal);</div>
</div><div>=========================</div><div><br></div><div>finally returns a normal which seems CORRECT.</div><div>After taking a look at vtkPlaneSource.cxx source, I believe that the problem is that while the implementation of the SetPoint1() and SetPoint2() methods finally calls UpdatePlane(), which also updates the normal, the implementation of SetOrigin() does not update the normal. Hence, if SetOrigin() is the last call, the resulting normal is incorrect in my opinion.</div>
<div><br></div><div>Can you please comment?</div><div>Thanks in advance,</div><div><br></div><div>Marco</div><div><br></div></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
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><br>
<br>
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><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div>