feat: sharp edge pipeline V02, tessellation presets, media cache-bust, GMSH plan
Sharp Edge Pipeline V02:
- export_step_to_gltf.py: replace BRep_Tool.Polygon3D_s (returns None in XCAF) with
GCPnts_UniformAbscissa curve sampling at 0.3mm step — extracts 17,129 segment pairs
- Inject sharp_edge_pairs + sharp_threshold_deg into GLB extras (scenes[0].extras)
via binary GLB JSON-chunk patching (no extra dependency)
- export_gltf.py: read schaeffler_sharp_edge_pairs from Blender scene custom props,
apply via KD-tree to mark edges sharp=True + seam=True (OCC mm Z-up → Blender transform)
- tools/restore_sharp_marks.py: dual-pass (dihedral angle + OCC pairs), updated coordinate
transform (X, -Z, Y) * 0.001
Tessellation:
- Admin UI: Draft / Standard / Fine preset buttons with active-state highlighting
- Default angular deflection: preview 0.5→0.1 rad, production 0.2→0.05 rad
- export_glb.py: read updated defaults from system_settings
Media / Cache:
- media/service.py: get_download_url appends ?v={file_size_bytes} cache-buster
- media/router.py: Cache-Control: no-cache for all download/thumbnail endpoints
Render pipeline:
- still_render.py / turntable_render.py: shared GPU activation + camera improvements
- render_order_line.py: global render position support
- render_thumbnail.py: updated defaults
Frontend:
- InlineCadViewer: file_size_bytes-aware URL update triggers re-fetch on regeneration
- ThreeDViewer: material panel, part selection, PBR mode improvements
- Admin.tsx: tessellation preset cards, GMSH setting dropdown
- MediaBrowser, ProductDetail, OrderDetail, Orders: various UI improvements
- New: MaterialPanel, GlobalRenderPositionsPanel, StepIndicator components
- New: renderPositions.ts API client
Plans / Docs:
- plan.md: GMSH Frontal-Delaunay tessellation plan (6 tasks)
- LEARNINGS.md: OCC Polygon3D_s None issue + GCPnts fix
- .gitignore: add backend/core (core dump from root process)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,9 +43,9 @@ SETTINGS_DEFAULTS: dict[str, str] = {
|
||||
"smtp_from_address": "",
|
||||
# glTF tessellation quality (OCC BRepMesh)
|
||||
"gltf_preview_linear_deflection": "0.1", # mm — geometry GLB for viewer
|
||||
"gltf_preview_angular_deflection": "0.5", # rad
|
||||
"gltf_preview_angular_deflection": "0.1", # rad — Standard preset
|
||||
"gltf_production_linear_deflection": "0.03", # mm — production GLB
|
||||
"gltf_production_angular_deflection": "0.2", # rad
|
||||
"gltf_production_angular_deflection": "0.05", # rad — Standard preset
|
||||
# 3D viewer / glTF export settings
|
||||
"gltf_scale_factor": "0.001",
|
||||
"gltf_smooth_normals": "true",
|
||||
@@ -77,9 +77,9 @@ class SettingsOut(BaseModel):
|
||||
smtp_password: str = ""
|
||||
smtp_from_address: str = ""
|
||||
gltf_preview_linear_deflection: float = 0.1
|
||||
gltf_preview_angular_deflection: float = 0.5
|
||||
gltf_preview_angular_deflection: float = 0.1
|
||||
gltf_production_linear_deflection: float = 0.03
|
||||
gltf_production_angular_deflection: float = 0.2
|
||||
gltf_production_angular_deflection: float = 0.05
|
||||
gltf_scale_factor: float = 0.001
|
||||
gltf_smooth_normals: bool = True
|
||||
viewer_max_distance: float = 50.0
|
||||
@@ -420,9 +420,12 @@ async def regenerate_thumbnails(
|
||||
admin: User = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Re-queue all completed CAD files for thumbnail regeneration."""
|
||||
"""Re-queue completed CAD files that are linked to a product for thumbnail regeneration."""
|
||||
from app.domains.products.models import Product
|
||||
result = await db.execute(
|
||||
select(CadFile).where(CadFile.processing_status == ProcessingStatus.completed)
|
||||
select(CadFile)
|
||||
.join(Product, Product.cad_file_id == CadFile.id)
|
||||
.where(CadFile.processing_status == ProcessingStatus.completed)
|
||||
)
|
||||
cad_files = result.scalars().all()
|
||||
|
||||
@@ -435,6 +438,71 @@ async def regenerate_thumbnails(
|
||||
return {"queued": queued, "message": f"Re-queued {queued} CAD file(s) for thumbnail regeneration"}
|
||||
|
||||
|
||||
@router.get("/settings/orphaned-cad-files")
|
||||
async def get_orphaned_cad_files(
|
||||
admin: User = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Return count and total disk size of CadFiles not linked to any product."""
|
||||
from sqlalchemy import func
|
||||
from app.domains.products.models import Product
|
||||
result = await db.execute(
|
||||
select(func.count(CadFile.id), func.sum(CadFile.file_size))
|
||||
.outerjoin(Product, Product.cad_file_id == CadFile.id)
|
||||
.where(Product.id.is_(None))
|
||||
)
|
||||
count, total_bytes = result.one()
|
||||
return {
|
||||
"count": count or 0,
|
||||
"total_mb": round((total_bytes or 0) / 1024 / 1024, 1),
|
||||
}
|
||||
|
||||
|
||||
@router.post("/settings/cleanup-orphaned-cad-files")
|
||||
async def cleanup_orphaned_cad_files(
|
||||
admin: User = Depends(require_admin),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Delete CadFile DB records and associated files on disk for all orphaned CadFiles.
|
||||
|
||||
A CadFile is orphaned if no product currently references it via products.cad_file_id.
|
||||
"""
|
||||
import os
|
||||
from app.domains.products.models import Product
|
||||
|
||||
result = await db.execute(
|
||||
select(CadFile)
|
||||
.outerjoin(Product, Product.cad_file_id == CadFile.id)
|
||||
.where(Product.id.is_(None))
|
||||
)
|
||||
orphans = result.scalars().all()
|
||||
|
||||
deleted_files = 0
|
||||
deleted_bytes = 0
|
||||
|
||||
for cad_file in orphans:
|
||||
# Remove files from disk (non-fatal if missing)
|
||||
for path_attr in ("stored_path", "thumbnail_path", "gltf_path"):
|
||||
path = getattr(cad_file, path_attr, None)
|
||||
if path:
|
||||
try:
|
||||
if os.path.isfile(path):
|
||||
size = os.path.getsize(path)
|
||||
os.remove(path)
|
||||
deleted_files += 1
|
||||
deleted_bytes += size
|
||||
except OSError:
|
||||
pass
|
||||
await db.delete(cad_file)
|
||||
|
||||
await db.commit()
|
||||
return {
|
||||
"deleted_records": len(orphans),
|
||||
"deleted_files": deleted_files,
|
||||
"freed_mb": round(deleted_bytes / 1024 / 1024, 1),
|
||||
}
|
||||
|
||||
|
||||
@router.post("/settings/reextract-metadata", status_code=status.HTTP_202_ACCEPTED)
|
||||
async def reextract_all_metadata(
|
||||
admin: User = Depends(require_admin),
|
||||
@@ -445,8 +513,11 @@ async def reextract_all_metadata(
|
||||
Updates mesh_attributes without re-rendering thumbnails or changing processing status.
|
||||
Use this after deploying bbox/edge extraction improvements.
|
||||
"""
|
||||
from app.domains.products.models import Product
|
||||
result = await db.execute(
|
||||
select(CadFile).where(
|
||||
select(CadFile)
|
||||
.join(Product, Product.cad_file_id == CadFile.id)
|
||||
.where(
|
||||
CadFile.processing_status == ProcessingStatus.completed,
|
||||
CadFile.stored_path.isnot(None),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user