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 <<a href="mailto:zemitis.janis@inbox.lv">zemitis.janis@inbox.lv</a>> wrote:<br>
> Dear all,<br>><br>> I have stumbled across a problem with the DataArrays and could use some<br>> help.<br>><br>> The idea is to import a .vtk Legacy format file for visualization within a<br>> different program.<br>
> I do so by giving the User the option to specify the Scalar/Vector/Tensor<br>> field to be imported and copying the contents from the specific array then.<br>> The Array is acquired via dataSet->GetCellData()->GetScalars(array name)<br>
> (for example for scalar).<br>><br>> pImage.reset(new CImage(IMAGE_GREY_F,<br>> CSize(dimension[0],dimension[1],dimension[2])));<br>> for (int i = 0,b=0; i < dimension[2]; i++)<br>> {<br>
> for (int j = 0; j < dimension[1]; j++)<br>> {<br>> for (int k = 0; k < dimension[0]; k++)<br>> {<br>> *reinterpret_cast<float*>(pImage->Buffer().Ptr()<br>
> + i * pImage->Stride().z + j * pImage->Stride().y + k * pImage->Stride().x)<br>> =<br>><br>> vtkDoubleArray::SafeDownCast(dataArray)->GetComponent(b,1);<br>> b++;<br>
><br>> }<br>> }<br>> }<br>><br>> However, the resulting picture seems to have some kind of shift compared to<br>> the original(if check in paraview). Do these Arrays have an offset or<br>
> something else I have to consider(could byte swap cause this)?<br>> Might it be easier and more precise to let vtk distinguish the<br>> Scalars/Tensors/... on a mapper level and then use some export class<br>> (vtkImageExport) instead?<br>
> Any suggestions would be much appreciated.<br>><br>> All the best,<br>> Frable<br>><br>><br>> --<br>> 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>
> Sent from the VTK - Users mailing list archive at Nabble.com.<br>> _______________________________________________<br>> Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>><br>> 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>
><br>> 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>><br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><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>