[vtkusers] error C2664: 'SetInput' : cannot convert parameter 1 from 'class vtkImageData *'

François Bertel francois.bertel at kitware.com
Tue Jul 26 11:09:01 EDT 2005


As this question is the number one question on the mailing list, I've
just added a new entry in the 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

David Cole wrote:
> #include "vtkImageData.h"
> 
> Ramisetti Srinivas wrote:
> 
>>
>> hi ,
>> I am new to VTK.....
>> I encountered a problem using this code,when comiled with VC++6...
>> here is my code and the error....
>> plz help me
>>
>>
>> // First include the required header files for the VTK classes we are
>> using.
>> #include "vtkConeSource.h"
>> #include "vtkPolyDataMapper.h"
>> #include "vtkRenderWindow.h"
>> #include "vtkRenderWindowInteractor.h"
>> #include "vtkCamera.h"
>> #include "vtkActor.h"
>> #include "vtkRenderer.h"
>> #include "vtkInteractorStyleTrackballCamera.h"
>> #include "vtkElevationFilter.h"
>> #include "vtkSphereSource.h"
>> #include "vtkQuadric.h"
>> #include "vtkPlane.h"
>> #include "vtkSampleFunction.h"
>> #include "vtkCutter.h"
>> int main( int argc, char *argv[] )
>> {
>>  vtkQuadric *quadric=vtkQuadric::New();
>>  quadric->SetCoefficients(.5 ,1, .2, 0, .1, 0, 0, .2, 0, 0);
>>
>>  vtkSampleFunction * data =vtkSampleFunction::New();
>>  data->SetSampleDimensions(30, 30, 30);
>>  data->SetImplicitFunction(quadric);
>>
>>  vtkPlane *plane=vtkPlane::New();
>>   //# eval plane SetOrigin [[data GetOutput] GetCenter]
>>    plane->SetOrigin( 0, 0, .2);
>>    plane->SetNormal( -0.287, 0, 0.9579);
>>
>>     vtkCutter *planeCut=vtkCutter::New();
>>    planeCut->SetInput(data->GetOutput());
>>    planeCut->SetCutFunction(plane);
>>
>>     vtkPolyDataMapper *cutMapper=vtkPolyDataMapper::New();
>>    cutMapper->SetInput (planeCut->GetOutput());
>> //#    eval cutMapper SetScalarRange \
>> //#      [[[[data GetOutput] GetPointData] GetScalars] GetRange]
>>     vtkActor *cutActor=vtkActor::New();
>>    cutActor->SetMapper (cutMapper);
>>     //ren1 AddActor cutActor
>>  vtkRenderer *ren1= vtkRenderer::New();
>>  ren1->AddActor( cutActor );
>>  ren1->SetBackground( 0.1, 0.2, 0.4 );
>>  vtkRenderWindow *renWin = vtkRenderWindow::New();
>>  renWin->AddRenderer( ren1 );
>>  renWin->SetSize( 300, 300 );
>>
>>  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>>  iren->SetRenderWindow(renWin);
>>
>>  vtkInteractorStyleTrackballCamera *style =
>>    vtkInteractorStyleTrackballCamera::New();
>>  iren->SetInteractorStyle(style);
>>
>>  iren->Initialize();
>>  iren->Start();
>>
>>  cone->Delete();
>>  ren1->Delete();
>>  renWin->Delete();
>>  iren->Delete();
>>  style->Delete();
>>
>>  return 0;
>> }
>>
>>
>>
>>
>> The following is my error:
>>
>> --------------------Configuration: Cone5 - Win32
>> Debug--------------------
>> Compiling...
>> Cone5.cxx
>> C:\Documents and Settings\Srinivas\Desktop\step\Cone5.cxx(99) : error
>> C2664: 'SetInput' : cannot convert parameter 1 from 'class
>> vtkImageData *' to 'class vtkDataSet *'
>>        Types pointed to are unrelated; conversion requires
>> reinterpret_cast, C-style cast or function-style cast
>> Error executing cl.exe.
>>
>> Cone5.exe - 1 error(s), 0 warning(s)
>>
>> _________________________________________________________________
>> 7000 classifieds
>> http://www.sulekha.com/classifieds/cllist.aspx?nma=IN&ref=msn
>> -Chennai, Mumbai, Hyderabad Bangalore.
>>
>> _______________________________________________
>> 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
> 


-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list