-1

我正在使用 python 创建 3d 对象的 2d 切片,我需要保留切片的大小。

如果我在中心切割一个球体,则创建的圆应该大于通过在表面附近切片创建的圆(控制轴会很好)。

我已经尝试过 trimesh section_multiplane,它有 2 个问题,直接将绘图保存到 png 不是直截了当的,我保持图像的大小与切片的面积成正比,结果甚至不接近它们应该是什么。

任何帮助将不胜感激。

此文件夹中的 3d 文件和切片图像: 链接到驱动器

代码:

import numpy as np
import trimesh
from trimesh.interfaces.gmsh import load_gmsh
from shapely.geometry import LineString
from pyglet import gl
import matplotlib.pyplot as plt

m = trimesh.load_mesh("pyr.stl", enable_post_processing=True, solid=True) #load mesh
#inside a loop 
slices = m.section_multiplane(plane_origin=bounds,
                                     plane_normal=[0,0,1],
                                     heights=[h]) # h is in range(0,n) n is number of slices d = 0.1 distance apart
slices[0].show() #shows the slice its a plot2d object which i need to save with size proporatinal to that in actual 3d object, lets say a projection of that slice on a place of finite size.
4

0 回答 0