[vtkusers] program error

胡正珲 zhengh.hu at gmail.com
Wed Jan 17 09:33:07 EST 2007


To all vtkuser:

       i am a VTK novice, i have the following program, but it has the
following wrong.

D:\C PROGRAM\test\test.cpp(53) : error C2664: 'void __thiscall
vtkImageBlend::SetInput(int,class vtkDataObject *)' : cannot convert
parameter 2 from 'class vtkImageData *' to 'class vtkDataObject *'
        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
D:\C PROGRAM\test\test.cpp(54) : error C2664: 'void __thiscall
vtkImageBlend::SetInput(int,class vtkDataObject *)' : cannot convert
parameter 2 from 'class vtkImageData *' to 'class vtkDataObject *'
        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

test.obj - 2 error(s), 0 warning(s)

 How should i do? anyone can give me some advices? thank you in advance.

//============================
============================================================================

#include "vtkImageGridSource.h"
#include "vtkBMPReader.h"
#include "vtkImageBlend.h"
#include "vtkImageViewer.h"
#include "vtkImageGaussianSmooth.h"
#include "vtkImageMathematics.h"

int main()
{

   vtkImageGridSource *imageGrid = vtkImageGridSource::New();
   imageGrid->SetGridSpacing(16, 16, 0);
   imageGrid->SetGridOrigin(0, 0, 0);
   imageGrid->SetDataExtent(0, 255, 0, 255, 0, 0);
   imageGrid->SetLineValue(4095);
   imageGrid->SetFillValue(0);
   imageGrid->SetDataScalarTypeToShort();

   vtkBMPReader *bmpReader = vtkBMPReader::New();
   bmpReader->SetFileName("aaa10.bmp");

   vtkImageBlend *blend = vtkImageBlend::New();
   blend->SetOpacity(0, 0.5);
   blend->SetOpacity(1, 0.5);
   blend->AddInput(0, imageGrid->GetOutput());
   blend->AddInput(1, bmpReader->GetOutput());

   vtkImageViewer *viewer = vtkImageViewer::New();
   viewer->SetInput(blend->GetOutput());
   viewer->SetColorWindow(1000);
   viewer->SetColorLevel(500);
   viewer->Render();

   imageGrid->Delete();
   bmpReader->Delete();
   blend->Delete();
   viewer->Delete();


return 0;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070117/726543a2/attachment.htm>


More information about the vtkusers mailing list