Hi Eugene,<br><br>To use your method, do I have to separate the points for the three polygons to three groups and input points to vtkPoints and vtkCellArray instead of reading them from the file? Is the first part of your code (reading data from file) related to the second part (the part worked fine for you)? I have trouble constructing 3 cells after reading in all the points... I can add all the data to vtkPoints with
<br><br>//Read the vtk data file.<br>vtkPolyDataReader *usa = vtkPolyDataReader::New();<br>usa->SetFileName("greatlakes.vtk");<br>for (int i = 0; i < usa->GetOutput()->GetNumberOfPoints(); i++) points->InsertNextPoint(usa->GetOutput()->GetPoint(i));
<br><br>But I can not insert part of the points to another instance of vtkPoints like:<br><br>for (i = 0,i<882; i++) points2->InsertNextPoint(usa->GetOutput()->GetPoint(i));<br><br>Any thoughts?<br>Thanks<br>Janny
<br><br><div><span class="gmail_quote">On 9/30/07,
<b class="gmail_sendername">
Eugene Dorfman</b> <<a href="mailto:justadreamer2007@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">justadreamer2007@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ok, I would do it simpler for the first approximation (for 1 polygon):<br><br>vtkPolyDataMapper *map = vtkPolyDataMapper::New();<br>vtkPolyDataReader *reader = ... New();<br>/*Read your data*/<br>vtkPolyData *data = reader->GetOutput();
<br>map->SetInput(data);<br>/*add a mapper to renderer and render*/<br>
<br><br>Then. What worked fine for me was: <br><br>vtkPoints* points = ...::New(); <br>vtkCellArray* cellArray = ...::New();<br><br>vtkIdList *idList = new vtkIdList::New();<br>vtkPoints* points1 = ...::New();<br><br>points->GetPoints(idList,points1);
<br>cellArray->InsertNextCell(points->GetNumberOfPoints()); //inserting a cell for 1 polygon<br>for (int i=0;i<points->GetNumberOfPoints();i++)<br> cellArray->InsertCellPoint(idList[i]);<br><br>//now we have constructed 1 cell
<br>vtkPolyData *polyData = ...::New();<br>polyData->SetPoints(points);<br>polyData->SetPolys(cellArray);<br>vtkPolyDataMapper * map = ...::New();<br>map->SetInput(polyData);<br><br>//then render <br><br>so we constructed single cell of a shape of your polygon - should work.
<br>
</blockquote></div><br>