Repository navigation
Default Offset Setting #6920
Closed
ParvGuptaSpCT
started this conversation in
General
Replies: 1 comment 1 reply
|
Hello! Expand/Shrink is from meshlib import mrmeshpy as mm
from meshlib import mrcudapy as mc
def expand_shrink(mesh: mm.Mesh, offset: float) -> mm.Mesh:
box = mesh.computeBoundingBox()
# "Standard" resolution: ~100M voxels in the box grown by the offset
size = box.size() + mm.Vector3f.diagonal(2 * offset)
voxelSize = float(f"{(size.x * size.y * size.z / 1e8) ** (1 / 3):.3g}")
params = mm.GeneralOffsetParameters()
params.voxelSize = voxelSize
params.signDetectionMode = mm.SignDetectionMode.HoleWindingRule
if not mesh.topology.isClosed():
params.fwn = mc.FastWindingNumber(mesh) # "Use NVIDIA GPU"
mesh = mm.generalOffsetMesh(mesh, 0, params) # close open mesh first
res = mm.doubleOffsetMesh(mesh, offset, -offset, params)
# "Decimate" + "Reduce Total Angle"
post = mm.MeshFromVoxelsPostProcessingParams()
post.voxelSize = voxelSize
post.decimate = True
post.reduceAngleNumIters = 3
post.tinyEdgeLength = box.diagonal() * 1e-4
mm.postprocessMeshFromVoxels(res, post)
return res
mesh = mm.loadMesh("input.stl")
mm.saveMesh(expand_shrink(mesh, 0.25), "output.stl")CUDA only speeds up closing an open mesh; a closed mesh is processed on CPU anyway. Without an NVIDIA GPU, just remove the This gives the same result as MeshInspector (needs meshlib 3.1.2 or newer). |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello Devs,
I'm trying to replicate the mesh offset as show in the image below, can you tell me which offset method has been used and what are the default settings used in MeshInspector UI
Thanks!
All reactions