[vtkusers] Is it possible to create a standalone vtkImage in vtk6 ?

David Doria daviddoria at gmail.com
Tue Mar 3 07:48:07 EST 2015


On Tue, Mar 3, 2015 at 7:16 AM, Nigel Mcfarlane <Nigel.Mcfarlane at beds.ac.uk>
wrote:

>  Dear mailing list,
>
>
>
> I am updating a colleague’s code to compile with vtk6.  It contains the
> following lines from vtk4/5, where the programmer is creating a
> vtkStructuredPoints.  The code is not embedded in a vtk filter.  I have
> indicated the lines which do not compile.
>
>
>
> std::cout << "Generating seg volume\n";
>
> vtkStructuredPoints * vol = vtkStructuredPoints::New();
>
> vol->SetDimensions(dim3d);
>
> vol->SetExtent(0, dim3d[0] - 1, 0, dim3d[1] - 1, 0, dim3d[2] - 1);
>
> vol->SetSpacing(spacing[0], spacing[1], spacing[2]);
>
> vol->SetOrigin(0, 0, 0);
>
> vol->SetNumberOfScalarComponents(1); // ERROR
>
> vol->SetScalarTypeToUnsignedChar(); // ERROR
>
> vol->AllocateScalars(); // ERROR
>
>
> vol->GetPointData()->GetScalars()->FillComponent(0,DrEyeLabels::LABEL_NONE);
>
>
>
> I know that SetNumberOfScalarComponents() and
> SetScalarTypeToUnsignedChar() have been replaced in vtk6 with
> SetPointDataActiveScalarInfo(), but this method requires a vtkInformation
> object, and is static, so I can’t see any way to use this outside of a
> RequestInformation() method in a filter.  Is it possible any longer to
> create a standalone vtkImage, or is this class now just a shell which can
> only be configured by a pipeline request?
>
>
>
> Thank you
>
> Nigel McFarlane
>
> University of Bedfordshire, UK
>

The AllocateScalars function has absorbed both the type and number of
components parameters:

imageData->AllocateScalars(VTK_FLOAT, 3);

See this for more details:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Changes_to_Scalars_Manipulation_Functions

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150303/a4f8b041/attachment.html>


More information about the vtkusers mailing list