#include <vtkCylinderSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkActor.h>
#include <vtkProperty.h>
int main()
{
vtkCylinderSource* cone=vtkCylinderSource::New();
cone->SetResolution(8);
vtkPolyDataMapper* mapper=vtkPolyDataMapper::New();
mapper->SetInput(cone->GetOutput());
vtkActor* actor=vtkActor::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(1.000,0.228,0.3111);
actor->RotateX(30);
actor->RotateY(-45);
vtkRenderer* render=vtkRenderer::New();
vtkRenderWindow* window=vtkRenderWindow::New();
window->AddRenderer(render);
vtkRenderWindowInteractor* interactor=vtkRenderWindowInteractor::New();
interactor->SetRenderWindow(window);
render->AddActor(actor);
render->SetBackground(0.1,0.2,0.4);
window->SetSize(200,200);
interactor->Initialize();
interactor->Start();
cone->Delete();
mapper->Delete();
actor->Delete();
render->Delete();
window->Delete();
interactor->Delete();
return 0;
}
这里值得注意的两句是
interactor->Initialize();
interactor->Start();
他们开始了整个程序的循环过程,接受你的输入,并作出响应。