<p>Hi VTK gurus</p>
<p>I am working on medical data, I have two pieces of bone in STL format and I have to align second with the first one and then merge both to form a single object. I am new to VTK and donot know exactly how to do. I tried to move the second bone by using vtkActor methods (RotateX, RotateY, AddPosition etc) but these only move the rendered pipeline and actual object data does not change. Then I tried to change the data manually by using &quot;vtkMatrix4x4&quot;, I could get the point data from STL object and change it by applying transformation, but I donot know how to set this changed point data back to the STL object. If any one can please help me how to do this. Is there any other easy way to do the same?
</p>
<p>Here is code snippit;</p>
<div>&nbsp;stlReader = vtkSTLReader::New();<br>&nbsp;stlReader-&gt;SetFileName(&quot;stlFile.stl&quot;);</div>
<div>// here goes other rendering stuff</div>
<p>&nbsp;//get PolyData from the STL object<br>&nbsp;vtkPolyData *pd = vtkPolyData::New();<br>&nbsp;pd = stlReader-&gt;GetOutput();<br>&nbsp;int n1 = pd-&gt;GetNumberOfPoints();</p>
<p>&nbsp;// get points data from PolyData object<br>&nbsp;vtkPoints *a = pd-&gt;GetPoints();<br>&nbsp;&nbsp;<br>&nbsp;vtkMatrix4x4 *t = vtkMatrix4x4::New();</p>
<p>&nbsp;t-&gt;Identity();<br>&nbsp;t-&gt;SetElement(0, 3, 5.0);<br>&nbsp;t-&gt;SetElement(1, 3, 0.0);<br>&nbsp;t-&gt;SetElement(2, 3, 0.0);</p>
<p>&nbsp;double *p, pin[4], pout[4];&nbsp;<br>&nbsp;for (int i=0; i&lt;n1;i++)<br>&nbsp;{<br>&nbsp;&nbsp;p = a-&gt;GetPoint(i);<br>&nbsp;&nbsp;pin[0] = p[0]; pin[1] = p[1]; pin[2] = p[2]; pin[3] = 1;</p>
<p>&nbsp;&nbsp;t-&gt;MultiplyPoint(pin, pout);<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;p[0]=pout[0]; p[1]=pout[1]; p[2]=pout[2];</p>
<p>&nbsp;&nbsp;a-&gt;SetPoint(i, p);<br>&nbsp;}</p>
<p>&nbsp;// return updated points to PolyData object<br>&nbsp;pd-&gt;SetPoints(a);</p>
<p>&nbsp;// upto here the code is OK, but after this I donot know how to return<br>&nbsp;// this changed PolyData object back to the &#39;stlReader&#39;<br>&nbsp;// I have tried to use the following</p>
<p>&nbsp;this-&gt;vtkReaderSoft-&gt;SetInputConnection(reinterpret_cast&lt;vtkAlgorithmOutput*&gt;(pd));</p>
<p>// but it gives the following runtime error</p>
<p><br>ERROR: In D:\Softwares\VTK5.0\Source\Filtering\vtkAlgorithm.cxx, line 567<br>vtkSTLReader (0x0288BDA8): Attempt to connect input port index 0 for an algorithm with 0 input ports.</p>
<p>Please help me to solve this and then how to merge two STL objects into a single object using operations like UNION, INTERSECTION, DIFFERENCE etc.</p>
<p>Thanks in advance.</p>
<p>MIRG</p>
<p>&nbsp;</p>