[vtkusers] Problem upgrading from VTK 3.2 to VTK 4.0

anast.jm at pg.com anast.jm at pg.com
Thu Feb 21 12:46:46 EST 2002


Have you tried...

w2if Modified


                                                                
 Internet Mail Message                                          
 Received from host:      public.kitware.com                    
 [208.136.18.25]                                                
                                                                


From: Joey Mukherjee <joey at phobos.space.swri.edu>@public.kitware.com on
02/21/2002 10:40 AM CST
                                                                                                      
     Joey Mukherjee <joey at phobos.space.swri.edu>           To:   vtkusers at public.kitware.com          
                             @public.kitware.com           Cc:    (bcc: John Anast-JM/PGI)            
                                                   Subject:      [vtkusers] Problem upgrading from    
                                                        VTK 3.2 to VTK 4.0                            
     Sent by:  vtkusers-admin at public.kitware.com                                                      
                             02/21/2002 11:40 AM                                                      
                Please respond to Joey Mukherjee                                                      
                    <joey at phobos.space.swri.edu>                                                      
                                                                                                      




I am upgrading my application from VTK 3.2 to VTK 4.0, and one feature that was
removed was the SaveFileAsPPM and now it uses vtkWindowToImageFilter and
vtkPNMWriter.

My problem is I am trying to make an animation so I do a rotation over one of
the axes and after each rotation, I save the file as a PPM.

Unfortunately, the vtkWindowToImageFilter/vtkPNMWriter only writes the first
image and not the new re-rendered ones.

However, if I do a New for the vtkWindowToImageFilter/vtkPNMWriter in the loop,
everything works, but is slow.

I feel an Update somewhere might solve the problem, but I can not tell where.
Is there a way to do this without having to create the
vtkWindowToImageFilter/vtkPNMWriter each time?

Also, I am using the VTK 4.0 release, not the nightly, so if this has already
been changed, please let me know.

Here is the code for what I am trying to do:

    float delta = 360.0 / nsteps;
    int n = 0;
    char filename [255];
    vtkCamera    *camera = _renderer->GetActiveCamera();

    _renWin->SetSize (hsize, vsize);

    vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New ();
    w2if->SetInput (_renWin);

    vtkPNMWriter *pnmw = vtkPNMWriter::New ();
    pnmw->SetInput (w2if->GetOutput ());

    while (n < nsteps) {
        n++;
        sprintf (filename, "%s_%03d.ppm", basename, n);
        _renWin->Render ();


// I expected this to work, but it doesn't

        w2if->Update ();

        pnmw->SetFileName (filename);
        pnmw->Write ();

        switch (whichAxis) {
            case 0 : camera->Azimuth (delta); break;
            case 1 : camera->Elevation (delta); break;
            case 2 : camera->SetRoll (delta); break;
        }
    }
    pnmw->Delete ();
    w2if->Delete ();

Joey

+--------------------------------------------------------------------------+
+                                                                          +
+     Joey Mukherjee                 "The price of freedom is eternal      +
+     joey at swri.org                   vigilance, or $12.50 as seen on      +
+                                     E-Bay...                             +
+                                                                          +
+--------------------------------------------------------------------------+


_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers






More information about the vtkusers mailing list