[vtkusers] SetScalarType refactor

Boxer, Aaron Aaron.Boxer at uhn.ca
Wed Apr 3 15:08:57 EDT 2013


Hello,
I am porting some code to the master branch.

I am passing an existing data set into vtk for rendering.

Since my data set could be either unsigned short or simply short,
the code used to call SetScalarType on the vtkImageData object.

I see that this has been removed.

My question:  will the following code work, or do I need to worry about
data types:

   _vtkVolume = vtkImageData::New();

    _vtkVolume->SetDimensions(volume->ArrayDimensions->Width, volume->ArrayDimensions->Height, volume->ArrayDimensions->Depth);
    _vtkVolume->SetOrigin(volume->Origin->X, volume->Origin->Y, volume->Origin->Z);
    _vtkVolume->SetSpacing(volume->VoxelSpacing->X, volume->VoxelSpacing->Y, volume->VoxelSpacing->Z);

    if (!volume->IsSigned())
    {
            vtkSmartPointer<vtkUnsignedShortArray> dataArray = vtkUnsignedShortArray::New();
            dataArray->SetArray(volume->PinnedAddress, volume->VolumeDataUInt16->Length, 1);
             _vtkVolume->GetPointData()->SetScalars(dataArray);
    }
    else
    {
            vtkSmartPointer<vtkShortArray> dataArray = vtkShortArray::New();
            dataArray->SetArray(volume->PinnedAddress, volume->VolumeDataInt16->Length, 1);
           _vtkVolume->GetPointData()->SetScalars(dataArray);
    }

    // This call is necessary to ensure vtkImageData data's info is correct (e->g-> updates WholeExtent values)
    _vtkVolume->UpdateInformation();




Thanks!

Aaron


This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient. 
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. 
If you have received this e-mail in error, please contact the sender and delete all copies. 
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130403/e2bc3714/attachment.htm>


More information about the vtkusers mailing list