refactor: extract training data collection into OpenNest.Training
Move brute-force data collection, TrainingDatabase, and GPU init from OpenNest.Console into a dedicated OpenNest.Training project. Replaces raw Microsoft.Data.Sqlite with EF Core. Console is now a pure nesting CLI with template support and cleaned-up usage output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
38
OpenNest.Training/Data/TrainingDbContext.cs
Normal file
38
OpenNest.Training/Data/TrainingDbContext.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace OpenNest.Training.Data
|
||||
{
|
||||
public class TrainingDbContext : DbContext
|
||||
{
|
||||
public DbSet<TrainingPart> Parts { get; set; }
|
||||
public DbSet<TrainingRun> Runs { get; set; }
|
||||
|
||||
private readonly string _dbPath;
|
||||
|
||||
public TrainingDbContext(string dbPath)
|
||||
{
|
||||
_dbPath = dbPath;
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
options.UseSqlite($"Data Source={_dbPath}");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<TrainingPart>(e =>
|
||||
{
|
||||
e.HasIndex(p => p.FileName).HasDatabaseName("idx_parts_filename");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TrainingRun>(e =>
|
||||
{
|
||||
e.HasIndex(r => r.PartId).HasDatabaseName("idx_runs_partid");
|
||||
e.HasOne(r => r.Part)
|
||||
.WithMany(p => p.Runs)
|
||||
.HasForeignKey(r => r.PartId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
28
OpenNest.Training/Data/TrainingPart.cs
Normal file
28
OpenNest.Training/Data/TrainingPart.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenNest.Training.Data
|
||||
{
|
||||
[Table("Parts")]
|
||||
public class TrainingPart
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[MaxLength(260)]
|
||||
public string FileName { get; set; }
|
||||
|
||||
public double Area { get; set; }
|
||||
public double Convexity { get; set; }
|
||||
public double AspectRatio { get; set; }
|
||||
public double BBFill { get; set; }
|
||||
public double Circularity { get; set; }
|
||||
public double PerimeterToAreaRatio { get; set; }
|
||||
public int VertexCount { get; set; }
|
||||
public byte[] Bitmask { get; set; }
|
||||
public string GeometryData { get; set; }
|
||||
|
||||
public List<TrainingRun> Runs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
25
OpenNest.Training/Data/TrainingRun.cs
Normal file
25
OpenNest.Training/Data/TrainingRun.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OpenNest.Training.Data
|
||||
{
|
||||
[Table("Runs")]
|
||||
public class TrainingRun
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long PartId { get; set; }
|
||||
public double SheetWidth { get; set; }
|
||||
public double SheetHeight { get; set; }
|
||||
public double Spacing { get; set; }
|
||||
public int PartCount { get; set; }
|
||||
public double Utilization { get; set; }
|
||||
public long TimeMs { get; set; }
|
||||
public string LayoutData { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
|
||||
[ForeignKey(nameof(PartId))]
|
||||
public TrainingPart Part { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user