[vtkusers] Manual polylines

Chris Scharver scharver at evl.uic.edu
Fri Feb 1 12:07:14 EST 2002


Hello,

I am trying a relatively simple action of creating polylines from sampled positions with VTK 3.2 on IRIX.  Points are samples from 3D space before being passed along to VTK.  However, it appears that I am not constructing the vtkPolyData correctly, as the vtkTubeFilter doesn't seem to create anything.  I can verify that I have all the points into the structures, but am I missing something in the assembly of the cell array?

(lineStruct is a simple structure with the length of the line and the vertices within it.)

...
  vtkPoints* points = vtkPoints::New();
  vtkCellArray* lines = vtkCellArray::New();
  lines->InsertNextCell(lineStruct->length[0]);
  float xyz[3];
  for (int i = 0; i < lineStruct->length[0]; ++i) {
    xyz[0] = lineStruct->verts[i][0];
    xyz[1] = lineStruct->verts[i][1];
    xyz[2] = lineStruct->verts[i][2];
    points->InsertPoint(i, xyz);
    lines->InsertCellPoint(i);
  }

  vtkPolyData* dataSet = vtkPolyData::New();
  dataSet->SetPoints(points);
  dataSet->SetLines(lines);

  vtkTubeFilter* tubes = vtkTubeFilter::New();
    tubes->SetRadius(0.5f);
    tubes->SetNumberOfSides(6);
    tubes->SetInput(dataSet);
  // Use a geometry filter for vtkActor to Performer translation
  vtkGeometryFilter* gf = vtkGeometryFilter::New();
    gf->SetInput(tubes->GetOutput());
  vtkPolyDataMapper* pntMapper = vtkPolyDataMapper::New();
    pntMapper->SetInput(gf->GetOutput());
    pntMapper->ScalarVisibilityOff();
  vtkActor* pntActor = vtkActor::New();
    pntActor->SetMapper(pntMapper);
    pntActor->GetProperty()->SetOpacity(1.0f);
    pntActor->GetProperty()->SetColor(0.9f,0.9f,0.0f);
...

Thanks,
Chris
--
Chris Scharver
Electronic Visualization Laboratory
The University of Illinois at Chicago
Ph: 312-996-3002   FAX: 312-413-7585
<http://www.evl.uic.edu/scharver/>



More information about the vtkusers mailing list