<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">You want to look at the vtkTransformPolyDataFilter classes. Then once you transform each of your STL datasets, then use vtkAppendPolyData filter to bring them together. <DIV><BR class="khtml-block-placeholder"></DIV><DIV> If they happen to have matching points, then run the vtkMergePoints filter to remove duplicate points.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Then you can save the data either as a vtk data file using the vtkXMLPolydataWriter or the vtkSTLWriter</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Bitstream Vera Sans; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-- </DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Mike Jackson Senior Research Engineer</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Innovative Management & Technology Services</DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR><DIV><DIV>On Mar 19, 2007, at 12:43 AM, MIRG UTM wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><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 "vtkMatrix4x4", 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> stlReader = vtkSTLReader::New();<BR> stlReader->SetFileName("stlFile.stl");</DIV> <DIV>// here goes other rendering stuff</DIV><P> //get PolyData from the STL object<BR> vtkPolyData *pd = vtkPolyData::New();<BR> pd = stlReader->GetOutput();<BR> int n1 = pd->GetNumberOfPoints();</P><P> // get points data from PolyData object<BR> vtkPoints *a = pd->GetPoints();<BR> <BR> vtkMatrix4x4 *t = vtkMatrix4x4::New();</P><P> t->Identity();<BR> t->SetElement(0, 3, 5.0);<BR> t->SetElement(1, 3, 0.0);<BR> t->SetElement(2, 3, 0.0);</P><P> double *p, pin[4], pout[4]; <BR> for (int i=0; i<n1;i++)<BR> {<BR> p = a->GetPoint(i);<BR> pin[0] = p[0]; pin[1] = p[1]; pin[2] = p[2]; pin[3] = 1;</P><P> t->MultiplyPoint(pin, pout);<BR> <BR> p[0]=pout[0]; p[1]=pout[1]; p[2]=pout[2];</P><P> a->SetPoint(i, p);<BR> }</P><P> // return updated points to PolyData object<BR> pd->SetPoints(a);</P><P> // upto here the code is OK, but after this I donot know how to return<BR> // this changed PolyData object back to the 'stlReader'<BR> // I have tried to use the following</P><P> this->vtkReaderSoft->SetInputConnection(reinterpret_cast<vtkAlgorithmOutput*>(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><DIV> <BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This is the private VTK discussion list.<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Please keep messages on-topic. Check the FAQ at: <A href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Follow this link to subscribe/unsubscribe:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>