From cd6c2f48e2f651b6129eeaa1b59153742480dd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hartmut=20N=C3=B6renberg?= Date: Wed, 11 Mar 2026 20:46:42 +0100 Subject: [PATCH] fix(gmsh): force preview-quality settings when GMSH fallback path is taken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fine production settings (0.03mm/0.05rad) with GMSH → CharacteristicLengthMax 0.45mm → OOM kill on large assemblies even with per-solid iteration. GMSH quality is algorithmic (conforming seams, no fan triangles) — a denser mesh provides no extra UV-unwrap benefit. Cap GMSH tessellation at preview settings (0.1mm/0.1rad) in the production fallback path. Normal path (GMSH + valid geometry GLB) is unaffected — continues to reuse _geometry.glb directly without re-tessellating. Co-Authored-By: Claude Sonnet 4.6 --- .../app/domains/pipeline/tasks/export_glb.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/app/domains/pipeline/tasks/export_glb.py b/backend/app/domains/pipeline/tasks/export_glb.py index 173563b..26f1353 100644 --- a/backend/app/domains/pipeline/tasks/export_glb.py +++ b/backend/app/domains/pipeline/tasks/export_glb.py @@ -283,20 +283,30 @@ def generate_gltf_production_task(self, cad_file_id: str, product_id: str | None "info", ) else: - # No usable cache: run tessellation from STEP + # No usable cache: run tessellation from STEP. + # When GMSH is selected, force preview-quality settings (0.1mm / 0.1rad) even here. + # Fine production settings (e.g. 0.03mm) combined with GMSH OOM-kill on large assemblies + # because CharacteristicLengthMax becomes too small. GMSH quality is algorithmic + # (conforming seams) not density-based — a denser GMSH mesh adds no UV-unwrap benefit. + if tessellation_engine == "gmsh": + eff_linear = float(sys_settings.get("gltf_preview_linear_deflection", "0.1")) + eff_angular = float(sys_settings.get("gltf_preview_angular_deflection", "0.1")) + else: + eff_linear = prod_linear + eff_angular = prod_angular occ_cmd = [ python_bin, str(occ_script), "--step_path", str(step_path), "--output_path", str(prod_geom_glb), - "--linear_deflection", str(prod_linear), - "--angular_deflection", str(prod_angular), + "--linear_deflection", str(eff_linear), + "--angular_deflection", str(eff_angular), "--sharp_threshold", str(sharp_threshold), "--tessellation_engine", tessellation_engine, ] log_task_event( self.request.id, - f"Tessellating STEP at production quality ({tessellation_engine}, " - f"linear={prod_linear}mm, angular={prod_angular}rad)", + f"Tessellating STEP for production ({tessellation_engine}, " + f"linear={eff_linear}mm, angular={eff_angular}rad)", "info", ) try: