예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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)));
        }
예제 #5
0
 private EMFace OtherNeighbor(EMEdge e, EMFace f)
 {
     if (Object.ReferenceEquals(e.Neighbors[0], f))
     {
         return(e.Neighbors[1]);
     }
     else
     {
         return(e.Neighbors[0]);
     }
 }
예제 #6
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;
 }
예제 #7
0
 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");
 }
예제 #8
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");
     }
 }
예제 #9
0
        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;
        }
예제 #10
0
 private EMFace OtherNeighbor(EMEdge e, EMFace f)
 {
     if (Object.ReferenceEquals(e.Neighbors[0], f)) return e.Neighbors[1];
     else return e.Neighbors[0];
 }
예제 #11
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");
 }
예제 #12
0
 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");
 }
예제 #13
0
파일: EdgeMesh.cs 프로젝트: Blecki/CCDC
 public Vector3 FindEdgeCenter(EMEdge e)
 {
     return (Verticies[e.Verticies[0]] + Verticies[e.Verticies[1]]) / 2.0f;
 }
예제 #14
0
파일: EdgeMesh.cs 프로젝트: Blecki/CCDC
 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;
 }
예제 #15
0
 public Vector3 FindEdgeCenter(EMEdge e)
 {
     return((Verticies[e.Verticies[0]] + Verticies[e.Verticies[1]]) / 2.0f);
 }