当前位置: 首页>>代码示例>>C#>>正文


C# TriMesh.AppendToVertexList方法代码示例

本文整理汇总了C#中GraphicResearchHuiZhao.TriMesh.AppendToVertexList方法的典型用法代码示例。如果您正苦于以下问题:C# TriMesh.AppendToVertexList方法的具体用法?C# TriMesh.AppendToVertexList怎么用?C# TriMesh.AppendToVertexList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicResearchHuiZhao.TriMesh的用法示例。


在下文中一共展示了TriMesh.AppendToVertexList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InverseFace

 public static void InverseFace(TriMesh mesh)
 {
     List<TriMesh.Vertex[]> faces = new List<HalfEdgeMesh.Vertex[]>();
     foreach (TriMesh.Face face in mesh.Faces)
     {
         TriMesh.HalfEdge hf = face.HalfEdge;
         TriMesh.Vertex[] arr = new TriMesh.Vertex[]{
             hf.Next.ToVertex,
             hf.ToVertex,
             hf.FromVertex
         };
         faces.Add(arr);
     }
     TriMesh.Vertex[] vertices = new TriMesh.Vertex[mesh.Vertices.Count];
     for (int i = 0; i < mesh.Vertices.Count; i++)
     {
         vertices[i] = mesh.Vertices[i];
         vertices[i].HalfEdge = null;
     }
     mesh.Clear(); 
     foreach (var v in vertices)
     {
         mesh.AppendToVertexList(v);
     } 
     foreach (var face in faces)
     {
         mesh.Faces.AddTriangles(face);
     }
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:29,代码来源:TriMeshInverse.cs

示例2: SeperateComponent

        public static List<TriMesh> SeperateComponent(TriMesh mesh)
        {
            List<TriMesh> meshes = new List<TriMesh>();
            Dictionary<int, TriMesh.Vertex> map = new Dictionary<int, HalfEdgeMesh.Vertex>();
            bool[] visited = new bool[mesh.Faces.Count];
            Queue<TriMesh.Face> queue = new Queue<HalfEdgeMesh.Face>();

            TriMesh newMesh = new TriMesh();
            queue.Enqueue(mesh.Faces[0]);
            visited[0] = true;
            while (queue.Count != 0)
            {
                TriMesh.Face face = queue.Dequeue();
                foreach (var hf in face.Halfedges)
                {
                    if (!map.ContainsKey(hf.ToVertex.Index))
                    {
                        TriMesh.Vertex v = 
                            new HalfEdgeMesh.Vertex(new VertexTraits(hf.ToVertex.Traits.Position));
                        newMesh.AppendToVertexList(v);
                        map[hf.ToVertex.Index] = v;
                    }
                    if (hf.Opposite.Face != null && !visited[hf.Opposite.Face.Index])
                    {
                        queue.Enqueue(hf.Opposite.Face);
                        visited[hf.Opposite.Face.Index] = true;
                    }
                }

                newMesh.Faces.AddTriangles(
                    map[face.HalfEdge.FromVertex.Index],
                    map[face.HalfEdge.ToVertex.Index],
                    map[face.HalfEdge.Next.ToVertex.Index]);

                if (queue.Count == 0)
                {
                    
                    meshes.Add(newMesh);

                    for (int i = 0; i < visited.Length; i++)
                    {
                        if (!visited[i])
                        {
                            newMesh = new TriMesh();
                            queue.Enqueue(mesh.Faces[i]);
                            visited[i] = true;
                            break;
                        }
                    }
                }
            }


            foreach (TriMesh child in meshes)
            {
                TriMeshUtil.SetUpNormalVertex(child);
            }
            return meshes ;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:59,代码来源:TriMeshComponent.cs

示例3: CreateGrid

        public static TriMesh CreateGrid(int m, int n, double lengthx,double lengthy)
        {
            TriMesh mesh = new TriMesh();
            TriMesh.Vertex[,] arr = new HalfEdgeMesh.Vertex[m, n];
            double x0 = -m * lengthx / 2d;
            double y0 = -n * lengthy / 2d;
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    arr[i, j] = new HalfEdgeMesh.Vertex();
                    arr[i, j].Traits = new VertexTraits(x0 + i * lengthx, y0 + j * lengthy, 0d);
                    mesh.AppendToVertexList(arr[i, j]);
                }
            }

            for (int i = 0; i < m - 1; i++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    mesh.Faces.AddTriangles(arr[i + 1, j], arr[i, j + 1], arr[i, j]);
                    mesh.Faces.AddTriangles(arr[i + 1, j], arr[i + 1, j + 1], arr[i, j + 1]);
                }
            }
            return mesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:26,代码来源:TriMeshShape.cs

示例4: Cut

        public TriMesh Cut(IEnumerable<TriMesh.Vertex> region)
        {
            Dictionary<int, TriMesh.Vertex> vMap = new Dictionary<int, HalfEdgeMesh.Vertex>();
            Dictionary<int, bool> fFlag = new Dictionary<int, bool>();

      
            TriMesh newMesh = new TriMesh();

            foreach (var v in region)
            {
                TriMesh.Vertex newV = new HalfEdgeMesh.Vertex(
                    new VertexTraits(v.Traits.Position));
                vMap[v.Index] = newV;
                newMesh.AppendToVertexList(newV);
            }

            foreach (var f in this.mesh.Faces)
            {
                bool inner = true;
                foreach (var v in f.Vertices)
                {
                    if (!vMap.ContainsKey(v.Index))
                    {
                        inner = false;
                        break;
                    }
                }
                if (inner)
                {
                    TriMesh.HalfEdge hf = f.HalfEdge;
                    newMesh.Faces.AddTriangles(
                        vMap[hf.FromVertex.Index],
                        vMap[hf.ToVertex.Index],
                        vMap[hf.Next.ToVertex.Index]);
                    fFlag[f.Index] = true;
                }
            }

            List<TriMesh.Edge> remove = new List<HalfEdgeMesh.Edge>();

            foreach (var e in this.mesh.Edges)
            {
                if (fFlag.ContainsKey(e.Face0.Index) 
                    && fFlag.ContainsKey(e.Face1.Index))
                {
                    remove.Add(e);
                }
            }
            foreach (var e in remove)
            {
                TriMeshModify.RemoveEdge(e);
            }

            foreach (var v in region)
            {
                bool inner = true;
                foreach (var round in v.Vertices)
                {
                    if (!vMap.ContainsKey(round.Index))
                    {
                        inner = false;
                    }
                }
                if (inner)
                {
                    this.mesh.RemoveVertex(v);
                }
            }

            return newMesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:71,代码来源:TriMeshFaceCut.cs

示例5: Create

        TriMesh Create(IEnumerable<TriMesh.Face> region)
        {
            TriMesh newMesh = new TriMesh();

            foreach (var f in region)
            {
                TriMesh.Vertex[] arr = new HalfEdgeMesh.Vertex[3];
                int i = 0;
                foreach (var v in f.Vertices)
                {
                    if (!this.vMap.ContainsKey(v))
                    {
                        TriMesh.Vertex newV =
                            new HalfEdgeMesh.Vertex(new VertexTraits(v.Traits.Position));
                        this.vMap[v] = newV;
                        newMesh.AppendToVertexList(newV);
                    }
                    arr[i++] = this.vMap[v];
                }
                newMesh.Faces.AddTriangles(arr);
                this.fFlag[f.Index] = true;
            }

            return newMesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:25,代码来源:TriMeshFaceCut.cs


注:本文中的GraphicResearchHuiZhao.TriMesh.AppendToVertexList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。