[英]How to crop/split mesh in Open3D
Is it possible to split the mesh in Open3D based on vertex threshold?是否可以根据顶点阈值在 Open3D 中分割网格?
For example, I need the mesh into two stl outputs, one with the z-vertex less than some value (with x and y throughout the domain) and second stl with remaining z-vertex.例如,我需要将网格划分为两个 stl 输出,一个 z 顶点小于某个值(x 和 y 贯穿整个域),另一个 stl 具有剩余 z 顶点。
In Open3D documentation, there is a way to crop the mesh.在 Open3D 文档中,有一种方法可以裁剪网格。 But it is according to the triangles assigned.但它是根据分配的三角形。 Below is the code from the website itself.以下是网站本身的代码。
mesh1 = copy.deepcopy(mesh)
mesh1.triangles = o3d.utility.Vector3iVector(
np.asarray(mesh1.triangles)[:len(mesh1.triangles) // 2, :])
mesh1.triangle_normals = o3d.utility.Vector3dVector(
np.asarray(mesh1.triangle_normals)[:len(mesh1.triangle_normals) // 2, :])
o3d.visualization.draw_geometries([mesh1])
So, based on this, How can I crop/split the mesh with respect to vertex?那么,基于此,我如何相对于顶点裁剪/分割网格? I can access the vertex with mesh.vertices.我可以使用 mesh.vertices 访问顶点。
Any leads will be appreciated.任何线索将不胜感激。
Regards, Sunag R A.问候, Sunag R A。
I'm not familiar with Open3D, but as there is points and facets arrays, you can simply do a loop like this:我对 Open3D 不熟悉,但是由于 arrays 的点和面,你可以简单地做一个这样的循环:
points = [...] # from your mesh
faces = [...] # from your mesh
threshold = 0 # z threshold
# the crop parts
below = []
above = []
for face in faces:
if all(points[p][2] < threshold for p in face):
below.append(face)
else:
above.append(face)
It looks every face of the mesh, when all face points are below the threshold the face is put in list below
, else in above
它看起来网格的每个面,当所有面点都低于阈值时,面被放在下面的列表below
,否则在above
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.