[vtkusers] from cosmo to png without user interaction

Sebastien Jourdain sebastien.jourdain at kitware.com
Thu Mar 10 07:56:46 EST 2011


Hi Ula,

you can use ParaView and with the python scripting interface, you
should be able to automated that process for all your files.
Start paraview, start python trace, do your processing for one file,
do the capture, then show trace.
This will show the python code that was needed for the whole process.
Then, you will just need to change the reader filename, and request a
new image capture for each new file that you may set inside a for loop
in python.

Seb

On Thu, Mar 10, 2011 at 12:25 AM, Ula Popov <ula.popov at gmail.com> wrote:
> Hello all,
>
> I have 5000 cosmo files that I need to visualize and save each as a .png
> file.
>
> If I had one file, I'd
> 1. open it in paraview
> 2. choose glyph filter
> 3. choose
>      vector : velocity
>      glyph type: arrow
>      color by: glyphVector
> 4. press "reset" button
> 5. adjust camera -> azimuth (XX)
> 6. File->Save ScreenShot
> 7. type "output_filename"
>
> I need to automate this process, but I don't know how.
> I do know how to read cosmo file into unstructured grid,
> how to create a window, but i don't know how to set
> all these parameters and save an image.
>
>
> int main ()
> {
>     vtkUnstructuredGrid *data;
>     vtkSmartPointer<vtkCosmoReader> reader =
> vtkSmartPointer<vtkCosmoReader>::New();
>
>     reader->SetFileName("input_filename.cosmo");
>     reader->Update();
>     data = reader->GetOutput(0);
>
>     vtkSmartPointer<vtkUnstructuredGridGeometryFilter> geometryFilter =
> vtkSmartPointer<vtkUnstructuredGridGeometryFilter>::New();
>     geometryFilter->SetInputConnection(data->GetOutputPort());
>     geometryFilter->Update();
>
>     //Create a mapper and actor
>     vtkSmartPointer<vtkDataSetMapper> mapper =
> vtkSmartPointer<vtkDataSetMapper>::New();
>     mapper->SetInputConnection(geometryFilter->GetOutputPort());
>     vtkSmartPointer<vtkActor> actor =  vtkSmartPointer<vtkActor>::New();
>     actor->SetMapper(mapper);
>
>     // a renderer and render window
>    vtkRenderer *ren = vtkRenderer::New();
>    vtkRenderWindow *renWin = vtkRenderWindow::New();
>    renWin->AddRenderer(ren);
>
>    // an interactor
>    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>    iren->SetRenderWindow(renWin);
>
>    // add the actor to the scene
>    ren->AddActor(actor);
>    ren->SetBackground(1,1,1); // Background color white
>
>    renWin->Render();
>
>   // begin mouse interaction
>    iren->Start();
>
>   ren1->Delete();
>   renWin->Delete();
>   iren->Delete();
>   return EXIT_SUCCESS;
> }
>
>
> Any ideas, suggestions, code examples are highly appreciated,
> ula
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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