Skip to content

feat: implement Feature 1 — File Loading#4

Merged
kraulerson merged 10 commits intomainfrom
feature/file-loading
Apr 6, 2026
Merged

feat: implement Feature 1 — File Loading#4
kraulerson merged 10 commits intomainfrom
feature/file-loading

Conversation

@kraulerson
Copy link
Copy Markdown
Owner

Summary

Implements the complete data-layer file loading pipeline for meshscope (Feature 1 of 10 in the MVP Cutline). Loads STL (binary/ASCII), OBJ, 3MF, and PLY mesh files into an in-memory MeshDocument with full validation, error handling, and computed metadata. No UI — viewport integration comes with Feature 2.

What's included

  • Exception hierarchy (MeshLoadErrorFileValidationError / MeshParseError subclasses) with user-facing messages ready for UI display
  • Immutable data model (BoundingBox, MeshMetadata, MeshData frozen dataclasses) with typed numpy arrays (mypy strict clean)
  • UndoStack ring buffer shell (populated by Features 7-8)
  • MeshDocument mutable session wrapper with deep-copied original mesh for reset
  • Path validation (extension, existence, readability, 500MB size limit)
  • load_mesh() pipeline: validate → detect format → pre-parse STL validation → parse via trimesh (explicit file_type, never generic load()) → Scene handling for 3MF → convert to data model → OBJ unsupported directive warnings → unit mismatch detection → structured logging
  • Test fixtures for all 4 formats (valid + invalid) with a regeneration script
  • 61 tests covering success paths, warnings, error conditions, and data integrity

Design spec deviations (deferred)

  • source_format stores "stl" / "ply" rather than sub-types ("stl_binary" / "ply_ascii"). Plan tests assert the simpler form. Can add sub-type detection when UI needs it.
  • parse_mesh is inlined in load_mesh rather than extracted as a separate function. Can extract if reuse is needed.

Test plan

  • 61 unit tests pass (pytest tests/ -v)
  • mypy strict clean (mypy src/meshscope/)
  • ruff clean
  • All pre-commit hooks pass (semgrep, gitleaks, ruff, trailing whitespace)
  • Verify CI passes on this PR

🤖 Generated with Claude Code

Karl Raulerson and others added 10 commits April 6, 2026 12:36
Brainstormed and approved design for Feature 1 (File Loading).
Data-layer only — no UI. Covers MeshData, MeshDocument, load_mesh()
API, exception hierarchy, format-specific handling, and test strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7-task TDD plan for Feature 1 (File Loading). Covers exception
hierarchy, dataclasses, undo stack, MeshDocument, test fixtures,
path validation, and load_mesh pipeline. Task 1 complete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generates cube meshes (8 verts, 12 faces) for STL binary, STL ASCII,
OBJ, OBJ+materials, PLY, and 3MF, plus 4 invalid fixtures for error
path testing. Adds networkx==3.6.1 and lxml==6.0.2 as required
dependencies for trimesh's 3MF loader.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndling

Completes mesh_loader.py with load_mesh(), OBJ warning detection,
unit mismatch warnings, and binary STL pre-parse validation to
differentiate corrupt vs empty files that trimesh silently swallows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kraulerson kraulerson merged commit a7f8fc2 into main Apr 6, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant