<div dir="ltr">hi all,<div><br></div><div>I am working on a 3D surface reconstruction problem.  Think of a 3D laser scanner, where I have multiple sets of 3D points (1 set per laser scan line).  I would like to visualize them as a set of polylines, 1 polyline per scan line.</div><div><br></div><div>I wrote the following code to read these data from 2 files. One file is a set of 3D points, the other is a text file indicating the number of points per scan line.  I then create 1 polyline per scan line, and append them together using vtkappendpolydata. I then wrote the results into a .vtk file.</div><div><br></div><div>However, visualizing the .vtk file suggests that the beginning of the nth scan line is connected to the end of the (n-1)th scan line.  How do I create a set of the disconnected polylines?</div><div><br></div><div>any help is very much appreciated,</div><div><br></div><div>My codes are as following:</div><div><br></div><div><div>#include <vtkSmartPointer.h></div><div>#include <vtkAppendPolyData.h></div><div>#include <vtkPoints.h></div><div>#include <vtkPolyLine.h></div><div>#include <vtkCellArray.h></div><div>#include <vtkCellData.h></div><div>#include <vtkPolyData.h></div><div>#include <vtkPolyDataWriter.h></div><div><br></div><div>int main ( int argc, char *argv[])</div><div>  {</div><div><br></div><div>  ifstream indexFile(argv[1]);</div><div>  ifstream pointFile(argv[2]);</div><div>  int num;</div><div>  double x, y, z;</div><div>  vtkSmartPointer< vtkAppendPolyData > append =</div><div>    vtkSmartPointer< vtkAppendPolyData >::New();</div><div><br></div><div>  while (indexFile >> num)</div><div>    {</div><div>    vtkSmartPointer< vtkPoints > points =</div><div>      vtkSmartPointer< vtkPoints >::New();</div><div>    vtkSmartPointer< vtkPolyLine > polyline =</div><div>      vtkSmartPointer< vtkPolyLine >::New();</div><div><br></div><div>    polyline->GetPointIds()->SetNumberOfIds(num);</div><div>    for (unsigned int i = 0; i < (unsigned int)num; i++)</div><div>      {</div><div>      pointFile >> x >> y >> z;</div><div>      points->InsertNextPoint(x, y, z);</div><div>      polyline->GetPointIds()->SetId(i, i);</div><div>      }</div><div><br></div><div>    vtkSmartPointer< vtkCellArray > cells =</div><div>      vtkSmartPointer< vtkCellArray >::New();</div><div>    cells->InsertNextCell(polyline);</div><div>    vtkSmartPointer< vtkPolyData > polyData =</div><div>      vtkSmartPointer< vtkPolyData >::New();</div><div>    polyData->SetPoints(points);</div><div>    polyData->SetLines(cells);</div><div>    polyData->Modified();</div><div><br></div><div>    append->AddInputData(polyData);</div><div>    append->Modified();</div><div>    }</div><div>  indexFile.close();</div><div>  pointFile.close();</div><div><br></div><div>  vtkSmartPointer< vtkPolyDataWriter > writer =</div><div>    vtkSmartPointer< vtkPolyDataWriter >::New();</div><div>  writer->SetFileName("test.vtk");</div><div>  writer->SetInputConnection(append->GetOutputPort());</div><div>  writer->Write();</div><div><br></div><div><br></div><div>  return (0);</div><div>  }</div></div></div>