[vtkusers] [other] Rendering 2D image and points
James Dippner
jdippner at informetric.com
Thu Aug 28 13:26:38 EDT 2008
You might try setting the cell visibility on the points actor to false,
you may also try setting the opacity for the same actor.
Pascale Beliveau wrote:
> 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();
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
More information about the vtkusers
mailing list