VTK显示.vtk格式文件
2015-02-05 15:58 采药的蜗牛 阅读(4087) 评论(2) 编辑 收藏 举报void ReadandShowVTKFile () { vtkSmartPointer<vtkRenderer > aRenderer = vtkSmartPointer<vtkRenderer >::New(); vtkSmartPointer<vtkRenderWindow > renWin = vtkSmartPointer<vtkRenderWindow >::New(); renWin->AddRenderer (aRenderer); vtkSmartPointer<vtkRenderWindowInteractor > iren = vtkSmartPointer<vtkRenderWindowInteractor >::New(); iren->SetRenderWindow (renWin); vtkSmartPointer<vtkPolyDataReader > vtkReader = vtkSmartPointer<vtkPolyDataReader >::New(); vtkReader->SetFileName ("polyline.vtk"); vtkSmartPointer<vtkPolyDataMapper > skinMapper = vtkSmartPointer<vtkPolyDataMapper >::New(); skinMapper->SetInputConnection (vtkReader-> GetOutputPort()); skinMapper->ScalarVisibilityOff (); vtkSmartPointer<vtkActor > skin = vtkSmartPointer<vtkActor >::New(); skin->SetMapper (skinMapper); vtkSmartPointer<vtkCamera > aCamera = vtkSmartPointer<vtkCamera >::New(); aCamera->SetViewUp (0, 0, -1); aCamera->SetPosition (0, 1, 0); aCamera->SetFocalPoint (0, 0, 0); aCamera->ComputeViewPlaneNormal (); aCamera->Azimuth (30.0); aCamera->Elevation (30.0); aCamera->Dolly (1.5); aRenderer->AddActor (skin); aRenderer->SetActiveCamera (aCamera); aRenderer->ResetCamera (); aRenderer->SetBackground (.2, .3, .4); aRenderer->ResetCameraClippingRange (); renWin->Render (); iren->Initialize (); iren->Start (); }