<br>Hi Patrik,<br><br><br>When you call:<br><br><font> phantom->ComputeObjectToWorldTransform()</font><br><br>the values of Offset and Matrix that you manually <br>set in the calls:<font><br><br>phantom->GetObjectToWorldTransform()->SetMatrix(transform->GetMatrix());</font><span style="white-space: pre-wrap;"><font>        </font></span><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div>
</div></blockquote><div><font>phantom->GetObjectToWorldTransform()->SetOffset(transform->GetOffset());</font></div>
<br>are overwritten.<br><br><br>See the implementation of the method in<br><br>itkSpatialObject.txx: lines 316-363.<br><br>The new "ObjectToWorldTransform" is computed by <br>composing the transforms:<br><br>* ObjectToNode<br>
* NodeToWorld<br><br><br><br> Regards,<br><br><br> Luis<br> <br><br>-----------------------------------------------------------------------<br><div class="gmail_quote">On Wed, Oct 13, 2010 at 8:29 PM, Patrik Brynolfsson <span dir="ltr"><<a href="mailto:patrik.brynolfsson@radfys.umu.se">patrik.brynolfsson@radfys.umu.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>Hello,</div><div><br></div><div>I have a GroupType phantom, containing some ellipses. I have applied a transform to the phantom group:</div>
<div><br></div><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div><div><font face="'courier new', monospace">phantom->GetObjectToWorldTransform()->SetMatrix(transform->GetMatrix());</font><span style="white-space: pre-wrap;"><font face="'courier new', monospace">        </font></span></div>
</div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div><font face="'courier new', monospace">phantom->GetObjectToWorldTransform()->SetOffset(transform->GetOffset());</font></div>
<div><font face="'courier new', monospace">phantom->ComputeObjectToWorldTransform();</font></div></blockquote><div><br></div><div>Now I try the transform to se if it produces reasonable results:</div>
<div><br></div><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div><font face="'courier new', monospace">EllipseType::PointType point;</font></div>
</blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"></blockquote>
<font face="'courier new', monospace">point[0] = -25/sqrt(2.0);</font></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"></blockquote>
<blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><font face="'courier new', monospace">point[1] = 25/sqrt(2.0);</font></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div><font face="'courier new', monospace">point[2] = -47.5;</font></div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div>
<font face="'courier new', monospace">EllipseType::PointType point2 = phantom->GetObjectToWorldTransform()->TransformPoint(point)</font>;</div><div><font face="'courier new', monospace">std::cout << "Transformed point 1 is: " << point2 << std::endl;</font></div>
</blockquote><div><br></div><div>I now try the same thing with one of the ellipses in the group:</div><div><br></div><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div>
<font face="'courier new', monospace">// Try with ellipse</font></div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div>
<font face="'courier new', monospace">GroupType::ChildrenListPointer children = phantom->GetChildren();</font></div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div><font face="'courier new', monospace">GroupType::ChildrenListType::const_iterator itr = children->begin();</font></div><div><font face="'courier new', monospace"><br>
</font></div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div><font face="'courier new', monospace">itr++;</font></div>
</blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div><font face="'courier new', monospace">point2 = itr->GetPointer()->GetObjectToWorldTransform()->TransformPoint(point);</font></div>
<div><font face="'courier new', monospace">std::cout << "Transformed point 2 is: " << point2 << std::endl;</font></div></blockquote><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div><font face="'courier new', monospace"><span style="white-space: pre-wrap;">delete children;</span></font></div></blockquote><font face="'courier new', monospace"><span style="white-space: pre-wrap;"><div>
<span style="white-space: pre-wrap;"><font face="arial, helvetica, sans-serif"><br></font></span></div><font face="arial, helvetica, sans-serif">But the points calculated with the two methods are not the same. The </font>point <font face="arial, helvetica, sans-serif">variable is the center of the ellipse, so</font></span></font><div>
<font face="'courier new', monospace"><span style="white-space: pre-wrap;"><font face="arial, helvetica, sans-serif"> </font></span></font><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;">
<div><span style="white-space: pre-wrap;"><font face="'courier new', monospace">EllipseType::PointType center = itr->GetPointer()->GetBoundingBox()->GetCenter();</font></span></div>
</blockquote><div><blockquote style="margin: 0pt 0pt 0pt 40px; border: medium none; padding: 0px;"><div><font face="'courier new', monospace"><span style="white-space: pre-wrap;">point2 = itr->GetPointer()->GetObjectToWorldTransform()->TransformPoint(center);</span><span style="white-space: pre-wrap;"><font face="arial, helvetica, sans-serif"> </font></span></font></div>
</blockquote><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;"><div><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;"><br>
</span></div>should produce the same result as when getting the world coordinate from the phantom group? </span></div><div><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;"><br>
</span></div><div><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;">If I use the GetObjectToParentTransform(), I get the ellipse position in the phantom, as I expect. I want to get the ellipse position in world coordinates from it's center, what am I doing wrong?</span></div>
<div><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;"><br></span></div><div><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;"></span><span style="font-family: arial,helvetica,sans-serif; white-space: pre-wrap;">Regards, </span></div>
<div><div>---<br>Patrik Brynolfsson<br><br><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<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>