Legacy vtk files written in binary are big endianness formatted. So if you are reading the file onto a little endian machine you will need to byte swap the values. <br><br>Mike <br><br>On Friday, November 18, 2011, Frable &lt;<a href="mailto:zemitis.janis@inbox.lv">zemitis.janis@inbox.lv</a>&gt; wrote:<br>
&gt; Dear all,<br>&gt;<br>&gt; I have stumbled across a problem with the DataArrays and could use some<br>&gt; help.<br>&gt;<br>&gt; The idea is to import a .vtk Legacy format file for visualization within a<br>&gt; different program.<br>
&gt; I do so by giving the User the option to specify the Scalar/Vector/Tensor<br>&gt; field to be imported and copying the contents from the specific array then.<br>&gt; The Array is acquired via dataSet-&gt;GetCellData()-&gt;GetScalars(array name)<br>
&gt; (for example for scalar).<br>&gt;<br>&gt; pImage.reset(new CImage(IMAGE_GREY_F,<br>&gt; CSize(dimension[0],dimension[1],dimension[2])));<br>&gt;                for (int i = 0,b=0; i &lt; dimension[2]; i++)<br>&gt;                {<br>
&gt;                    for (int j = 0; j &lt; dimension[1]; j++)<br>&gt;                    {<br>&gt;                        for (int k = 0; k &lt; dimension[0]; k++)<br>&gt;                        {<br>&gt;                            *reinterpret_cast&lt;float*&gt;(pImage-&gt;Buffer().Ptr()<br>
&gt; + i * pImage-&gt;Stride().z + j * pImage-&gt;Stride().y + k * pImage-&gt;Stride().x)<br>&gt; =<br>&gt;<br>&gt; vtkDoubleArray::SafeDownCast(dataArray)-&gt;GetComponent(b,1);<br>&gt;                            b++;<br>
&gt;<br>&gt;                        }<br>&gt;                    }<br>&gt;                }<br>&gt;<br>&gt; However, the resulting picture seems to have some kind of shift compared to<br>&gt; the original(if check in paraview). Do these Arrays have an offset or<br>
&gt; something else I have to consider(could byte swap cause this)?<br>&gt; Might it be easier and more precise to let vtk distinguish the<br>&gt; Scalars/Tensors/... on a mapper level and then use some export class<br>&gt; (vtkImageExport) instead?<br>
&gt; Any suggestions would be much appreciated.<br>&gt;<br>&gt; All the best,<br>&gt; Frable<br>&gt;<br>&gt;<br>&gt; --<br>&gt; View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkDataArray-to-C-Array-problem-tp5004171p5004171.html">http://vtk.1045678.n5.nabble.com/vtkDataArray-to-C-Array-problem-tp5004171p5004171.html</a><br>
&gt; Sent from the VTK - Users mailing list archive at Nabble.com.<br>&gt; _______________________________________________<br>&gt; Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>&gt; Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;<br><br>-- <br>_________________________________________________________<br>Mike Jackson                  <a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a><br>BlueQuartz Software                    <a href="http://www.bluequartz.net">www.bluequartz.net</a><br>
Principal Software Engineer                  Dayton, Ohio<br>