Add bin grouping to consolidate identical bins in results
Implements grouping of identical bins (same items in same order) to reduce visual clutter in the results grid. Instead of showing 10 identical bins as separate rows, they now appear as a single row with a count. - Add BinComparer for deep equality comparison of bins - Add BinGroup to represent grouped bins with count - Update ResultsForm to display grouped bins in grid - Add Count column to show how many of each bin pattern - Maintain original bins list for file export This improves readability when the optimizer generates multiple identical cutting patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
51
SawCut/BinGroup.cs
Normal file
51
SawCut/BinGroup.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace SawCut
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a group of identical bins (bins with the same items in the same order).
|
||||
/// Used for displaying consolidated results.
|
||||
/// </summary>
|
||||
public class BinGroup
|
||||
{
|
||||
public BinGroup(Bin representativeBin, int count)
|
||||
{
|
||||
if (representativeBin == null)
|
||||
throw new ArgumentNullException(nameof(representativeBin));
|
||||
|
||||
if (count <= 0)
|
||||
throw new ArgumentException("Count must be greater than zero", nameof(count));
|
||||
|
||||
RepresentativeBin = representativeBin;
|
||||
Count = count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A representative bin from this group (all bins in the group are identical).
|
||||
/// </summary>
|
||||
public Bin RepresentativeBin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of identical bins in this group.
|
||||
/// </summary>
|
||||
public int Count { get; }
|
||||
|
||||
// Properties that delegate to the representative bin for data binding
|
||||
public double Spacing => RepresentativeBin.Spacing;
|
||||
public double Length => RepresentativeBin.Length;
|
||||
public double UsedLength => RepresentativeBin.UsedLength;
|
||||
public double RemainingLength => RepresentativeBin.RemainingLength;
|
||||
public double Utilization => RepresentativeBin.Utilization;
|
||||
public IReadOnlyList<BinItem> Items => RepresentativeBin.Items;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Count == 1)
|
||||
return RepresentativeBin.ToString();
|
||||
|
||||
return $"{RepresentativeBin} (x{Count})";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user