[vtkusers] Scalar data on 2-D plane and how to

Oliver Kania ptw.freiburg at googlemail.com
Wed Aug 6 03:49:57 EDT 2008


Hello fred,
this is a misunderstanding.
You can create the vtkImageData inside
your program by setting each scalar to the correct value:

void makeImage(float p_data[] ,int p_xdim, int p_ydim) {

vtkImageData* m_rawIimageData = vtkImageData::New();
m_rawImageData->SetDimensions(p_xdim,p_ydim,1);
    m_rawImageData->SetScalarTypeToFloat();
    m_rawImageData->SetNumberOfScalarComponents(1);
    m_rawImageData->SetSpacing(1.0,1.0,1.0);
    m_rawImageData->AllocateScalars();

    float* dataPointer = NULL;
    for (int i = 0; i < p_ydim ; ++i) {
        for (int j = 0; j < p_xdim; ++j) {
            float val = p_data[(p_ydim - i - 1)*p_xdim + j];
            dataPointer = (float*) m_rawImageData->GetScalarPointer(j,i,0);
            (*dataPointer) = val;
        }
    }

}

cheers, Oliver

PS: This gives you a vtkImageData which can be used for all
types of operations. Take a look at the examples.

2008/8/6 fred <fredmfp at gmail.com>

> Oliver Kania a écrit :
>
>> Hello,
>> What do you mean by "vti file" ?
>>
> A VTK ImageData file (XML format).
>
>
> Cheers,
>
> --
> Fred
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080806/ddaf8cb3/attachment.htm>


More information about the vtkusers mailing list