[vtkusers] vtk data type inconsistent

Obada Mahdi omahdi at gmx.de
Tue Oct 31 06:18:57 EST 2006


Hi Wenyu,

you need to add
#include "vtkStructuredGrid.h"
somewhere at the beginning of your example source.

On 10/31/06, 付文宇 <fuwenyu at emails.bjut.edu.cn> wrote:
> hi all
>    I am a fresher here. Now I am learning 3d image reconstructing by vtk in MS
> VC++6.0. I encounter a question now. When I do exercise followed by the example in
> "vtk-5.0.2\VTK\Examples\Annotation\Tcl\xyPlot.tcl"(I have changed Tcl code into
> c++),there are three errors in compiling(the type of three errors is same).The
> error information is:
>
> --------------------Configuration: xyPlot - Win32 Debug--------------------
> Compiling...
> xyPlot.cxx
> D:\fwy\xyPlot\xyPlot.cxx(73) : error C2664: 'SetSource' : cannot convert parameter
> 1 from 'class vtkStructuredGrid *' to 'class vtkDataObject *'
>         Types pointed to are unrelated; conversion requires reinterpret_cast,
> C-style cast or function-style cast
> .....

The problem with the compiler not recognizing vtkStructuredGrid as a
descendant of vtkDataObject (which is actually is) in your example
stems from the use of "shallow" class forward declarations in VTK
header files.  Many referenced classes are introduced just by name
instead of with their whole declaration (by including the
corresponding header files), which reduces the preprocessor's workload
and thus overall compile time.

Once a class whose name was implicitly introduced by another header
file is being dereferenced or otherwise "worked" with, it is necessary
to include the actual header containing the full declaration in order
to satisfy the compiler.


Regards

Obada



More information about the vtkusers mailing list