标签:style class blog code http tar
1. 案例说明
在实际计算中,常常需要大量的数据, 这个时候数据文件就必不可少, 例如
数据文件points.dat, 中存放了三个点的坐标,
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
1.0 1.0 0.0
读取坐标文件最简单的方法就是使用vtkSimplePointsReader, 比如下面的形式
vtkSmartPointer<vtkSimplePointsReader> reader = vtkSmartPointer<vtkSimplePointsReader>::New();
reader->SetFileName ( "points.dat" );
reader->Update();
vtkSimplePointsReader的继承关系如下图所示:
1 int main(int argc, char* argv[]) 2 { 3 // Verify input arguments 4 if ( argc != 2 ) 5 { 6 std::cout << "Usage: " << argv[0] 7 << " Filename(.xyz)" << std::endl; 8 return EXIT_FAILURE; 9 } 10 11 // Read the file 12 vtkSmartPointer<vtkSimplePointsReader> reader = 13 vtkSmartPointer<vtkSimplePointsReader>::New(); 14 reader->SetFileName ( argv[1] ); 15 reader->Update(); 16 17 // Visualize 18 vtkSmartPointer<vtkPolyDataMapper> mapper = 19 vtkSmartPointer<vtkPolyDataMapper>::New(); 20 mapper->SetInputConnection(reader->GetOutputPort()); 21 22 vtkSmartPointer<vtkActor> actor = 23 vtkSmartPointer<vtkActor>::New(); 24 actor->SetMapper(mapper); 25 actor->GetProperty()->SetPointSize(4); 26 27 vtkSmartPointer<vtkRenderer> renderer = 28 vtkSmartPointer<vtkRenderer>::New(); 29 vtkSmartPointer<vtkRenderWindow> renderWindow = 30 vtkSmartPointer<vtkRenderWindow>::New(); 31 renderWindow->AddRenderer(renderer); 32 vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = 33 vtkSmartPointer<vtkRenderWindowInteractor>::New(); 34 renderWindowInteractor->SetRenderWindow(renderWindow); 35 36 renderer->AddActor(actor); 37 renderer->SetBackground(.3, .6, .3); // Background color green 38 39 renderWindow->Render(); 40 renderWindowInteractor->Start(); 41 42 return EXIT_SUCCESS; 43 }
3.程序运行效果
原文地址: http://blog.csdn.net/chinamming/article/details/16860051
程序源码下载地址:
http://download.csdn.net/detail/chinamming/6587083
标签:style class blog code http tar
原文地址:http://www.cnblogs.com/vranger/p/3806995.html