<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
<RTE_TEXT>Hi, VTKers.<BR>
<BR>
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. <BR>
<BR>
// Create polydatamapper<BR>
vtkCellArray *verts = vtkCellArray::New();<BR> for( int i=0; i<points->GetNumberOfPoints(); i++)<BR> verts->InsertNextCell(1, &i ); // each cell contains only one point<BR>
// Create a PolyData dummy variable<BR> vtkPolyData *dummyPolyData = vtkPolyData::New(); <BR> dummyPolyData->SetPoints( points ); // points are vtkPoints type and known ahead<BR> dummyPolyData->SetVerts( verts );<BR>
vtkPolyDataMapper *pointsMapper = vtkPolyDataMapper::New();<BR> pointsMapper->SetInput( dummyPolyData );<BR> pointsMapper->ScalarVisibilityOff();<BR>
vtkActor *pointsActor = vtkActor::New();<BR> pointsActor->SetMapper( pointsMapper );<BR>
<BR>
// Create imageMapper<BR>
vtkImageMapper * imageMapper = vtkImageMapper::New();<BR> imageMapper->SetInput( image ); // image is vtkImageData type and known ahead<BR> imageMapper->SetColorLevel( 0 );<BR> imageMapper->SetColorWindow( 512 );<BR>
vtkActor2D *imageActor = vtkActor2D::New();<BR>
imageActor->SetMapper( imageMapper ); <BR>
<BR>
// Create Renderer, Window, Interactor and etc<BR>
vtkRenderer *ren = vtkRenderer::New();<BR>
ren->AddActor(pointsActor);<BR>
ren->AddActor(imageActor);<BR>
vtkRenderWindowInteractor * Interactor = vtkRenderWindowInteractor::New(); <BR> vtkRenderWindow * RenderWindow = vtkRenderWindow::New(); <BR> RenderWindow->SetSize(512,512); <BR> RenderWindow->SetInteractor(Interactor); <BR> RenderWindow->AddRenderer(ren); <BR>
RenderWindow->Render();<BR>
Interactor->Start();<BR>
<BR>
Thanks<BR>
Siqi<BR>
<BR>
<BR>
<BR>
</RTE_TEXT><BR><br /><hr />MSN保护盾,十八般武艺保障MSN安全! <a href='http://im.live.cn/safe/' target='_new'>现在就下载!</a></body>
</html>