mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-25 15:47:40 -05:00
Best-fit slide distances rebuilt their band indexes for every offset: over half of a slide's time and nearly all of its allocation (5.8 GB for the 225,684 slides of 51 drawings). CpuDistanceComputer now slides a batch through Core's SlideBatch, which packs the two boundaries and builds their vertices, contact topology and one band index per boundary and push axis once. The pair search prepares each pair once for its first slides and its settling slides (IPreparedDistanceComputer). For pushes along an axis a slide also passes over pairs that cannot change its answer: a vertex or curve outside the other boundary's whole extent across the push, which every band test rejects, and, while the nearest contact is searched for, a pair whose gap along the push already reaches the nearest distance found, which the search discards. Both keep margins for the kernels' own tolerances; a ray hits a line up to epsilon of its length past its ends. Every distance is bit for bit what the per-slide query returns: CpuDistanceComputerEquivalenceTests compares the batch with a frozen copy of the old computer on hand-built boundaries, grazing and touching starts and the pair search's own batches. The per-slide sources and SlideResolver are unchanged and remain what every other caller uses. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Engine.BestFit
|
|
{
|
|
/// <summary>
|
|
/// A distance computer that can prepare one pair of boundaries once for several batches
|
|
/// of slides, as the pair search does: the grid of first slides, then the settling slides
|
|
/// of the same two boundaries.
|
|
/// </summary>
|
|
public interface IPreparedDistanceComputer : IDistanceComputer
|
|
{
|
|
/// <summary>
|
|
/// Prepares the boundaries. The lists must not change while the result is in use.
|
|
/// </summary>
|
|
IPreparedDistances Prepare(List<Entity> stationaryEntities, List<Entity> movingEntities);
|
|
}
|
|
|
|
/// <summary>One pair of boundaries prepared by an <see cref="IPreparedDistanceComputer"/>.</summary>
|
|
public interface IPreparedDistances
|
|
{
|
|
/// <summary>
|
|
/// What <see cref="IDistanceComputer.ComputeDistances(List{Entity}, List{Entity}, SlideOffset[])"/>
|
|
/// returns for the prepared boundaries and these offsets. One batch at a time.
|
|
/// </summary>
|
|
double[] ComputeDistances(SlideOffset[] offsets);
|
|
}
|
|
}
|