1.插入点
void NextPoint() {
double x = t * cos(t);
double y = t * sin(t);
points->InsertNextPoint(x, y, t);
numOfPoints++;
polyLine->GetPointIds()->InsertNextId(numOfPoints);
polyLine->GetPointIds()->SetId(numOfPoints-1, numOfPoints-1);
t += 0.1;
}
2.更新PolyData
NextPoint(); // Add another point to polyData
points->Modified();
cells->Initialize(); // reset the cells to remove the old spiral
cells->InsertNextCell(polyLine); // re-insert the updated spiral
cells->Modified(); // required to update
//data->Modified(); // required to update
++this->TimerCount;
cout << t << endl;
renderWindow->Render(); // refresh the render window after each update
3.运行效果图
QQ录屏20230713095111
有需要完整代码可以留言 或者留下QQ邮箱