Skip to content

Meshcutter fully working#20

Merged
nullStack65 merged 11 commits intoreleasesfrom
dev
Jan 10, 2026
Merged

Meshcutter fully working#20
nullStack65 merged 11 commits intoreleasesfrom
dev

Conversation

@nullStack65
Copy link
Owner

No description provided.

Your Name and others added 11 commits January 9, 2026 06:44
Add --overshoot CLI argument to control how far cuts extend beyond
the part boundary. Change default behavior to not clip grid mask
to footprint, allowing cuts to go completely through each foot cell
instead of stopping at the part edge.
…lidation

Major refactoring of meshcutter core:
- Extract geometry utilities (grid detection, cell centers) into geometry.py
- Extract foot cutting logic into foot_cutter.py with manifold support
- Add cq_cutter.py for CadQuery-based Gridfinity profile generation
- Add validation.py for mesh validation utilities

Fix cutter taper direction:
- Changed flip_z logic to translate instead of negate Z coordinates
- This preserves correct taper direction (narrow at z=0, wide at z=5)
- Removed unnecessary mesh.invert() call after translation

Results: Volume difference from expected reduced from 2.53% to 0.67%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The cutter's F1-Fm formula creates a rim that exactly matches the 1U foot
boundary. For edge cells, micro-foot outer boundaries are coplanar with
the model's outer wall (both at 20.75mm from cell center), leaving no
material for the cutter to remove.

Add two parameters to fix this:
- wall_cut: Shrinks micro-feet in cutter calculation, creating cutter
  material that extends into the model at outer edges. Default 0.5mm
  now cuts ~0.35-1.27mm into outer walls.
- overshoot: Extends cutter envelope beyond normal F1 boundary (optional,
  for through-cuts).

Tested: wall_cut=0.5 increases volume removed from 26273.5 to 29105.7 mm³

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add automatic input mesh cleanup to remove floating/degenerate components
  (fixes 4 degenerate triangles in microfinity-generated STLs)
- Shift cutter Z by -epsilon to avoid coplanar faces at Z=0
  (eliminates up/down duplicate faces at foot tips)
- Change --overshoot default from 0.0 to 1.0 to cut outer walls by default
- Add --no-clean flag to disable automatic cleanup if needed

Before: 14630 flat Z=0 faces (7407 up, 7223 down), 1328 non-manifold edges
After: 19096 flat Z=0 faces (all down), 591 non-manifold edges (at Z=4-5mm only)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change foot_size from micro_pitch to (micro_pitch - GR_TOL) to match
  microfinity's actual foot dimensions (10.0mm instead of 10.5mm for div=4)
- Add generate_boundary_fill() to cover outer chamfer regions of edge cells
- Add output mesh cleanup to remove small floating boolean artifacts
- Add tests verifying micro-foot matches microfinity output exactly

The meshcutter output now matches microfinity-generated reference:
- Foot width at straight section: 5.2mm (was 5.7mm, +0.5mm error)
- All chamfer and vertical wall dimensions now correct
- Output is single watertight component after cleanup
… seams

- Add _top_chamfer_run() helper to calculate chamfer horizontal extent (~2.4mm)
- Increase channel width from 2.5mm to 5.4mm (GR_TOL + 2*top_run + eps_xy)
- Add eps_xy overshoot to channel lengths to avoid plus-shaped remnants
- Fix boundary fill rim thickness to properly cover outer chamfer regions
- Keep outer boundary fixed to avoid nicking sidewalls
Add footprint_bounds parameter to generate_intercell_channels() and
generate_boundary_fill() to prevent cutter geometry from extending
beyond the model's actual XY extent.

Key changes:
- Use mesh_bounds (full model extent at foot base) instead of
  footprint.bounds (at Z=0 foot tip where feet are narrower)
- Clip channel lengths to footprint bounds to avoid corner clipping
- Add corner inset calculation to prevent wide tapered channels from
  extending into the model's rounded corners
- Boundary fill now constrained to model footprint

This reduces the corner clipping artifacts where triangles would
extend up the full height of the model sidewalls. Remaining diff
vs reference is ~0.12% of model volume, primarily due to
tessellation differences.
Implement a new approach that replaces the entire foot region instead of
carving with boolean operations. This eliminates the ~50mm³ geometric
residuals that occurred at junction points and outer corners.

Key changes:
- Add meshcutter/core/replace_base.py with the new pipeline:
  - trim_mesh_above_z(): Extract top portion using Manifold's trimByPlane
  - generate_micro_base_with_sleeve(): Generate fresh micro-feet base
  - replace_base_pipeline(): Combine trimmed top with new base via union
  - convert_to_micro(): High-level convenience API

- Update foot_cutter.py with convert_to_micro_feet() API that supports
  both approaches via use_replace_base parameter

- Update CLI (meshcut.py) to use replace-base by default:
  - New --use-boolean flag to opt into legacy boolean subtraction
  - Legacy approach preserves magnet holes but has residuals
  - Replace-base produces exact match but removes base features

- Mark generate_junction_correction() as deprecated (doesn't work)

Results:
- Replace-base: 0.01mm³ total geometric difference vs reference
- Boolean subtraction: 49.78mm³ difference (unchanged)

Limitation: Replace-base removes everything below z=5mm including
magnet holes, screw holes, and embossed text on base.
- Add centralized utility modules:
  - constants.py: Re-export Gridfinity constants from microfinity
  - mesh_utils.py: Mesh conversion and repair functions
  - cq_utils.py: CadQuery utilities (ZLEN_FIX, extrude_profile)
  - grid_utils.py: Grid offset calculations

- Update existing modules to use shared utilities:
  - detection.py: Add robust frame detection helpers
  - validation.py: Improve mesh validation

- Add project documentation:
  - CLAUDE.md: Project context for AI assistants
  - REFACTOR_TODO.md: Track refactoring progress
  - docs/TODO_FUTURE_DIVISIONS.md: Future 0.5U/1/3U plans

- Update tests for new grid_utils signatures

All 93 meshcutter tests pass. End-to-end conversion produces
<0.01mm³ volume difference vs native micro-generated boxes.
- Sync dev version to 1.2.0 (matches PyPI releases)
- Meshcutter now imports __version__ from microfinity (single source of truth)
- Update CLI to use meshcutter.core.constants instead of hardcoded values
- Add meshcutter/ to CI lint and test paths
- Add manifold3d to CI test dependencies
- Add sync-to-dev workflow to sync version bumps after releases
- Add auto-merge workflow for release-please PRs

All 93 meshcutter tests pass. Versions now unified:
  microfinity: 1.2.0
  meshcutter:  1.2.0
  CLI:         1.2.0
- Fix flake8 lint errors (F541 unused f-strings, E501 line too long)
- Add pytest markers: integration, golden
- Mark test_integration.py tests with @pytest.mark.integration
- Refactor CI workflow into separate jobs:
  - lint: black + flake8
  - test-microfinity: Python 3.9-3.12 matrix
  - test-meshcutter-unit: Python 3.9-3.12 matrix (excludes integration)
  - test-meshcutter-integration: Python 3.11 only
  - build: package build validation

This provides faster feedback and clearer test results.
@nullStack65 nullStack65 merged commit a4c911f into releases Jan 10, 2026
13 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