首页 > 代码库 > vtk 基础概念
vtk 基础概念
#include <vtk-5.10/vtkSmartPointer.h>
#include <vtk-5.10/vtkRenderWindow.h>
#include <vtk-5.10/vtkRenderer.h>
#include <vtk-5.10/vtkCylinderSource.h>
#include <vtk-5.10/vtkPolyDataMapper.h>
#include <vtk-5.10/vtkActor.h>
#include <vtk-5.10/vtkRenderWindowInteractor.h>
#include <vtk-5.10/vtkInteractorStyleTrackballCamera.h>
int main()
{
vtkSmartPointer<vtkCylinderSource> cylinder=vtkSmartPointer<vtkCylinderSource>::New();
cylinder->SetHeight(3.0);
cylinder->SetRadius(1.0);
cylinder->SetResolution(10);
vtkSmartPointer<vtkPolyDataMapper> polydata=http://www.mamicode.com/vtkSmartPointer::New();
polydata->SetInputConnection(cylinder->GetOutputPort());
vtkSmartPointer<vtkActor> cylinderActor=vtkSmartPointer<vtkActor>::New();
cylinderActor->SetMapper(polydata);
vtkSmartPointer<vtkRenderer> render=vtkSmartPointer<vtkRenderer>::New();
render->AddActor(cylinderActor);
render->SetBackground(0.1, 0.2, 0.4);
vtkSmartPointer<vtkRenderWindow> renderWindow=vtkSmartPointer<vtkRenderWindow >::New();
renderWindow->AddRenderer(render);
renderWindow->SetSize(640, 480);
vtkSmartPointer<vtkRenderWindowInteractor> renderwindowInteractor=vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderwindowInteractor->SetRenderWindow(renderWindow);
vtkSmartPointer<vtkInteractorStyleTrackballCamera> interactorStyle =vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderwindowInteractor->SetInteractorStyle(interactorStyle);
renderwindowInteractor->Initialize();
renderwindowInteractor->Start();
std::cin.get();
return 0;
}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。