<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma" size="2">Hi VTK,</font><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">I have some problems with ICP and I hope you can help me.</div><div style="font-family: Tahoma; font-size: 10pt; ">I have two clouds of points:</div><div style="font-family: Tahoma; font-size: 10pt; ">&nbsp;1. source points =&gt; 638 3D Points</div><div style="font-family: Tahoma; font-size: 10pt; ">&nbsp;2. target points &nbsp;=&gt; 204 3D Points</div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">I used&nbsp;vtkIterativeClosestPointTransform&nbsp;to map the source points to the target points, everything work fines in terms of compilation and transformation ( i have printed the transfomration matrix)</div><div style="font-family: Tahoma; font-size: 10pt; ">but I can not apply the computed transfomration on the source points. Here is the code, probably I am doing some very basic mistake:</div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" face="Tahoma" size="2">void ShapeAlignment::iterativeClosesPoint( const PointArray &amp;mesh, const std::vector&lt;PointArray&gt; &amp;sparseMesh, PointArray &amp;mappedMesh )</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">{</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>//MESH</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPointsPtr vtkMesh;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>VTKConversion::convertSeC2VTK(mesh,vtkMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(mesh,MString("mesh"),PointType(1,0,0),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">&nbsp;&nbsp; &nbsp; &nbsp; //vtkMesh is of type vtkPoints =&gt; 638 3D vtkPoints</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkPolyData&gt; vtkPolyDataMesh = vtkSmartPointer&lt;vtkPolyData&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataMesh-&gt;SetPoints(vtkMesh);</font></div><div><span class="Apple-style-span" style="font-family: Tahoma; font-size: 10pt; "><span class="Apple-tab-span" style="white-space:pre">        </span></span></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkVertexGlyphFilter&gt; vertexMesh = vtkSmartPointer&lt;vtkVertexGlyphFilter&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexMesh-&gt;SetInputConnection(vtkPolyDataMesh-&gt;GetProducerPort());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexMesh-&gt;Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>//SPARSE MESH</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPointsPtr vtkSparseMesh;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>VTKConversion::convertSeC2VTK(sparseMesh,vtkSparseMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(vtkSparseMesh,MString("sparseMesh"),PointType(0,1,0),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//vtkSparseMesh is of type vtkPoints =&gt; 204 3D points</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkPolyData&gt; vtkPolyDataSparseMesh = vtkSmartPointer&lt;vtkPolyData&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataSparseMesh-&gt;SetPoints(vtkSparseMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkVertexGlyphFilter&gt; vertexSparseMesh = vtkSmartPointer&lt;vtkVertexGlyphFilter&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexSparseMesh-&gt;SetInputConnection(vtkPolyDataSparseMesh-&gt;GetProducerPort());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexSparseMesh-&gt;Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">&nbsp;&nbsp; &nbsp; &nbsp; //setup ICP</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkIterativeClosestPointTransform&gt; icp = vtkSmartPointer&lt;vtkIterativeClosestPointTransform&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetSource(<span class="Apple-style-span" style="font-size: 13px; ">vertexMesh</span>-&gt;GetOutput()); &nbsp;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetTarget(vertexSparseMesh-&gt;GetOutput());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;DebugOn();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;GetLandmarkTransform()-&gt;SetModeToRigidBody();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetMaximumNumberOfIterations(40);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetMaximumNumberOfLandmarks(vertexSparseMesh-&gt;GetOutput()-&gt;GetNumberOfPoints());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetCheckMeanDistance(1);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;SetMaximumMeanDistance(0.0000001);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;Modified();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp-&gt;Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkMatrix4x4&gt; m = icp-&gt;GetMatrix();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; "The resulting matrix is: " &lt;&lt; *m &lt;&lt; std::endl;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>// Transform the source points by the ICP solution</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; icpTransformFilter = vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt;::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter-&gt;SetInput(vertexSparseMesh-&gt;GetOutput());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter-&gt;SetTransform(icp);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter-&gt;Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp; &nbsp; &nbsp; //visualize transformed mesh</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(vertexSparseMesh-&gt;GetOutput()-&gt;GetPoints(),MString("mesh"),PointType(0,0,1),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">}</font></div></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">Can you please give me some feedback.</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">Thanks a lot,</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">padre</font></div>                                               </body>
</html>