コード例 #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
ファイル: SimplifyEdgeMesh.cs プロジェクト: Blecki/CCDC
        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
ファイル: EdgeMesh.cs プロジェクト: Blecki/GemgineCore
 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
ファイル: SimplifyEdgeMesh.cs プロジェクト: Blecki/CCDC
        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
ファイル: SimplifyEdgeMesh.cs プロジェクト: Blecki/CCDC
 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
ファイル: SimplifyEdgeMesh.cs プロジェクト: Blecki/CCDC
 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
ファイル: SimplifyEdgeMesh.cs プロジェクト: Blecki/CCDC
 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
ファイル: EdgeMesh.cs プロジェクト: Blecki/GemgineCore
 public Vector3 FindEdgeCenter(EMEdge e)
 {
     return((Verticies[e.Verticies[0]] + Verticies[e.Verticies[1]]) / 2.0f);
 }