简体   繁体   English

使用 Delaunay 方法创建三角形网格

[英]Create a triangular mesh using Delaunay methods

I'm trying create a triangular mesh using python.我正在尝试使用 python 创建一个三角形网格。 As I know the boundary points, I think the delaunay method is more appropriated.由于我知道边界点,我认为 delaunay 方法更合适。 I tried use scipy.我尝试使用 scipy。 the code is very simple代码很简单

from scipy.spatial import Delaunay
pixelpoints = np.transpose(np.nonzero(binaryImage))
tri = Delaunay(pixelpoints)
import matplotlib.pyplot as plt
plt.triplot(pixelpoints[:,0], pixelpoints[:,1], tri.simplices.copy())
plt.plot(pixelpoints[:,0], pixelpoints[:,1], 'o')
plt.show()

输出三角测量 But I don't want this.但我不想要这个。 I'd like to mesh inside the image bounds.我想在图像边界内进行网格划分。 Also, I don't want to mesh inside the holes.另外,我不想在孔内网格化。 Can I control the number of triangles to cover a surface?我可以控制覆盖表面的三角形数量吗? Is there an alternative way to do this?有没有其他方法可以做到这一点?

Thank you.谢谢你。

You can easily remove additional triangles using the Polygon.IsPointInside(tCentroid) where tCentroid is the triangle centroid.您可以使用Polygon.IsPointInside(tCentroid)轻松删除其他三角形,其中tCentroid是三角形质心。 IsPointInside() can be derived by this: http://geomalgorithms.com/a03-_inclusion.html . IsPointInside()可以通过以下方式派生: http : IsPointInside()

The Triangle program supports both these needs: refining triangles to a prescribed size and removing triangles outside the polygon or in holes. Triangle程序支持这两种需求:将三角形细化到规定的大小并去除多边形外或孔中的三角形。 There seems to be a python interface floating around: the API describes how to specify holes and a maximum triangle area.似乎有一个python 接口浮动: API描述了如何指定孔和最大三角形区域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM