[vtkusers] How to display points in VTK?
    Bob 
    oraciotaglia at tiscali.it
       
    Fri Nov  2 13:31:15 EDT 2007
    
    
  
2007/11/1, Alam, Mohammed <malam at med.wayne.edu>:
[...]
>
> Can someone please explain me how can I display a set of points (cloud of
> points) in VTK? What will the vtk file format and the process? Thank you.
>
[...]
Well, the file formats that I use to store clouds of points is simple
ASCII xyz, one point per line, in the form
x[0]  y[0]  z[0]
x[1]  y[1]  z[1]
....
You can simply read and convert these to binary using, for example,
C++ STL iostreams tools.
The procedure to visualize the points it's like the following,
assuming you have read nump points in the vector of floats pointed to
by pp:
----------------
vtkPoints* newp= vtkPoints::New();
vtkCellArray* newv= vtkCellArray::New();
vtkPolyData* pd= vtkPolyData::New();
pd->SetPoints( newp );
pd->SetVerts( newv );
while( nump-- > 0 )
{
   vtkIdType id= newp->InsertNextPoint( *pp++ );
   newv->InsertNextCell( 1, &id );
}
vtkPolyDataMapper* mapper= vtkPolyDataMapper::New();
vtkActor* actor= vtkActor::New();
mapper->SetInput( pd );
actor->SetMapper( mapper );
----------------
Once done this, you have to put the created actor in a Renderer
instance in order to view the points in a render window.
HTH.
Bob
    
    
More information about the vtkusers
mailing list