[vtkusers] Render image and points
chensiqi
pidanchen at hotmail.com
Tue Jan 13 15:56:33 EST 2009
Hi, VTKers.
I want to render a 2D image and some points over it. But somehow the points are not rendered at all. I attach the code here, if someone could go over it and point out where I was wrong, your help would be highly appreciated.
// Create polydatamapper
vtkCellArray *verts = vtkCellArray::New(); for( int i=0; i<points->GetNumberOfPoints(); i++) verts->InsertNextCell(1, &i ); // each cell contains only one point
// Create a PolyData dummy variable vtkPolyData *dummyPolyData = vtkPolyData::New(); dummyPolyData->SetPoints( points ); // points are vtkPoints type and known ahead dummyPolyData->SetVerts( verts );
vtkPolyDataMapper *pointsMapper = vtkPolyDataMapper::New(); pointsMapper->SetInput( dummyPolyData ); pointsMapper->ScalarVisibilityOff();
vtkActor *pointsActor = vtkActor::New(); pointsActor->SetMapper( pointsMapper );
// Create imageMapper
vtkImageMapper * imageMapper = vtkImageMapper::New(); imageMapper->SetInput( image ); // image is vtkImageData type and known ahead imageMapper->SetColorLevel( 0 ); imageMapper->SetColorWindow( 512 );
vtkActor2D *imageActor = vtkActor2D::New();
imageActor->SetMapper( imageMapper );
// Create Renderer, Window, Interactor and etc
vtkRenderer *ren = vtkRenderer::New();
ren->AddActor(pointsActor);
ren->AddActor(imageActor);
vtkRenderWindowInteractor * Interactor = vtkRenderWindowInteractor::New(); vtkRenderWindow * RenderWindow = vtkRenderWindow::New(); RenderWindow->SetSize(512,512); RenderWindow->SetInteractor(Interactor); RenderWindow->AddRenderer(ren);
RenderWindow->Render();
Interactor->Start();
Thanks
Siqi
_________________________________________________________________
微软地图率先推出跨城市多点驾车路线查询!
http://ditu.live.com/?form=MRAHAB&rtp=pos.30.454167_116.308611_%E5%A4%AA%E6%B9%96__~pos.29.554046_115.983427_%E5%BA%90%E5%B1%B1__~pos.29.116111_110.478889_%E5%BC%A0%E5%AE%B6%E7%95%8C__&rtop=0~0~0&encType=1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090114/77d38cb1/attachment.htm>
More information about the vtkusers
mailing list