File size: 924 Bytes
b6a0fc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using ILGPU;
using ILGPU.Runtime;
using System;

namespace FastPrint.Slicing
{
    public class SliceAccelerator : IDisposable
    {
        private Context context;
        private Accelerator accelerator;

        public SliceAccelerator()
        {
            context = Context.CreateDefault();
            accelerator = context.GetPreferredDevice(preferCPU: false).CreateAccelerator(context);
        }

        // Example kernel for slicing
        public void Slice(float[] vertices, float layerHeight, Action<float[]> onSliced)
        {
            using var buffer = accelerator.Allocate1D(vertices);
            accelerator.Synchronize();
            // Placeholder: actual slicing logic should be implemented here
            onSliced(vertices);
        }

        public void Dispose()
        {
            accelerator.Dispose();
            context.Dispose();
        }
    }
}