92 lines
2.1 KiB
C#
92 lines
2.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Runtime.Serialization;
|
|
using BITKit;
|
|
using BITKit.CommandPattern;
|
|
using Microsoft.SqlServer.Server;
|
|
using Newtonsoft.Json;
|
|
using Unity.Mathematics;
|
|
|
|
namespace BITFactory.Cutting
|
|
{
|
|
public interface ICuttingCommand : ICommand
|
|
{
|
|
string Name { get; }
|
|
}
|
|
public abstract class CuttingCommand:ICuttingCommand,IBinarySerialize
|
|
{
|
|
public virtual string Name => "切削命令";
|
|
public virtual void Execute()
|
|
{
|
|
}
|
|
|
|
public virtual void Undo()
|
|
{
|
|
}
|
|
|
|
public virtual void Read(BinaryReader r)
|
|
{
|
|
}
|
|
|
|
public virtual void Write(BinaryWriter w)
|
|
{
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class CuttingPointCommand : CuttingCommand
|
|
{
|
|
public override string Name => $"切削点:[{PlanePoint.x:F2}]Y[{PlanePoint.y:F2}]Z[{PlanePoint.z:F2}]";
|
|
public float3 PlaneNormal;
|
|
public float3 PlanePoint;
|
|
public override void Write(BinaryWriter w)
|
|
{
|
|
w.WriteFloat3(PlaneNormal);
|
|
w.WriteFloat3(PlanePoint);
|
|
}
|
|
public override void Read(BinaryReader r)
|
|
{
|
|
PlaneNormal = r.ReadFloat3();
|
|
PlanePoint = r.ReadFloat3();
|
|
}
|
|
}
|
|
[Serializable]
|
|
public sealed class CuttingSphereCommand : CuttingCommand
|
|
{
|
|
public override string Name => $"切削球:X[{PlanePoint.x:F2}]Y[{PlanePoint.y:F2}]Z[{PlanePoint.z:F2}]R[{Radius}]";
|
|
public float3 PlaneNormal;
|
|
public float3 PlanePoint;
|
|
public float Radius;
|
|
public override void Write(BinaryWriter w)
|
|
{
|
|
w.WriteFloat3(PlaneNormal);
|
|
w.WriteFloat3(PlanePoint);
|
|
w.Write(Radius);
|
|
}
|
|
public override void Read(BinaryReader r)
|
|
{
|
|
PlaneNormal = r.ReadFloat3();
|
|
PlanePoint = r.ReadFloat3();
|
|
Radius = r.ReadSingle();
|
|
}
|
|
}
|
|
[Serializable]
|
|
public sealed class CuttingLineCommand : CuttingCommand
|
|
{
|
|
public override string Name => $"切削线:线段数[{Line.Length}]";
|
|
|
|
public float3 PlaneNormal;
|
|
public float3[] Line;
|
|
}
|
|
[Serializable]
|
|
public sealed class CuttingFillCommand : CuttingCommand
|
|
{
|
|
public override string Name => $"填充区块:{PlanePosition}";
|
|
|
|
public float3 PlaneNormal;
|
|
public float3 PlanePosition;
|
|
}
|
|
}
|