[vtkusers] Hi

LinX camilo.jimenez at spymac.com
Sun Jul 25 19:06:47 EDT 2004


Hi everybody.

I'm starting with VTK in C++. The book is written primarily for Tcl Users so 
I have been translating examples to Cxx 'cause as you know it isn't pretty 
hard.

I had a problem translating the ClipCow.tcl code with the implementation of 
the vtkCutter class.

The code I used is





#include"vtkPolyDataMapper.h"
#include"vtkActor.h"
#include"vtkRenderer.h"
#include"vtkRenderWindow.h"
#include"vtkRenderWindowInteractor.h"
#include"vtkPlane.h"
#include"vtkClipPolyData.h"
#include"vtkPolyDataReader.h"
#include"vtkPolyDataNormals.h"
#include"vtkCutter.h"

int main(void){
  vtkPolyDataReader *Reader=vtkPolyDataReader::New();
  Reader->SetFileName("a.vtk");

  vtkPolyDataNormals *Normals=vtkPolyDataNormals::New();
  Normals->SetInput(Reader->GetOutput());
  
  vtkPlane *Plane=vtkPlane::New();
  //Plane->SetOrigin(106,156,90); 
  //Plane->SetNormal(1,0,0);
  Plane->SetOrigin(168,107,126); 
  Plane->SetNormal(0,0,1);
  
  vtkClipPolyData *Clipper=vtkClipPolyData::New();
  Clipper->SetInput(Normals->GetOutput());
  Clipper->SetClipFunction(Plane);
  Clipper->GenerateClippedOutputOn();
  
  vtkPolyDataMapper *CylinderMapper=vtkPolyDataMapper::New();
  CylinderMapper->SetInput(Clipper->GetOutput());

  vtkActor *CylinderActor=vtkActor::New();
  CylinderActor->SetMapper(CylinderMapper);

  vtkPolyDataMapper *RestMapper=vtkPolyDataMapper::New();
  RestMapper->SetInput(Clipper->GetClippedOutput());
  
  vtkActor *RestActor=vtkActor::New();
  RestActor->SetMapper(RestMapper);
  
  vtkRenderer *Renderer=vtkRenderer::New();
  Renderer->AddActor(CylinderActor);
  Renderer->AddActor(RestActor);
  Renderer->SetBackground(.2,.2,.5);

  vtkRenderWindow *RenderWindow=vtkRenderWindow::New();
  RenderWindow->AddRenderer(Renderer);
 
  vtkRenderWindowInteractor *Interactor=vtkRenderWindowInteractor::New();
  Interactor->SetRenderWindow(RenderWindow);
  Interactor->Initialize();
  Interactor->Start();

  return 0;
}





This code works fine, but when I use 




vtkCutter *cutEdges=vtkCutter::New(); 
cutEdges->SetInput(Normals->GetOutput());




the pipeline breaks and this message is printed when making





[19:59:50] XowL> make 
Building dependencies cmake.check_depends...
-- Loading VTK CMake commands
-- Loading VTK CMake commands - done
Building object file Cylinder.o...
/home/xowl/Examples/Examples/VTK/Clip/Cylinder.cxx: In function `int main()':
/home/xowl/Examples/Examples/VTK/Clip/Cylinder.cxx:43: error: no matching 
   function for call to `vtkCutter::SetInput(vtkPolyData*)'
/home/xowl/local/include/vtk/vtkDataSetToPolyDataFilter.h:44: error: 
candidates 
   are: virtual void vtkDataSetToPolyDataFilter::SetInput(vtkDataSet*)
make[1]: *** [Cylinder.o] Error 1
make: *** [default_target] Error 2
[19:59:56] XowL>





And I don't  know the reason. 

If somebody knows why this happen or what am I doing bad I would appreciate 
information.

Thanks

LinX

P.D. I apologize for my terrible English.



More information about the vtkusers mailing list