Files
HartOMat/backend/app/api/routers/global_render_positions.py
T
Hartmut ca62319688 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>
2026-03-11 14:40:36 +01:00

76 lines
2.6 KiB
Python

import uuid
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.database import get_db
from app.models import GlobalRenderPosition
from app.domains.rendering.schemas import (
GlobalRenderPositionCreate,
GlobalRenderPositionPatch,
GlobalRenderPositionOut,
)
from app.utils.auth import require_admin, get_current_user
router = APIRouter(prefix="/render-positions/global", tags=["global-render-positions"])
@router.get("", response_model=list[GlobalRenderPositionOut])
async def list_global_render_positions(
db: AsyncSession = Depends(get_db),
_user=Depends(get_current_user),
):
"""List all global render positions (available to all authenticated users)."""
result = await db.execute(
select(GlobalRenderPosition).order_by(GlobalRenderPosition.sort_order, GlobalRenderPosition.name)
)
return result.scalars().all()
@router.post("", response_model=GlobalRenderPositionOut, status_code=status.HTTP_201_CREATED)
async def create_global_render_position(
body: GlobalRenderPositionCreate,
db: AsyncSession = Depends(get_db),
_user=Depends(require_admin),
):
"""Create a new global render position (admin only)."""
pos = GlobalRenderPosition(**body.model_dump())
db.add(pos)
await db.commit()
await db.refresh(pos)
return pos
@router.patch("/{pos_id}", response_model=GlobalRenderPositionOut)
async def update_global_render_position(
pos_id: uuid.UUID,
body: GlobalRenderPositionPatch,
db: AsyncSession = Depends(get_db),
_user=Depends(require_admin),
):
"""Update a global render position (admin only)."""
result = await db.execute(select(GlobalRenderPosition).where(GlobalRenderPosition.id == pos_id))
pos = result.scalar_one_or_none()
if not pos:
raise HTTPException(status_code=404, detail="Global render position not found")
for field, value in body.model_dump(exclude_unset=True).items():
setattr(pos, field, value)
await db.commit()
await db.refresh(pos)
return pos
@router.delete("/{pos_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_global_render_position(
pos_id: uuid.UUID,
db: AsyncSession = Depends(get_db),
_user=Depends(require_admin),
):
"""Delete a global render position (admin only)."""
result = await db.execute(select(GlobalRenderPosition).where(GlobalRenderPosition.id == pos_id))
pos = result.scalar_one_or_none()
if not pos:
raise HTTPException(status_code=404, detail="Global render position not found")
await db.delete(pos)
await db.commit()