[vtkusers] Confusion

Albion Baucom baucom at biology.ucsc.edu
Thu Nov 25 01:09:54 EST 2004


Why does this code work?

-------------------------------------------------------

vtkSphereSource 	*_sphereSource;
vtkDataSetMapper	*_sphereMapper;

_sphereSource = vtkSphereSource::New();
_sphereSource->SetThetaResolution(SPHERE_RESOLUTION);
_sphereSource->SetPhiResolution(SPHERE_RESOLUTION);

_sphereMapper = vtkDataSetMapper::New();
_sphereMapper->SetInput(_sphereSource->GetOutput());

-------------------------------------------------------

A vtkDataSetMapper has the following method:

void SetInput(vtkDataSet *input);

yet a vtkSphereSource returns the following from the GetOutput() method
since it is subclassed from vtkPolyDataSource

vtkPolyData *GetOutput();

What puzzles me most (well is actually driving me insane >:0) is the code
above is in an example called Animoltion that is available online, and it
compiles. This is a use of vtk in Cocoa, here is the link to the source
code

http://www.macdevcenter.com/mac/2003/02/11/examples/vtk.zip

So, if I try to use this code in my own project I get the following
(expected) error

error: no matching function for call to
'vtkDataSetMapper'::SetInput(vtkPolyData *)

The Animoltion project uses the same VTK version (headers and libriares)
as my project; I have them installed and simply point the paths to the
same directories.

Under what circumstances should a vtkDataSetMapper accept as input a
vtkPolyData? Why would the above code work? I'm confused.

What would be the standard way to render a sphere in a VTK view? I have
been trying to use vtkPolyDataNormals to compute point normals from the
sphereSource, and then pass the normal to a vtkPolyDataMapper, but that
never displays my spheres.

Any help would be greatly appreciated.

Thanks

Albion

Albion E. Baucom
http://rna.ucsc.edu/albion



More information about the vtkusers mailing list