<div dir="ltr">My guess is that the PNG writer expect three components, not a single component array. vtkImageAppendComponents would be one way to make a three tuple, but it would be more straightforward to do it in the array construction with<div>SetNumberOfComponents(3) followed by</div><div>yourloop {</div><div>   InsertNextTuple3(Tint,Tint,Tint);</div><div>}<br><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>David E DeMarle<br>Kitware, Inc.<br>Principal Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4909</div></div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Jan 16, 2018 at 3:49 AM, Stephan Lenz <span dir="ltr"><<a href="mailto:stephan.lenz@tu-bs.de" target="_blank">stephan.lenz@tu-bs.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everybody,<br>
<br>
I have problems setting up a pipeline to write data to an PNG-file.<br>
<br>
I have a 2-D simulation on a large rectangular non-uniform grid ( ~60.000.000 Cells ). For visualization of the results I would like to write PNG files (or other Imagefiles) in order to create an animation.<br>
<br>
I am already able to write VTK-ImageData files (.vti) and make an animation in Paraview. Nevertheless I would prefer to generate the animation directly from images, as the simulation domain should fill the whole animation domain. With paraview fitting the simulation domain seamlessly in the view is not trivial.<br>
<br>
My current pipeline is:<br>
<br>
          // this adapter function couples my simulation datastructures to VTK<br>
            vtkSmartPointer<vtkUnstructure<wbr>dGrid> grid = getVtkUnstructuredGrid(dataBas<wbr>e);<br>
<br>
            // generate the field data<br>
            vtkSmartPointer<vtkUnsignedCha<wbr>rArray> data = vtkSmartPointer<vtkUnsignedCha<wbr>rArray>::New();<br>
            data->SetNumberOfComponents( 1 );<br>
            data->SetName( "T" );<br>
            for( Idx cellIdx = 0; cellIdx < numberOfCells; cellIdx++ ){<br>
                unsigned char value = getValue( cellIdx );<br>
                data->InsertNextValue( Tint );<br>
            }<br>
            grid->GetCellData()->AddArray( data );<br>
<br>
            // define the grid for the output<br>
            vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>:<wbr>:New();<br>
            image->SetDimensions(512+1,256<wbr>+1,1);<br>
            image->SetSpacing( L/512, H/256, 0 );<br>
<br>
            // resample the field data to the coarser vtkImageData<br>
            vtkSmartPointer<vtkResampleWit<wbr>hDataSet> resample = vtkSmartPointer<vtkResampleWit<wbr>hDataSet>::New();<br>
            resample->SetSourceData( grid );<br>
            resample->SetInputData( image );<br>
<br>
            // write the data to PNG-file (does not work!)<br>
            vtkSmartPointer<vtkPNGWriter> writerPNG = vtkSmartPointer<vtkPNGWriter>:<wbr>:New();<br>
            writerPNG->SetFileName( ( simulationName + ".png").c_str() );<br>
            writerPNG->SetInputData( resample->GetOutput() );<br>
            writerPNG->Write();<br>
<br>
            // write the data to VTI-file (works!)<br>
            vtkSmartPointer<vtkXMLImageDat<wbr>aWriter> writer = vtkSmartPointer<vtkXMLImageDat<wbr>aWriter>::New();<br>
            writer->SetFileName( ( simulationName + "." + writer->GetDefaultFileExtensio<wbr>n() ).c_str() );<br>
            writer->SetDataMode( vtkXMLWriter::Binary );<br>
            writer->SetInputData( resample->GetOutput() );<br>
            writer->Write();<br>
<br>
The above code compiles and runs without errors, but I do not get any PNG-Files. The VTI-files are written and I can open them in Paraview, as usual. I tried many different things, but did not get single PNG-file out of this.<br>
<br>
When I, for example, change<br>
<br>
writerPNG->SetInputData( resample->GetOutput() );<br>
<br>
to<br>
<br>
writerPNG->SetInputConnection( resample->GetOutputPort() );<br>
<br>
I get a VTK Error message, that says "PNGWriter only supports unsigned char and unsigned short inputs". But as far as I see it the field data is unsigned char and this is confirmed by Paraview, when I look into the VTI-files (generated with both SetInputData and SetInputConnection).<br>
<br>
Do you see any obvious mistakes I make? How do I have to set up such a pipeline to get a PNG (or other image file) output. I would be glad for any help.<br>
<br>
Thank you very much,<br>
<br>
Stephan Lenz<br>
<br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/listin<wbr>fo/vtkusers</a><br>
</blockquote></div><br></div>