|
|
|
@ -431,8 +431,11 @@ public class ViewportHelperPro |
|
|
|
|
public static List<GeometryModel3D> GenerateLineTextModels(List<Viewport3DTriangleEntity> entities, |
|
|
|
|
Color4? textColor = null,bool showAll = false) |
|
|
|
|
{ |
|
|
|
|
var selFacet = entities; |
|
|
|
|
var selFacetType = entities.First().PlaneType; |
|
|
|
|
|
|
|
|
|
var result = new List<GeometryModel3D>(); |
|
|
|
|
if (entities.Count > 0 && entities[0].PlaneType == PlaneType.Girdle) |
|
|
|
|
if (selFacetType == PlaneType.Girdle) |
|
|
|
|
{ |
|
|
|
|
if (ViewportManager.MainModelGirdleMaxLines != null || ViewportManager.MainModelGirdleMinLines != null || |
|
|
|
|
ViewportManager.MainModelGirdleAvgLines != null) |
|
|
|
@ -447,30 +450,52 @@ public class ViewportHelperPro |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
var selFaceVector = entities |
|
|
|
|
.SelectMany(entity => new[] { entity.Point1, entity.Point2, entity.Point3 }) |
|
|
|
|
.Distinct() |
|
|
|
|
.ToList(); |
|
|
|
|
var uniqueLines = new HashSet<string>(); |
|
|
|
|
var sortedVectors = VectorClockwiseSort(selFaceVector); |
|
|
|
|
for (int i = 0; i < sortedVectors.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var current = sortedVectors[i]; |
|
|
|
|
var next = sortedVectors[(i + 1) % sortedVectors.Count]; |
|
|
|
|
//查找同类面 |
|
|
|
|
List<Viewport3DTriangleEntity> facetTypeAll = |
|
|
|
|
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType); |
|
|
|
|
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode) |
|
|
|
|
.ToDictionary(group => group.Key, group => group.ToList()); |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* 思路: |
|
|
|
|
* 1、以面分组,1组为台面、底面,8组、16组、64组、other |
|
|
|
|
* 2、每组数据区别 |
|
|
|
|
* 1组:取第一个数据 |
|
|
|
|
* 8组:按索引0-7 -> 1-8 |
|
|
|
|
* 16组:1-2、3-4、5-6、7-8、9-10、11-12、13-14、15-0共享数据 |
|
|
|
|
* 64组:这组特殊理论上是腰,按照else里的东西来 |
|
|
|
|
* 3、这个方法是主动点击,被动触发理论上通用 |
|
|
|
|
* 4、主动触发:循环遍历面组,根据面类型获取算法存储的数据,在Manager里制定面-参数的一对多关系,主动触发时,取参数的首位为默认 |
|
|
|
|
* 5、被动触发:根据结果页传入的参数编号,找到对应的面,循环遍历面组,根据面类型获取算法存储的数据,根据被动传入参数找到值 |
|
|
|
|
* 6、 ①组面可能由至少两个三角形组成,计算出三角形拼接出的多边形的中心作为文字显示的中心 |
|
|
|
|
* ②在从算法结果数据对应好面组的索引,做成值-组面id的文本,计算出这个文本的大小 |
|
|
|
|
* ③在拼接的图片中心,平行于平面,向中心点外偏移“文本大小高度+0.1"个单位 显示文本
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
double length = (next - current).Length(); |
|
|
|
|
string lineKey = $"{length:F2}"; |
|
|
|
|
if (showAll == false) |
|
|
|
|
{ |
|
|
|
|
if (uniqueLines.Contains(lineKey)) continue; |
|
|
|
|
uniqueLines.Add(lineKey); |
|
|
|
|
} |
|
|
|
|
var midPoint = (current + next) / 2; |
|
|
|
|
var text = $"{length:F2}mm"; |
|
|
|
|
var textY = midPoint.Y > ViewportManager.CenterVector.Y ? midPoint.Y + 0.3f : midPoint.Y - 0.3f; |
|
|
|
|
var lengthTextModel = DisplayText3D(text, new Vector3(midPoint.X, textY, midPoint.Z),next - current, textColor); |
|
|
|
|
result.Add(lengthTextModel); |
|
|
|
|
} |
|
|
|
|
// var selFaceVector = entities |
|
|
|
|
// .SelectMany(entity => new[] { entity.Point1, entity.Point2, entity.Point3 }) |
|
|
|
|
// .Distinct() |
|
|
|
|
// .ToList(); |
|
|
|
|
// var uniqueLines = new HashSet<string>(); |
|
|
|
|
// var sortedVectors = VectorClockwiseSort(selFaceVector); |
|
|
|
|
// for (int i = 0; i < sortedVectors.Count; i++) |
|
|
|
|
// { |
|
|
|
|
// var current = sortedVectors[i]; |
|
|
|
|
// var next = sortedVectors[(i + 1) % sortedVectors.Count]; |
|
|
|
|
// |
|
|
|
|
// double length = (next - current).Length(); |
|
|
|
|
// string lineKey = $"{length:F2}"; |
|
|
|
|
// if (showAll == false) |
|
|
|
|
// { |
|
|
|
|
// if (uniqueLines.Contains(lineKey)) continue; |
|
|
|
|
// uniqueLines.Add(lineKey); |
|
|
|
|
// } |
|
|
|
|
// var midPoint = (current + next) / 2; |
|
|
|
|
// var text = $"{length:F2}mm"; |
|
|
|
|
// var textY = midPoint.Y > ViewportManager.CenterVector.Y ? midPoint.Y + 0.3f : midPoint.Y - 0.3f; |
|
|
|
|
// var lengthTextModel = DisplayText3D(text, new Vector3(midPoint.X, textY, midPoint.Z),next - current, textColor); |
|
|
|
|
// result.Add(lengthTextModel); |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1106,11 +1131,11 @@ public class ViewportHelperPro |
|
|
|
|
avgLine = lineLengths.OrderBy(l => Math.Abs(l.Length - lineLengths.Average(ll => ll.Length))) |
|
|
|
|
.First().Line; |
|
|
|
|
} |
|
|
|
|
private static float CalculateLength(Tuple<Vector3, Vector3> line) |
|
|
|
|
private static double CalculateLength(Tuple<Vector3, Vector3> line) |
|
|
|
|
{ |
|
|
|
|
Vector3 startPoint = line.Item1; |
|
|
|
|
Vector3 endPoint = line.Item2; |
|
|
|
|
return Vector3.Distance(startPoint, endPoint); |
|
|
|
|
return Math.Round(Vector3.Distance(startPoint, endPoint), 2); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|