[vtkusers] RE:How to display points in VTK
Alam, Mohammed
malam at med.wayne.edu
Sat Nov 3 23:38:38 EDT 2007
Hi Bob,
I tried to visualize the following and the result was a white (blank)
window with no points. Not sure what I am missing...
x[0][0] = 0;
x[0][1] = 0;
x[0][2] = 0;
x[1][0] = 0;
x[1][1] = 1;
x[1][2] = 0;
x[2][0] = 1;
x[2][1] = 0;
x[2][2] = 0;
x[3][0] = 1;
x[3][1] = 1;
x[3][2] = 0;
vtkPoints newp = new vtkPoints();
vtkCellArray newv = new vtkCellArray();
int nump = 4;
int pp = 0;
while( nump-- > 0 )
{
int id1 = newp.InsertNextPoint(x[pp][0], x[pp][1],
x[pp][2]);
newv.InsertNextCell(id1);
pp++;
}
vtkPolyData pd = new vtkPolyData();
pd.SetPoints(newp);
pd.SetVerts(newv);
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInput(pd);
vtkActor cubeActor = new vtkActor();
cubeActor.SetMapper(mapper);
vtkRenderer renderer = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(renderer);
vtkRenderWindowInteractor iren = new
vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
renderer.AddActor(cubeActor);
renderer.SetBackground(1,1,1);
renWin.SetSize(600, 600);
renWin.Render();
iren.Initialize();
renWin.Render();
iren.Start();
Thanks
Alam
More information about the vtkusers
mailing list