1 #include<vtkSmartPointer.h> 2 #include<vtkRenderWindow.h> 3 #include<vtkRenderer.h> 4 #include<vtkRenderWindowInteractor.h> 5 #include<vtkInteractorStyleTrackballCamera.h> 6 #include<vtkCylinderSource.h> 7 #include<vtkPolyDataMapper.h> 8 #include<vtkActor.h> 9 #include<vtkLight.h> 10 #include<vtkCamera.h> 11 #include<vtkJPEGReader.h> 12 #include<vtkTexture.h> 13 #include<vtkPlaneSource.h> 14 #include<vtkStructuredPointsReader.h> 15 #include<vtkMarchingCubes.h> 16 #include "vtkOpenGLRenderWindow.h" 17 int main() 18 { 19 vtkSmartPointer<vtkStructuredPointsReader> reader = vtkSmartPointer<vtkStructuredPointsReader>::New(); 20 reader->SetFileName("D:\zeng\vtkData\CT-Head.vtk"); 21 22 vtkSmartPointer<vtkMarchingCubes> marchingCubes = vtkSmartPointer<vtkMarchingCubes>::New(); 23 marchingCubes->SetInputConnection(reader->GetOutputPort()); 24 marchingCubes->SetValue(0,200); 25 26 vtkSmartPointer<vtkPolyDataMapper> manpper = vtkSmartPointer<vtkPolyDataMapper>::New(); 27 manpper->SetInputConnection(marchingCubes->GetOutputPort()); 28 29 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); 30 actor->SetMapper(manpper); 31 32 vtkSmartPointer<vtkRenderer> marchingCubesRender = vtkSmartPointer<vtkRenderer>::New(); 33 vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New(); 34 vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New(); 35 renWin->AddRenderer(marchingCubesRender); 36 iren->SetRenderWindow(renWin); 37 marchingCubesRender->AddActor(actor); 38 vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New(); 39 iren->SetInteractorStyle(style); 40 renWin->SetSize(300, 300); 41 //marchingCubesRender->Render(); 42 43 iren->Initialize(); 44 iren->Start(); 45 return 0; 46 }
结果展示:
数据“CT-Head.vtk”,已上传到文件中,需要的朋友可以到文件中下载。
没有找到下载别人博客园的文件的入口,有需要这个数据的请留下邮箱,给你们发