Friday, June 10, 2005
VTK:the use of vtkPolyDataReader
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataReader.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
int main()
{
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkPolyDataReader *polydata = vtkPolyDataReader::New();
polydata->SetFileName("02463_458.vtk");//the name of the file
vtkPolyDataMapper *datamapper = vtkPolyDataMapper::New();
datamapper->SetInput( polydata->GetOutput() );
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
mapper->SetInput(polydata->GetOutput());
vtkActor *actor = vtkActor::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderer->SetBackground(0,0,0);
renWin->SetSize(450,450);
renWin->Render();
iren->Start();
renderer->Delete();
renWin->Delete();
iren->Delete();
mapper->Delete();
actor->Delete();
}
//note: no return 0;
//make sure in the CMake, u must include
//in the TARGET_LINK_LIBRARIES (vtkIO)
// if still doesnt work include vtkHybrid
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataReader.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
int main()
{
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkPolyDataReader *polydata = vtkPolyDataReader::New();
polydata->SetFileName("02463_458.vtk");//the name of the file
vtkPolyDataMapper *datamapper = vtkPolyDataMapper::New();
datamapper->SetInput( polydata->GetOutput() );
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
mapper->SetInput(polydata->GetOutput());
vtkActor *actor = vtkActor::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderer->SetBackground(0,0,0);
renWin->SetSize(450,450);
renWin->Render();
iren->Start();
renderer->Delete();
renWin->Delete();
iren->Delete();
mapper->Delete();
actor->Delete();
}
//note: no return 0;
//make sure in the CMake, u must include
//in the TARGET_LINK_LIBRARIES (vtkIO)
// if still doesnt work include vtkHybrid