[vtkusers] vtkDataArray to C Array problem

Michael Jackson mike.jackson at bluequartz.net
Fri Nov 18 07:59:05 EST 2011


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.

Mike

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

-- 
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111118/0364ed72/attachment.htm>


More information about the vtkusers mailing list