-
它要求算法进行实际计算。这是因为 VTK 是惰性求值的,所以只在需要时才计算输出。
它允许您更改算法参数而不会触发不需要的计算。 -
例子:
vtkNew<vtkSphereSource> sphereSource;
sphereSource->Update(); // compute sphere with default
vtkPolyData* sphere = sphereSource->GetOutput();
sphereSource->SetThetaResolution(100); // change from default. Does not trigger any computation.
vtkPolyData* oldSphere = sphereSource->GetOutput(); // old output, source still not recomputed
sphereSource->Update(); // compute new sphere
vtkPolyData* sphere100 = sphereSource->GetOutput(); // new output
https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#afa4eff301069b8b47703cd4939aeffa7
Update() : Bring this algorithm’s outputs up-to-date.
Reimplemented in vtkImageResliceMapper, vtkPolyDataMapper, and vtkCellGridMapper.
https://stackoverflow.com/questions/69870728/what-is-the-role-of-update-in-vtk
- 通常,程序不显式调用Update()函数,应为在渲染引擎的最后,当调用Render()函数时,Actor会收到渲染请求,接着Actor会请求Mapper给它发送数据,而Mapper又会请求上一层的Filter的数据,Filter最后请求Source给它数据,于是,整条管线被执行。除非像以上代码所列,读入数据后,中间需要输出某些信息,在得到这些信息之前,就应该显示地调用Update()函数。