public List <FaceWE> FlipEdge(EdgeWE e) { List <FaceWE> f = new List <FaceWE>(); FaceWE lf = e.LeftFace; FaceWE rf = e.RightFace; VertexWE v1 = e.Vertex1; VertexWE v2 = e.Vertex2; VertexWE rv = null; VertexWE lv = null; List <VertexWE> rfvertices = GetFaceVertices(rf); List <VertexWE> lfvertices = GetFaceVertices(lf); for (int i = 0; i < rfvertices.Count; i++) { if (!Equals(v1, rfvertices[i]) && !Equals(v2, rfvertices[i])) { rv = rfvertices[i]; } if (!Equals(v1, lfvertices[i]) && !Equals(v2, lfvertices[i])) { lv = lfvertices[i]; } } RemoveFace(rf); RemoveFace(lf); f.Add(AddFace(rv, lv, v1)); f.Add(AddFace(rv, lv, v2)); return(f); }
public FaceWE AddFace(VertexWE a, VertexWE b, VertexWE c) { if (!FaceAlreadyExist(a, b, c)) { if (!IsClockwise(a, b, c)) { VertexWE aux = a; a = b; b = aux; } FaceWE f = ScriptableObject.CreateInstance("FaceWE") as FaceWE; EdgeWE e1 = EdgeAlreadyExist(a, b); EdgeWE e2 = EdgeAlreadyExist(b, c); EdgeWE e3 = EdgeAlreadyExist(c, a); if (e1 == null) { EdgeWE aux1 = ScriptableObject.CreateInstance("EdgeWE") as EdgeWE; aux1.Init(a, b); a.Edges.Add(aux1); b.Edges.Add(aux1); Edges.Add(aux1); f.Edges.Add(aux1); aux1.RightFace = f; } else { if (e1.RightFace == null) { e1.RightFace = f; } else { e1.LeftFace = f; } f.Edges.Add(e1); } if (e2 == null) { EdgeWE aux2 = ScriptableObject.CreateInstance("EdgeWE") as EdgeWE; aux2.Init(b, c); b.Edges.Add(aux2); c.Edges.Add(aux2); Edges.Add(aux2); aux2.RightFace = f; f.Edges.Add(aux2); } else { if (e2.RightFace == null) { e2.RightFace = f; } else { e2.LeftFace = f; } f.Edges.Add(e2); } if (e3 == null) { EdgeWE aux3 = ScriptableObject.CreateInstance("EdgeWE") as EdgeWE; aux3.Init(c, a); c.Edges.Add(aux3); a.Edges.Add(aux3); Edges.Add(aux3); aux3.RightFace = f; f.Edges.Add(aux3); } else { if (e3.RightFace == null) { e3.RightFace = f; } else { e3.LeftFace = f; } f.Edges.Add(e3); } Faces.Add(f); return(f); } return(null); }