[vtkusers] weird behaviour of BackgroundImage example on Wiki

Giancarlo Amati ilferraresebono at hotmail.it
Thu Mar 18 12:53:57 EDT 2010


Hello Guys, so my probelm is this one:

I load a list of jpeg contained in qImgList. Each of them will be the wallpaper of my rendering window. now.. ... I have a weird problem. If I keep the code as it is...well everything works for the first image. 
Now, if i take the statements (A),(B),(C) (see below) inside the loop for at level (AA): everything stop working. Can anybody enlight me please?

Thanks. GC.

if(qImgList.size() != 0) {
        this->mI_vtkImageAct = this->mv_vtkImageActor.begin();

        cout << "N images: " << qImgList.size();
        
        vtkSmartPointer<vtkJPEGReader> jpegReader = vtkSmartPointer<vtkJPEGReader>::New();
//            itImg = qImgList.begin();         
(AA)        for(itImg = qImgList.begin(); itImg!= qImgList.end(); ++itImg) {
            
            jpegReader->SetFileName((*itImg).toAscii().data());

            vtkSmartPointer<vtkImageActor> imgAct =  vtkSmartPointer<vtkImageActor>::New();
            imgAct->SetInput(jpegReader->GetOutput());
            
            mv_vtkImageActor.push_back(imgAct);
        }


        vtkSmartPointer<vtkRenderWindow> renderWindow = mp_VTKwidget->GetRenderWindow();
        rendererIMG->SetLayer(0);
        rendererIMG->InteractiveOff();

        renderer->SetLayer(1);
        renderWindow->SetNumberOfLayers(2);
        renderWindow->AddRenderer(rendererIMG);
        renderWindow->AddRenderer(renderer);
        
        mI_vtkImageAct =  mv_vtkImageActor.begin();

        rendererIMG->AddActor((*mI_vtkImageAct));

        renderWindow->Render();

        vtkSmartPointer<vtkCamera> tmpCam = rendererIMG->GetActiveCamera();
        tmpCam->ParallelProjectionOn();

 (A)       jpegReader->GetOutput()->GetOrigin( origin );
 (B)      jpegReader->GetOutput()->GetSpacing( spacing );
 (C)       jpegReader->GetOutput()->GetExtent( extent );

        xc = origin[0] + 0.5*(extent[0] + extent[1])*spacing[0];
        yc = origin[1] + 0.5*(extent[2] + extent[3])*spacing[1];
        xd = (extent[1] - extent[0] + 1)*spacing[0];
        yd = (extent[3] - extent[2] + 1)*spacing[1];
        d = tmpCam->GetDistance();

        tmpCam->SetParallelScale(0.5*yd);
        tmpCam->SetFocalPoint(xc,yc,0.0);
        tmpCam->SetPosition(xc,yc,d);


        renderWindow->Render(); 		 	   		  
_________________________________________________________________
Scatta, ritocca e condividi le tue foto online. Gratis per te
http://www.windowslive.it/foto.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100318/886a0c7e/attachment.htm>


More information about the vtkusers mailing list