using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace ProBuilder2.Common { // Token: 0x0200005C RID: 92 public class pb_WingedEdge : IEquatable, IEnumerable { // Token: 0x060002B7 RID: 695 RVA: 0x00020F55 File Offset: 0x0001F355 public bool Equals(pb_WingedEdge b) { return b != null && this.edge.local.Equals(b.edge.local); } // Token: 0x060002B8 RID: 696 RVA: 0x00020F7C File Offset: 0x0001F37C public override bool Equals(object b) { pb_WingedEdge pb_WingedEdge = b as pb_WingedEdge; if (pb_WingedEdge != null && this.Equals(pb_WingedEdge)) { return true; } pb_Edge pb_Edge = b as pb_Edge; return pb_Edge == null || !this.Equals(pb_Edge) || true; } // Token: 0x060002B9 RID: 697 RVA: 0x00020FC0 File Offset: 0x0001F3C0 public override int GetHashCode() { return this.edge.local.GetHashCode(); } // Token: 0x060002BA RID: 698 RVA: 0x00020FD2 File Offset: 0x0001F3D2 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } // Token: 0x060002BB RID: 699 RVA: 0x00020FDA File Offset: 0x0001F3DA public pb_WingedEdgeEnumerator GetEnumerator() { return new pb_WingedEdgeEnumerator(this); } // Token: 0x060002BC RID: 700 RVA: 0x00020FE4 File Offset: 0x0001F3E4 public override string ToString() { return string.Format("Common: {0}\nLocal: {1}\nOpposite: {2}\nFace: {3}", new object[] { this.edge.common.ToString(), this.edge.local.ToString(), (this.opposite != null) ? this.opposite.edge.ToString() : "null", this.face.ToString() }); } // Token: 0x060002BD RID: 701 RVA: 0x00021060 File Offset: 0x0001F460 public pb_WingedEdge GetAdjacentEdgeWithCommonIndex(int common) { if (this.next.edge.common.Contains(common)) { return this.next; } if (this.previous.edge.common.Contains(common)) { return this.previous; } return null; } // Token: 0x060002BE RID: 702 RVA: 0x000210B4 File Offset: 0x0001F4B4 public static List SortEdgesByAdjacency(pb_Face face) { List list = new List(face.edges); return pb_WingedEdge.SortEdgesByAdjacency(list); } // Token: 0x060002BF RID: 703 RVA: 0x000210D4 File Offset: 0x0001F4D4 public static List SortEdgesByAdjacency(List edges) { for (int i = 1; i < edges.Count; i++) { int y = edges[i - 1].y; for (int j = i + 1; j < edges.Count; j++) { if (edges[j].x == y || edges[j].y == y) { pb_Edge pb_Edge = edges[j]; edges[j] = edges[i]; edges[i] = pb_Edge; } } } return edges; } // Token: 0x060002C0 RID: 704 RVA: 0x00021164 File Offset: 0x0001F564 public static Dictionary> GetSpokes(List wings) { Dictionary> dictionary = new Dictionary>(); List list = null; for (int i = 0; i < wings.Count; i++) { if (dictionary.TryGetValue(wings[i].edge.common.x, out list)) { list.Add(wings[i]); } else { dictionary.Add(wings[i].edge.common.x, new List { wings[i] }); } if (dictionary.TryGetValue(wings[i].edge.common.y, out list)) { list.Add(wings[i]); } else { dictionary.Add(wings[i].edge.common.y, new List { wings[i] }); } } return dictionary; } // Token: 0x060002C1 RID: 705 RVA: 0x0002125C File Offset: 0x0001F65C public static List SortCommonIndicesByAdjacency(List wings, HashSet common) { List list = (from x in wings where common.Contains(x.edge.common.x) && common.Contains(x.edge.common.y) select x into y select y.edge.common).ToList(); if (list.Count != common.Count) { return null; } return (from x in pb_WingedEdge.SortEdgesByAdjacency(list) select x.x).ToList(); } // Token: 0x060002C2 RID: 706 RVA: 0x000212F5 File Offset: 0x0001F6F5 public static List GetWingedEdges(pb_Object pb, bool oneWingPerFace = false) { return pb_WingedEdge.GetWingedEdges(pb, pb.faces, oneWingPerFace, null); } // Token: 0x060002C3 RID: 707 RVA: 0x00021308 File Offset: 0x0001F708 public static List GetWingedEdges(pb_Object pb, IEnumerable faces, bool oneWingPerFace = false, Dictionary sharedIndexLookup = null) { Dictionary dictionary = ((sharedIndexLookup != null) ? sharedIndexLookup : pb.sharedIndices.ToDictionary()); IEnumerable enumerable = faces.Distinct(); List list = new List(); Dictionary dictionary2 = new Dictionary(); int num = 0; foreach (pb_Face pb_Face in enumerable) { List list2 = pb_WingedEdge.SortEdgesByAdjacency(pb_Face); int count = list2.Count; pb_WingedEdge pb_WingedEdge = null; pb_WingedEdge pb_WingedEdge2 = null; for (int i = 0; i < count; i++) { pb_Edge pb_Edge = list2[i]; pb_WingedEdge pb_WingedEdge3 = new pb_WingedEdge(); pb_WingedEdge3.edge = new pb_EdgeLookup(dictionary[pb_Edge.x], dictionary[pb_Edge.y], pb_Edge.x, pb_Edge.y); pb_WingedEdge3.face = pb_Face; if (i < 1) { pb_WingedEdge = pb_WingedEdge3; } if (i > 0) { pb_WingedEdge3.previous = pb_WingedEdge2; pb_WingedEdge2.next = pb_WingedEdge3; } if (i == count - 1) { pb_WingedEdge3.next = pb_WingedEdge; pb_WingedEdge.previous = pb_WingedEdge3; } pb_WingedEdge2 = pb_WingedEdge3; pb_WingedEdge pb_WingedEdge4; if (dictionary2.TryGetValue(pb_WingedEdge3.edge.common, out pb_WingedEdge4)) { pb_WingedEdge4.opposite = pb_WingedEdge3; pb_WingedEdge3.opposite = pb_WingedEdge4; } else { pb_WingedEdge3.opposite = null; dictionary2.Add(pb_WingedEdge3.edge.common, pb_WingedEdge3); } if (!oneWingPerFace || i < 1) { list.Add(pb_WingedEdge3); } } num += count; } return list; } // Token: 0x040001EB RID: 491 public pb_EdgeLookup edge; // Token: 0x040001EC RID: 492 public pb_Face face; // Token: 0x040001ED RID: 493 public pb_WingedEdge next; // Token: 0x040001EE RID: 494 public pb_WingedEdge previous; // Token: 0x040001EF RID: 495 public pb_WingedEdge opposite; } }