[vtkusers] SetScalarType refactor

Bill Lorensen bill.lorensen at gmail.com
Wed Apr 3 15:55:55 EDT 2013


Aaron,

What did you code look like ijn VTK5.x?

This is how you would typically do things in VTK6:
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
 image->SetDimensions(10, 10, 10);

#if VTK_MAJOR_VERSION <= 5
  image->SetNumberOfScalarComponents(1);
  image->SetScalarTypeToUnsignedChar();
  image->AllocateScalars();
#else
  image->AllocateScalars(VTK_UNSIGNED_CHAR,1);
#endif




On Wed, Apr 3, 2013 at 3:08 PM, Boxer, Aaron <Aaron.Boxer at uhn.ca> wrote:

>  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.
>
> _______________________________________________
> 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
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130403/8e6be9f4/attachment.htm>


More information about the vtkusers mailing list