简单圆柱体vtk程序编写

一剑行天下 posted @ 2008年11月09日 04:55 in vtk , 2348 阅读

#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include "vtkInteractorStyleTrackballCamera.h"
int main (int argc,char* argv[])
{
        vtkCylinderSource *cylinder = vtkCylinderSource::New();
        cylinder->SetRadius(2);
        cylinder->SetHeight(5);
        cylinder->SetResolution(800);


        vtkPolyDataMapper *map = vtkPolyDataMapper::New();
        map->SetInputConnection(cylinder->GetOutputPort());

        vtkActor *actor = vtkActor::New();
        actor->SetMapper(map);
        actor->GetProperty()->SetColor(0.200,0.6,0.6);

        vtkRenderer * ren=vtkRenderer::New();
        ren->AddActor(actor);
        ren->SetBackground(0.1,0.5,0.3);


        vtkRenderWindow* win=vtkRenderWindow::New();
        win->AddRenderer(ren);
        win->SetSize(400,400)


        vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
        iren->SetRenderWindow(win);
               
    vtkInteractorStyleTrackballCamera *style =
        vtkInteractorStyleTrackballCamera::New();
    iren->SetInteractorStyle(style);       
               

 
        iren->Start();

        cylinder->Delete();
        map->Delete();
        actor->Delete();
        ren->Delete();
        iren->Delete();
        return 0;

}
 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter