访问 vtkActor 构造对象并附加新数据
Access vtkActor construction object and append new data
我正在使用 VTK-6.1,我想使用多个 vtkUnstructuredGrid
创建一个 vtkActor
。首先,我从网格创建演员...
vtkSmartPointer<vtkActor> create_actor()
{
vtkSmartPointer<vtkUnstructuredGrid> grid = create_grid_a();
auto mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(grid);
auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(0.5, 0.5, 0.5);
actor->GetProperty()->SetEdgeVisibility(1);
return actor;
}
然后我(尝试)使用另一个网格更新演员:
void update_actor(<vtkSmartPointer<vtkActor> actor)
{
// get current grid
vtkAlgorithm* algorithm = actor->GetMapper()->GetInputAlgorithm();
actor_grid = dynamic_cast<vtkUnstructuredGrid>(algorithm);
// create new grid
vtkSmartPointer<vtkUnstructuredGrid> new_grid = create_grid_b();
// combine grids
auto append_filter = vtkSmartPointer<vtkAppendFilter>::New();
append_filter->AddInputData(actor_grid);
append_filter->AddInputData(new_grid);
append_filter->Update();
// update actor
auto mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(append_filter->GetOutput());
actor->SetMapper(mapper);
}
问题是actor不包含网格的组合
备注:
(create_grid_x()
功能有点太复杂,无法提供,但它们
当然可以,因为第一个演员创建正确)
SafeDownCast
如 1 所示也不起作用。
参考文献:
有问题的部分是从 vtkActor
检索 vtkUnstructuredGrid
。
// get current grid
vtkDataSet* actor_data = actor->getMapper()->GetInput();
...而不是使用 vtkAlgorithm
我正在使用 VTK-6.1,我想使用多个 vtkUnstructuredGrid
创建一个 vtkActor
。首先,我从网格创建演员...
vtkSmartPointer<vtkActor> create_actor()
{
vtkSmartPointer<vtkUnstructuredGrid> grid = create_grid_a();
auto mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(grid);
auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(0.5, 0.5, 0.5);
actor->GetProperty()->SetEdgeVisibility(1);
return actor;
}
然后我(尝试)使用另一个网格更新演员:
void update_actor(<vtkSmartPointer<vtkActor> actor)
{
// get current grid
vtkAlgorithm* algorithm = actor->GetMapper()->GetInputAlgorithm();
actor_grid = dynamic_cast<vtkUnstructuredGrid>(algorithm);
// create new grid
vtkSmartPointer<vtkUnstructuredGrid> new_grid = create_grid_b();
// combine grids
auto append_filter = vtkSmartPointer<vtkAppendFilter>::New();
append_filter->AddInputData(actor_grid);
append_filter->AddInputData(new_grid);
append_filter->Update();
// update actor
auto mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(append_filter->GetOutput());
actor->SetMapper(mapper);
}
问题是actor不包含网格的组合
备注:
(create_grid_x()
功能有点太复杂,无法提供,但它们
当然可以,因为第一个演员创建正确)
SafeDownCast
如 1 所示也不起作用。
参考文献:
有问题的部分是从 vtkActor
检索 vtkUnstructuredGrid
。
// get current grid
vtkDataSet* actor_data = actor->getMapper()->GetInput();
...而不是使用 vtkAlgorithm