这种网格体积计算算法可以处理不完美的网格吗? [英] Can this mesh volume calculation algorithm handle imperfect meshes?

查看:176
本文介绍了这种网格体积计算算法可以处理不完美的网格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照





而且我不确定该算法将如何处理不完美的3D模型。



我是否需要生成仅由真实,完整,大量的3D对象组成的模型,否则该方法无法正常工作?

解决方案

您找到的方法可以通过遍历所有三角形来实现,例如每个三角形都将其角与(0,0,0)点相连,从而形成四面体。然后,它计算其体积并汇总所有结果。此处使用符号表示基于三角形面,某些四面体将具有负体积。



如果您有个正确的网格,它就可以工作,但是您的不完美网格基本上是一个完美网格,但是缺少几个三角形,因此您会错过其中的一些四面体您的最终款项。从统计上讲,其中一些是正体积,有些是负体积,因此这也会在某种程度上抵消。



您缺少的三角形越多和/或它们得到的越大那么在计算的体积值中会得到更多的错误,但是算法不会中断或爆炸,只是精度降低。



还有另一个问题这种方法:



当您有两个彼此完全重叠的完全封闭的立方体网格时,此算法将计算其体积的总和,而不是体积的总和。他们创造的形状。我们对您的模型了解不多,但我认为这是一个比非封闭式网格更大的问题。
要解决此问题,您需要执行 CSG Union 操作,但它仅适用于封闭的网格:/。


As per this answer, I read this research paper (very brief). To quote the answer:

This all boils down to the following simple function:

public float SignedVolumeOfTriangle(Vector p1, Vector p2, Vector p3) {
    var v321 = p3.X*p2.Y*p1.Z;
    var v231 = p2.X*p3.Y*p1.Z;
    var v312 = p3.X*p1.Y*p2.Z;
    var v132 = p1.X*p3.Y*p2.Z;
    var v213 = p2.X*p1.Y*p3.Z;
    var v123 = p1.X*p2.Y*p3.Z;
    return (1.0f/6.0f)*(-v321 + v231 + v312 - v132 - v213 + v123);
}

and then a driver to calculate the volume of the mesh:

public float VolumeOfMesh(Mesh mesh) {
    var vols = from t in mesh.Triangles
               select SignedVolumeOfTriangle(t.P1, t.P2, t.P3);
    return Math.Abs(vols.Sum());
}

This seems much better than the voxel based approach for determining volume of an advanced 3D object, however, in the models I currently have available to me:

  • Many of the surfaces are not complete 3D voluminous shapes, but rather hollow 2D meshes wrapped into a 3-D looking shape where the ends don't actually meet up to form a complete surface of a true 3D object.
  • Some surfaces are outright flat 2D shapes.
  • Are just plain messy internally.

And I'm unsure about how the algorithm will handle imperfect 3D models.

Do I need to produce models which are made up only of true, complete, voluminous 3D objects for this method to work, or will it work on common 3D models as shown above?

解决方案

The method you've found works by iterating over all triangles, for each triangle it connects its corners with (0,0,0) point making a tetrahedron. Then it computes its volume and sum up all the results. The signed word used here means that some tetrahedrons will have negative volume, based on triangle facing. Thanks to this trick overlapping tetrahedrons will cancel out each other.

If you have correct mesh it just works, but your imperfect mesh is basically a perfect one but with few triangles missing, so you'll miss some of your tetrahedrons in your final sum. Statistically some of them are positive volumes and some are negative ones, so this will also cancel out to some extent.

The more triangles you lack and/or the bigger they get then the more error you'll get in computed volume value, but the algorithm won't break or explode, just loose precision.

There's also another problem with this approach:

When you have two perfectly closed cube meshes that are overlapping each other this algorithm will compute the sum of their volumes, not the volume of the shape they've created. We don't know much about your models but I'd consider it a bigger problem than non-closed mesh. To solve this you'd need to do CSG Union operation, but it works only for closed meshes :/.

这篇关于这种网格体积计算算法可以处理不完美的网格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆