在项目中使用QVTKOpenGLNativeWidget来显示点云模型。
目前遇到的问题时,使用
VTKRenderWindow->Render();
我本来以为我遇到的问题是VTK不会实时更新,必须要我每次都拖动一下VTK窗口,更改一下视角他才会更新。后来我发现问题不在于此,我再项目中VTK窗口即需要展示点云
pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>);
cloud->points.push_back(PointT(0,0,0));
renderWindowVTK->AddRenderer(rendererVTK);
viewer.reset(new pcl::visualization::PCLVisualizer(rendererVTK, renderWindowVTK, "viewer", false));
又需要增加图片
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
plane->SetCenter(0, 0, 0);
plane->SetOrigin(-10,-10,0);
plane->SetPoint1(10,-10,0);
plane->SetPoint2(-10,10,0);
plane->SetNormal(0, 0, 1);
vtkSmartPointer<vtkTextureMapToPlane> texturePlane = vtkSmartPointer<vtkTextureMapToPlane>::New();
texturePlane->SetInputConnection(plane->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
planeMapper->SetInputConnection(texturePlane->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
//中间省略一些操作
rendererVTK->AddActor(actor);
然后我用
VTKRenderWindow->Render();
来更新VTK渲染时,只更新了PCL点云的渲染,也就是PCLvisualization的渲染,所以点云是永远实时更新的,但是图片的actor,却并不能实时更新,非要我点击VTK窗口后,他才会更新。
请问为什么会出现这个问题,是因为VTKRenderWindow->Render();语句并不会更新所有的actor吗。