[vtkusers] Rendering 2D image and points

Pascale Beliveau beliveaup at gmail.com
Tue Aug 26 12:26:31 EDT 2008


Hi vtkusers,

   I want to try a simple task: show an image (jpg) and see points over it.
I have done the following code but the image is shown darker than it should.
When rendered alone, the image has the correct intensities. Here is what I
did:

- create polydata from points and cells
- create PolyDataMapper, Actor and Renderer for polydata
- create ImageMapper, Actor2D and Renderer for image (vtkImageData)
- create RenderWindow and add both renderer for polydata and for image

Is there something I'm missing, or do I add both images incorectly to the
RenderWindow? I'm a bit puzzled by this effect and did not find anything
helpfull on the mailing list.

Thanks in advance for your help,
Pascale


The following is the code I created:

// create set of points that will deform image
vtkPoints * Points = vtkPoints::New();
Points->SetNumberOfPoints(2);
Points->SetPoint(0,1,1,1);
Points->SetPoint(1,10,10,10);
vtkCellArray * Cells = vtkCellArray::New();
Cells->InsertNextCell(2);
Cells->InsertCellPoint(0);
Cells->InsertCellPoint(1);

vtkPolyData * PolyData = vtkPolyData::New();
PolyData->SetPoints(Points);
PolyData->SetVerts(Cells);

// create image viewer
vtkImageMapper * MapImage = vtkImageMapper::New();
MapImage->SetInput(Image);
vtkActor2D * ImActor = vtkActor2D::New();
ImActor->SetMapper(MapImage);
vtkRenderer * ImRenderer = vtkRenderer::New();
ImRenderer->AddActor2D(ImActor);

vtkRenderWindowInteractor * Interactor = vtkRenderWindowInteractor::New();

// create viewer for points
vtkPolyDataMapper * Mapper = vtkPolyDataMapper::New();
Mapper->SetInput(PolyData);
vtkActor * Actor = vtkActor::New();
Actor->SetMapper(Mapper);
vtkRenderer * Renderer = vtkRenderer::New();
Renderer->AddViewProp(Actor);

 // add both to main render window
vtkRenderWindow * RenderWindow = vtkRenderWindow::New();
RenderWindow->SetSize(400,600);
RenderWindow->SetInteractor(Interactor);
RenderWindow->AddRenderer(Renderer);
RenderWindow->AddRenderer(ImRenderer);

 RenderWindow->Render();
Interactor->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080826/e230c848/attachment.htm>


More information about the vtkusers mailing list