[vtkusers] vtkDataArray to C Array problem

Frable zemitis.janis at inbox.lv
Fri Nov 18 07:40:37 EST 2011


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.



More information about the vtkusers mailing list