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=vtkSmartPointer<vtkPolyDataMapper>::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;
}

你可能感兴趣的:(vtk 基础概念)