mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-03 10:59:27 -05:00
refactor: share duplicated fill, cache, settings and toggle code
- fill_plate and fill_area share one MCP fill helper - FillLinear uses FillHelpers.HasOverlappingParts - BestFitCache and FillResultCache entries derive from DrawingCacheEntry - NestDefaults and ClampSettings read through SettingsFile.TryReadText - MainForm view toggles share one ToggleView handler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b61d249c0
commit
d77693aaff
10 files changed
+178
-217
No files matched your search
@@ -227,23 +227,13 @@ namespace OpenNest.Engine.BestFit
|
||||
}
|
||||
}
|
||||
|
||||
private static Entry GetEntry(Drawing drawing)
|
||||
{
|
||||
var source = CanonicalFrame.SourceOf(drawing);
|
||||
|
||||
if (_entries.TryGetValue(source, out var entry) && entry.IsCurrentFor(source))
|
||||
return entry;
|
||||
|
||||
lock (_entriesLock)
|
||||
{
|
||||
if (_entries.TryGetValue(source, out entry) && entry.IsCurrentFor(source))
|
||||
return entry;
|
||||
|
||||
entry = new Entry(source);
|
||||
_entries.AddOrUpdate(source, entry);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
private static Entry GetEntry(Drawing drawing) =>
|
||||
DrawingCacheEntry.GetOrCreate(
|
||||
_entries,
|
||||
_entriesLock,
|
||||
CanonicalFrame.SourceOf(drawing),
|
||||
static source => new Entry(source)
|
||||
);
|
||||
|
||||
private static List<BestFitResult> GetCandidates(Entry entry, Drawing drawing, double spacing)
|
||||
{
|
||||
@@ -407,11 +397,8 @@ namespace OpenNest.Engine.BestFit
|
||||
return copy;
|
||||
}
|
||||
|
||||
private sealed class Entry
|
||||
private sealed class Entry : DrawingCacheEntry
|
||||
{
|
||||
private readonly CNC.Program _program;
|
||||
private readonly double _sourceAngle;
|
||||
|
||||
public readonly ConcurrentDictionary<double, Lazy<List<BestFitResult>>> Unfiltered = new();
|
||||
|
||||
public readonly ConcurrentDictionary<
|
||||
@@ -420,14 +407,7 @@ namespace OpenNest.Engine.BestFit
|
||||
> Filtered = new();
|
||||
|
||||
public Entry(Drawing source)
|
||||
{
|
||||
_program = source.Program;
|
||||
_sourceAngle = source.Source?.Angle ?? 0.0;
|
||||
}
|
||||
|
||||
public bool IsCurrentFor(Drawing source) =>
|
||||
ReferenceEquals(_program, source.Program)
|
||||
&& _sourceAngle == (source.Source?.Angle ?? 0.0);
|
||||
: base(source) { }
|
||||
}
|
||||
|
||||
/// <summary>The geometry a drawing was reconstructed from, and the program built then.</summary>
|
||||
|
||||
Reference in new issue
Block a user