ITK更新功能

时间:2016-03-07 18:00:26

标签: c++ itk

我试图让球体变形,然后在vtk上显示。

我在使用Update()函数时遇到问题,因为我不确定在创建的每个过滤器后是否必须使用它。

typedef itk::TriangleMeshToSimplexMeshFilter< TMesh, TSimplex > TConvert;
typedef itk::SimplexMeshToTriangleMeshFilter< TSimplex, TMesh > TReverseConvert;
typedef itk::DeformableSimplexMesh3DBalloonForceFilter< TSimplex, TSimplex > TDeform;

TConvert::Pointer convertSimplex = TConvert::New();
convertSimplex->SetInput(sphere->GetOutput());
//If I use Update the next line then I'm having errors at execution
convertSimplex->Update();

TDeform::Pointer balloon = TDeform::New();
balloon->SetInput(convertSimplex->GetOutput());
//....Some deform values i.e. alpha and beta
balloon->SetRigidity(0);
balloon->Update(); //Again the same problem

TReverseConvert::Pointer reverse = TReverseConvert::New();
reverse->SetInput(ballon->GetOutputPort());
reverse->Update();

我是否必须在所有过滤器结束时执行此操作?如果我添加越来越多的过滤器并且我不知道它们的顺序怎么办? (假设订单取决于用户操作)

1 个答案:

答案 0 :(得分:3)

您只需在管道中的最后一个过滤器上调用Update()即可。这个答案的其余部分就是解释。

ITK使用管道执行框架进行过滤。假设我们有三个按顺序连接的过滤器,如下所示:

输入 - &gt; |过滤器1 | - &GT; |过滤器2 | - &GT; |过滤器3 | - &GT;输出

如果您在filter3上调用Update(),ITK将从filter3启动并检查每个过滤器的输入是否已更改。如果有,ITK会依次调用它们。请参阅此link的幻灯片5。