private EMFace MergeFaces(EMFace A, EMFace B) { if (Object.ReferenceEquals(A, B)) { throw new InvalidOperationException("Attempt to merge face with itself"); } EMEdge sharedEdge = null; foreach (var e in A.edges) { if (e.Neighbors.Contains(B)) { sharedEdge = e; } } if (sharedEdge == null) { throw new InvalidOperationException("Attempt to merge faces with no shared edge."); } var newFace = new EMFace(); newFace.edges = new List <EMEdge>(A.edges); newFace.edges.InsertRange(0, B.edges); newFace.edges.RemoveAll((e) => Object.ReferenceEquals(e, sharedEdge)); if (newFace.edges.Count <= 2) { throw new InvalidOperationException("Degenerate face generated"); } return(newFace); }
private short[] ExtractPointSequence(EMEdge a, EMEdge b) { var points = new short[3]; if (b.Verticies.Contains(a.Verticies[1])) { points[0] = a.Verticies[0]; points[1] = a.Verticies[1]; } else { points[0] = a.Verticies[1]; points[1] = a.Verticies[0]; } if (b.Verticies[0] == points[1]) { points[2] = b.Verticies[1]; } else { points[2] = b.Verticies[0]; } return(points); }
public bool EdgesAreColinear(EMEdge A, EMEdge B) { var points = new List<Vector3>(ExtractPointSequence(A, B).Select((s) => Verticies[s])); var v0 = points[1] - points[0]; var v1 = points[2] - points[1]; return Gem.Math.Utility.AlmostZero(AngleBetweenVectors(v0, v1)); }
public bool EdgesAreColinear(EMEdge A, EMEdge B) { var points = new List <Vector3>(ExtractPointSequence(A, B).Select((s) => Verticies[s])); var v0 = points[1] - points[0]; var v1 = points[2] - points[1]; return(Gem.Math.Utility.AlmostZero(AngleBetweenVectors(v0, v1))); }
private EMFace OtherNeighbor(EMEdge e, EMFace f) { if (Object.ReferenceEquals(e.Neighbors[0], f)) { return(e.Neighbors[1]); } else { return(e.Neighbors[0]); } }
internal void SetRecipricalNeighbor(EMEdge edge, EMFace neighbor) { foreach (var e in edges) { if (Object.ReferenceEquals(e, edge)) { e.Neighbors[1] = neighbor; } } //for (int i = 0; i < 3; ++i) // if (Object.ReferenceEquals(Edges[i],edge)) Neighbors[i] = neighbor; }
private EMEdge FindNextEdgeInSequence(EMFace of, EMEdge after, short endpoint) { foreach (var e in of.edges) { if (Object.ReferenceEquals(e, after)) { continue; } if (e.Verticies.Contains(endpoint)) { return(e); } } throw new InvalidOperationException("Malformed edge mesh"); }
private short FindSharedEndpoint(EMEdge a, EMEdge b) { if (b.Verticies.Contains(a.Verticies[0])) { return(a.Verticies[0]); } else if (b.Verticies.Contains(a.Verticies[1])) { return(a.Verticies[1]); } else { throw new InvalidOperationException("Attempt to find shared endpoint of edges with no shared endpoint"); } }
private short[] ExtractPointSequence(EMEdge a, EMEdge b) { var points = new short[3]; if (b.Verticies.Contains(a.Verticies[1])) { points[0] = a.Verticies[0]; points[1] = a.Verticies[1]; } else { points[0] = a.Verticies[1]; points[1] = a.Verticies[0]; } if (b.Verticies[0] == points[1]) points[2] = b.Verticies[1]; else points[2] = b.Verticies[0]; return points; }
private EMFace OtherNeighbor(EMEdge e, EMFace f) { if (Object.ReferenceEquals(e.Neighbors[0], f)) return e.Neighbors[1]; else return e.Neighbors[0]; }
private short FindSharedEndpoint(EMEdge a, EMEdge b) { if (b.Verticies.Contains(a.Verticies[0])) return a.Verticies[0]; else if (b.Verticies.Contains(a.Verticies[1])) return a.Verticies[1]; else throw new InvalidOperationException("Attempt to find shared endpoint of edges with no shared endpoint"); }
private EMEdge FindNextEdgeInSequence(EMFace of, EMEdge after, short endpoint) { foreach (var e in of.edges) { if (Object.ReferenceEquals(e, after)) continue; if (e.Verticies.Contains(endpoint)) return e; } throw new InvalidOperationException("Malformed edge mesh"); }
public Vector3 FindEdgeCenter(EMEdge e) { return (Verticies[e.Verticies[0]] + Verticies[e.Verticies[1]]) / 2.0f; }
internal void SetRecipricalNeighbor(EMEdge edge, EMFace neighbor) { foreach (var e in edges) if (Object.ReferenceEquals(e, edge)) e.Neighbors[1] = neighbor; //for (int i = 0; i < 3; ++i) // if (Object.ReferenceEquals(Edges[i],edge)) Neighbors[i] = neighbor; }
public Vector3 FindEdgeCenter(EMEdge e) { return((Verticies[e.Verticies[0]] + Verticies[e.Verticies[1]]) / 2.0f); }