I am currently trying to do some Boolean operations between a mesh and a surface:
I would like to return the portion of the surface (as a surface mesh) constrained by the mesh. However, when attempting the Boolean operations in PyVista, I instead get the cut portion of the mesh:
Using an OpenScad-based engine, I can obtain the desired output:
I would like to be able to complete the same operation in PyVista, is this possible? How might I go about this?
Below is my code to reproduce the above images:
import pyvista as pv
import numpy as np
import trimesh as tm
import pymeshfix as pf
model_mesh = pv.read('stl/Tensile_Bar_Thick.stl')
model_trimesh = tm.load('stl/Tensile_Bar_Thick.stl')
x = np.arange(-100, 100, 2)
y = np.arange(-100, 100, 2)
x, y = np.meshgrid(x, y)
z = np.sin(0.2 * x) * np.sin(0.25 * y)
points = np.c_[x.reshape(-1), y.reshape(-1), z.reshape(-1)]
point_cloud = pv.PolyData(points)
surf = point_cloud.delaunay_2d()
intersecting_surf = model_mesh.boolean_cut(surf)
surf_trimesh = pf.MeshFix(surf)
surf_trimesh = tm.Trimesh(surf_trimesh.v, surf_trimesh.f)
intersecting_surf_trimesh = tm.boolean.intersection([model_trimesh, surf_trimesh], engine='scad')
intersecting_surf_trimesh.show()
intersecting_surf.plot()
Description
Hi,
I am currently trying to do some Boolean operations between a mesh and a surface: I would like to return the portion of the surface (as a surface mesh) constrained by the mesh. However, when attempting the Boolean operations in PyVista, I instead get the cut portion of the mesh:
Using an OpenScad-based engine, I can obtain the desired output:
I would like to be able to complete the same operation in PyVista, is this possible? How might I go about this? Below is my code to reproduce the above images: