|
|
|
@ -123,21 +123,21 @@ public class ViewportHelperPro |
|
|
|
|
switch (planeType) |
|
|
|
|
{ |
|
|
|
|
case PlaneType.Girdle: |
|
|
|
|
return new Color4(0, 0.74901f, 1, 0.2f); |
|
|
|
|
return ViewportManager.ColorConfig.GirdleFacetColor; |
|
|
|
|
case PlaneType.TableFacet : |
|
|
|
|
return new Color4(0.52941f, 0.80734f, 0.98039f, 1); |
|
|
|
|
return ViewportManager.ColorConfig.TableFacetColor; |
|
|
|
|
case PlaneType.UpperMainFacet: |
|
|
|
|
return new Color4(30/255f, 144/255f, 1, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.UpperMainFacetColor; |
|
|
|
|
case PlaneType.StarFacet: |
|
|
|
|
return new Color4(0, 0, 1, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.StarFacetColor; |
|
|
|
|
case PlaneType.UpperGirdleFacet: |
|
|
|
|
return new Color4(100/255f, 149/255f, 237/255f, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.UpperGirdleFacetColor; |
|
|
|
|
case PlaneType.PavilionMainFacet: |
|
|
|
|
return new Color4(106/255f, 90/255f, 205/255f, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.PavilionFacetColor; |
|
|
|
|
case PlaneType.LowerGirdleFact: |
|
|
|
|
return new Color4(175/255f, 238/255f, 238/255f, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.LowerGirdleFacetColor; |
|
|
|
|
case PlaneType.Culet: |
|
|
|
|
return new Color4(255/255f, 255/255f, 255/255f, 1f); |
|
|
|
|
return ViewportManager.ColorConfig.CuletFacetColor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
@ -338,10 +338,10 @@ public class ViewportHelperPro |
|
|
|
|
} |
|
|
|
|
HashSet<Vector3> uniqueVectors = new HashSet<Vector3>(selFaceVector); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < uniqueVectors.ToList().Count - 1; i++) |
|
|
|
|
for (int i = 0; i < selFaceVector.ToList().Count - 1; i++) |
|
|
|
|
{ |
|
|
|
|
var nowItem = uniqueVectors.ToList()[i]; |
|
|
|
|
var nextItem = uniqueVectors.ToList()[i + 1]; |
|
|
|
|
var nowItem = selFaceVector.ToList()[i]; |
|
|
|
|
var nextItem = selFaceVector.ToList()[i + 1]; |
|
|
|
|
var line = new Tuple<Vector3, Vector3>(nowItem, nextItem); |
|
|
|
|
if (IsLineSegmentParallelToYAxis(line)) |
|
|
|
|
{ |
|
|
|
@ -455,7 +455,21 @@ public class ViewportHelperPro |
|
|
|
|
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType); |
|
|
|
|
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode) |
|
|
|
|
.ToDictionary(group => group.Key, group => group.ToList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var kv in groupedDic) |
|
|
|
|
{ |
|
|
|
|
var value = kv.Value; |
|
|
|
|
var key = kv.Key; |
|
|
|
|
var facetIndex = key.Split("_")[1]; |
|
|
|
|
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)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* 思路: |
|
|
|
|
* 1、以面分组,1组为台面、底面,8组、16组、64组、other |
|
|
|
@ -677,6 +691,8 @@ public class ViewportHelperPro |
|
|
|
|
{ |
|
|
|
|
Foreground = color??ViewportManager.ColorConfig.SelFontColor, |
|
|
|
|
Scale = 0.8f, |
|
|
|
|
VerticalAlignment = BillboardVerticalAlignment.Center, |
|
|
|
|
HorizontalAlignment = BillboardHorizontalAlignment.Center |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
billboardTextModel.Geometry = billboardText; |
|
|
|
@ -1059,6 +1075,22 @@ public class ViewportHelperPro |
|
|
|
|
float z = vectors.Sum(v => v.Z) / vectors.Count; |
|
|
|
|
return new Vector3(x, y, z); |
|
|
|
|
} |
|
|
|
|
public static Vector3 GetOffsetCenter(List<Vector3> facetVector, Vector3 center, float dev = 0.4f) |
|
|
|
|
{ |
|
|
|
|
// 1. 去重 facetVector |
|
|
|
|
var distinctFacetVector = facetVector.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
// 2. 计算多边形的几何中心 |
|
|
|
|
Vector3 polygonCenter = GetCentroid(distinctFacetVector); |
|
|
|
|
|
|
|
|
|
// 3. 计算从模型中心点到几何中心的向量 |
|
|
|
|
Vector3 direction = polygonCenter - center; |
|
|
|
|
|
|
|
|
|
// 4. 归一化方向向量并根据偏移量 dev 计算最终的偏移位置 |
|
|
|
|
Vector3 offsetCenter = polygonCenter + Vector3.Normalize(direction) * dev; |
|
|
|
|
|
|
|
|
|
return offsetCenter; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 计算夹角度数 |
|
|
|
|
/// </summary> |
|
|
|
|