You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Vedo导出双3D Gyroid结构的水密STL用于3D打印?

解决Vedo导出3D打印水密文件的方法

核心要点

3D打印要求网格必须是**水密(流形)**状态——无重复顶点、非流形边/面,且为闭合体积。Vedo内置了网格修复与格式导出的工具,按以下步骤即可实现需求:

代码修改与导出流程

  1. 清理网格,修复拓扑问题
    Vedo的Mesh类自带clean()方法,可自动合并重复顶点、删除孤立面、修复非流形结构,这是生成水密网格的关键操作。

  2. 导出为3D打印兼容格式
    使用write()方法导出为STL(3D打印最通用格式)或OBJ,Vedo会自动完成格式转换。

修改后的完整代码

from vedo import *
import numpy as np

# Parameters
a = 5
length = 100
width = 100
height = 10

pi = np.pi

x, y, z = np.mgrid[:length, :width, :height]

def gen_strut(start, stop):
    '''Generate the strut parameter t for the gyroid surface. Create a linear gradient'''
    strut_param = np.ones((length, 1))
    strut_param = strut_param * np.linspace(start, stop, width)
    t = np.repeat(strut_param[:, :, np.newaxis], height, axis=2)
    return t

plt = Plotter(shape=(1, 1), interactive=False, axes=3)

scale=0.5
cox = cos(scale * pi * x / a)
siy = sin(scale * pi * y / a)
coy = cos(scale * pi * y / a)
siz = sin(scale * pi * z / a)
coz = cos(scale * pi * z / a)
six = sin(scale * pi * x / a)
U1 = ((six ** 2) * (coy ** 2) +
      (siy ** 2) * (coz ** 2) +
      (siz ** 2) * (cox ** 2) +
      (2 * six * coy * siy * coz) +
      (2 * six * coy * siz * cox) +
      (2 * cox * siy * siz * coz)) - (gen_strut(0, 1.3) ** 2)

threshold = 0
iso1 = Volume(U1).isosurface(threshold).c('silver').alpha(1)
cube = TessellatedBox(n=(int(length-1), int(width-1), int(height-1)), spacing=(1, 1, 1))
iso_cut = cube.cutWithMesh(iso1).c('silver').alpha(1)

# --- 新增:网格处理与导出逻辑 ---
# 清理切割后的网格,确保水密
iso_cut_clean = iso_cut.clean()
# 检查网格是否为流形(水密)
print("网格是否水密:", iso_cut_clean.isManifold())

# 导出为二进制STL(3D打印首选,文件体积小)
iso_cut_clean.write("double_gyroid_watertight.stl")

# 若需ASCII格式STL,可指定参数
# iso_cut_clean.write("double_gyroid_watertight.stl", binary=False)

# 也可导出为OBJ格式
# iso_cut_clean.write("double_gyroid_watertight.obj")

plt.at(0).show([cube, iso1], "Double Gyroid 1", resetcam=False)
plt.interactive().close()

额外修复技巧

  • 若clean()后仍非水密,可尝试用fillHoles()填补小缺口:
    iso_cut_clean = iso_cut.clean().fillHoles()
    
  • 用checkManifold()查看具体非流形问题,针对性修复:
    iso_cut.checkManifold()
    

内容的提问来源于stack exchange,提问作者agentsmith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 22:21:00