mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 08:21:05 -04:00
Reading a nest used to fill the engine's static BestFitCache as a side effect, which is the only reason OpenNest.IO referenced OpenNest.Engine. Core now defines SavedPairSet/SavedPairResult and IBestFitStore; the mapping to BestFitResult moved verbatim into Engine's BestFitCacheStore. NestReader/NestWriter take the store as an optional BestFitStore property and skip bestfits/ entries without one. Every production reader and writer opts into BestFitCacheStore.Shared, so behaviour is unchanged; the golden round-trip test still matches byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace OpenNest.BestFit
|
|
{
|
|
/// <summary>One saved best-fit pair result, as persisted in a .nest archive.</summary>
|
|
public sealed record SavedPairResult(
|
|
double Part1Rotation,
|
|
double Part2Rotation,
|
|
double Part2OffsetX,
|
|
double Part2OffsetY,
|
|
int StrategyType,
|
|
int TestNumber,
|
|
double CandidateSpacing,
|
|
double RotatedArea,
|
|
double BoundingWidth,
|
|
double BoundingHeight,
|
|
double OptimalRotation,
|
|
bool Keep,
|
|
string Reason,
|
|
double TrueArea,
|
|
IReadOnlyList<double> HullAngles
|
|
);
|
|
|
|
/// <summary>The saved best-fit results for one drawing at one plate size and spacing.</summary>
|
|
public sealed record SavedPairSet(
|
|
double PlateWidth,
|
|
double PlateHeight,
|
|
double Spacing,
|
|
IReadOnlyList<SavedPairResult> Results
|
|
);
|
|
|
|
/// <summary>
|
|
/// Persists best-fit pair caches across .nest round trips. Implementations own their
|
|
/// cache; readers and writers never assume one exists, and a file without saved sets is
|
|
/// always valid because the data can be recomputed.
|
|
/// </summary>
|
|
public interface IBestFitStore
|
|
{
|
|
/// <summary>
|
|
/// Sets to save for <paramref name="drawing"/>, limited to the given
|
|
/// (plate width, plate length, part spacing) keys.
|
|
/// </summary>
|
|
IReadOnlyList<SavedPairSet> Export(
|
|
Drawing drawing,
|
|
IReadOnlySet<(double Width, double Length, double Spacing)> plateKeys
|
|
);
|
|
|
|
/// <summary>Restores saved sets for <paramref name="drawing"/>.</summary>
|
|
void Import(Drawing drawing, IReadOnlyList<SavedPairSet> sets);
|
|
}
|
|
}
|