diff --git a/Views/UserControl/ViewportData/Helper/ObjExporter.cs b/Views/UserControl/ViewportData/Helper/ObjExporter.cs index 91b7c64..3064d1d 100644 --- a/Views/UserControl/ViewportData/Helper/ObjExporter.cs +++ b/Views/UserControl/ViewportData/Helper/ObjExporter.cs @@ -17,9 +17,13 @@ public class ObjExporter .GroupBy(entity => entity.PlaneCode) .ToDictionary(group => group.Key, group => group.ToList()); //腰 单组 - List waistList = entities + // List waistList = entities + // .Where(entity => entity.PlaneType == PlaneType.Girdle) + // .ToList(); + Dictionary> gridleList = entities .Where(entity => entity.PlaneType == PlaneType.Girdle) - .ToList(); + .GroupBy(entity => entity.PlaneCode) + .ToDictionary(group => group.Key, group => group.ToList()); //同一个面只保留外边框(除了腰) Dictionary> resultPoints = new Dictionary>(); @@ -35,17 +39,29 @@ public class ObjExporter } resultPoints.Add(dic.Key, ViewportHelperPro.VectorClockwiseSort(new HashSet(tempPoints).ToList())); } - List selFaceVector = new List(); - if (waistList.Count > 0) + + foreach (var dic in gridleList) { - foreach (var entity in waistList) + List tempPoints = new List(); + foreach (var entity in dic.Value) { - selFaceVector.Add(entity.Point1); - selFaceVector.Add(entity.Point2); - selFaceVector.Add(entity.Point3); + tempPoints.Add(entity.Point1); + tempPoints.Add(entity.Point2); + tempPoints.Add(entity.Point3); } + resultPoints.Add(dic.Key, ViewportHelperPro.VectorClockwiseSort(new HashSet(tempPoints).ToList())); } - resultPoints.Add("yao", selFaceVector); + // List selFaceVector = new List(); + // if (waistList.Count > 0) + // { + // foreach (var entity in waistList) + // { + // selFaceVector.Add(entity.Point1); + // selFaceVector.Add(entity.Point2); + // selFaceVector.Add(entity.Point3); + // } + // } + // resultPoints.Add("yao", selFaceVector); StringBuilder sb = new StringBuilder(); @@ -83,8 +99,13 @@ public class ObjExporter // 获取面上的所有顶点并排序 List faceVertices = face.Value; - // Vector3 center = GetCenterOfVertices(faceVertices); - // faceVertices.Sort((v1, v2) => GetAngle(v1, center).CompareTo(GetAngle(v2, center))); + if (!face.Key.StartsWith("11_")) + { + Vector3 center = GetCenterOfVertices(faceVertices); + faceVertices.Sort((v1, v2) => GetAngle(v1, center).CompareTo(GetAngle(v2, center))); + } + + // 正面:按顺时针顺序输出 sb.Append("f");