<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:10pt"><DIV>Hello all;</DIV>
<DIV><FONT size=3>I want to convert itk mesh to vtk poly data,does anyone any suggestion how to accomplish that?</FONT></DIV>
<DIV><FONT size=3></FONT>&nbsp;</DIV>
<DIV><FONT size=3></FONT>&nbsp;</DIV>
<DIV>// Get the number of points in the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B><BR>&nbsp; int numPoints = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>-&gt;GetNumberOfPoints();<BR>&nbsp; if(numPoints == 0)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>-&gt;Print(std::cerr);<BR>&nbsp; }<BR><BR>&nbsp; // Create the vtkPoints object and set the number of points<BR>&nbsp; vtkPoints* vpoints = vtkPoints::New();<BR>&nbsp; vpoints-&gt;SetNumberOfPoints(numPoints);<BR><BR>&nbsp; // iterate over all the points in the <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">itk</B> <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B> filling in<BR>&nbsp; // the vtkPoints object as we go<BR>&nbsp; MeshType::PointsContainer::Pointer points = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>-&gt;GetPoints();<BR>&nbsp; for(MeshType::PointsContainer::Iterator i = points-&gt;Begin(); i !=
 <BR>points-&gt;End(); ++i)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; // Get the point index from the point container iterator<BR>&nbsp;&nbsp;&nbsp; int idx = i-&gt;Index();<BR>&nbsp;&nbsp;&nbsp; // Set the <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> point at the index with the the coord array from <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">itk</B><BR>&nbsp;&nbsp;&nbsp; // <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">itk</B> returns a const pointer, but <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> is not const correct, so<BR>&nbsp;&nbsp;&nbsp; // we have to use a const cast to get rid of the const<BR>&nbsp;&nbsp;&nbsp; vpoints-&gt;SetPoint(idx, const_cast&lt;FLOAT*&gt;(i-&gt;Value().GetDataPointer()));<BR>&nbsp; }<BR>&nbsp; // Set the points on the <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> grid<BR>&nbsp; <B style="COLOR: black; BACKGROUND-COLOR: #ff66ff">polydata</B>-&gt;SetPoints(vpoints);<BR><BR>&nbsp; // Now create the
 cells using the MulitVisitor<BR>&nbsp; // 1. Create a MultiVisitor<BR>&nbsp; MeshType::CellType::MultiVisitor::Pointer mv = <BR>MeshType::CellType::MultiVisitor::New();<BR><BR>&nbsp; // 2. Create a triangle and quadrilateral visitor<BR>&nbsp; TriangleVisitor::Pointer tv = TriangleVisitor::New();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=4><FONT color=#ff0000>Here It gives error;how can I Define&nbsp; TriangleVisitor and Quadriteralvisitor?</FONT><BR></FONT>&nbsp; QuadrilateralVisitor::Pointer qv =&nbsp; QuadrilateralVisitor::New();<BR><BR>&nbsp; // 3. Set up the visitors<BR>&nbsp; int vtkCellCount = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // running counter for current cell being <BR>inserted into <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B><BR>&nbsp; int numCells = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>-&gt;GetNumberOfCells();<BR>&nbsp; int *types = new int[numCells];&nbsp; // type array for <B style="COLOR: black;
 BACKGROUND-COLOR: #ff9999">vtk</B><BR>&nbsp; // create <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> cells and estimate the size<BR>&nbsp; vtkCellArray* cells = vtkCellArray::New();<BR>&nbsp; cells-&gt;EstimateSize(numCells, 4);<BR><BR>&nbsp; // Set the TypeArray CellCount and CellArray for both visitors<BR>&nbsp; tv-&gt;SetTypeArray(types);<BR>&nbsp; tv-&gt;SetCellCounter(&amp;vtkCellCount);<BR>&nbsp; tv-&gt;SetCellArray(cells);<BR><BR>&nbsp; qv-&gt;SetTypeArray(types);<BR>&nbsp; qv-&gt;SetCellCounter(&amp;vtkCellCount);<BR>&nbsp; qv-&gt;SetCellArray(cells);<BR><BR>&nbsp; // add the visitors to the multivisitor<BR>&nbsp; mv-&gt;AddVisitor(tv);<BR>&nbsp; mv-&gt;AddVisitor(qv);<BR>&nbsp; // Now ask the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B> to accept the multivisitor which<BR>&nbsp; // will Call Visit for each cell in the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B> that matches the<BR>&nbsp; // cell types of the visitors
 added to the MultiVisitor<BR>&nbsp; <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>-&gt;Accept(mv);<BR><BR>&nbsp; // Now set the cells on the <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> <B style="COLOR: black; BACKGROUND-COLOR: #ff66ff">polydata</B><BR>&nbsp; <B style="COLOR: black; BACKGROUND-COLOR: #ff66ff">polydata</B>-&gt;SetPolys(cells);<BR><BR>&nbsp; // Clean up <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> objects (no vtkSmartPointer ... )<BR>&nbsp; cells-&gt;Delete();<BR>&nbsp; vpoints-&gt;Delete();<BR>}<BR><BR></DIV></div><br>

<hr size=1>Expecting? Get great news right away with <a href="http://us.rd.yahoo.com/evt=49982/*http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html">email Auto-Check.</a><br>Try the <a href="http://us.rd.yahoo.com/evt=49982/*http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html">Yahoo! Mail Beta.</a></body></html>