[vtkusers] Problems about Texture Mapping using C++

n9693119 at mail.ncku.edu.tw n9693119 at mail.ncku.edu.tw
Sat Dec 3 12:01:35 EST 2005


I have written a simple program (GenerateTextureCoords.tcl), and this 
program is just to 
translate 
$VTK_HOME\Examples\VisualizationAlgorithms\Tcl\GenerateTextureCoords.tcl 
into C++ language...

But when I compiler this C++ source file, I got some errors as follow:
-----------------------------------------------------------------------------
Building object file GenerateTextureCoords.o...
/home/vtk/vtk-src-unix/Examples/BearCxx/Texture/GenerateTextureCoords.cxx: 
In function `int main(int, char**)':
/home/vtk/vtk-src-
unix/Examples/BearCxx/Texture/GenerateTextureCoords.cxx:31: error: no 
matching function for call to `vtkDelaunay3D::SetInput(vtkPolyData*)'
/usr/local/include/vtk/vtkDelaunay3D.h:185: note: candidates are: virtual 
void vtkDelaunay3D::SetInput(vtkPointSet*)
/home/vtk/vtk-src-
unix/Examples/BearCxx/Texture/GenerateTextureCoords.cxx:38: error: no 
matching function for call to `vtkTextureMapToCylinder::SetInput
(vtkUnstructuredGrid*)'
/usr/local/include/vtk/vtkDataSetToDataSetFilter.h:59: note: candidates are: 
void vtkDataSetToDataSetFilter::SetInput(vtkDataSet*)
make[1]: *** [GenerateTextureCoords.o] Error 1
make: *** [default_target] Error 2
-----------------------------------------------------------------------------

I don't understand what the problem is ...
Here's the code:
=============================================================================

#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkTexture.h"
#include "vtkBMPReader.h"
#include "vtkTextureMapToCylinder.h"
#include "vtkTransformTextureCoords.h"
#include "vtkDataSetMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkPointSource.h"
#include "vtkDelaunay3D.h"

int main( int argc, char *argv[] )
{

vtkPointSource *sphere=vtkPointSource::New();
  sphere -> SetNumberOfPoints(25);

vtkDelaunay3D *del=vtkDelaunay3D::New();
  del -> SetInput(sphere -> GetOutput());
  del -> SetTolerance(0.01);

vtkTextureMapToCylinder *tmapper = vtkTextureMapToCylinder::New();
  tmapper -> SetInput (del -> GetOutput());
  tmapper -> PreventSeamOn();

vtkTransformTextureCoords *xform = vtkTransformTextureCoords::New();
  xform->SetInput(tmapper->GetOutput());
  xform->SetScale(4,4,1);

vtkDataSetMapper *mapper = vtkDataSetMapper::New();
  mapper -> SetInput (xform -> GetOutput());

vtkBMPReader *bmpReader = vtkBMPReader::New();
  bmpReader -> SetFileName("/home/vtk/VTKData/Data/masonry.bmp");
vtkTexture *atext = vtkTexture::New();
  atext -> SetInput(bmpReader->GetOutput());
  atext -> InterpolateOn();

vtkActor *triangulation = vtkActor::New();
    triangulation -> SetMapper(mapper);
    triangulation -> SetTexture(atext);

vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin -> AddRenderer(ren1);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren -> SetRenderWindow(renWin);

ren1 -> AddActor(triangulation);
ren1->SetBackground(1, 1, 1);
renWin->SetSize(300, 300);

 iren->Initialize();
 iren->Start();

return 0;
}
=============================================================================



More information about the vtkusers mailing list