[vtkusers] cast vtkImageData to VtkDataSet

Amy Squillacote amy.squillacote at kitware.com
Wed May 2 13:28:03 EDT 2007


Hi Markus,

Please keep the discussion on the vtkusers mailing list instead of 
emailing me directly.

I've included a couple comments interspersed with your code fragments below.

- Amy

Markus Voigt wrote:
> Hi Amy
>
> I'm using this code:
> vtkJPEGReader *movingReader = vtkJPEGReader::New();
> vtkIterativeClosestPointTransform *icpTransform = 
> vtkIterativeClosestPointTransform::New();
> icpTransform->SetSource( movingReader->GetOutput());
>
> I get the error Message that it isn't possible to cast from 
> vtkJPEGData to vtkDataSet.
> I've tried vtkImageReader instead of using vtkJPEGReader but with the 
> same result. Only the error message is differnet "...not possible to 
> cast from vtkImageData to vtkDataSet.."
>
If the error you're seeing was during compiling, then you probably need 
to include the header file vtkImageData.h in your source code. See the 
following entry in the VTK FAQ: 
http://www.vtk.org/Wiki/VTK_FAQ#The_C.2B.2B_compiler_cannot_convert_some_pointer_type_to_another_pointer_type_in_my_little_program.
> I changed the code to:
> vtkJPEGReader *movingReader = vtkJPEGReader::New();
> vtkIterativeClosestPointTransform *icpTransform = 
> vtkIterativeClosestPointTransform::New();
> icpTransform->SetSource( (vtkDataSet *) movingReader->GetOutput());
>
The above line of code will work, but casting to vtkDataSet* is 
unnecessary because vtkImageData is a subclass of vtkDataSet.
> Now it is compiling but it breaks later (at the Update (last row)):
>
>   vtkTransformPolyDataFilter *resampleMeshFilter = 
> vtkTransformPolyDataFilter::New();
>   resampleMeshFilter->SetInput( (vtkPolyData *) 
> movingReader->GetOutput( ) );
The above line won't work because vtkImageData is not a subclass of 
vtkPolyData. You may be able to use vtkImageReslice (which operates on 
vtkImageData) instead.
>   resampleMeshFilter->SetTransform(icpTransform);
>   //resampleMeshFilter->Update();
>
> Markus
>
>
> Amy Squillacote schrieb:
>> Hi Markus,
>>
>> Actually, vtkImageData is already a vtkDataSet. No conversion is needed.
>>
>> - Amy
>>
>> dirce wrote:
>>> Hi, try to use vtkImageDataGeometryFilter
>>>
>>> Assunto: [vtkusers] cast vtkImageData to VtkDataSet
>>>
>>> Hello,
>>>  
>>> I'm trying to read JPEG-files (vtkImageData) to use them later for
>>> vtkIterativeClosestPointTransform. But there I need vtkDataset. Is 
>>> there any
>>> chance to cast the jpeg-Files to vtkDataset so that I can use the
>>> vtkIterativeClosestPointTransform?
>>> thanks
>>>  
>>> Markus
>>> _______________________________________________
>>> 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
>>>
>>> _______________________________________________
>>> 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
>>>
>>>   
>>
>
>

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106




More information about the vtkusers mailing list