[vtkusers] Save vtkChartXY to PNG

Jakub Poła jakub.pola at gmail.com
Thu Oct 25 03:34:21 EDT 2012


Hello Alex,

I found as well the OffScreenRendering option. To make it work I had to 
install osmesa (8.0.4 Ubuntu 12.04) and compile paraview 3.14-1 with 
option VTK_OPENGL_HAS_OSMESA set to ON.
Then in my code I have following set of instructions:

vtkSmartPointer<vtkGraphicsFactory> graphics_factory =
             vtkSmartPointer<vtkGraphicsFactory>::New();
     graphics_factory->SetOffScreenOnlyMode( 1);
     graphics_factory->SetUseMesaClasses( 1 );

     vtkSmartPointer<vtkImagingFactory> imaging_factory =
             vtkSmartPointer<vtkImagingFactory>::New();
     imaging_factory->SetUseMesaClasses( 1 );

     VTK_CREATE(vtkRenderWindow, renderWindow);
     renderWindow->AddRenderer(view->GetRenderer());
     renderWindow->SetOffScreenRendering(1);
     renderWindow->Render();
     VTK_CREATE(vtkWindowToImageFilter, windowToImageFilter);
     windowToImageFilter->SetInput(renderWindow);
     windowToImageFilter->Update();

     VTK_CREATE(vtkPNGWriter, pngWriter);
     pngWriter->SetFileName("ble.png");
     pngWriter->SetInput(windowToImageFilter->GetOutput());
     pngWriter->Write();


When program reach instruction renderWindow->Render,  the segmentation 
fault occurs. It is caused by code from vtkOpenGLExtensionManager.
First one is at the line 567 (version is NULL):
const char *version =
     reinterpret_cast<const char *>(glGetString(GL_VERSION));

Version seems to be NULL therefore I applied patch according to this bug 
description:
http://paraview.org/Bug/bug_relationship_graph.php?bug_id=8554&graph=relation

Then segmentation fault comes from vtkOpenGLContextDevice2D::LoadExtensions
const char *gl_version =
       reinterpret_cast<const char *>(glGetString(GL_VERSION));
     const char *mesa_version = strstr(gl_version, "Mesa");
     if (mesa_version != 0)
       {
       supported = false;
       }
     }
this time gl_version is NULL:

Does anyone having similar behaviour. Am I missing something?
I've attached glxinfo -s log if someone is curious, and my version of 
system is Ubuntu 12.04:
Linux 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 
x86_64 x86_64 x86_64 GNU/Linux

Thank you in advance for any help.
Jakub

On 10/25/2012 03:39 AM, Alex Malyushytskyy wrote:
 > Actually I take it back, I am not sure this would work when system is
 > not able to support X11.
 >
 > Alex
 >
 > On Wed, Oct 24, 2012 at 6:33 PM, Alex Malyushytskyy
 > <alexmalvtk at gmail.com> wrote:
 >> You can forcevtk use an offscreen rendering:
 >> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering
 >>
 >> Alex
 >>
 >> On Wed, Oct 24, 2012 at 6:29 AM, Jakub Poła <jakub.pola at gmail.com> 
wrote:
 >>>
 >>> Thank you for your help Jothy. This filter is working but I have to 
create
 >>> renderWindow and call at least once Render() method to obtain 
proper output
 >>> data from vtkWindowToImageFilter. I would like to omit render 
window and go
 >>> directly from vtkChartXY to PNG ( Let  assume that there is no X11 
support
 >>> on the machine where program will work), but I suppose that it is not
 >>> possible easily.
 >>>
 >>>
 >>>
 >>>
 >>> On 10/24/2012 01:55 PM, Jothybasu Selvaraj wrote:
 >>>>
 >>>> Here you go
 >>>>
 >>>> vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
 >>>> vtkSmartPointer<vtkWindowToImageFilter>::New();
 >>>> windowToImageFilter->SetInput(this->view->GetRenderWindow());
 >>>>      windowToImageFilter->Update();
 >>>>
 >>>>
 >>>>      vtkSmartPointer<vtkPNGWriter> writer =
 >>>> vtkSmartPointer<vtkPNGWriter>::New();
 >>>>      writer->SetFileName("FileName");
 >>>> writer->SetInput(windowToImageFilter->GetOutput());
 >>>>      writer->Write();
 >>>>
 >>>> Jothy
 >>>>
 >>>> On Wed, Oct 24, 2012 at 12:52 PM, Jakub Poła 
<jakub.pola at gmail.com> wrote:
 >>>>>
 >>>>> Good Morning,
 >>>>>
 >>>>> I have question related to create charts in vtk. Is it possible 
to save
 >>>>> chart as png image without creating the snapshot of window like in
 >>>>> paraview?
 >>>>> I would like to write a batch program which aims to analyze large 
data
 >>>>> set
 >>>>> and creates series of charts.
 >>>>> I have vtkTable feeded by the vtkExtractArraysOverTime filter, then
 >>>>> basing
 >>>>> on this table I would like to create chart object which I would 
like save
 >>>>> as
 >>>>> PNG image.
 >>>>>
 >>>>> Thank you very much for your support.
 >>>>> Jakub
 >>>>>
 >>>>> --
 >>>>> Pozdrawiam,
 >>>>> Jakub Poła
 >>>>>
 >>>>> _______________________________________________
 >>>>> 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
 >>>>
 >>>>
 >>>>
 >>>
 >>>
 >>> --
 >>> Pozdrawiam,
 >>> Jakub Poła
 >>>
 >>> _______________________________________________
 >>> 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
 > _______________________________________________
 > 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


-- 
Pozdrawiam,
Jakub Poła

On 10/25/2012 03:39 AM, Alex Malyushytskyy wrote:
> Actually I take it back, I am not sure this would work when system is
> not able to support X11.
>
> Alex
>
> On Wed, Oct 24, 2012 at 6:33 PM, Alex Malyushytskyy
> <alexmalvtk at gmail.com> wrote:
>> You can forcevtk use an offscreen rendering:
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering
>>
>> Alex
>>
>> On Wed, Oct 24, 2012 at 6:29 AM, Jakub Poła <jakub.pola at gmail.com> wrote:
>>> Thank you for your help Jothy. This filter is working but I have to create
>>> renderWindow and call at least once Render() method to obtain proper output
>>> data from vtkWindowToImageFilter. I would like to omit render window and go
>>> directly from vtkChartXY to PNG ( Let  assume that there is no X11 support
>>> on the machine where program will work), but I suppose that it is not
>>> possible easily.
>>>
>>>
>>>
>>>
>>> On 10/24/2012 01:55 PM, Jothybasu Selvaraj wrote:
>>>> Here you go
>>>>
>>>> vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
>>>>               vtkSmartPointer<vtkWindowToImageFilter>::New();
>>>>       windowToImageFilter->SetInput(this->view->GetRenderWindow());
>>>>       windowToImageFilter->Update();
>>>>
>>>>
>>>>       vtkSmartPointer<vtkPNGWriter> writer =
>>>>               vtkSmartPointer<vtkPNGWriter>::New();
>>>>       writer->SetFileName("FileName");
>>>>       writer->SetInput(windowToImageFilter->GetOutput());
>>>>       writer->Write();
>>>>
>>>> Jothy
>>>>
>>>> On Wed, Oct 24, 2012 at 12:52 PM, Jakub Poła <jakub.pola at gmail.com> wrote:
>>>>> Good Morning,
>>>>>
>>>>> I have question related to create charts in vtk. Is it possible to save
>>>>> chart as png image without creating the snapshot of window like in
>>>>> paraview?
>>>>> I would like to write a batch program which aims to analyze large data
>>>>> set
>>>>> and creates series of charts.
>>>>> I have vtkTable feeded by the vtkExtractArraysOverTime filter, then
>>>>> basing
>>>>> on this table I would like to create chart object which I would like save
>>>>> as
>>>>> PNG image.
>>>>>
>>>>> Thank you very much for your support.
>>>>> Jakub
>>>>>
>>>>> --
>>>>> Pozdrawiam,
>>>>> Jakub Poła
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>> --
>>> Pozdrawiam,
>>> Jakub Poła
>>>
>>> _______________________________________________
>>> 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
> _______________________________________________
> 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


-- 
Pozdrawiam,
Jakub Poła

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121025/eab21a9b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glxextensions.log
Type: text/x-log
Size: 52626 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121025/eab21a9b/attachment.bin>


More information about the vtkusers mailing list