|
|
|
@ -21,6 +21,8 @@ using SparkClient.Views.UserControl.ViewportData.Enum; |
|
|
|
|
using SparkClient.Views.UserControl.ViewportData.Entity; |
|
|
|
|
using Color = SharpDX.Color; |
|
|
|
|
using GeometryModel3D = HelixToolkit.Wpf.SharpDX.GeometryModel3D; |
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
|
using MeshGeometry3D = HelixToolkit.Wpf.SharpDX.MeshGeometry3D; |
|
|
|
|
|
|
|
|
|
namespace SparkClient.Views.UserControl.ViewportData.Helper; |
|
|
|
|
|
|
|
|
@ -1274,6 +1276,78 @@ public class ViewportHelperPro |
|
|
|
|
lights.ForEach(item => viewport.Items.Remove(item)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<LineGeometryModel3D> ShowMeshLines(List<Viewport3DTriangleEntity> entities, double thickness = 1.0) |
|
|
|
|
{ |
|
|
|
|
List<LineGeometryModel3D> lines = new(); |
|
|
|
|
var Y = -0.01F; |
|
|
|
|
var center = ViewportManager.CenterVector; |
|
|
|
|
center.Y = Y; |
|
|
|
|
Viewport3DTriangleEntity firstPoint = entities.Where(x => x.PlaneType == PlaneType.TableFacet).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
//var b = ((center.Z * firstPoint.Point1.X) - (firstPoint.Point1.Z * center.X)) / (firstPoint.Point1.X - center.X); |
|
|
|
|
//var a = (firstPoint.Point1.Z - b) / firstPoint.Point1.X; |
|
|
|
|
var lineCal = new LineCalculationHelper(firstPoint.Point1, center); |
|
|
|
|
|
|
|
|
|
var edgeLines = new List<Tuple<Vector3, Vector3>>(); |
|
|
|
|
Color4 XlineColor =new Color4(255f, 0f, 0f, 1f); |
|
|
|
|
var x1 = 5; |
|
|
|
|
var z1 = lineCal.calZ(x1); |
|
|
|
|
var x2 = -5; |
|
|
|
|
var z2 = lineCal.calZ(x2); |
|
|
|
|
edgeLines.Add(new Tuple<Vector3, Vector3>(new Vector3(x1, Y, z1), new Vector3(x2, Y, z2))); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, XlineColor)); |
|
|
|
|
|
|
|
|
|
edgeLines.Add(lineCal.calLineOfOffset(new Tuple<Vector3, Vector3>(new Vector3(x1, Y, z1), new Vector3(x2, Y, z2)),2)); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, XlineColor)); |
|
|
|
|
|
|
|
|
|
edgeLines.Add(lineCal.calLineOfOffset(new Tuple<Vector3, Vector3>(new Vector3(x1, Y, z1), new Vector3(x2, Y, z2)), -2)); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, XlineColor)); |
|
|
|
|
|
|
|
|
|
Color4 YlineColor = new Color4(0F, 255f, 0f, 1f); |
|
|
|
|
var x3 = 5; |
|
|
|
|
var z3 = lineCal.calZVertical(x3); |
|
|
|
|
var x4 = -5; |
|
|
|
|
var z4 = lineCal.calZVertical(x4); |
|
|
|
|
edgeLines.Add(new Tuple<Vector3, Vector3>(new Vector3(x3, Y, z3), new Vector3(x4, Y, z4))); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, YlineColor)); |
|
|
|
|
|
|
|
|
|
edgeLines.Add(lineCal.calLineOfOffset(new Tuple<Vector3, Vector3>(new Vector3(x3, Y, z3), new Vector3(x4, Y, z4)), 2)); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, YlineColor)); |
|
|
|
|
|
|
|
|
|
edgeLines.Add(lineCal.calLineOfOffset(new Tuple<Vector3, Vector3>(new Vector3(x3, Y, z3), new Vector3(x4, Y, z4)), -2)); |
|
|
|
|
lines.Add(DisplayLineModel3D(edgeLines, YlineColor)); |
|
|
|
|
return lines; |
|
|
|
|
} |
|
|
|
|
public static LineGeometryModel3D ShowCircleLine(double radius = 1.0, double thickness = 1.0) |
|
|
|
|
{ |
|
|
|
|
var Y = -0.01F; |
|
|
|
|
var center = ViewportManager.CenterVector; |
|
|
|
|
center.Y = Y; |
|
|
|
|
return UpdateCircleGeometry(center); |
|
|
|
|
} |
|
|
|
|
private static LineGeometryModel3D UpdateCircleGeometry(Vector3 center, double radius = 1.0) |
|
|
|
|
{ |
|
|
|
|
// 生成圆形线的点 |
|
|
|
|
int segments = 100; // 圆的细分段数 |
|
|
|
|
var positions = new List<Vector3>(); |
|
|
|
|
var indices = new List<int>(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < segments; i++) |
|
|
|
|
{ |
|
|
|
|
float angle = (float)(2 * Math.PI * i / segments); |
|
|
|
|
float x = (float)(center.X + radius * Math.Cos(angle)); |
|
|
|
|
float y = (float)(center.Y); |
|
|
|
|
float z = (float)(center.Z + radius * Math.Sin(angle)); |
|
|
|
|
|
|
|
|
|
positions.Add(new Vector3(x, y, z)); |
|
|
|
|
indices.Add(i); |
|
|
|
|
indices.Add((i + 1) % segments); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新圆形线的几何形状 |
|
|
|
|
return DisplayLineModel3D(positions, Color4.Black); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region 私有方法 |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|