Commit Graph

73 Commits

Author SHA1 Message Date
c575d82f80 Merge feature/gpu-bitmap-bestfit into master 2026-03-07 20:02:22 -05:00
90b89a5dfa feat: add FillRectangleBestFit strategy and remove false overlap rejection
- Remove IsBetterValidFill overlap gate for FillLinear results; the
  geometry-aware spacing in FillLinear is sufficient and the overlap
  check produced false positives on parts with arcs/curves, causing
  valid grid layouts to be rejected in favor of inferior pair fills.
- Add FillRectangleBestFit strategy that uses BestCombination to mix
  normal and rotated orientations, filling remnant strips for higher
  part counts on rectangular parts.
- All Fill overloads now compare linear, rectangle best-fit, and
  pair-based strategies, picking whichever yields the most parts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:00:38 -05:00
0c14d7f854 fix: align best-fit sweep to include offset=0 for grid arrangements
The perpendicular sweep started at perpMin (e.g. -8.75) which with
coarse step sizes never landed on offset=0, missing the perfect
side-by-side and stacked same-orientation patterns for rectangular parts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:24:37 -05:00
73c20c30ce fix: exclude rapid moves from Part.Intersects to fix FillLinear rejection
Part.Intersects included rapid move geometry (G00 traversals) when
checking for overlaps, causing false positives. The overlap validation
added in 5bebfcb rejected all FillLinear configs, producing 0 parts.
Every other GetShapes caller already filters SpecialLayers.Rapid.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:52:35 -05:00
7ed4572f8a feat: add GPU status indicator and device probe
- GpuEvaluatorFactory probes for CUDA/OpenCL devices at startup
- Status bar shows "GPU : <device name>" (green) or "GPU : None (CPU)" (gray)
- Factory skips GPU evaluator creation entirely when no device found
- Logs actual exception message on failure for debugging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:34:45 -05:00
5bebfcb612 feat: wire GpuPairEvaluator into NestEngine with auto-detection
NestEngine.CreateEvaluator factory delegate allows injection of GPU
evaluator from UI layer. GpuEvaluatorFactory.Create attempts GPU,
returns null (CPU fallback) if unavailable. All NestEngine call sites
wired up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:27:15 -05:00
1c1508bc9e feat: add GpuPairEvaluator with ILGPU bitmap overlap kernel
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:24:39 -05:00
8d28167b2f feat: add OpenNest.Gpu project with PartBitmap rasterizer
Introduces the OpenNest.Gpu class library with ILGPU dependencies and a
PartBitmap class that rasterizes Drawing closed shapes into integer grids
for GPU-based overlap testing. Supports rotation and spacing dilation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:22:27 -05:00
b83d09c3a7 refactor: extract IPairEvaluator interface from PairEvaluator
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:19:05 -05:00
dd7383467b feat: add Polygon.ContainsPoint using ray casting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:13:12 -05:00
688b00b3e4 docs: add GPU bitmap best fit implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:06:01 -05:00
443556d2e3 docs: add GPU bitmap best fit evaluation design
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:03:40 -05:00
bc411949b8 fix: use offset geometry for moving part in FillLinear spacing
Offset the moving shape's geometry by PartSpacing instead of adding
spacing linearly to the copy distance. This guarantees minimum clearance
in all directions for curved/complex shapes, not just along the slide axis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 14:10:48 -05:00
54cdf21264 docs: update CLAUDE.md for .NET 8 migration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:32:11 -05:00
0e7eb3df81 chore: update solution file for Visual Studio 17
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:31:43 -05:00
e6e87b7cad refactor: simplify MainApp for .NET 8 DPI handling
DPI awareness is now handled by the ApplicationHighDpiMode project property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:31:19 -05:00
848023a2b9 refactor: rewrite DxfExporter for ACadSharp
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:30:23 -05:00
d185adecfa refactor: rewrite DxfImporter for ACadSharp
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:26:33 -05:00
3baa942f4e refactor: rewrite IO Extensions for ACadSharp
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:25:04 -05:00
263c2d0ae1 feat: convert OpenNest WinForms project to .NET 8 SDK-style
Build errors expected in IO files — netDxf references not yet migrated to ACadSharp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:23:47 -05:00
a6949a390d feat: convert OpenNest.Engine to .NET 8 SDK-style project
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:22:09 -05:00
6ce81d99a7 feat: convert OpenNest.Core to .NET 8 SDK-style project
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:21:16 -05:00
afca2068cc feat: integrate best-fit pair finding into NestEngine.Fill
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 12:03:03 -05:00
955446a2f4 feat: add BestFitFinder orchestrator with hull edge angle strategies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:54:26 -05:00
7a0aac9f59 feat: add BestFitFilter and TileEvaluator for pair filtering and tiling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:51:44 -05:00
2a8b2dfdee feat: add PairEvaluator with overlap detection and rotating calipers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:49:26 -05:00
21e1c959d3 feat: add RotationSlideStrategy with directional push contact algorithm
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:45:28 -05:00
86fee08670 feat: add PairCandidate, BestFitResult, and IBestFitStrategy for best-fit pair finding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:42:43 -05:00
b030de77a8 feat: restore previous action on Escape from ActionSelect
Pressing Escape from ActionSelect now restores the previous action
(e.g. ActionClone) instead of staying in Select mode. Adds
ConnectEvents() to the Action base class for action resume support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:51:28 -05:00
0573cb2f6d feat: fill open area and optimize pattern rotation via convex hull
ActionClone.Fill() now computes the largest open rectangle from the
cursor position (trying both vertical and horizontal) and passes it
to the engine, so fills no longer overlap existing parts.

Pattern fills try all convex hull edge angles to find the rotation
that maximizes part count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:51:21 -05:00
0b2100a661 fix: restore SelectedParts after plate switch in ActionClone
SetPlate clears SelectedParts, which broke bounds drawing and rotation
for surviving actions. Add OnPlateChanged hook so ActionClone can
re-populate SelectedParts after a plate switch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:11:22 -05:00
fd778e2fd2 fix: preserve ActionClone across plate switches
SetPlate unconditionally reset the action to ActionSelect, clearing
the clone pattern when switching plates. Add SurvivesPlateChange
virtual property to Action base class so actions can opt in to
persisting across plate changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:05:13 -05:00
40b40ca4ba feat: unify ActionAddPart into ActionClone and add group fill support
Merge ActionAddPart into ActionClone by adding a Drawing constructor,
eliminating the redundant class. ActionClone now handles both adding
new parts from a drawing and cloning selected part groups. Added
Ctrl+F fill support for groups using FillLinear pattern tiling, and
adopted quadrant-aware push directions from ActionAddPart. Refactored
FillLinear to extract shared helpers and add a Fill(Pattern) overload
for tiling arbitrary part groups across the work area.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 09:56:48 -05:00
5807255931 feat: replace Fill method with geometry-aware FillLinear algorithm
Fill(NestItem) now uses actual part geometry instead of bounding boxes.
Also fixes Fill(NestItem, maxCount) which previously threw NotImplementedException.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 07:53:02 -05:00
5707bff89b feat: rotate selected parts 90° on middle mouse click
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:12:03 -05:00
be8b499880 feat: add NestEngine.FillLinear with 4-config rotation/axis optimization
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 01:01:41 -05:00
98818d32e3 feat: add full plate fill with pattern-level geometry-aware tiling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:58:35 -05:00
1193091338 feat: add FillRow method for single-axis geometry-aware fill
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:56:44 -05:00
b8d9155cd0 feat: add FillLinear class with geometry-aware copy distance
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:54:06 -05:00
f4779b878c feat: add Pattern class for grouping parts with relative positions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:52:11 -05:00
949a9ffc7d chore: remove rotating calipers design plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:50:27 -05:00
1c8763a201 feat: update FindBestRotation to use rotating calipers algorithm
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:49:09 -05:00
a190ed25b4 feat: add RotatingCalipers class with minimum bounding rectangle algorithm
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:46:42 -05:00
13e93c3534 feat: add ConvexHull class with Andrew's monotone chain algorithm
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:44:04 -05:00
0424d8db20 docs: add rotating calipers design plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:39:09 -05:00
4d270ae68e fix: remove self-intersecting loops from polygon offset
Polygon offset at concave corners creates geometry that folds back
through itself. Added RemoveSelfIntersections() to Polygon that
detects non-adjacent edge crossings and removes the smaller loop
at each crossing. Applied to both collision detection and rendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:23:44 -05:00
08b31d0797 fix: stop push at contact boundary and filter edges by direction
RayEdgeDistance returned double.MaxValue for touching vertices (dist ≈ 0),
causing rays from other vertices to hit the far side of stationary parts
and allow movement through obstacles. Now returns 0 when touching so the
distance > 0 check in PushSelected correctly prevents further movement.

Added directional edge filtering using outward normals to discard
back-facing edges before ray checks, reducing line count by ~2/3.
DirectionalDistance now checks both StartPoint and EndPoint per line
to preserve vertices at filtered edge boundaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 21:42:40 -05:00
49cc65903d chore: remove obsolete geometry push design plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 20:54:24 -05:00
6561b478a5 fix: prevent scientific notation in G-code output
ProgramReader treats 'E' as a code letter, so values like
"6.66E-08" get split into X:"6.66" and E:"-08", corrupting
the parsed coordinate. Use fixed-point format string instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 20:54:20 -05:00
1c4015ac62 fix: CadConverter SetRotation ignored rotation parameter
SetRotation always forced CW regardless of the requested rotation,
so cutouts (which should be CCW for kerf-left) were also set to CW.
Now uses the rotation parameter to set the correct winding direction.

Also reverts the Shape.OffsetEntity cutout side inversion since the
correct fix is proper winding from the converter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 19:41:42 -05:00