<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:12pt"><DIV>Does anybody try the following code,does it work correctly?</DIV>
<DIV>&nbsp;</DIV>
<DIV>*&nbsp; Convert itk mesh to <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">vtk</B> <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">PolyData</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<BR>/************************************************************************/<BR>void MeshToPolyData(MeshType* mesh, vtkPolyData* <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">polydata</B>)<BR>{<BR>&nbsp; // Get the number of points in the mesh<BR>&nbsp; int numPoints = mesh-&gt;GetNumberOfPoints();<BR>&nbsp; if(numPoints == 0)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; mesh-&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 itk mesh
 filling in<BR>&nbsp; // the vtkPoints object as we go<BR>&nbsp; MeshType::PointsContainer::Pointer points = mesh-&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: #a0ffff">vtk</B> point at the index with the the coord array from itk<BR>&nbsp;&nbsp;&nbsp; // itk returns a const pointer, but <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">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: #a0ffff">vtk</B> grid<BR>&nbsp; <B style="COLOR:
 black; BACKGROUND-COLOR: #99ff99">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();<BR>&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: #a0ffff">vtk</B><BR>&nbsp; int numCells = mesh-&gt;GetNumberOfCells();<BR>&nbsp; int *types = new int[numCells];&nbsp; // type array for <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">vtk</B><BR>&nbsp; // create <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">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 mesh to accept the multivisitor which<BR>&nbsp; // will Call Visit for each cell in the mesh that matches the<BR>&nbsp; // cell types of the visitors added to the MultiVisitor<BR>&nbsp; mesh-&gt;Accept(mv);<BR><BR>&nbsp; // Now set the cells on the <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">vtk</B> <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">polydata</B><BR>&nbsp; <B style="COLOR:
 black; BACKGROUND-COLOR: #99ff99">polydata</B>-&gt;SetPolys(cells);<BR><BR>&nbsp; // Clean up <B style="COLOR: black; BACKGROUND-COLOR: #a0ffff">vtk</B> objects (no vtkSmartPointer ... )<BR>&nbsp; cells-&gt;Delete();<BR>&nbsp; vpoints-&gt;Delete();<BR>}<BR></DIV></div><br>

<hr size=1>It's here! Your new message!<br>Get
<a href="http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/"> new email alerts</a> with the free <a href="
http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/">Yahoo! Toolbar.</a></body></html>