|
|
@ -21,6 +21,8 @@ using SparkClient.Views.UserControl.ViewportData.Enum; |
|
|
|
using SparkClient.Views.UserControl.ViewportData.Entity; |
|
|
|
using SparkClient.Views.UserControl.ViewportData.Entity; |
|
|
|
using Color = SharpDX.Color; |
|
|
|
using Color = SharpDX.Color; |
|
|
|
using GeometryModel3D = HelixToolkit.Wpf.SharpDX.GeometryModel3D; |
|
|
|
using GeometryModel3D = HelixToolkit.Wpf.SharpDX.GeometryModel3D; |
|
|
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
|
|
|
|
using MeshGeometry3D = HelixToolkit.Wpf.SharpDX.MeshGeometry3D; |
|
|
|
|
|
|
|
|
|
|
|
namespace SparkClient.Views.UserControl.ViewportData.Helper; |
|
|
|
namespace SparkClient.Views.UserControl.ViewportData.Helper; |
|
|
|
|
|
|
|
|
|
|
@ -35,8 +37,8 @@ public class ViewportHelperPro |
|
|
|
/// <returns></returns> |
|
|
|
/// <returns></returns> |
|
|
|
public static MeshGeometryModel3D GenerateTypePanelHot(PlaneType planeType, Color4? color = null) |
|
|
|
public static MeshGeometryModel3D GenerateTypePanelHot(PlaneType planeType, Color4? color = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var entities = ViewportManager.ViewportTriangle.Where(e=>e.PlaneType==planeType).ToList(); |
|
|
|
var entities = ViewportManager.ViewportTriangle.Where(e => e.PlaneType == planeType).ToList(); |
|
|
|
return GenerateModelByEntity(entities, color??ViewportManager.ColorConfig.ErrFacetColor); |
|
|
|
return GenerateModelByEntity(entities, color ?? ViewportManager.ColorConfig.ErrFacetColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 已经确定和调整好的方法 |
|
|
|
#region 已经确定和调整好的方法 |
|
|
@ -66,7 +68,7 @@ public class ViewportHelperPro |
|
|
|
if (entity.PlaneType == PlaneType.Girdle) |
|
|
|
if (entity.PlaneType == PlaneType.Girdle) |
|
|
|
{ |
|
|
|
{ |
|
|
|
meshBuilder.AddTriangleFan(new List<Vector3>() { entity.Point1, entity.Point2, entity.Point3 }, |
|
|
|
meshBuilder.AddTriangleFan(new List<Vector3>() { entity.Point1, entity.Point2, entity.Point3 }, |
|
|
|
new List<Vector3>() { new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0) }); |
|
|
|
new List<Vector3>() { new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 0) }); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -77,8 +79,8 @@ public class ViewportHelperPro |
|
|
|
|
|
|
|
|
|
|
|
var material = new PBRMaterial |
|
|
|
var material = new PBRMaterial |
|
|
|
{ |
|
|
|
{ |
|
|
|
AlbedoColor = new Color4(0.0f, 0f,0f,1f), // 黑色,避免其他光照影响 |
|
|
|
AlbedoColor = new Color4(0.0f, 0f, 0f, 1f), // 黑色,避免其他光照影响 |
|
|
|
EmissiveColor =color ?? ViewportManager.ColorConfig.MainFacetColor , // LightGray #D3D3D3 |
|
|
|
EmissiveColor = color ?? ViewportManager.ColorConfig.MainFacetColor, // LightGray #D3D3D3 |
|
|
|
MetallicFactor = 0.0, // 非金属 |
|
|
|
MetallicFactor = 0.0, // 非金属 |
|
|
|
RoughnessFactor = 1.0, // 高粗糙度,避免反射效果 |
|
|
|
RoughnessFactor = 1.0, // 高粗糙度,避免反射效果 |
|
|
|
ReflectanceFactor = 0.0, // 无反射 |
|
|
|
ReflectanceFactor = 0.0, // 无反射 |
|
|
@ -128,7 +130,7 @@ public class ViewportHelperPro |
|
|
|
{ |
|
|
|
{ |
|
|
|
case PlaneType.Girdle: |
|
|
|
case PlaneType.Girdle: |
|
|
|
return ViewportManager.ColorConfig.GirdleFacetColor; |
|
|
|
return ViewportManager.ColorConfig.GirdleFacetColor; |
|
|
|
case PlaneType.TableFacet : |
|
|
|
case PlaneType.TableFacet: |
|
|
|
return ViewportManager.ColorConfig.TableFacetColor; |
|
|
|
return ViewportManager.ColorConfig.TableFacetColor; |
|
|
|
case PlaneType.UpperMainFacet: |
|
|
|
case PlaneType.UpperMainFacet: |
|
|
|
return ViewportManager.ColorConfig.UpperMainFacetColor; |
|
|
|
return ViewportManager.ColorConfig.UpperMainFacetColor; |
|
|
@ -241,7 +243,7 @@ public class ViewportHelperPro |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="viewport"></param> |
|
|
|
/// <param name="viewport"></param> |
|
|
|
/// <param name="filePath"></param> |
|
|
|
/// <param name="filePath"></param> |
|
|
|
public static async Task ExportModelsToStlASync( string filePath) |
|
|
|
public static async Task ExportModelsToStlASync(string filePath) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Viewport3DX viewport = ViewportManager.GetViewport3D(); |
|
|
|
Viewport3DX viewport = ViewportManager.GetViewport3D(); |
|
|
|
|
|
|
|
|
|
|
@ -350,7 +352,7 @@ public class ViewportHelperPro |
|
|
|
if (IsLineSegmentParallelToYAxis(line)) |
|
|
|
if (IsLineSegmentParallelToYAxis(line)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
lines.Add(line); |
|
|
|
lines.Add(line); |
|
|
|
result.Add(DisplayLineModel3D(new List<Vector3>(){nowItem,nextItem }, color??ViewportManager.ColorConfig.MainBorderColor, thickness)); |
|
|
|
result.Add(DisplayLineModel3D(new List<Vector3>() { nowItem, nextItem }, color ?? ViewportManager.ColorConfig.MainBorderColor, thickness)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -390,7 +392,7 @@ public class ViewportHelperPro |
|
|
|
temp.Add(entity.Point2); |
|
|
|
temp.Add(entity.Point2); |
|
|
|
temp.Add(entity.Point3); |
|
|
|
temp.Add(entity.Point3); |
|
|
|
} |
|
|
|
} |
|
|
|
result.Add(DisplayLineModel3D(VectorClockwiseSort(new HashSet<Vector3>(temp).ToList()), color??ViewportManager.ColorConfig.MainBorderColor, thickness)); |
|
|
|
result.Add(DisplayLineModel3D(VectorClockwiseSort(new HashSet<Vector3>(temp).ToList()), color ?? ViewportManager.ColorConfig.MainBorderColor, thickness)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//腰 - 特殊 |
|
|
|
//腰 - 特殊 |
|
|
@ -412,7 +414,7 @@ public class ViewportHelperPro |
|
|
|
ViewportManager.GirdleBottomLines.Clear(); |
|
|
|
ViewportManager.GirdleBottomLines.Clear(); |
|
|
|
foreach (var vector in uniqueVectors) |
|
|
|
foreach (var vector in uniqueVectors) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(vector.Y < mid) |
|
|
|
if (vector.Y < mid) |
|
|
|
ViewportManager.GirdleBottomLines.Add(vector); |
|
|
|
ViewportManager.GirdleBottomLines.Add(vector); |
|
|
|
else |
|
|
|
else |
|
|
|
ViewportManager.GirdleTopLines.Add(vector); |
|
|
|
ViewportManager.GirdleTopLines.Add(vector); |
|
|
@ -433,7 +435,7 @@ public class ViewportHelperPro |
|
|
|
string planCode = ""; |
|
|
|
string planCode = ""; |
|
|
|
ViewportManager.ViewportTriangle.ForEach(e => |
|
|
|
ViewportManager.ViewportTriangle.ForEach(e => |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (e.PlaneType == type && (e.PlaneCode==planCode || string.IsNullOrEmpty(planCode))) |
|
|
|
if (e.PlaneType == type && (e.PlaneCode == planCode || string.IsNullOrEmpty(planCode))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
planCode = e.PlaneCode; |
|
|
|
planCode = e.PlaneCode; |
|
|
|
entities.Add(e); |
|
|
|
entities.Add(e); |
|
|
@ -495,35 +497,35 @@ public class ViewportHelperPro |
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
var longestLine1 = GetLongestOrShortestLineSegment(facetPoints, returnLongest: true); |
|
|
|
var longestLine1 = GetLongestOrShortestLineSegment(facetPoints, returnLongest: true); |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){longestLine1}, new Color4(1f, 0, 0, 1f) , 2f)); |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3, Vector3>>() { longestLine1 }, new Color4(1f, 0, 0, 1f), 2f)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
var longestLine2 = GetLongestOrShortestLineSegment(facetPoints, returnLongest: false); |
|
|
|
var longestLine2 = GetLongestOrShortestLineSegment(facetPoints, returnLongest: false); |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){longestLine2}, new Color4(1f, 0, 0, 1f) , 2f)); |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3, Vector3>>() { longestLine2 }, new Color4(1f, 0, 0, 1f), 2f)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//开始找值 |
|
|
|
//开始找值 |
|
|
|
string param = string.Empty; |
|
|
|
string param = string.Empty; |
|
|
|
var valueIndex = 0; |
|
|
|
var valueIndex = 0; |
|
|
|
if (facetIndex % 8 == 0 || (facetIndex+1) % 8 == 0) |
|
|
|
if (facetIndex % 8 == 0 || (facetIndex + 1) % 8 == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//上腰面 |
|
|
|
//上腰面 |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【上腰面】"); |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【上腰面】"); |
|
|
|
valueIndex = (int)Math.Ceiling(facetIndex / 8.0) == 8 ? 0 : (int)Math.Ceiling(facetIndex / 8.0); |
|
|
|
valueIndex = (int)Math.Ceiling(facetIndex / 8.0) == 8 ? 0 : (int)Math.Ceiling(facetIndex / 8.0); |
|
|
|
param = "GIRDLE_BONE"; |
|
|
|
param = "GIRDLE_BONE"; |
|
|
|
}else if (linePointType == 3 || linePointType == 0) |
|
|
|
} else if (linePointType == 3 || linePointType == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//风筝面 |
|
|
|
//风筝面 |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【风筝面】"); |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【风筝面】"); |
|
|
|
valueIndex = (facetIndex / 8) ; |
|
|
|
valueIndex = (facetIndex / 8); |
|
|
|
param = "GIRDLE_BEZEL"; |
|
|
|
param = "GIRDLE_BEZEL"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
//腰厚比 |
|
|
|
//腰厚比 |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【腰厚比】"); |
|
|
|
Logger.Info($"【面文本生成】 腰面值 波峰【腰厚比】"); |
|
|
|
valueIndex = (facetIndex / 4) ; |
|
|
|
valueIndex = (facetIndex / 4); |
|
|
|
param = "GIRDLE_VALLEY"; |
|
|
|
param = "GIRDLE_VALLEY"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -542,7 +544,7 @@ public class ViewportHelperPro |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{valueIndex} ==={paramValue}"); |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{valueIndex} ==={paramValue}"); |
|
|
|
var valueFloat = (Math.Floor(float.Parse(paramValue.ToString())*1000)/10).ToString(); |
|
|
|
var valueFloat = (Math.Floor(float.Parse(paramValue.ToString()) * 1000) / 10).ToString(); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {valueIndex}"); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {valueIndex}"); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
result.Add(DisplayText3D($"{valueFloat}", facetTextPoint)); |
|
|
|
result.Add(DisplayText3D($"{valueFloat}", facetTextPoint)); |
|
|
@ -567,7 +569,7 @@ public class ViewportHelperPro |
|
|
|
// */ |
|
|
|
// */ |
|
|
|
// |
|
|
|
// |
|
|
|
// } |
|
|
|
// } |
|
|
|
}else if (selFacetType == PlaneType.Girdle && !string.IsNullOrWhiteSpace(valKey)) |
|
|
|
} else if (selFacetType == PlaneType.Girdle && !string.IsNullOrWhiteSpace(valKey)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Logger.Info($"【面文本生成】 命中面{selFacetType},是腰,显示值{valKey}"); |
|
|
|
Logger.Info($"【面文本生成】 命中面{selFacetType},是腰,显示值{valKey}"); |
|
|
|
/*** |
|
|
|
/*** |
|
|
@ -584,11 +586,11 @@ public class ViewportHelperPro |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (valKey) |
|
|
|
switch (valKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case "GIRDLE_BEZEL": if(i%8==4)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
case "GIRDLE_BEZEL": if (i % 8 == 4) resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "GIRDLE_BONE": if(i%8==0)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
case "GIRDLE_BONE": if (i % 8 == 0) resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "GIRDLE_VALLEY": if(i%4==2)resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
case "GIRDLE_VALLEY": if (i % 4 == 2) resultDic.Add($"0_{i}", groupedDic[$"0_{i}"]); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -605,7 +607,7 @@ public class ViewportHelperPro |
|
|
|
dic.Value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
dic.Value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
//高亮的线 |
|
|
|
//高亮的线 |
|
|
|
var showLine = GetLeftParallelLineSegment(facetPoints); |
|
|
|
var showLine = GetLeftParallelLineSegment(facetPoints); |
|
|
|
if(showLine == null)continue; |
|
|
|
if (showLine == null) continue; |
|
|
|
|
|
|
|
|
|
|
|
//文字显示位置 |
|
|
|
//文字显示位置 |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
@ -625,8 +627,8 @@ public class ViewportHelperPro |
|
|
|
Logger.Info($"【面文本生成】 {valKey}_DETAIL.{valKey}_{resIndex} Key不存在"); |
|
|
|
Logger.Info($"【面文本生成】 {valKey}_DETAIL.{valKey}_{resIndex} Key不存在"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){showLine}, new Color4(1f, 0, 0, 1f) , 2f)); |
|
|
|
result.Add(DisplayLineModel3D(new List<Tuple<Vector3, Vector3>>() { showLine }, new Color4(1f, 0, 0, 1f), 2f)); |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(),valKey); |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(), valKey); |
|
|
|
result.Add(DisplayText3D($" {resIndex} \r\n {valueFloat}", facetTextPoint)); |
|
|
|
result.Add(DisplayText3D($" {resIndex} \r\n {valueFloat}", facetTextPoint)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -649,7 +651,7 @@ public class ViewportHelperPro |
|
|
|
int.TryParse(key.Split("_")[1], out facetIndex); |
|
|
|
int.TryParse(key.Split("_")[1], out facetIndex); |
|
|
|
List<Vector3> facetPoints = new List<Vector3>(); |
|
|
|
List<Vector3> facetPoints = new List<Vector3>(); |
|
|
|
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); }); |
|
|
|
var param = string.IsNullOrWhiteSpace(valKey)? ViewportManager.DicFacetToValueParam.ContainsKey(selFacetType) ? ViewportManager.DicFacetToValueParam[selFacetType] : null : valKey; |
|
|
|
var param = string.IsNullOrWhiteSpace(valKey) ? ViewportManager.DicFacetToValueParam.ContainsKey(selFacetType) ? ViewportManager.DicFacetToValueParam[selFacetType] : null : valKey; |
|
|
|
if (param == null) |
|
|
|
if (param == null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -663,12 +665,12 @@ public class ViewportHelperPro |
|
|
|
Logger.Info($"【面文本生成】 {param} Key不存在"); |
|
|
|
Logger.Info($"【面文本生成】 {param} Key不存在"); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(),param); |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(), param); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}"); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}"); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
result.Add(DisplayText3D($"{valueFloat}", facetTextPoint)); |
|
|
|
result.Add(DisplayText3D($"{valueFloat}", facetTextPoint)); |
|
|
|
|
|
|
|
|
|
|
|
}else if (groupedDic.Count == 16) |
|
|
|
} else if (groupedDic.Count == 16) |
|
|
|
{ |
|
|
|
{ |
|
|
|
facetIndex += 1; |
|
|
|
facetIndex += 1; |
|
|
|
valueIndex = facetIndex == 16 ? 1 : facetIndex % 2 == 0 ? valueIndex + 1 : valueIndex; |
|
|
|
valueIndex = facetIndex == 16 ? 1 : facetIndex % 2 == 0 ? valueIndex + 1 : valueIndex; |
|
|
@ -687,10 +689,10 @@ public class ViewportHelperPro |
|
|
|
} |
|
|
|
} |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{valueIndex} ==={paramValue}"); |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{valueIndex} ==={paramValue}"); |
|
|
|
|
|
|
|
|
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(),param); |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(), param); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {valueIndex}"); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {valueIndex}"); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", new Vector3(facetTextPoint.X, facetTextPoint.Y+0.1f, facetTextPoint.Z))); |
|
|
|
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", new Vector3(facetTextPoint.X, facetTextPoint.Y + 0.1f, facetTextPoint.Z))); |
|
|
|
|
|
|
|
|
|
|
|
} else if (ViewportManager.DiamondData.Count > 1 && facetIndex != -1) |
|
|
|
} else if (ViewportManager.DiamondData.Count > 1 && facetIndex != -1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -711,7 +713,7 @@ public class ViewportHelperPro |
|
|
|
} |
|
|
|
} |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} ==={paramValue}"); |
|
|
|
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} ==={paramValue}"); |
|
|
|
|
|
|
|
|
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(),param); |
|
|
|
var valueFloat = ValueFormat(paramValue.ToString(), param); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}"); |
|
|
|
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}"); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector); |
|
|
|
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", facetTextPoint)); |
|
|
|
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", facetTextPoint)); |
|
|
@ -773,7 +775,7 @@ public class ViewportHelperPro |
|
|
|
public static List<GeometryModel3D> GentrateChosenView(string triangleCode, string valKey = "", params SelShowType[] selType) |
|
|
|
public static List<GeometryModel3D> GentrateChosenView(string triangleCode, string valKey = "", params SelShowType[] selType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var res = ViewportManager.ViewportTriangle.Find(e => triangleCode.Equals(e.TriangleCode)); |
|
|
|
var res = ViewportManager.ViewportTriangle.Find(e => triangleCode.Equals(e.TriangleCode)); |
|
|
|
if(res != null) |
|
|
|
if (res != null) |
|
|
|
return GentrateChosenView(res, valKey, selType); |
|
|
|
return GentrateChosenView(res, valKey, selType); |
|
|
|
return new List<GeometryModel3D>(); |
|
|
|
return new List<GeometryModel3D>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -802,7 +804,7 @@ public class ViewportHelperPro |
|
|
|
var selPanel = ViewportManager.ViewportTriangle.Where(e => entity.PlaneCode.Equals(e.PlaneCode)).ToList(); |
|
|
|
var selPanel = ViewportManager.ViewportTriangle.Where(e => entity.PlaneCode.Equals(e.PlaneCode)).ToList(); |
|
|
|
//选中同类的面 |
|
|
|
//选中同类的面 |
|
|
|
var selPanelType = ViewportManager.ViewportTriangle.Where(e => entity.PlaneType.Equals(e.PlaneType)).ToList(); |
|
|
|
var selPanelType = ViewportManager.ViewportTriangle.Where(e => entity.PlaneType.Equals(e.PlaneType)).ToList(); |
|
|
|
selPanel.ForEach(e=>selPanelType.Remove(e)); |
|
|
|
selPanel.ForEach(e => selPanelType.Remove(e)); |
|
|
|
foreach (var type in selType) |
|
|
|
foreach (var type in selType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (type) |
|
|
|
switch (type) |
|
|
@ -826,7 +828,7 @@ public class ViewportHelperPro |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SelShowType.BorderAngle: |
|
|
|
case SelShowType.BorderAngle: |
|
|
|
//选中面 每条边向内的夹角 |
|
|
|
//选中面 每条边向内的夹角 |
|
|
|
if(PlaneType.Girdle == entity.PlaneType)break; |
|
|
|
if (PlaneType.Girdle == entity.PlaneType) break; |
|
|
|
result.AddRange(GenerateLineAngleTextModels(selPanel)); |
|
|
|
result.AddRange(GenerateLineAngleTextModels(selPanel)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -909,7 +911,7 @@ public class ViewportHelperPro |
|
|
|
|
|
|
|
|
|
|
|
// 将旋转变换应用到模型 |
|
|
|
// 将旋转变换应用到模型 |
|
|
|
ViewportManager.MainModel3D.Transform = rotateTransform; |
|
|
|
ViewportManager.MainModel3D.Transform = rotateTransform; |
|
|
|
if(hasLine) |
|
|
|
if (hasLine) |
|
|
|
ViewportManager.MainModelLines.ForEach(e => e.Transform = rotateTransform); |
|
|
|
ViewportManager.MainModelLines.ForEach(e => e.Transform = rotateTransform); |
|
|
|
|
|
|
|
|
|
|
|
double currentAngle = rotation.Angle; |
|
|
|
double currentAngle = rotation.Angle; |
|
|
@ -938,7 +940,7 @@ public class ViewportHelperPro |
|
|
|
var billboardText = new BillboardText3D(); |
|
|
|
var billboardText = new BillboardText3D(); |
|
|
|
billboardText.TextInfo.Add(new TextInfo(text, position) |
|
|
|
billboardText.TextInfo.Add(new TextInfo(text, position) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Foreground = color??ViewportManager.ColorConfig.SelFontColor, |
|
|
|
Foreground = color ?? ViewportManager.ColorConfig.SelFontColor, |
|
|
|
Scale = 0.8f, |
|
|
|
Scale = 0.8f, |
|
|
|
VerticalAlignment = BillboardVerticalAlignment.Center, |
|
|
|
VerticalAlignment = BillboardVerticalAlignment.Center, |
|
|
|
HorizontalAlignment = BillboardHorizontalAlignment.Center |
|
|
|
HorizontalAlignment = BillboardHorizontalAlignment.Center |
|
|
@ -1274,6 +1276,78 @@ public class ViewportHelperPro |
|
|
|
lights.ForEach(item => viewport.Items.Remove(item)); |
|
|
|
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 私有方法 |
|
|
|
#region 私有方法 |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|