Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用tetgen或triangle(或meshpy)创建空心圆顶_Python_Mesh_Tetgen - Fatal编程技术网

Python 使用tetgen或triangle(或meshpy)创建空心圆顶

Python 使用tetgen或triangle(或meshpy)创建空心圆顶,python,mesh,tetgen,Python,Mesh,Tetgen,我用tetgen试着创造一个空心圆顶。我使用了三角形,然后只是对一个圆进行三角剖分,并根据方程z=sqrtabsr^2-x^2-y^2提高z值,但是我在边缘附近得到了非常糟糕的拉伸 所以我只想生成圆顶的一堆点,然后在不填充的情况下对其进行网格划分。Tetgen基本上是通过提供.node和.faces文件来为我实现这一点的,但问题是我仍然有一个底部,我不知道如何摆脱它。我对tetgen和meshpy还很陌生,所以如果有人能给我一个工作流程,我将不胜感激。答案其实可能很简单 例如,我可以使用一个简单

我用tetgen试着创造一个空心圆顶。我使用了三角形,然后只是对一个圆进行三角剖分,并根据方程z=sqrtabsr^2-x^2-y^2提高z值,但是我在边缘附近得到了非常糟糕的拉伸

所以我只想生成圆顶的一堆点,然后在不填充的情况下对其进行网格划分。Tetgen基本上是通过提供.node和.faces文件来为我实现这一点的,但问题是我仍然有一个底部,我不知道如何摆脱它。我对tetgen和meshpy还很陌生,所以如果有人能给我一个工作流程,我将不胜感激。答案其实可能很简单

例如,我可以使用一个简单的函数在圆的底部周围创建点:

def gen_pts_on_circle(num_pts, radius):
    pnts = []
    theta = 360.0 / num_pts

    # loop through circle using theta for point placement
    for i in np.arange(0, 360, theta):
        x = radius * np.cos(np.radians(i))
        y = radius * np.sin(np.radians(i))
        z = 0.0
        pnts.append((x,y,z))
     return np.array(pnts)
def gen_random_pts(num_pts, radius): 
    pts = []
    for i in xrange(num_pts):
        q = np.random.random() * (np.pi * 2.0)
        r = np.sqrt(np.random.random())
        x = (radius * r) * np.cos(q)
        y = (radius * r) * np.sin(q) 
        # Just the sphere equation with abs value to make a dome
        z = np.sqrt(abs(r**2 - x**2 - y**2))
        pts.append((x,y,z))
    return np.array(pts)
然后我使用函数在圆顶上生成随机点:

def gen_pts_on_circle(num_pts, radius):
    pnts = []
    theta = 360.0 / num_pts

    # loop through circle using theta for point placement
    for i in np.arange(0, 360, theta):
        x = radius * np.cos(np.radians(i))
        y = radius * np.sin(np.radians(i))
        z = 0.0
        pnts.append((x,y,z))
     return np.array(pnts)
def gen_random_pts(num_pts, radius): 
    pts = []
    for i in xrange(num_pts):
        q = np.random.random() * (np.pi * 2.0)
        r = np.sqrt(np.random.random())
        x = (radius * r) * np.cos(q)
        y = (radius * r) * np.sin(q) 
        # Just the sphere equation with abs value to make a dome
        z = np.sqrt(abs(r**2 - x**2 - y**2))
        pts.append((x,y,z))
    return np.array(pts)
然后,我只需从.node文件中删除头文件,然后运行tetgen来获取.face文件。这种方法唯一的问题是,当我需要它是一个开放的圆顶时,底部就在那里

我更愿意使用meshpy,但生成这些点,然后像这样将其输入meshpy不会返回任何结果

from meshpy.tet import MeshInfo, build 

# Generating all of the points using the functions
pts_circ = gen_pts_on_circle(100, 5) 
points = np.vstack((pts_circle, gen_random_pts(500, 5)))

# Building with tet
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh = build(info)
打印np.arraymesh.facets和 print np.arraymesh.points现在只是空数组


有没有人知道如何在不设置所有方面的情况下使用meshpy,或者像命令行tetgen那样使用这种构建方法来构建方面?这并不能真正解决我的问题,即圆顶的底部没有打开,但我一直在努力解决这个问题。任何帮助都将不胜感激。谢谢

以防万一,其他人正在寻找这个答案,我是从meshpy的创建者那里得到的。基本上,您需要覆盖选项以摆脱默认的“pq”命令。所以

from meshpy.tet import MeshInfo, Options, build

opts = Options("") # Overriding 'pq' with no options or flags
mesh_info = MeshInfo()
mesh = build(mesh_info, options=opts)

希望这能帮助那些偶然发现同样问题的人。

您能在原始帖子中提供设置圆顶几何体的最小代码吗?