VTK支持三种消减方法,vtkDecimatePro,vtkQuadricClustering和vtkQuadricDecimation。尽管每一种都有各自的优缺点,但在应用上基本都一致。
它的思想基于Siggraph2000中的论文“Out-of-Core Simplification of Large Polygonal Models”。它能够高速的消减大网格模型。并且支持网格片段消减(利用StartAppend(), Append()和EndAppend()方法)。这样能够避免读取整个模型到内存中。
对于大网格模型,该方法有较好的效果;可是当网格变小时,三角化过程效果不是非常好(须要结合其它的算法会有较理想的效果)
多边形数据,如果数据量过大,可能会 降采样。在保持近似的原始网格条件下对三角网格的三角形进行削减。
1)该算法不能保证网格的拓扑结构;
2)它保证了用户给定的网格系数;
3)它建立了生成渐进网格的方法
样例:
- auto decimate = vsp<vtkDecimatePro>::New();
- decimate->SetInputData(inputPD);
- decimate->SetTargetReduction(reduciton);
- decimate->Update();
reduciton SetTargetReduction 削减的三角形的百分比 0.9 减少90%
注:
输入只能是三角形网格数据,如果是多边形数据, 要将它三角化
- auto triangles = vsp<vtkTriangleFilter>::New();
- triangles->SetInputConnection(reader->GetOutputPort());
- triangles->Update();
保持原始的拓扑结构 ,将不会发生网格分裂和孔洞。
其它参数见
VTK: vtkDecimatePro Class Reference
vtkQuadricDecimation是一个用于削减三角形数量的类,然后得到一个很好的近似原始形状的几何。也是采用边塌陷方法来剔除顶点和三角面片。但误差度量方式是二次误差度量。二次误差度量常常被认为是比较好的误差度量方式
- vtkSmartPointer<vtkQuadricDecimation> decimation =
- vtkSmartPointer<vtkQuadricDecimation>::New();
- decimation->SetInputData(reader->GetOutput());
- decimation->SetTargetReduction(0.6);
- decimation->Update();
vtkQuadricClustering
用于削减三角形的类,得到一个近似的几何图形。它的输入是vtkPolyData类型的数据,可以处理所有类型的多边形网格。相比前两个算法,他的速度是很快的。它能快速的削减大网格模型,并且支持网格片段削减(利用startAppend, Append, endAppend方法),这样可以避免把整个模型载入内存中。对于大型网络模型,它有较好的效果,但是当网格变小时,三角化效果不是很好,需结合其它的方法。
- auto decimate = vsp<vtkQuadricClustering>::New();
- decimate->StartAppend (bounds);
- decimate->Append (data);
- decimate->EndAppend ();
- decimate->UseFeatureEdgesOn();
- decimate->Update();
-
- void StartAppend (double *bounds)
- These methods provide an alternative way of executing the filter. More...
-
- void StartAppend (double x0, double x1, double y0, double y1, double z0, double z1)
- These methods provide an alternative way of executing the filter. More...
-
- void Append (vtkPolyData *piece)
- These methods provide an alternative way of executing the filter. More...
-
- void EndAppend ()
- These methods provide an alternative way of executing the filter. More...
网线加密:
- vtkSmartPointer<vtkLinearSubdivisionFilter> linear =
- vtkSmartPointer<vtkLinearSubdivisionFilter>::New();
- linear->SetInputData(orig);
- linear->SetNumberOfSubdivisions(4);
- linear->Update();