[vtkusers] VTK Examples and C++

Mathieu Malaterre mathieu.malaterre at kitware.com
Tue Jun 15 09:49:11 EDT 2004


Almost there :)

You just need:

#include "vtkPolyData.h"

HTH
Mathieu


Nick Arini wrote:
> 
> Dear VTK Users,
> 
> I am learning VTK by example. I am however not at all experienced in Tcl 
> or Python. There are not a great many C++ examples in VTK/Examples.
> 
> My assumption therefore was that I could read the Tcl code and convert 
> it directly to C++. I have for example done that for the Tcl example 
> mentioned on pp391 of the VTK book:
> 
> Examples/VisualizationAlgorithms/Tcl/imageWarp.tcl
> 
> I converted this line for line into what I thought was equivalent C++ 
> code (see below), however the objects don't seem to be compatible as 
> C++. The compiler errors describing mismatched prototypes is also pasted 
> in below.
> 
> What is the difference if any between VTK code written in Tcl (or 
> python) and pure C++? (Or what have I done bad?)
> 
> Why are there so few C++ examples in VTK/Examples?
> 
> Is there any interest in more C++ examples?
> 
> 
> Best regards and thanks,
> 
> Nick
> 
> 
> <begin Tcl>
> 
> vtkBMPReader reader
>   reader SetFileName $VTK_DATA_ROOT/Data/masonry.bmp
> 
> vtkImageLuminance luminance
>   luminance SetInput [reader GetOutput]
> 
> vtkImageDataGeometryFilter geometry
>   geometry SetInput [luminance GetOutput]
> 
> vtkWarpScalar warp
>   warp SetInput [geometry GetOutput]
>   warp SetScaleFactor -0.1
> 
> vtkMergeFilter merge
>   merge SetGeometry [warp GetOutput]
>   merge SetScalars  [reader GetOutput]
> 
> vtkDataSetMapper mapper
>   mapper SetInput [merge GetOutput]
>   mapper SetScalarRange 0 255
>   mapper ImmediateModeRenderingOff
> 
> <end Tcl>
> 
> 
> <begin C++>
> 
> #include <vtkTIFFReader.h>
> #include <vtkImageLuminance.h>
> #include <vtkImageDataGeometryFilter.h>
> #include <vtkWarpScalar.h>
> #include <vtkMergeFilter.h>
> #include <vtkDataSetMapper.h>
> 
> int main( int argc, char * argv[] )
> {
> 
>   vtkTIFFReader *reader = vtkTIFFReader::New();
>   reader->SetFilePrefix("test.tif");
>   reader->SetFilePattern("%s");
>  
>   vtkImageLuminance *luminance = vtkImageLuminance::New();
>   luminance->SetInput( reader->GetOutput() );
>  
>   vtkImageDataGeometryFilter *geometry = vtkImageDataGeometryFilter::New();
>   geometry->SetInput( luminance->GetOutput() );
> 
>   vtkWarpScalar *warp = vtkWarpScalar::New();
>   warp->SetInput( geometry->GetOutput() );
>   warp->SetScaleFactor( -0.1 );
> 
>   vtkMergeFilter *merge = vtkMergeFilter::New();
>   merge->SetGeometry( warp->GetOutput() );
>   merge->SetScalars( reader->GetOutput() );
> 
>   vtkDataSetMapper *mapper = vtkDataSetMapper::New();
>   mapper->SetInput( merge->GetOutput() );
>   mapper->SetScalarRange( 0, 255 );
>   mapper->ImmediateModeRenderingOff();
> 
>   return 0;
> }
> 
> <end C++>
> 
> 
> <begin compiler>
> 
> [nicha at localhost Linux_x86]$ make
> Building dependencies cmake.check_depends...
> -- Loading VTK CMake commands
> -- Loading VTK CMake commands - done
> Building object file vtkimage.o...
> /home/nicha/vtkimage/vtkimage.cpp: In function `int main(int, char**)':
> /home/nicha/vtkimage/vtkimage.cpp:38: error: no matching function for 
> call to `
>    vtkWarpScalar::SetInput(vtkPolyData*)'
> /usr/local/include/vtk/vtkPointSetToPointSetFilter.h:57: error: 
> candidates are:
>    void vtkPointSetToPointSetFilter::SetInput(vtkPointSet*)
> /home/nicha/vtkimage/vtkimage.cpp:42: error: no matching function for 
> call to `
>    vtkMergeFilter::SetGeometry(vtkPointSet*)'
> /usr/local/include/vtk/vtkMergeFilter.h:41: error: candidates are: void
>    vtkMergeFilter::SetGeometry(vtkDataSet*)
> /home/nicha/vtkimage/vtkimage.cpp:43: error: no matching function for 
> call to `
>    vtkMergeFilter::SetScalars(vtkImageData*)'
> /usr/local/include/vtk/vtkMergeFilter.h:46: error: candidates are: void
>    vtkMergeFilter::SetScalars(vtkDataSet*)
> make[1]: *** [vtkimage.o] Error 1
> make: *** [default_target] Error 2
> 
> <end compiler>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers






More information about the vtkusers mailing list