如何在VTK中进行抽取后得到固定数量的顶点

时间:2016-03-24 14:56:16

标签: image 3d mesh vtk itk

我正在使用VTK进行3D网格处理。我有一个网格,我使用函数vtkDecimatePro()来完成缩减。函数本身接受TargetReduction,这与三角形数量的减少(百分比)有关。问题是我需要有固定数量的顶点,例如我希望我的所有网格都有2000个顶点。目前我在一个名为openflipper的软件中这样做,它允许将抽取约束到固定数量的顶点。但是,在VTK中我不知道如何完成这项任务。

感谢您的任何建议。

1 个答案:

答案 0 :(得分:1)

无法设置所需的顶点数。它不起作用。即使目标缩减也只是近似值,并且您无法保证完全顶点数。

你可以做的,非常简单地计算缩减因子并设置:

// desiredN is the desired number of vertices after reduction
double f = static_cast<double>(desiredN) / poly->GetNumberOfVertices(); 

//...
decimate->SetTargetReduction(1.0 - f);

// We want to preserve topology so that reduction factor applies to vertices 
// (otherwise it prescribes reduction in number of faces)
decimate->SetPreserveTopology(1);

HTH,

米罗