|
|
|
@ -10,6 +10,7 @@ using System.Windows.Media.Imaging; |
|
|
|
|
using System.Windows.Media.Media3D; |
|
|
|
|
using System.Windows.Threading; |
|
|
|
|
using HelixToolkit.Wpf.SharpDX; |
|
|
|
|
using log4net; |
|
|
|
|
using NPOI.OpenXmlFormats.Vml.Office; |
|
|
|
|
using SharpDX; |
|
|
|
|
using SharpDX.Direct3D11; |
|
|
|
@ -23,6 +24,7 @@ namespace SparkClient.Views.UserControl.ViewportData.Helper; |
|
|
|
|
|
|
|
|
|
public class ViewportHelperPro |
|
|
|
|
{ |
|
|
|
|
private static readonly ILog Logger = LogManager.GetLogger(typeof(ViewportHelperPro)); |
|
|
|
|
/// <summary> |
|
|
|
|
/// 对指定类型的面进行标色 |
|
|
|
|
/// </summary> |
|
|
|
@ -420,7 +422,25 @@ public class ViewportHelperPro |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<GeometryModel3D> GenerateLineTextModelsByType(string type, Color4? textColor = null, |
|
|
|
|
bool showAll = false) |
|
|
|
|
{ |
|
|
|
|
var planType = ViewportManager.DicValueParamToFacet[type]; |
|
|
|
|
List<Viewport3DTriangleEntity> entities = new List<Viewport3DTriangleEntity>(); |
|
|
|
|
string planCode = ""; |
|
|
|
|
ViewportManager.ViewportTriangle.ForEach(e => |
|
|
|
|
{ |
|
|
|
|
if (e.PlaneType == planType && (e.PlaneCode==planCode || string.IsNullOrEmpty(planCode))) |
|
|
|
|
{ |
|
|
|
|
planCode = e.PlaneCode; |
|
|
|
|
entities.Add(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return GenerateLineTextModels(entities, textColor, showAll); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 显示线段长度mm |
|
|
|
|
/// </summary> |
|
|
|
@ -431,43 +451,91 @@ public class ViewportHelperPro |
|
|
|
|
public static List<GeometryModel3D> GenerateLineTextModels(List<Viewport3DTriangleEntity> entities, |
|
|
|
|
Color4? textColor = null,bool showAll = false) |
|
|
|
|
{ |
|
|
|
|
Logger.Info("【面文本生成】开始生成面相关文本信息"); |
|
|
|
|
var selFacet = entities; |
|
|
|
|
var selFacetType = entities.First().PlaneType; |
|
|
|
|
|
|
|
|
|
var result = new List<GeometryModel3D>(); |
|
|
|
|
if (selFacetType == PlaneType.Girdle) |
|
|
|
|
{ |
|
|
|
|
if (ViewportManager.MainModelGirdleMaxLines != null || ViewportManager.MainModelGirdleMinLines != null || |
|
|
|
|
ViewportManager.MainModelGirdleAvgLines != null) |
|
|
|
|
Logger.Info($"【面文本生成】 命中面{selFacetType},是腰"); |
|
|
|
|
// if (ViewportManager.MainModelGirdleMaxLines != null || ViewportManager.MainModelGirdleMinLines != null || |
|
|
|
|
// ViewportManager.MainModelGirdleAvgLines != null) |
|
|
|
|
// { |
|
|
|
|
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMaxLines}, new Color4(1f, 0, 0, 1f) )); |
|
|
|
|
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMinLines}, new Color4(0f, 1f, 0, 1f) )); |
|
|
|
|
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleAvgLines}, new Color4(1f, 0.5f, 0, 1f) )); |
|
|
|
|
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMaxLines)}mm", ViewportManager.MainModelGirdleMaxLines.Item1, textColor)); |
|
|
|
|
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMinLines)}mm", ViewportManager.MainModelGirdleMinLines.Item1, textColor)); |
|
|
|
|
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleAvgLines)}mm", ViewportManager.MainModelGirdleAvgLines.Item1, textColor)); |
|
|
|
|
// } |
|
|
|
|
List<Viewport3DTriangleEntity> facetTypeAll = |
|
|
|
|
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType); |
|
|
|
|
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode) |
|
|
|
|
.ToDictionary(group => group.Key, group => group.ToList()); |
|
|
|
|
Logger.Info($"【面文本生成】 腰由{groupedDic.Count}个面组成"); |
|
|
|
|
foreach (var kv in groupedDic) |
|
|
|
|
{ |
|
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMaxLines}, new Color4(1f, 0, 0, 1f) )); |
|
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMinLines}, new Color4(0f, 1f, 0, 1f) )); |
|
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleAvgLines}, new Color4(1f, 0.5f, 0, 1f) )); |
|
|
|
|
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMaxLines)}mm", ViewportManager.MainModelGirdleMaxLines.Item1, textColor)); |
|
|
|
|
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMinLines)}mm", ViewportManager.MainModelGirdleMinLines.Item1, textColor)); |
|
|
|
|
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleAvgLines)}mm", ViewportManager.MainModelGirdleAvgLines.Item1, textColor)); |
|
|
|
|
var value = kv.Value; |
|
|
|
|
var key = kv.Key; |
|
|
|
|
var facetIndex = -1; |
|
|
|
|
int.TryParse(key.Split("_")[1], out facetIndex); |
|
|
|
|
List<Vector3> facetPoints = new List<Vector3>(); |
|
|
|
|
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
|
/*** |
|
|
|
|
* 0 1 2 3 |
|
|
|
|
* 4 5 6 7 |
|
|
|
|
* 面id-loop4 = 0 - 高亮左边的竖线 - 波峰 - |
|
|
|
|
* 面id-loop4 = 1 - 高亮右边的竖线 - 波谷 |
|
|
|
|
* 面id-loop4 = 2 - 高亮左边的竖线 - 波谷 |
|
|
|
|
* 面id-loop4 = 3 - 高亮右边的竖线 - 波峰 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 命中面{selFacetType},不是腰"); |
|
|
|
|
//查找同类面 |
|
|
|
|
List<Viewport3DTriangleEntity> facetTypeAll = |
|
|
|
|
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType); |
|
|
|
|
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode) |
|
|
|
|
.ToDictionary(group => group.Key, group => group.ToList()); |
|
|
|
|
|
|
|
|
|
Logger.Info($"【面文本生成】 同类面{groupedDic.Count}个"); |
|
|
|
|
foreach (var kv in groupedDic) |
|
|
|
|
{ |
|
|
|
|
var value = kv.Value; |
|
|
|
|
var key = kv.Key; |
|
|
|
|
var facetIndex = key.Split("_")[1]; |
|
|
|
|
var facetIndex = -1; |
|
|
|
|
int.TryParse(key.Split("_")[1], out facetIndex); |
|
|
|
|
List<Vector3> facetPoints = new List<Vector3>(); |
|
|
|
|
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
|
result.Add(DisplayText3D($"{key.Split("_")[1]} \r\n 12334", facetTextPoint, textColor)); |
|
|
|
|
|
|
|
|
|
if (ViewportManager.DiamondData.Count > 1 && facetIndex != -1) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 钻石数据有效,Index有效"); |
|
|
|
|
facetIndex += 1; |
|
|
|
|
var param = ViewportManager.DicFacetToValueParam[selFacetType]; |
|
|
|
|
var detail = ViewportManager.DiamondData[$"{param}_DETAIL"]; |
|
|
|
|
if (detail == null) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL Key不存在"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL == {detail}"); |
|
|
|
|
var paramValue = detail[$"{param}_{facetIndex}"]; |
|
|
|
|
if (paramValue == null) |
|
|
|
|
{ |
|
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} Key不存在"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} ==={paramValue}"); |
|
|
|
|
|
|
|
|
|
var valueFloat = Math.Round(float.Parse(paramValue.ToString()), MidpointRounding.ToZero); |
|
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}"); |
|
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
|
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", facetTextPoint, textColor)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|