We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import trimesh import numpy as np # Load meshes try_mesh = trimesh.load_mesh('/Users/xd_anshul/Desktop/Research/Defect/obj.stl') defect_mesh = trimesh.load_mesh('/Users/xd_anshul/Desktop/Research/Defect/sphere.ply') defect_mesh.apply_scale(0.04) # Voxelize object mesh voxel_grid = trimesh.voxel.creation.voxelize(try_mesh, 0.003) # Adjust resolution as needed # Get all voxel centers voxel_centers = voxel_grid.points # Select a random voxel center random_voxel_index = np.random.randint(len(voxel_centers)) random_voxel_center = voxel_centers[random_voxel_index] # Translate defect mesh to random voxel center defect_mesh.apply_translation(random_voxel_center) defect_mesh.visual.vertex_colors = trimesh.visual.random_color() # Perform Boolean difference (using a suitable engine) try_mesh = trimesh.boolean.difference([try_mesh, defect_mesh], engine="blender") # Adjust engine if needed scene = trimesh.Scene([try_mesh,defect_mesh]) scene.show() # Visualize
This could add a surface defect wasily, but I wanted to insert the defecr completely! Any suggestion?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This could add a surface defect wasily, but I wanted to insert the defecr completely! Any suggestion?
The text was updated successfully, but these errors were encountered: