<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi vtkusers,</div>

<div>I just started using VTK and i'm currently having some problems with simply drawing lines between different points.</div>

<div>What i basically want to do is to read a file of coordinates (which works) and then connect these points whith lines. I basically adapted the code from this wiki example:  http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/LongLine</div>

<div>As i understand this example my code should now connect the 1st point with the 2nd and so on. However for some reason this doesnt happen. When i define my points as:</div>

<div>1.0 1.0 0.0<br/>
2.0 1.0 0.0<br/>
1.0 2.0 0.0<br/>
2.0 2.0 0.0</div>

<div>They get connected with eachother however they get connected with the origin aswell.</div>

<div>If somebody could explain to me why this happens i would be grateful. Regards,</div>

<div>Michael</div>

<div> </div>

<div>**************************************</div>

<div>float coord[number_of_points][3];</div>

<div>for (i = 0; i < number_of_points; i++)<br/>
  {<br/>
    fin >> coord[i][0] >> coord[i][1] >> coord[i][2];<br/>
  }</div>

<div> </div>

<div>
<div>vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();</div>

<div>  for (i = 0; i < number_of_points; i++)<br/>
  {<br/>
    points->InsertNextPoint(coord[i]);<br/>
  }</div>

<div> </div>

<div>vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();</div>

<div> </div>

<div>
<div>for(i = 0; i < number_of_points; i++)<br/>
  {<br/>
      vtkSmartPointer<vtkLine> line = vtkSmartPointer<vtkLine>::New();<br/>
      line->GetPointIds()->SetId(0,i);<br/>
      line->GetPointIds()->SetId(1,i+1);<br/>
      lines->InsertNextCell(line);<br/>
    }<br/>
  }</div>

<div><br/>
  // Create a polydata to store everything in<br/>
   vtkSmartPointer<vtkPolyData> linesPolyData =<br/>
    vtkSmartPointer<vtkPolyData>::New();<br/>
 <br/>
  // Add the points to the dataset<br/>
  linesPolyData->SetPoints(points);<br/>
 <br/>
  // Add the lines to the dataset<br/>
  linesPolyData->SetLines(lines);<br/>
 <br/>
  // Setup actor and mapper<br/>
  vtkSmartPointer<vtkPolyDataMapper> mapper =<br/>
    vtkSmartPointer<vtkPolyDataMapper>::New();</div>

<div>  mapper->SetInputData(linesPolyData);<br/>
 <br/>
  vtkSmartPointer<vtkActor> actor =<br/>
    vtkSmartPointer<vtkActor>::New();<br/>
  actor->SetMapper(mapper);<br/>
 <br/>
  // Setup render window, renderer, and interactor<br/>
  vtkSmartPointer<vtkRenderer> renderer =<br/>
    vtkSmartPointer<vtkRenderer>::New();<br/>
  vtkSmartPointer<vtkRenderWindow> renderWindow =<br/>
    vtkSmartPointer<vtkRenderWindow>::New();<br/>
  renderWindow->AddRenderer(renderer);<br/>
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br/>
      vtkSmartPointer<vtkRenderWindowInteractor>::New();<br/>
  renderWindowInteractor->SetRenderWindow(renderWindow);<br/>
  renderer->AddActor(actor);<br/>
 <br/>
  renderWindow->Render();<br/>
  renderWindowInteractor->Start();</div>

<div>*********************************************</div>
</div>
</div></div></body></html>