using System; using System.Collections.Generic; using TriangleNet.Data; using TriangleNet.Geometry; using TriangleNet.Log; namespace TriangleNet.IO { // Token: 0x02000024 RID: 36 internal static class DataReader { // Token: 0x06000128 RID: 296 RVA: 0x00015400 File Offset: 0x00013600 public static int Reconstruct(Mesh mesh, InputGeometry input, ITriangle[] triangles) { int num = 0; Otri otri = default(Otri); Otri otri2 = default(Otri); Otri otri3 = default(Otri); Otri otri4 = default(Otri); Otri otri5 = default(Otri); Osub osub = default(Osub); int[] array = new int[3]; int[] array2 = new int[2]; int num2 = ((triangles == null) ? 0 : triangles.Length); int count = input.segments.Count; mesh.inelements = num2; mesh.regions.AddRange(input.regions); int i; for (i = 0; i < mesh.inelements; i++) { mesh.MakeTriangle(ref otri); } if (mesh.behavior.Poly) { mesh.insegments = count; for (i = 0; i < mesh.insegments; i++) { mesh.MakeSegment(ref osub); } } List[] array3 = new List[mesh.vertices.Count]; for (i = 0; i < mesh.vertices.Count; i++) { Otri otri6 = default(Otri); otri6.triangle = Mesh.dummytri; array3[i] = new List(3); array3[i].Add(otri6); } i = 0; foreach (Triangle triangle in mesh.triangles.Values) { otri.triangle = triangle; array[0] = triangles[i].P0; array[1] = triangles[i].P1; array[2] = triangles[i].P2; for (int j = 0; j < 3; j++) { if (array[j] < 0 || array[j] >= mesh.invertices) { SimpleLog.Instance.Error("Triangle has an invalid vertex index.", "MeshReader.Reconstruct()"); throw new Exception("Triangle has an invalid vertex index."); } } otri.triangle.region = triangles[i].Region; if (mesh.behavior.VarArea) { otri.triangle.area = triangles[i].Area; } otri.orient = 0; otri.SetOrg(mesh.vertices[array[0]]); otri.SetDest(mesh.vertices[array[1]]); otri.SetApex(mesh.vertices[array[2]]); otri.orient = 0; while (otri.orient < 3) { int num3 = array[otri.orient]; int num4 = array3[num3].Count - 1; Otri otri7 = array3[num3][num4]; array3[num3].Add(otri); otri3 = otri7; if (otri3.triangle != Mesh.dummytri) { Vertex vertex = otri.Dest(); Vertex vertex2 = otri.Apex(); do { Vertex vertex3 = otri3.Dest(); Vertex vertex4 = otri3.Apex(); if (vertex2 == vertex3) { otri.Lprev(ref otri2); otri2.Bond(ref otri3); } if (vertex == vertex4) { otri3.Lprev(ref otri4); otri.Bond(ref otri4); } num4--; otri7 = array3[num3][num4]; otri3 = otri7; } while (otri3.triangle != Mesh.dummytri); } otri.orient++; } i++; } num = 0; if (mesh.behavior.Poly) { i = 0; foreach (Segment segment in mesh.subsegs.Values) { osub.seg = segment; array2[0] = input.segments[i].P0; array2[1] = input.segments[i].P1; int boundary = input.segments[i].Boundary; for (int k = 0; k < 2; k++) { if (array2[k] < 0 || array2[k] >= mesh.invertices) { SimpleLog.Instance.Error("Segment has an invalid vertex index.", "MeshReader.Reconstruct()"); throw new Exception("Segment has an invalid vertex index."); } } osub.orient = 0; Vertex vertex5 = mesh.vertices[array2[0]]; Vertex vertex6 = mesh.vertices[array2[1]]; osub.SetOrg(vertex5); osub.SetDest(vertex6); osub.SetSegOrg(vertex5); osub.SetSegDest(vertex6); osub.seg.boundary = boundary; osub.orient = 0; while (osub.orient < 2) { int num3 = array2[1 - osub.orient]; int num5 = array3[num3].Count - 1; Otri otri8 = array3[num3][num5]; Otri otri7 = array3[num3][num5]; otri3 = otri7; Vertex vertex7 = osub.Org(); bool flag = true; while (flag && otri3.triangle != Mesh.dummytri) { Vertex vertex3 = otri3.Dest(); if (vertex7 == vertex3) { array3[num3].Remove(otri8); otri3.SegBond(ref osub); otri3.Sym(ref otri5); if (otri5.triangle == Mesh.dummytri) { mesh.InsertSubseg(ref otri3, 1); num++; } flag = false; } num5--; otri8 = array3[num3][num5]; otri7 = array3[num3][num5]; otri3 = otri7; } osub.orient++; } i++; } } for (i = 0; i < mesh.vertices.Count; i++) { int num6 = array3[i].Count - 1; Otri otri7 = array3[i][num6]; otri3 = otri7; while (otri3.triangle != Mesh.dummytri) { num6--; otri7 = array3[i][num6]; otri3.SegDissolve(); otri3.Sym(ref otri5); if (otri5.triangle == Mesh.dummytri) { mesh.InsertSubseg(ref otri3, 1); num++; } otri3 = otri7; } } return num; } } }