[vtkusers] Windows offscreen image rendering

Ermin Hasičević Ermin.Hasicevic at iskon.hr
Sat Sep 8 04:00:47 EDT 2001


Hi!
 
I would like to render a sequence of images in offscreen mode
using VTK on Windows platform. But it seems I can't just simply
tell vtkWin32OpenGLImageWindow to render images offscreen.
I have tried to set memory rendering by calling 
SetupMemoryRendering(xsize, ysize, NULL) but after calling
Render method on image window I still get window opened
and don't know how to prevent it's opening.
 
What modifications should I make to following code to achieve
offscreen rendering of images?
 
     vtkCellArray *segResCellArr = vtkCellArray::New();
        vtkPolyData *segResPD = vtkPolyData::New();
        //vtkExtentTranslator *segResExtTr = vtkExtentTranslator::New();
        vtkPolyDataMapper2D *segResMapper = vtkPolyDataMapper2D::New();
        vtkActor2D *segResActor = vtkActor2D::New();
        vtkImager *segResImager = vtkImager::New();
        vtkWin32OpenGLImageWindow *segResWnd =
vtkWin32OpenGLImageWindow::New();
        vtkWindowToImageFilter *segResWnd2Img;
        vtkImageAppend *segResImgApp = vtkImageAppend::New();
        vtkImageBlend *segResImgBlend = vtkImageBlend::New();
        vtkBMPWriter *segResWriter = vtkBMPWriter::New();
        segResImgApp->SetAppendAxis(2);
        segResImgApp->Update();
        segResWnd->AddImager(segResImager);
        segResWnd->SetSize(MaxCoord[0] + 1, MaxCoord[1] + 1);
        segResWriter->SetFilePrefix((InputDirectory + "SEGRes" +
BMPInputFilePrefix).c_str());
        segResWriter->SetFilePattern("%s_%03d.bmp");
        int n = VFTemplatesRadioGroup->ItemIndex;
        int contour_no = deformSurfsPD[n]->GetNumberOfCells();
        int segRes_point_no;
        int *segRes_ptIds;
        for(int i = 0; i < contour_no; i ++) {
                segRes_point_no =
deformSurfsPD[n]->GetCell(i)->GetNumberOfPoints();
                segRes_ptIds = new int[segRes_point_no + 1];
                for(int j = 0; j < segRes_point_no; j ++) {
                        segRes_ptIds[j] = j;
                }
                segRes_ptIds[segRes_point_no] = 0;
                segResCellArr->Initialize();
                segResCellArr->InsertNextCell(segRes_point_no + 1,
segRes_ptIds);
 
segResPD->SetPoints(deformSurfsPD[n]->GetCell(i)->GetPoints());
                segResPD->SetLines(segResCellArr);
                segResPD->Update();
                segResMapper->SetInput(segResPD);
                segResActor->SetMapper(segResMapper);
                segResImager->AddActor2D(segResActor);
                segResWnd->Render();
                segResWnd2Img = vtkWindowToImageFilter::New();
                segResWnd2Img->SetInput(segResWnd);
                segResWnd2Img->Update();
                segResImgApp->AddInput(segResWnd2Img->GetOutput());
                segResImgApp->Update();
                segResWnd2Img->Delete();
                segResImager->RemoveActor2D(segResActor);
        }
        segResImgBlend->SetInput(0, OrigImgData);
        segResImgBlend->SetInput(1, segResImgApp->GetOutput());
        segResImgBlend->SetOpacity(1, 0.2);
        segResImgBlend->Update();
        segResWriter->SetInput(segResImgBlend->GetOutput());
        segResWriter->Write();
        segResCellArr->Delete();
        segResPD->Delete();
        segResMapper->Delete();
        segResActor->Delete();
        segResImager->Delete();
        segResWnd->Delete();
        segResImgBlend->Delete();
        segResWriter->Delete();
 
BTW. Does anybody know how to accelerate vtkBMPWriter. It takes him
about 20 seconds
for 20 50kB images.
 
Thanks in advance.
 
Ermin 



More information about the vtkusers mailing list