-1
我正在使用一些簡單的代碼在循環中渲染網格。在每次迭代實踐中,我將更改視點並保存渲染圖像。我已經減少這下面一個小編譯例如:如何自動關閉VTKRenderWindow
int main(int argc, char **argv) {
vtkSmartPointer<vtkPLYReader> fileReader = vtkSmartPointer<vtkPLYReader>::New();
fileReader->SetFileName("benchvise_mesh.ply");
fileReader->Update();
vtkSmartPointer<vtkPolyData> polydata_ = fileReader->GetOutput();
vtkSmartPointer<vtkRenderWindow> render_win = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkActor> actor_view = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkCamera> cam = vtkSmartPointer<vtkCamera>::New();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
for (int i = 0; i < 100; i++) {
mapper->SetInput(polydata_);
mapper->Update();
cam->SetViewAngle(58);
cam->SetClippingRange(0.00001, 10000);
//Invert view Up
cam->SetViewUp(0, -1, 0);
cam->SetPosition(0, 0, -500);
cam->SetFocalPoint(0, 0, 1);
cam->Modified();
actor_view->SetMapper(mapper);
actor_view->Modified();
renderer->SetActiveCamera(cam);
renderer->AddActor(actor_view);
renderer->SetBackground(1.0, 1.0, 1.0);
renderer->Modified();
render_win->AddRenderer(renderer);
render_win->SetSize(640, 480);
//white
render_win->Modified();
render_win->Start();
render_win->Render();
render_win->Finalize();
}
}
的問題是,當我跑這麼多vtkWindow圖標出現在我的任務欄上,並最終把PC停止。它看起來好像在每個循環中渲染窗口保持活動狀態。但是,當我點擊一個圖標時,窗口實際上並沒有出現。
有什麼我失蹤,將清理每次迭代的渲染窗口。
BTW,我Ubntu下運行VTK與5.8