Skip to content

Commit 988576a

Browse files
committed
remeshing: remesh_surface supports per-vertex sizing via Medit .sol
- Detect optional in.sol in the working directory and pass it to MMGS using -sol. - Keep behavior unchanged when no .sol is present. - Clean up in.sol after remeshing to avoid leaking temp files.
1 parent 4eeb5a8 commit 988576a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

svv/utils/remeshing/remesh.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,14 @@ def remesh_surface(pv_polydata_object, autofix=True, ar=None, hausd=None, hgrad=
459459
raise NotImplementedError("Operating system not supported.")
460460
devnull = open(os.devnull, 'w')
461461
executable_list = [_EXE_, "tmp.mesh"]
462+
# If caller prepared a sizing function file in the working directory,
463+
# detect and pass it through to MMG.
464+
sol_path = None
465+
try:
466+
if os.path.exists("in.sol"):
467+
sol_path = "in.sol"
468+
except Exception:
469+
sol_path = None
462470
if ar is not None:
463471
executable_list.extend(["-ar", str(ar)])
464472
if hausd is not None:
@@ -487,6 +495,8 @@ def remesh_surface(pv_polydata_object, autofix=True, ar=None, hausd=None, hgrad=
487495
executable_list.extend(["-optim"])
488496
if rn is not None:
489497
executable_list.extend(["-rn", str(rn)])
498+
if sol_path:
499+
executable_list.extend(["-sol", sol_path])
490500
if verbosity == 0:
491501
try:
492502
subprocess.check_call(executable_list, stdout=devnull, stderr=devnull)
@@ -522,6 +532,12 @@ def remesh_surface(pv_polydata_object, autofix=True, ar=None, hausd=None, hgrad=
522532
os.remove("tmp.mesh")
523533
os.remove("tmp.o.sol")
524534
os.remove("tmp.o.mesh")
535+
# Clean up sizing file if provided
536+
if sol_path and os.path.exists(sol_path):
537+
try:
538+
os.remove(sol_path)
539+
except Exception:
540+
pass
525541
return remeshed_surface
526542

527543

@@ -1033,4 +1049,4 @@ def sphere_refinement(
10331049
os.remove("tmp.o.sol")
10341050
os.remove("tmp.o.mesh")
10351051
os.remove("in.sol")
1036-
return remeshed_surface
1052+
return remeshed_surface

0 commit comments

Comments
 (0)