<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>Hi Tony,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I suspect that you've already found the vtk2itk.cxx example in InsightApplications. Take a look at line 220. That is where TriangleVisitor and Quadrilateral visitor are defined.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-Rob</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV><DIV>On Jan 31, 2007, at 8:52 AM, tony hakki wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><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> </DIV> <DIV><FONT size="3"></FONT> </DIV> <DIV>// Get the number of points in the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B><BR> int numPoints = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>->GetNumberOfPoints();<BR> if(numPoints == 0)<BR> {<BR> <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>->Print(std::cerr);<BR> }<BR><BR> // Create the vtkPoints object and set the number of points<BR> vtkPoints* vpoints = vtkPoints::New();<BR> vpoints->SetNumberOfPoints(numPoints);<BR><BR> // 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> // the vtkPoints object as we go<BR> MeshType::PointsContainer::Pointer points = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>->GetPoints();<BR> for(MeshType::PointsContainer::Iterator i = points->Begin(); i != <BR>points->End(); ++i)<BR> {<BR> // Get the point index from the point container iterator<BR> int idx = i->Index();<BR> // 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> // <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> // we have to use a const cast to get rid of the const<BR> vpoints->SetPoint(idx, const_cast<FLOAT*>(i->Value().GetDataPointer()));<BR> }<BR> // Set the points on the <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> grid<BR> <B style="COLOR: black; BACKGROUND-COLOR: #ff66ff">polydata</B>->SetPoints(vpoints);<BR><BR> // Now create the cells using the MulitVisitor<BR> // 1. Create a MultiVisitor<BR> MeshType::CellType::MultiVisitor::Pointer mv = <BR>MeshType::CellType::MultiVisitor::New();<BR><BR> // 2. Create a triangle and quadrilateral visitor<BR> TriangleVisitor::Pointer tv = TriangleVisitor::New(); <FONT size="4"><FONT color="#ff0000">Here It gives error;how can I Define TriangleVisitor and Quadriteralvisitor?</FONT><BR></FONT> QuadrilateralVisitor::Pointer qv = QuadrilateralVisitor::New();<BR><BR> // 3. Set up the visitors<BR> int vtkCellCount = 0; // running counter for current cell being <BR>inserted into <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B><BR> int numCells = <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>->GetNumberOfCells();<BR> int *types = new int[numCells]; // type array for <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B><BR> // create <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> cells and estimate the size<BR> vtkCellArray* cells = vtkCellArray::New();<BR> cells->EstimateSize(numCells, 4);<BR><BR> // Set the TypeArray CellCount and CellArray for both visitors<BR> tv->SetTypeArray(types);<BR> tv->SetCellCounter(&vtkCellCount);<BR> tv->SetCellArray(cells);<BR><BR> qv->SetTypeArray(types);<BR> qv->SetCellCounter(&vtkCellCount);<BR> qv->SetCellArray(cells);<BR><BR> // add the visitors to the multivisitor<BR> mv->AddVisitor(tv);<BR> mv->AddVisitor(qv);<BR> // Now ask the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B> to accept the multivisitor which<BR> // will Call Visit for each cell in the <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B> that matches the<BR> // cell types of the visitors added to the MultiVisitor<BR> <B style="COLOR: black; BACKGROUND-COLOR: #99ff99">mesh</B>->Accept(mv);<BR><BR> // 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> <B style="COLOR: black; BACKGROUND-COLOR: #ff66ff">polydata</B>->SetPolys(cells);<BR><BR> // Clean up <B style="COLOR: black; BACKGROUND-COLOR: #ff9999">vtk</B> objects (no vtkSmartPointer ... )<BR> cells->Delete();<BR> vpoints->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><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; ">Insight-users mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Insight-users@itk.org">Insight-users@itk.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</A></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>