|
|
|
@ -567,10 +567,68 @@ public class ViewportHelperPro |
|
|
|
|
// */ |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
}else if (selFacetType == PlaneType.Girdle && string.IsNullOrWhiteSpace(valKey)) |
|
|
|
|
}else if (selFacetType == PlaneType.Girdle && !string.IsNullOrWhiteSpace(valKey)) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 命中面{selFacetType},是腰,显示值{valKey}"); |
|
|
|
|
/*** |
|
|
|
|
* GIRDLE_BEZEL 风筝 |
|
|
|
|
* GIRDLE_BONE 上腰 |
|
|
|
|
* GIRDLE_VALLEY 波谷 |
|
|
|
|
*/ |
|
|
|
|
List<Viewport3DTriangleEntity> facetTypeAll = |
|
|
|
|
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType); |
|
|
|
|
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode) |
|
|
|
|
.ToDictionary(group => group.Key, group => group.ToList()); |
|
|
|
|
var resultDic = new Dictionary<string, List<Viewport3DTriangleEntity>>(); |
|
|
|
|
for (int i = 0; i < groupedDic.Count; i++) |
|
|
|
|
{ |
|
|
|
|
switch (valKey) |
|
|
|
|
{ |
|
|
|
|
case "GIRDLE_BEZEL": if(i%8==4)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
|
break; |
|
|
|
|
case "GIRDLE_BONE": if(i%8==0)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
|
break; |
|
|
|
|
case "GIRDLE_VALLEY": if(i%4==2)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (resultDic.Count == 0) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 关联面获取失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (var dic in resultDic) |
|
|
|
|
{ |
|
|
|
|
//高亮四边形左边的线,并绑定值 |
|
|
|
|
List<Vector3> facetPoints = new List<Vector3>(); |
|
|
|
|
dic.Value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
|
//高亮的线 |
|
|
|
|
var showLine = GetLeftParallelLineSegment(facetPoints); |
|
|
|
|
if(showLine == null)continue; |
|
|
|
|
|
|
|
|
|
//文字显示位置 |
|
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
|
var resIndex = resultDic.Keys.ToList().IndexOf(dic.Key); |
|
|
|
|
if (resIndex == -1) continue; |
|
|
|
|
resIndex += 1; |
|
|
|
|
var detail = ViewportManager.DiamondData[$"{valKey}_DETAIL"]; |
|
|
|
|
if (detail == null) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 {valKey}_DETAIL Key不存在"); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
Logger.Info($"【面文本生成】 {valKey}_DETAIL == {detail}"); |
|
|
|
|
var paramValue = detail[$"{valKey}_{resIndex}"]; |
|
|
|
|
if (paramValue == null) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 {valKey}_DETAIL.{valKey}_{resIndex} Key不存在"); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){showLine}, new Color4(1f, 0, 0, 1f) , 2f)); |
|
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(),valKey); |
|
|
|
|
result.Add(DisplayText3D($" {resIndex} \r\n {valueFloat}", facetTextPoint)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -1396,12 +1454,55 @@ public class ViewportHelperPro |
|
|
|
|
return Math.Round(Vector3.Distance(startPoint, endPoint), 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 获取四边形内平行于Y轴且位于左侧的边线 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="facetPoints">四边形的顶点列表</param> |
|
|
|
|
/// <param name="returnLongest">是否返回最长的边线</param> |
|
|
|
|
/// <returns>符合条件的边线,如果不存在则返回null</returns> |
|
|
|
|
public static Tuple<Vector3, Vector3> GetLeftParallelLineSegment( |
|
|
|
|
List<Vector3> facetPoints) |
|
|
|
|
{ |
|
|
|
|
if (facetPoints == null || facetPoints.Count < 4) |
|
|
|
|
throw new ArgumentException("facetPoints must contain at least four points."); |
|
|
|
|
|
|
|
|
|
// 计算多边形(四边形)的中心点 |
|
|
|
|
Vector3 center = GetCenter(facetPoints); |
|
|
|
|
|
|
|
|
|
float minX = float.MaxValue; |
|
|
|
|
Tuple<Vector3, Vector3> resultLine = null; |
|
|
|
|
|
|
|
|
|
// 遍历所有边线 |
|
|
|
|
for (int i = 0; i < facetPoints.Count; i++) |
|
|
|
|
{ |
|
|
|
|
Vector3 p1 = facetPoints[i]; |
|
|
|
|
Vector3 p2 = facetPoints[(i + 1) % facetPoints.Count]; // 环形连接 |
|
|
|
|
|
|
|
|
|
var lineSegment = new Tuple<Vector3, Vector3>(p1, p2); |
|
|
|
|
|
|
|
|
|
// 判断该边线是否平行于 Y 轴 |
|
|
|
|
if (IsLineSegmentParallelToYAxis(lineSegment)) |
|
|
|
|
{ |
|
|
|
|
return lineSegment; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return resultLine; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static string ValueFormat(string value, string type, bool hasUnit = false) |
|
|
|
|
{ |
|
|
|
|
if (double.TryParse(value, out var v) ) |
|
|
|
|
{ |
|
|
|
|
switch (type) |
|
|
|
|
{ |
|
|
|
|
case "GIRDLE_BEZEL": |
|
|
|
|
case "GIRDLE_BONE": |
|
|
|
|
case "GIRDLE_VALLEY": |
|
|
|
|
v = Math.Floor(v * 1000) / 1000; |
|
|
|
|
return hasUnit ? $"{(v*100).ToString("F1")}mm" : (v*100).ToString("F1"); |
|
|
|
|
case "DIAMETER": |
|
|
|
|
v = Math.Floor(v * 10) / 10; |
|
|
|
|
return hasUnit ? $"{v.ToString("F1")}mm" : v.ToString("F1"); |
|
|
|
|